PluginProbe
Gutenberg / 23.3.1
Gutenberg v23.3.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 / widgets / news / render.js

render.js in Gutenberg 23.3.1, at build/widgets/news/render.js

26,480 lines 915.3 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 === React51.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 = useState36({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect6(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect32(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue2(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 (error) {
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 React51 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React51.useState, useEffect32 = React51.useEffect, useLayoutEffect6 = React51.useLayoutEffect, useDebugValue2 = React51.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 !== React51.useSyncExternalStore ? React51.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 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
143 var require_with_selector_development = __commonJS({
144 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
145 "use strict";
146 (function() {
147 function is(x2, y2) {
148 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React51 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef44 = React51.useRef, useEffect32 = React51.useEffect, useMemo40 = React51.useMemo, useDebugValue2 = React51.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef44(null);
154 if (null === instRef.current) {
155 var inst = { hasValue: false, value: null };
156 instRef.current = inst;
157 } else inst = instRef.current;
158 instRef = useMemo40(
159 function() {
160 function memoizedSelector(nextSnapshot) {
161 if (!hasMemo) {
162 hasMemo = true;
163 memoizedSnapshot = nextSnapshot;
164 nextSnapshot = selector2(nextSnapshot);
165 if (void 0 !== isEqual && inst.hasValue) {
166 var currentSelection = inst.value;
167 if (isEqual(currentSelection, nextSnapshot))
168 return memoizedSelection = currentSelection;
169 }
170 return memoizedSelection = nextSnapshot;
171 }
172 currentSelection = memoizedSelection;
173 if (objectIs(memoizedSnapshot, nextSnapshot))
174 return currentSelection;
175 var nextSelection = selector2(nextSnapshot);
176 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
177 return memoizedSnapshot = nextSnapshot, currentSelection;
178 memoizedSnapshot = nextSnapshot;
179 return memoizedSelection = nextSelection;
180 }
181 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
182 return [
183 function() {
184 return memoizedSelector(getSnapshot());
185 },
186 null === maybeGetServerSnapshot ? void 0 : function() {
187 return memoizedSelector(maybeGetServerSnapshot());
188 }
189 ];
190 },
191 [getSnapshot, getServerSnapshot, selector2, isEqual]
192 );
193 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
194 useEffect32(
195 function() {
196 inst.hasValue = true;
197 inst.value = value;
198 },
199 [value]
200 );
201 useDebugValue2(value);
202 return value;
203 };
204 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
205 })();
206 }
207 });
208
209 // node_modules/use-sync-external-store/shim/with-selector.js
210 var require_with_selector = __commonJS({
211 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
212 "use strict";
213 if (false) {
214 module.exports = null;
215 } else {
216 module.exports = require_with_selector_development();
217 }
218 }
219 });
220
221 // package-external:@wordpress/primitives
222 var require_primitives = __commonJS({
223 "package-external:@wordpress/primitives"(exports, module) {
224 module.exports = window.wp.primitives;
225 }
226 });
227
228 // package-external:@wordpress/compose
229 var require_compose = __commonJS({
230 "package-external:@wordpress/compose"(exports, module) {
231 module.exports = window.wp.compose;
232 }
233 });
234
235 // package-external:@wordpress/theme
236 var require_theme = __commonJS({
237 "package-external:@wordpress/theme"(exports, module) {
238 module.exports = window.wp.theme;
239 }
240 });
241
242 // package-external:@wordpress/private-apis
243 var require_private_apis = __commonJS({
244 "package-external:@wordpress/private-apis"(exports, module) {
245 module.exports = window.wp.privateApis;
246 }
247 });
248
249 // package-external:@wordpress/components
250 var require_components = __commonJS({
251 "package-external:@wordpress/components"(exports, module) {
252 module.exports = window.wp.components;
253 }
254 });
255
256 // package-external:@wordpress/keycodes
257 var require_keycodes = __commonJS({
258 "package-external:@wordpress/keycodes"(exports, module) {
259 module.exports = window.wp.keycodes;
260 }
261 });
262
263 // package-external:@wordpress/data
264 var require_data = __commonJS({
265 "package-external:@wordpress/data"(exports, module) {
266 module.exports = window.wp.data;
267 }
268 });
269
270 // node_modules/remove-accents/index.js
271 var require_remove_accents = __commonJS({
272 "node_modules/remove-accents/index.js"(exports, module) {
273 var characterMap = {
274 "\xC0": "A",
275 "\xC1": "A",
276 "\xC2": "A",
277 "\xC3": "A",
278 "\xC4": "A",
279 "\xC5": "A",
280 "\u1EA4": "A",
281 "\u1EAE": "A",
282 "\u1EB2": "A",
283 "\u1EB4": "A",
284 "\u1EB6": "A",
285 "\xC6": "AE",
286 "\u1EA6": "A",
287 "\u1EB0": "A",
288 "\u0202": "A",
289 "\u1EA2": "A",
290 "\u1EA0": "A",
291 "\u1EA8": "A",
292 "\u1EAA": "A",
293 "\u1EAC": "A",
294 "\xC7": "C",
295 "\u1E08": "C",
296 "\xC8": "E",
297 "\xC9": "E",
298 "\xCA": "E",
299 "\xCB": "E",
300 "\u1EBE": "E",
301 "\u1E16": "E",
302 "\u1EC0": "E",
303 "\u1E14": "E",
304 "\u1E1C": "E",
305 "\u0206": "E",
306 "\u1EBA": "E",
307 "\u1EBC": "E",
308 "\u1EB8": "E",
309 "\u1EC2": "E",
310 "\u1EC4": "E",
311 "\u1EC6": "E",
312 "\xCC": "I",
313 "\xCD": "I",
314 "\xCE": "I",
315 "\xCF": "I",
316 "\u1E2E": "I",
317 "\u020A": "I",
318 "\u1EC8": "I",
319 "\u1ECA": "I",
320 "\xD0": "D",
321 "\xD1": "N",
322 "\xD2": "O",
323 "\xD3": "O",
324 "\xD4": "O",
325 "\xD5": "O",
326 "\xD6": "O",
327 "\xD8": "O",
328 "\u1ED0": "O",
329 "\u1E4C": "O",
330 "\u1E52": "O",
331 "\u020E": "O",
332 "\u1ECE": "O",
333 "\u1ECC": "O",
334 "\u1ED4": "O",
335 "\u1ED6": "O",
336 "\u1ED8": "O",
337 "\u1EDC": "O",
338 "\u1EDE": "O",
339 "\u1EE0": "O",
340 "\u1EDA": "O",
341 "\u1EE2": "O",
342 "\xD9": "U",
343 "\xDA": "U",
344 "\xDB": "U",
345 "\xDC": "U",
346 "\u1EE6": "U",
347 "\u1EE4": "U",
348 "\u1EEC": "U",
349 "\u1EEE": "U",
350 "\u1EF0": "U",
351 "\xDD": "Y",
352 "\xE0": "a",
353 "\xE1": "a",
354 "\xE2": "a",
355 "\xE3": "a",
356 "\xE4": "a",
357 "\xE5": "a",
358 "\u1EA5": "a",
359 "\u1EAF": "a",
360 "\u1EB3": "a",
361 "\u1EB5": "a",
362 "\u1EB7": "a",
363 "\xE6": "ae",
364 "\u1EA7": "a",
365 "\u1EB1": "a",
366 "\u0203": "a",
367 "\u1EA3": "a",
368 "\u1EA1": "a",
369 "\u1EA9": "a",
370 "\u1EAB": "a",
371 "\u1EAD": "a",
372 "\xE7": "c",
373 "\u1E09": "c",
374 "\xE8": "e",
375 "\xE9": "e",
376 "\xEA": "e",
377 "\xEB": "e",
378 "\u1EBF": "e",
379 "\u1E17": "e",
380 "\u1EC1": "e",
381 "\u1E15": "e",
382 "\u1E1D": "e",
383 "\u0207": "e",
384 "\u1EBB": "e",
385 "\u1EBD": "e",
386 "\u1EB9": "e",
387 "\u1EC3": "e",
388 "\u1EC5": "e",
389 "\u1EC7": "e",
390 "\xEC": "i",
391 "\xED": "i",
392 "\xEE": "i",
393 "\xEF": "i",
394 "\u1E2F": "i",
395 "\u020B": "i",
396 "\u1EC9": "i",
397 "\u1ECB": "i",
398 "\xF0": "d",
399 "\xF1": "n",
400 "\xF2": "o",
401 "\xF3": "o",
402 "\xF4": "o",
403 "\xF5": "o",
404 "\xF6": "o",
405 "\xF8": "o",
406 "\u1ED1": "o",
407 "\u1E4D": "o",
408 "\u1E53": "o",
409 "\u020F": "o",
410 "\u1ECF": "o",
411 "\u1ECD": "o",
412 "\u1ED5": "o",
413 "\u1ED7": "o",
414 "\u1ED9": "o",
415 "\u1EDD": "o",
416 "\u1EDF": "o",
417 "\u1EE1": "o",
418 "\u1EDB": "o",
419 "\u1EE3": "o",
420 "\xF9": "u",
421 "\xFA": "u",
422 "\xFB": "u",
423 "\xFC": "u",
424 "\u1EE7": "u",
425 "\u1EE5": "u",
426 "\u1EED": "u",
427 "\u1EEF": "u",
428 "\u1EF1": "u",
429 "\xFD": "y",
430 "\xFF": "y",
431 "\u0100": "A",
432 "\u0101": "a",
433 "\u0102": "A",
434 "\u0103": "a",
435 "\u0104": "A",
436 "\u0105": "a",
437 "\u0106": "C",
438 "\u0107": "c",
439 "\u0108": "C",
440 "\u0109": "c",
441 "\u010A": "C",
442 "\u010B": "c",
443 "\u010C": "C",
444 "\u010D": "c",
445 "C\u0306": "C",
446 "c\u0306": "c",
447 "\u010E": "D",
448 "\u010F": "d",
449 "\u0110": "D",
450 "\u0111": "d",
451 "\u0112": "E",
452 "\u0113": "e",
453 "\u0114": "E",
454 "\u0115": "e",
455 "\u0116": "E",
456 "\u0117": "e",
457 "\u0118": "E",
458 "\u0119": "e",
459 "\u011A": "E",
460 "\u011B": "e",
461 "\u011C": "G",
462 "\u01F4": "G",
463 "\u011D": "g",
464 "\u01F5": "g",
465 "\u011E": "G",
466 "\u011F": "g",
467 "\u0120": "G",
468 "\u0121": "g",
469 "\u0122": "G",
470 "\u0123": "g",
471 "\u0124": "H",
472 "\u0125": "h",
473 "\u0126": "H",
474 "\u0127": "h",
475 "\u1E2A": "H",
476 "\u1E2B": "h",
477 "\u0128": "I",
478 "\u0129": "i",
479 "\u012A": "I",
480 "\u012B": "i",
481 "\u012C": "I",
482 "\u012D": "i",
483 "\u012E": "I",
484 "\u012F": "i",
485 "\u0130": "I",
486 "\u0131": "i",
487 "\u0132": "IJ",
488 "\u0133": "ij",
489 "\u0134": "J",
490 "\u0135": "j",
491 "\u0136": "K",
492 "\u0137": "k",
493 "\u1E30": "K",
494 "\u1E31": "k",
495 "K\u0306": "K",
496 "k\u0306": "k",
497 "\u0139": "L",
498 "\u013A": "l",
499 "\u013B": "L",
500 "\u013C": "l",
501 "\u013D": "L",
502 "\u013E": "l",
503 "\u013F": "L",
504 "\u0140": "l",
505 "\u0141": "l",
506 "\u0142": "l",
507 "\u1E3E": "M",
508 "\u1E3F": "m",
509 "M\u0306": "M",
510 "m\u0306": "m",
511 "\u0143": "N",
512 "\u0144": "n",
513 "\u0145": "N",
514 "\u0146": "n",
515 "\u0147": "N",
516 "\u0148": "n",
517 "\u0149": "n",
518 "N\u0306": "N",
519 "n\u0306": "n",
520 "\u014C": "O",
521 "\u014D": "o",
522 "\u014E": "O",
523 "\u014F": "o",
524 "\u0150": "O",
525 "\u0151": "o",
526 "\u0152": "OE",
527 "\u0153": "oe",
528 "P\u0306": "P",
529 "p\u0306": "p",
530 "\u0154": "R",
531 "\u0155": "r",
532 "\u0156": "R",
533 "\u0157": "r",
534 "\u0158": "R",
535 "\u0159": "r",
536 "R\u0306": "R",
537 "r\u0306": "r",
538 "\u0212": "R",
539 "\u0213": "r",
540 "\u015A": "S",
541 "\u015B": "s",
542 "\u015C": "S",
543 "\u015D": "s",
544 "\u015E": "S",
545 "\u0218": "S",
546 "\u0219": "s",
547 "\u015F": "s",
548 "\u0160": "S",
549 "\u0161": "s",
550 "\u0162": "T",
551 "\u0163": "t",
552 "\u021B": "t",
553 "\u021A": "T",
554 "\u0164": "T",
555 "\u0165": "t",
556 "\u0166": "T",
557 "\u0167": "t",
558 "T\u0306": "T",
559 "t\u0306": "t",
560 "\u0168": "U",
561 "\u0169": "u",
562 "\u016A": "U",
563 "\u016B": "u",
564 "\u016C": "U",
565 "\u016D": "u",
566 "\u016E": "U",
567 "\u016F": "u",
568 "\u0170": "U",
569 "\u0171": "u",
570 "\u0172": "U",
571 "\u0173": "u",
572 "\u0216": "U",
573 "\u0217": "u",
574 "V\u0306": "V",
575 "v\u0306": "v",
576 "\u0174": "W",
577 "\u0175": "w",
578 "\u1E82": "W",
579 "\u1E83": "w",
580 "X\u0306": "X",
581 "x\u0306": "x",
582 "\u0176": "Y",
583 "\u0177": "y",
584 "\u0178": "Y",
585 "Y\u0306": "Y",
586 "y\u0306": "y",
587 "\u0179": "Z",
588 "\u017A": "z",
589 "\u017B": "Z",
590 "\u017C": "z",
591 "\u017D": "Z",
592 "\u017E": "z",
593 "\u017F": "s",
594 "\u0192": "f",
595 "\u01A0": "O",
596 "\u01A1": "o",
597 "\u01AF": "U",
598 "\u01B0": "u",
599 "\u01CD": "A",
600 "\u01CE": "a",
601 "\u01CF": "I",
602 "\u01D0": "i",
603 "\u01D1": "O",
604 "\u01D2": "o",
605 "\u01D3": "U",
606 "\u01D4": "u",
607 "\u01D5": "U",
608 "\u01D6": "u",
609 "\u01D7": "U",
610 "\u01D8": "u",
611 "\u01D9": "U",
612 "\u01DA": "u",
613 "\u01DB": "U",
614 "\u01DC": "u",
615 "\u1EE8": "U",
616 "\u1EE9": "u",
617 "\u1E78": "U",
618 "\u1E79": "u",
619 "\u01FA": "A",
620 "\u01FB": "a",
621 "\u01FC": "AE",
622 "\u01FD": "ae",
623 "\u01FE": "O",
624 "\u01FF": "o",
625 "\xDE": "TH",
626 "\xFE": "th",
627 "\u1E54": "P",
628 "\u1E55": "p",
629 "\u1E64": "S",
630 "\u1E65": "s",
631 "X\u0301": "X",
632 "x\u0301": "x",
633 "\u0403": "\u0413",
634 "\u0453": "\u0433",
635 "\u040C": "\u041A",
636 "\u045C": "\u043A",
637 "A\u030B": "A",
638 "a\u030B": "a",
639 "E\u030B": "E",
640 "e\u030B": "e",
641 "I\u030B": "I",
642 "i\u030B": "i",
643 "\u01F8": "N",
644 "\u01F9": "n",
645 "\u1ED2": "O",
646 "\u1ED3": "o",
647 "\u1E50": "O",
648 "\u1E51": "o",
649 "\u1EEA": "U",
650 "\u1EEB": "u",
651 "\u1E80": "W",
652 "\u1E81": "w",
653 "\u1EF2": "Y",
654 "\u1EF3": "y",
655 "\u0200": "A",
656 "\u0201": "a",
657 "\u0204": "E",
658 "\u0205": "e",
659 "\u0208": "I",
660 "\u0209": "i",
661 "\u020C": "O",
662 "\u020D": "o",
663 "\u0210": "R",
664 "\u0211": "r",
665 "\u0214": "U",
666 "\u0215": "u",
667 "B\u030C": "B",
668 "b\u030C": "b",
669 "\u010C\u0323": "C",
670 "\u010D\u0323": "c",
671 "\xCA\u030C": "E",
672 "\xEA\u030C": "e",
673 "F\u030C": "F",
674 "f\u030C": "f",
675 "\u01E6": "G",
676 "\u01E7": "g",
677 "\u021E": "H",
678 "\u021F": "h",
679 "J\u030C": "J",
680 "\u01F0": "j",
681 "\u01E8": "K",
682 "\u01E9": "k",
683 "M\u030C": "M",
684 "m\u030C": "m",
685 "P\u030C": "P",
686 "p\u030C": "p",
687 "Q\u030C": "Q",
688 "q\u030C": "q",
689 "\u0158\u0329": "R",
690 "\u0159\u0329": "r",
691 "\u1E66": "S",
692 "\u1E67": "s",
693 "V\u030C": "V",
694 "v\u030C": "v",
695 "W\u030C": "W",
696 "w\u030C": "w",
697 "X\u030C": "X",
698 "x\u030C": "x",
699 "Y\u030C": "Y",
700 "y\u030C": "y",
701 "A\u0327": "A",
702 "a\u0327": "a",
703 "B\u0327": "B",
704 "b\u0327": "b",
705 "\u1E10": "D",
706 "\u1E11": "d",
707 "\u0228": "E",
708 "\u0229": "e",
709 "\u0190\u0327": "E",
710 "\u025B\u0327": "e",
711 "\u1E28": "H",
712 "\u1E29": "h",
713 "I\u0327": "I",
714 "i\u0327": "i",
715 "\u0197\u0327": "I",
716 "\u0268\u0327": "i",
717 "M\u0327": "M",
718 "m\u0327": "m",
719 "O\u0327": "O",
720 "o\u0327": "o",
721 "Q\u0327": "Q",
722 "q\u0327": "q",
723 "U\u0327": "U",
724 "u\u0327": "u",
725 "X\u0327": "X",
726 "x\u0327": "x",
727 "Z\u0327": "Z",
728 "z\u0327": "z",
729 "\u0439": "\u0438",
730 "\u0419": "\u0418",
731 "\u0451": "\u0435",
732 "\u0401": "\u0415"
733 };
734 var chars = Object.keys(characterMap).join("|");
735 var allAccents = new RegExp(chars, "g");
736 var firstAccent = new RegExp(chars, "");
737 function matcher(match2) {
738 return characterMap[match2];
739 }
740 var removeAccents2 = function(string) {
741 return string.replace(allAccents, matcher);
742 };
743 var hasAccents = function(string) {
744 return !!string.match(firstAccent);
745 };
746 module.exports = removeAccents2;
747 module.exports.has = hasAccents;
748 module.exports.remove = removeAccents2;
749 }
750 });
751
752 // node_modules/fast-deep-equal/es6/index.js
753 var require_es6 = __commonJS({
754 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
755 "use strict";
756 module.exports = function equal(a2, b2) {
757 if (a2 === b2) return true;
758 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
759 if (a2.constructor !== b2.constructor) return false;
760 var length, i2, keys;
761 if (Array.isArray(a2)) {
762 length = a2.length;
763 if (length != b2.length) return false;
764 for (i2 = length; i2-- !== 0; )
765 if (!equal(a2[i2], b2[i2])) return false;
766 return true;
767 }
768 if (a2 instanceof Map && b2 instanceof Map) {
769 if (a2.size !== b2.size) return false;
770 for (i2 of a2.entries())
771 if (!b2.has(i2[0])) return false;
772 for (i2 of a2.entries())
773 if (!equal(i2[1], b2.get(i2[0]))) return false;
774 return true;
775 }
776 if (a2 instanceof Set && b2 instanceof Set) {
777 if (a2.size !== b2.size) return false;
778 for (i2 of a2.entries())
779 if (!b2.has(i2[0])) return false;
780 return true;
781 }
782 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (a2[i2] !== b2[i2]) return false;
787 return true;
788 }
789 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
790 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
791 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
792 keys = Object.keys(a2);
793 length = keys.length;
794 if (length !== Object.keys(b2).length) return false;
795 for (i2 = length; i2-- !== 0; )
796 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
797 for (i2 = length; i2-- !== 0; ) {
798 var key = keys[i2];
799 if (!equal(a2[key], b2[key])) return false;
800 }
801 return true;
802 }
803 return a2 !== a2 && b2 !== b2;
804 };
805 }
806 });
807
808 // package-external:@wordpress/date
809 var require_date = __commonJS({
810 "package-external:@wordpress/date"(exports, module) {
811 module.exports = window.wp.date;
812 }
813 });
814
815 // package-external:@wordpress/warning
816 var require_warning = __commonJS({
817 "package-external:@wordpress/warning"(exports, module) {
818 module.exports = window.wp.warning;
819 }
820 });
821
822 // package-external:@wordpress/html-entities
823 var require_html_entities = __commonJS({
824 "package-external:@wordpress/html-entities"(exports, module) {
825 module.exports = window.wp.htmlEntities;
826 }
827 });
828
829 // widgets/news/render.tsx
830 var import_i18n45 = __toESM(require_i18n());
831
832 // node_modules/clsx/dist/clsx.mjs
833 function r(e2) {
834 var t2, f2, n2 = "";
835 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
836 else if ("object" == typeof e2) if (Array.isArray(e2)) {
837 var o2 = e2.length;
838 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
839 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
840 return n2;
841 }
842 function clsx() {
843 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
844 return n2;
845 }
846 var clsx_default = clsx;
847
848 // node_modules/@base-ui/utils/esm/useStableCallback.js
849 var React2 = __toESM(require_react(), 1);
850
851 // node_modules/@base-ui/utils/esm/useRefWithInit.js
852 var React = __toESM(require_react(), 1);
853 var UNINITIALIZED = {};
854 function useRefWithInit(init2, initArg) {
855 const ref = React.useRef(UNINITIALIZED);
856 if (ref.current === UNINITIALIZED) {
857 ref.current = init2(initArg);
858 }
859 return ref;
860 }
861
862 // node_modules/@base-ui/utils/esm/useStableCallback.js
863 var useInsertionEffect = React2[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
864 var useSafeInsertionEffect = (
865 // React 17 doesn't have useInsertionEffect.
866 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
867 useInsertionEffect !== React2.useLayoutEffect ? useInsertionEffect : (fn) => fn()
868 );
869 function useStableCallback(callback) {
870 const stable = useRefWithInit(createStableCallback).current;
871 stable.next = callback;
872 useSafeInsertionEffect(stable.effect);
873 return stable.trampoline;
874 }
875 function createStableCallback() {
876 const stable = {
877 next: void 0,
878 callback: assertNotCalled,
879 trampoline: (...args) => stable.callback?.(...args),
880 effect: () => {
881 stable.callback = stable.next;
882 }
883 };
884 return stable;
885 }
886 function assertNotCalled() {
887 if (true) {
888 throw (
889 /* minify-error-disabled */
890 new Error("Base UI: Cannot call an event handler while rendering.")
891 );
892 }
893 }
894
895 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
896 var React3 = __toESM(require_react(), 1);
897 var noop = () => {
898 };
899 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
900
901 // node_modules/@base-ui/utils/esm/warn.js
902 var set;
903 if (true) {
904 set = /* @__PURE__ */ new Set();
905 }
906 function warn(...messages) {
907 if (true) {
908 const messageKey = messages.join(" ");
909 if (!set.has(messageKey)) {
910 set.add(messageKey);
911 console.warn(`Base UI: ${messageKey}`);
912 }
913 }
914 }
915
916 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
917 var React4 = __toESM(require_react(), 1);
918 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
919 if (true) DirectionContext.displayName = "DirectionContext";
920 function useDirection() {
921 const context = React4.useContext(DirectionContext);
922 return context?.direction ?? "ltr";
923 }
924
925 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
926 var React7 = __toESM(require_react(), 1);
927
928 // node_modules/@base-ui/utils/esm/useMergedRefs.js
929 function useMergedRefs(a2, b2, c2, d2) {
930 const forkRef = useRefWithInit(createForkRef).current;
931 if (didChange(forkRef, a2, b2, c2, d2)) {
932 update(forkRef, [a2, b2, c2, d2]);
933 }
934 return forkRef.callback;
935 }
936 function useMergedRefsN(refs) {
937 const forkRef = useRefWithInit(createForkRef).current;
938 if (didChangeN(forkRef, refs)) {
939 update(forkRef, refs);
940 }
941 return forkRef.callback;
942 }
943 function createForkRef() {
944 return {
945 callback: null,
946 cleanup: null,
947 refs: []
948 };
949 }
950 function didChange(forkRef, a2, b2, c2, d2) {
951 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
952 }
953 function didChangeN(forkRef, newRefs) {
954 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
955 }
956 function update(forkRef, refs) {
957 forkRef.refs = refs;
958 if (refs.every((ref) => ref == null)) {
959 forkRef.callback = null;
960 return;
961 }
962 forkRef.callback = (instance) => {
963 if (forkRef.cleanup) {
964 forkRef.cleanup();
965 forkRef.cleanup = null;
966 }
967 if (instance != null) {
968 const cleanupCallbacks = Array(refs.length).fill(null);
969 for (let i2 = 0; i2 < refs.length; i2 += 1) {
970 const ref = refs[i2];
971 if (ref == null) {
972 continue;
973 }
974 switch (typeof ref) {
975 case "function": {
976 const refCleanup = ref(instance);
977 if (typeof refCleanup === "function") {
978 cleanupCallbacks[i2] = refCleanup;
979 }
980 break;
981 }
982 case "object": {
983 ref.current = instance;
984 break;
985 }
986 default:
987 }
988 }
989 forkRef.cleanup = () => {
990 for (let i2 = 0; i2 < refs.length; i2 += 1) {
991 const ref = refs[i2];
992 if (ref == null) {
993 continue;
994 }
995 switch (typeof ref) {
996 case "function": {
997 const cleanupCallback = cleanupCallbacks[i2];
998 if (typeof cleanupCallback === "function") {
999 cleanupCallback();
1000 } else {
1001 ref(null);
1002 }
1003 break;
1004 }
1005 case "object": {
1006 ref.current = null;
1007 break;
1008 }
1009 default:
1010 }
1011 }
1012 };
1013 }
1014 };
1015 }
1016
1017 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1018 var React6 = __toESM(require_react(), 1);
1019
1020 // node_modules/@base-ui/utils/esm/reactVersion.js
1021 var React5 = __toESM(require_react(), 1);
1022 var majorVersion = parseInt(React5.version, 10);
1023 function isReactVersionAtLeast(reactVersionToCheck) {
1024 return majorVersion >= reactVersionToCheck;
1025 }
1026
1027 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1028 function getReactElementRef(element) {
1029 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1030 return null;
1031 }
1032 const reactElement = element;
1033 const propsWithRef = reactElement.props;
1034 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1035 }
1036
1037 // node_modules/@base-ui/utils/esm/mergeObjects.js
1038 function mergeObjects(a2, b2) {
1039 if (a2 && !b2) {
1040 return a2;
1041 }
1042 if (!a2 && b2) {
1043 return b2;
1044 }
1045 if (a2 || b2) {
1046 return {
1047 ...a2,
1048 ...b2
1049 };
1050 }
1051 return void 0;
1052 }
1053
1054 // node_modules/@base-ui/utils/esm/empty.js
1055 function NOOP() {
1056 }
1057 var EMPTY_ARRAY = Object.freeze([]);
1058 var EMPTY_OBJECT = Object.freeze({});
1059
1060 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1061 function getStateAttributesProps(state, customMapping) {
1062 const props = {};
1063 for (const key in state) {
1064 const value = state[key];
1065 if (customMapping?.hasOwnProperty(key)) {
1066 const customProps = customMapping[key](value);
1067 if (customProps != null) {
1068 Object.assign(props, customProps);
1069 }
1070 continue;
1071 }
1072 if (value === true) {
1073 props[`data-${key.toLowerCase()}`] = "";
1074 } else if (value) {
1075 props[`data-${key.toLowerCase()}`] = value.toString();
1076 }
1077 }
1078 return props;
1079 }
1080
1081 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1082 function resolveClassName(className, state) {
1083 return typeof className === "function" ? className(state) : className;
1084 }
1085
1086 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1087 function resolveStyle(style, state) {
1088 return typeof style === "function" ? style(state) : style;
1089 }
1090
1091 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1092 var EMPTY_PROPS = {};
1093 function mergeProps(a2, b2, c2, d2, e2) {
1094 if (!c2 && !d2 && !e2 && !a2) {
1095 return createInitialMergedProps(b2);
1096 }
1097 let merged = createInitialMergedProps(a2);
1098 if (b2) {
1099 merged = mergeInto(merged, b2);
1100 }
1101 if (c2) {
1102 merged = mergeInto(merged, c2);
1103 }
1104 if (d2) {
1105 merged = mergeInto(merged, d2);
1106 }
1107 if (e2) {
1108 merged = mergeInto(merged, e2);
1109 }
1110 return merged;
1111 }
1112 function mergePropsN(props) {
1113 if (props.length === 0) {
1114 return EMPTY_PROPS;
1115 }
1116 if (props.length === 1) {
1117 return createInitialMergedProps(props[0]);
1118 }
1119 let merged = createInitialMergedProps(props[0]);
1120 for (let i2 = 1; i2 < props.length; i2 += 1) {
1121 merged = mergeInto(merged, props[i2]);
1122 }
1123 return merged;
1124 }
1125 function createInitialMergedProps(inputProps) {
1126 if (isPropsGetter(inputProps)) {
1127 return {
1128 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1129 };
1130 }
1131 return copyInitialProps(inputProps);
1132 }
1133 function mergeInto(merged, inputProps) {
1134 if (isPropsGetter(inputProps)) {
1135 return resolvePropsGetter(inputProps, merged);
1136 }
1137 return mutablyMergeInto(merged, inputProps);
1138 }
1139 function copyInitialProps(inputProps) {
1140 const copiedProps = {
1141 ...inputProps
1142 };
1143 for (const propName in copiedProps) {
1144 const propValue = copiedProps[propName];
1145 if (isEventHandler(propName, propValue)) {
1146 copiedProps[propName] = wrapEventHandler(propValue);
1147 }
1148 }
1149 return copiedProps;
1150 }
1151 function mutablyMergeInto(mergedProps, externalProps) {
1152 if (!externalProps) {
1153 return mergedProps;
1154 }
1155 for (const propName in externalProps) {
1156 const externalPropValue = externalProps[propName];
1157 switch (propName) {
1158 case "style": {
1159 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1160 break;
1161 }
1162 case "className": {
1163 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1164 break;
1165 }
1166 default: {
1167 if (isEventHandler(propName, externalPropValue)) {
1168 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1169 } else {
1170 mergedProps[propName] = externalPropValue;
1171 }
1172 }
1173 }
1174 }
1175 return mergedProps;
1176 }
1177 function isEventHandler(key, value) {
1178 const code0 = key.charCodeAt(0);
1179 const code1 = key.charCodeAt(1);
1180 const code2 = key.charCodeAt(2);
1181 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1182 }
1183 function isPropsGetter(inputProps) {
1184 return typeof inputProps === "function";
1185 }
1186 function resolvePropsGetter(inputProps, previousProps) {
1187 if (isPropsGetter(inputProps)) {
1188 return inputProps(previousProps);
1189 }
1190 return inputProps ?? EMPTY_PROPS;
1191 }
1192 function mergeEventHandlers(ourHandler, theirHandler) {
1193 if (!theirHandler) {
1194 return ourHandler;
1195 }
1196 if (!ourHandler) {
1197 return wrapEventHandler(theirHandler);
1198 }
1199 return (...args) => {
1200 const event = args[0];
1201 if (isSyntheticEvent(event)) {
1202 const baseUIEvent = event;
1203 makeEventPreventable(baseUIEvent);
1204 const result2 = theirHandler(...args);
1205 if (!baseUIEvent.baseUIHandlerPrevented) {
1206 ourHandler?.(...args);
1207 }
1208 return result2;
1209 }
1210 const result = theirHandler(...args);
1211 ourHandler?.(...args);
1212 return result;
1213 };
1214 }
1215 function wrapEventHandler(handler) {
1216 if (!handler) {
1217 return handler;
1218 }
1219 return (...args) => {
1220 const event = args[0];
1221 if (isSyntheticEvent(event)) {
1222 makeEventPreventable(event);
1223 }
1224 return handler(...args);
1225 };
1226 }
1227 function makeEventPreventable(event) {
1228 event.preventBaseUIHandler = () => {
1229 event.baseUIHandlerPrevented = true;
1230 };
1231 return event;
1232 }
1233 function mergeClassNames(ourClassName, theirClassName) {
1234 if (theirClassName) {
1235 if (ourClassName) {
1236 return theirClassName + " " + ourClassName;
1237 }
1238 return theirClassName;
1239 }
1240 return ourClassName;
1241 }
1242 function isSyntheticEvent(event) {
1243 return event != null && typeof event === "object" && "nativeEvent" in event;
1244 }
1245
1246 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1247 var import_react = __toESM(require_react(), 1);
1248 function useRenderElement(element, componentProps, params = {}) {
1249 const renderProp = componentProps.render;
1250 const outProps = useRenderElementProps(componentProps, params);
1251 if (params.enabled === false) {
1252 return null;
1253 }
1254 const state = params.state ?? EMPTY_OBJECT;
1255 return evaluateRenderProp(element, renderProp, outProps, state);
1256 }
1257 function useRenderElementProps(componentProps, params = {}) {
1258 const {
1259 className: classNameProp,
1260 style: styleProp,
1261 render: renderProp
1262 } = componentProps;
1263 const {
1264 state = EMPTY_OBJECT,
1265 ref,
1266 props,
1267 stateAttributesMapping: stateAttributesMapping3,
1268 enabled = true
1269 } = params;
1270 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1271 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1272 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1273 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1274 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1275 if (typeof document !== "undefined") {
1276 if (!enabled) {
1277 useMergedRefs(null, null);
1278 } else if (Array.isArray(ref)) {
1279 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1280 } else {
1281 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1282 }
1283 }
1284 if (!enabled) {
1285 return EMPTY_OBJECT;
1286 }
1287 if (className !== void 0) {
1288 outProps.className = mergeClassNames(outProps.className, className);
1289 }
1290 if (style !== void 0) {
1291 outProps.style = mergeObjects(outProps.style, style);
1292 }
1293 return outProps;
1294 }
1295 function resolveRenderFunctionProps(props) {
1296 if (Array.isArray(props)) {
1297 return mergePropsN(props);
1298 }
1299 return mergeProps(void 0, props);
1300 }
1301 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1302 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1303 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1304 function evaluateRenderProp(element, render4, props, state) {
1305 if (render4) {
1306 if (typeof render4 === "function") {
1307 if (true) {
1308 warnIfRenderPropLooksLikeComponent(render4);
1309 }
1310 return render4(props, state);
1311 }
1312 const mergedProps = mergeProps(props, render4.props);
1313 mergedProps.ref = props.ref;
1314 let newElement = render4;
1315 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1316 const children = React7.Children.toArray(render4);
1317 newElement = children[0];
1318 }
1319 if (true) {
1320 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1321 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"));
1322 }
1323 }
1324 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1325 }
1326 if (element) {
1327 if (typeof element === "string") {
1328 return renderTag(element, props);
1329 }
1330 }
1331 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1332 }
1333 function warnIfRenderPropLooksLikeComponent(renderFn) {
1334 const functionName = renderFn.name;
1335 if (functionName.length === 0) {
1336 return;
1337 }
1338 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1339 return;
1340 }
1341 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1342 return;
1343 }
1344 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");
1345 }
1346 function renderTag(Tag, props) {
1347 if (Tag === "button") {
1348 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1349 type: "button",
1350 ...props,
1351 key: props.key
1352 });
1353 }
1354 if (Tag === "img") {
1355 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1356 alt: "",
1357 ...props,
1358 key: props.key
1359 });
1360 }
1361 return /* @__PURE__ */ React7.createElement(Tag, props);
1362 }
1363
1364 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1365 var reason_parts_exports = {};
1366 __export(reason_parts_exports, {
1367 cancelOpen: () => cancelOpen,
1368 chipRemovePress: () => chipRemovePress,
1369 clearPress: () => clearPress,
1370 closePress: () => closePress,
1371 closeWatcher: () => closeWatcher,
1372 decrementPress: () => decrementPress,
1373 disabled: () => disabled,
1374 drag: () => drag,
1375 escapeKey: () => escapeKey,
1376 focusOut: () => focusOut,
1377 imperativeAction: () => imperativeAction,
1378 incrementPress: () => incrementPress,
1379 inputBlur: () => inputBlur,
1380 inputChange: () => inputChange,
1381 inputClear: () => inputClear,
1382 inputPaste: () => inputPaste,
1383 inputPress: () => inputPress,
1384 itemPress: () => itemPress,
1385 keyboard: () => keyboard,
1386 linkPress: () => linkPress,
1387 listNavigation: () => listNavigation,
1388 none: () => none,
1389 outsidePress: () => outsidePress,
1390 pointer: () => pointer,
1391 scrub: () => scrub,
1392 siblingOpen: () => siblingOpen,
1393 swipe: () => swipe,
1394 trackPress: () => trackPress,
1395 triggerFocus: () => triggerFocus,
1396 triggerHover: () => triggerHover,
1397 triggerPress: () => triggerPress,
1398 wheel: () => wheel,
1399 windowResize: () => windowResize
1400 });
1401 var none = "none";
1402 var triggerPress = "trigger-press";
1403 var triggerHover = "trigger-hover";
1404 var triggerFocus = "trigger-focus";
1405 var outsidePress = "outside-press";
1406 var itemPress = "item-press";
1407 var closePress = "close-press";
1408 var linkPress = "link-press";
1409 var clearPress = "clear-press";
1410 var chipRemovePress = "chip-remove-press";
1411 var trackPress = "track-press";
1412 var incrementPress = "increment-press";
1413 var decrementPress = "decrement-press";
1414 var inputChange = "input-change";
1415 var inputClear = "input-clear";
1416 var inputBlur = "input-blur";
1417 var inputPaste = "input-paste";
1418 var inputPress = "input-press";
1419 var focusOut = "focus-out";
1420 var escapeKey = "escape-key";
1421 var closeWatcher = "close-watcher";
1422 var listNavigation = "list-navigation";
1423 var keyboard = "keyboard";
1424 var pointer = "pointer";
1425 var drag = "drag";
1426 var wheel = "wheel";
1427 var scrub = "scrub";
1428 var cancelOpen = "cancel-open";
1429 var siblingOpen = "sibling-open";
1430 var disabled = "disabled";
1431 var imperativeAction = "imperative-action";
1432 var swipe = "swipe";
1433 var windowResize = "window-resize";
1434
1435 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1436 function createChangeEventDetails(reason, event, trigger, customProperties) {
1437 let canceled = false;
1438 let allowPropagation = false;
1439 const custom = customProperties ?? EMPTY_OBJECT;
1440 const details = {
1441 reason,
1442 event: event ?? new Event("base-ui"),
1443 cancel() {
1444 canceled = true;
1445 },
1446 allowPropagation() {
1447 allowPropagation = true;
1448 },
1449 get isCanceled() {
1450 return canceled;
1451 },
1452 get isPropagationAllowed() {
1453 return allowPropagation;
1454 },
1455 trigger,
1456 ...custom
1457 };
1458 return details;
1459 }
1460
1461 // node_modules/@base-ui/utils/esm/useId.js
1462 var React9 = __toESM(require_react(), 1);
1463
1464 // node_modules/@base-ui/utils/esm/safeReact.js
1465 var React8 = __toESM(require_react(), 1);
1466 var SafeReact = {
1467 ...React8
1468 };
1469
1470 // node_modules/@base-ui/utils/esm/useId.js
1471 var globalId = 0;
1472 function useGlobalId(idOverride, prefix = "mui") {
1473 const [defaultId, setDefaultId] = React9.useState(idOverride);
1474 const id = idOverride || defaultId;
1475 React9.useEffect(() => {
1476 if (defaultId == null) {
1477 globalId += 1;
1478 setDefaultId(`${prefix}-${globalId}`);
1479 }
1480 }, [defaultId, prefix]);
1481 return id;
1482 }
1483 var maybeReactUseId = SafeReact.useId;
1484 function useId(idOverride, prefix) {
1485 if (maybeReactUseId !== void 0) {
1486 const reactId = maybeReactUseId();
1487 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1488 }
1489 return useGlobalId(idOverride, prefix);
1490 }
1491
1492 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1493 function useBaseUiId(idOverride) {
1494 return useId(idOverride, "base-ui");
1495 }
1496
1497 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1498 var ReactDOM = __toESM(require_react_dom(), 1);
1499
1500 // node_modules/@base-ui/utils/esm/useOnMount.js
1501 var React10 = __toESM(require_react(), 1);
1502 var EMPTY = [];
1503 function useOnMount(fn) {
1504 React10.useEffect(fn, EMPTY);
1505 }
1506
1507 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1508 var EMPTY2 = null;
1509 var LAST_RAF = globalThis.requestAnimationFrame;
1510 var Scheduler = class {
1511 /* This implementation uses an array as a backing data-structure for frame callbacks.
1512 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1513 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1514 * be much more efficient if there is a call pattern that alterns as
1515 * "request-cancel-request-cancel-…".
1516 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1517 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1518 callbacks = [];
1519 callbacksCount = 0;
1520 nextId = 1;
1521 startId = 1;
1522 isScheduled = false;
1523 tick = (timestamp) => {
1524 this.isScheduled = false;
1525 const currentCallbacks = this.callbacks;
1526 const currentCallbacksCount = this.callbacksCount;
1527 this.callbacks = [];
1528 this.callbacksCount = 0;
1529 this.startId = this.nextId;
1530 if (currentCallbacksCount > 0) {
1531 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1532 currentCallbacks[i2]?.(timestamp);
1533 }
1534 }
1535 };
1536 request(fn) {
1537 const id = this.nextId;
1538 this.nextId += 1;
1539 this.callbacks.push(fn);
1540 this.callbacksCount += 1;
1541 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1542 if (!this.isScheduled || didRAFChange) {
1543 requestAnimationFrame(this.tick);
1544 this.isScheduled = true;
1545 }
1546 return id;
1547 }
1548 cancel(id) {
1549 const index2 = id - this.startId;
1550 if (index2 < 0 || index2 >= this.callbacks.length) {
1551 return;
1552 }
1553 this.callbacks[index2] = null;
1554 this.callbacksCount -= 1;
1555 }
1556 };
1557 var scheduler = new Scheduler();
1558 var AnimationFrame = class _AnimationFrame {
1559 static create() {
1560 return new _AnimationFrame();
1561 }
1562 static request(fn) {
1563 return scheduler.request(fn);
1564 }
1565 static cancel(id) {
1566 return scheduler.cancel(id);
1567 }
1568 currentId = EMPTY2;
1569 /**
1570 * Executes `fn` after `delay`, clearing any previously scheduled call.
1571 */
1572 request(fn) {
1573 this.cancel();
1574 this.currentId = scheduler.request(() => {
1575 this.currentId = EMPTY2;
1576 fn();
1577 });
1578 }
1579 cancel = () => {
1580 if (this.currentId !== EMPTY2) {
1581 scheduler.cancel(this.currentId);
1582 this.currentId = EMPTY2;
1583 }
1584 };
1585 disposeEffect = () => {
1586 return this.cancel;
1587 };
1588 };
1589 function useAnimationFrame() {
1590 const timeout = useRefWithInit(AnimationFrame.create).current;
1591 useOnMount(timeout.disposeEffect);
1592 return timeout;
1593 }
1594
1595 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1596 function resolveRef(maybeRef) {
1597 if (maybeRef == null) {
1598 return maybeRef;
1599 }
1600 return "current" in maybeRef ? maybeRef.current : maybeRef;
1601 }
1602
1603 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1604 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1605 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1606 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1607 return TransitionStatusDataAttributes2;
1608 })({});
1609 var STARTING_HOOK = {
1610 [TransitionStatusDataAttributes.startingStyle]: ""
1611 };
1612 var ENDING_HOOK = {
1613 [TransitionStatusDataAttributes.endingStyle]: ""
1614 };
1615 var transitionStatusMapping = {
1616 transitionStatus(value) {
1617 if (value === "starting") {
1618 return STARTING_HOOK;
1619 }
1620 if (value === "ending") {
1621 return ENDING_HOOK;
1622 }
1623 return null;
1624 }
1625 };
1626
1627 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1628 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1629 const frame = useAnimationFrame();
1630 return useStableCallback((fnToExecute, signal = null) => {
1631 frame.cancel();
1632 const element = resolveRef(elementOrRef);
1633 if (element == null) {
1634 return;
1635 }
1636 const resolvedElement = element;
1637 const done = () => {
1638 ReactDOM.flushSync(fnToExecute);
1639 };
1640 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1641 fnToExecute();
1642 return;
1643 }
1644 function exec() {
1645 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1646 if (!signal?.aborted) {
1647 done();
1648 }
1649 }).catch(() => {
1650 if (treatAbortedAsFinished) {
1651 if (!signal?.aborted) {
1652 done();
1653 }
1654 return;
1655 }
1656 const currentAnimations = resolvedElement.getAnimations();
1657 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1658 exec();
1659 }
1660 });
1661 }
1662 if (waitForStartingStyleRemoved) {
1663 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1664 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1665 frame.request(exec);
1666 return;
1667 }
1668 const attributeObserver = new MutationObserver(() => {
1669 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1670 attributeObserver.disconnect();
1671 exec();
1672 }
1673 });
1674 attributeObserver.observe(resolvedElement, {
1675 attributes: true,
1676 attributeFilter: [startingStyleAttribute]
1677 });
1678 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1679 once: true
1680 });
1681 return;
1682 }
1683 frame.request(exec);
1684 });
1685 }
1686
1687 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1688 var React11 = __toESM(require_react(), 1);
1689 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1690 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1691 const [mounted, setMounted] = React11.useState(open);
1692 if (open && !mounted) {
1693 setMounted(true);
1694 setTransitionStatus("starting");
1695 }
1696 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1697 setTransitionStatus("ending");
1698 }
1699 if (!open && !mounted && transitionStatus === "ending") {
1700 setTransitionStatus(void 0);
1701 }
1702 useIsoLayoutEffect(() => {
1703 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1704 const frame = AnimationFrame.request(() => {
1705 setTransitionStatus("ending");
1706 });
1707 return () => {
1708 AnimationFrame.cancel(frame);
1709 };
1710 }
1711 return void 0;
1712 }, [open, mounted, transitionStatus, deferEndingState]);
1713 useIsoLayoutEffect(() => {
1714 if (!open || enableIdleState) {
1715 return void 0;
1716 }
1717 const frame = AnimationFrame.request(() => {
1718 setTransitionStatus(void 0);
1719 });
1720 return () => {
1721 AnimationFrame.cancel(frame);
1722 };
1723 }, [enableIdleState, open]);
1724 useIsoLayoutEffect(() => {
1725 if (!open || !enableIdleState) {
1726 return void 0;
1727 }
1728 if (open && mounted && transitionStatus !== "idle") {
1729 setTransitionStatus("starting");
1730 }
1731 const frame = AnimationFrame.request(() => {
1732 setTransitionStatus("idle");
1733 });
1734 return () => {
1735 AnimationFrame.cancel(frame);
1736 };
1737 }, [enableIdleState, open, mounted, transitionStatus]);
1738 return {
1739 mounted,
1740 setMounted,
1741 transitionStatus
1742 };
1743 }
1744
1745 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1746 function hasWindow() {
1747 return typeof window !== "undefined";
1748 }
1749 function getNodeName(node) {
1750 if (isNode(node)) {
1751 return (node.nodeName || "").toLowerCase();
1752 }
1753 return "#document";
1754 }
1755 function getWindow(node) {
1756 var _node$ownerDocument;
1757 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1758 }
1759 function getDocumentElement(node) {
1760 var _ref;
1761 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1762 }
1763 function isNode(value) {
1764 if (!hasWindow()) {
1765 return false;
1766 }
1767 return value instanceof Node || value instanceof getWindow(value).Node;
1768 }
1769 function isElement(value) {
1770 if (!hasWindow()) {
1771 return false;
1772 }
1773 return value instanceof Element || value instanceof getWindow(value).Element;
1774 }
1775 function isHTMLElement(value) {
1776 if (!hasWindow()) {
1777 return false;
1778 }
1779 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1780 }
1781 function isShadowRoot(value) {
1782 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1783 return false;
1784 }
1785 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1786 }
1787 function isOverflowElement(element) {
1788 const {
1789 overflow,
1790 overflowX,
1791 overflowY,
1792 display
1793 } = getComputedStyle2(element);
1794 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1795 }
1796 function isTableElement(element) {
1797 return /^(table|td|th)$/.test(getNodeName(element));
1798 }
1799 function isTopLayer(element) {
1800 try {
1801 if (element.matches(":popover-open")) {
1802 return true;
1803 }
1804 } catch (_e) {
1805 }
1806 try {
1807 return element.matches(":modal");
1808 } catch (_e) {
1809 return false;
1810 }
1811 }
1812 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1813 var containRe = /paint|layout|strict|content/;
1814 var isNotNone = (value) => !!value && value !== "none";
1815 var isWebKitValue;
1816 function isContainingBlock(elementOrCss) {
1817 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1818 return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
1819 }
1820 function getContainingBlock(element) {
1821 let currentNode = getParentNode(element);
1822 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1823 if (isContainingBlock(currentNode)) {
1824 return currentNode;
1825 } else if (isTopLayer(currentNode)) {
1826 return null;
1827 }
1828 currentNode = getParentNode(currentNode);
1829 }
1830 return null;
1831 }
1832 function isWebKit() {
1833 if (isWebKitValue == null) {
1834 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1835 }
1836 return isWebKitValue;
1837 }
1838 function isLastTraversableNode(node) {
1839 return /^(html|body|#document)$/.test(getNodeName(node));
1840 }
1841 function getComputedStyle2(element) {
1842 return getWindow(element).getComputedStyle(element);
1843 }
1844 function getNodeScroll(element) {
1845 if (isElement(element)) {
1846 return {
1847 scrollLeft: element.scrollLeft,
1848 scrollTop: element.scrollTop
1849 };
1850 }
1851 return {
1852 scrollLeft: element.scrollX,
1853 scrollTop: element.scrollY
1854 };
1855 }
1856 function getParentNode(node) {
1857 if (getNodeName(node) === "html") {
1858 return node;
1859 }
1860 const result = (
1861 // Step into the shadow DOM of the parent of a slotted node.
1862 node.assignedSlot || // DOM Element detected.
1863 node.parentNode || // ShadowRoot detected.
1864 isShadowRoot(node) && node.host || // Fallback.
1865 getDocumentElement(node)
1866 );
1867 return isShadowRoot(result) ? result.host : result;
1868 }
1869 function getNearestOverflowAncestor(node) {
1870 const parentNode = getParentNode(node);
1871 if (isLastTraversableNode(parentNode)) {
1872 return node.ownerDocument ? node.ownerDocument.body : node.body;
1873 }
1874 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1875 return parentNode;
1876 }
1877 return getNearestOverflowAncestor(parentNode);
1878 }
1879 function getOverflowAncestors(node, list, traverseIframes) {
1880 var _node$ownerDocument2;
1881 if (list === void 0) {
1882 list = [];
1883 }
1884 if (traverseIframes === void 0) {
1885 traverseIframes = true;
1886 }
1887 const scrollableAncestor = getNearestOverflowAncestor(node);
1888 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1889 const win = getWindow(scrollableAncestor);
1890 if (isBody) {
1891 const frameElement = getFrameElement(win);
1892 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1893 } else {
1894 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1895 }
1896 }
1897 function getFrameElement(win) {
1898 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1899 }
1900
1901 // node_modules/@base-ui/utils/esm/detectBrowser.js
1902 var hasNavigator = typeof navigator !== "undefined";
1903 var nav = getNavigatorData();
1904 var platform = getPlatform();
1905 var userAgent = getUserAgent();
1906 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1907 var isIOS = (
1908 // iPads can claim to be MacIntel
1909 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
1910 );
1911 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
1912 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
1913 var isEdge = hasNavigator && /Edg/i.test(userAgent);
1914 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
1915 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
1916 var isJSDOM = userAgent.includes("jsdom/");
1917 function getNavigatorData() {
1918 if (!hasNavigator) {
1919 return {
1920 platform: "",
1921 maxTouchPoints: -1
1922 };
1923 }
1924 const uaData = navigator.userAgentData;
1925 if (uaData?.platform) {
1926 return {
1927 platform: uaData.platform,
1928 maxTouchPoints: navigator.maxTouchPoints
1929 };
1930 }
1931 return {
1932 platform: navigator.platform ?? "",
1933 maxTouchPoints: navigator.maxTouchPoints ?? -1
1934 };
1935 }
1936 function getUserAgent() {
1937 if (!hasNavigator) {
1938 return "";
1939 }
1940 const uaData = navigator.userAgentData;
1941 if (uaData && Array.isArray(uaData.brands)) {
1942 return uaData.brands.map(({
1943 brand,
1944 version: version2
1945 }) => `${brand}/${version2}`).join(" ");
1946 }
1947 return navigator.userAgent;
1948 }
1949 function getPlatform() {
1950 if (!hasNavigator) {
1951 return "";
1952 }
1953 const uaData = navigator.userAgentData;
1954 if (uaData?.platform) {
1955 return uaData.platform;
1956 }
1957 return navigator.platform ?? "";
1958 }
1959
1960 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
1961 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
1962 var ACTIVE_KEY = "active";
1963 var SELECTED_KEY = "selected";
1964 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1965
1966 // node_modules/@base-ui/react/esm/internals/shadowDom.js
1967 function activeElement(doc) {
1968 let element = doc.activeElement;
1969 while (element?.shadowRoot?.activeElement != null) {
1970 element = element.shadowRoot.activeElement;
1971 }
1972 return element;
1973 }
1974 function contains(parent, child) {
1975 if (!parent || !child) {
1976 return false;
1977 }
1978 const rootNode = child.getRootNode?.();
1979 if (parent.contains(child)) {
1980 return true;
1981 }
1982 if (rootNode && isShadowRoot(rootNode)) {
1983 let next = child;
1984 while (next) {
1985 if (parent === next) {
1986 return true;
1987 }
1988 next = next.parentNode || next.host;
1989 }
1990 }
1991 return false;
1992 }
1993 function getTarget(event) {
1994 if ("composedPath" in event) {
1995 return event.composedPath()[0];
1996 }
1997 return event.target;
1998 }
1999
2000 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2001 function isTargetInsideEnabledTrigger(target, triggerElements) {
2002 if (!isElement(target)) {
2003 return false;
2004 }
2005 const targetElement = target;
2006 if (triggerElements.hasElement(targetElement)) {
2007 return !targetElement.hasAttribute("data-trigger-disabled");
2008 }
2009 for (const [, trigger] of triggerElements.entries()) {
2010 if (contains(trigger, targetElement)) {
2011 return !trigger.hasAttribute("data-trigger-disabled");
2012 }
2013 }
2014 return false;
2015 }
2016 function isEventTargetWithin(event, node) {
2017 if (node == null) {
2018 return false;
2019 }
2020 if ("composedPath" in event) {
2021 return event.composedPath().includes(node);
2022 }
2023 const eventAgain = event;
2024 return eventAgain.target != null && node.contains(eventAgain.target);
2025 }
2026 function isRootElement(element) {
2027 return element.matches("html,body");
2028 }
2029 function isTypeableElement(element) {
2030 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2031 }
2032 function isInteractiveElement(element) {
2033 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2034 }
2035 function matchesFocusVisible(element) {
2036 if (!element || isJSDOM) {
2037 return true;
2038 }
2039 try {
2040 return element.matches(":focus-visible");
2041 } catch (_e) {
2042 return true;
2043 }
2044 }
2045
2046 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2047 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2048 const directChildren = nodes.filter((node) => node.parentId === id);
2049 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2050 }
2051
2052 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2053 function isReactEvent(event) {
2054 return "nativeEvent" in event;
2055 }
2056 function isMouseLikePointerType(pointerType, strict) {
2057 const values = ["mouse", "pen"];
2058 if (!strict) {
2059 values.push("", void 0);
2060 }
2061 return values.includes(pointerType);
2062 }
2063 function isClickLikeEvent(event) {
2064 const type = event.type;
2065 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2066 }
2067
2068 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2069 var sides = ["top", "right", "bottom", "left"];
2070 var min = Math.min;
2071 var max = Math.max;
2072 var round = Math.round;
2073 var floor = Math.floor;
2074 var createCoords = (v2) => ({
2075 x: v2,
2076 y: v2
2077 });
2078 var oppositeSideMap = {
2079 left: "right",
2080 right: "left",
2081 bottom: "top",
2082 top: "bottom"
2083 };
2084 function clamp(start, value, end) {
2085 return max(start, min(value, end));
2086 }
2087 function evaluate(value, param) {
2088 return typeof value === "function" ? value(param) : value;
2089 }
2090 function getSide(placement) {
2091 return placement.split("-")[0];
2092 }
2093 function getAlignment(placement) {
2094 return placement.split("-")[1];
2095 }
2096 function getOppositeAxis(axis) {
2097 return axis === "x" ? "y" : "x";
2098 }
2099 function getAxisLength(axis) {
2100 return axis === "y" ? "height" : "width";
2101 }
2102 function getSideAxis(placement) {
2103 const firstChar = placement[0];
2104 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2105 }
2106 function getAlignmentAxis(placement) {
2107 return getOppositeAxis(getSideAxis(placement));
2108 }
2109 function getAlignmentSides(placement, rects, rtl) {
2110 if (rtl === void 0) {
2111 rtl = false;
2112 }
2113 const alignment = getAlignment(placement);
2114 const alignmentAxis = getAlignmentAxis(placement);
2115 const length = getAxisLength(alignmentAxis);
2116 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2117 if (rects.reference[length] > rects.floating[length]) {
2118 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2119 }
2120 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2121 }
2122 function getExpandedPlacements(placement) {
2123 const oppositePlacement = getOppositePlacement(placement);
2124 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2125 }
2126 function getOppositeAlignmentPlacement(placement) {
2127 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2128 }
2129 var lrPlacement = ["left", "right"];
2130 var rlPlacement = ["right", "left"];
2131 var tbPlacement = ["top", "bottom"];
2132 var btPlacement = ["bottom", "top"];
2133 function getSideList(side, isStart, rtl) {
2134 switch (side) {
2135 case "top":
2136 case "bottom":
2137 if (rtl) return isStart ? rlPlacement : lrPlacement;
2138 return isStart ? lrPlacement : rlPlacement;
2139 case "left":
2140 case "right":
2141 return isStart ? tbPlacement : btPlacement;
2142 default:
2143 return [];
2144 }
2145 }
2146 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2147 const alignment = getAlignment(placement);
2148 let list = getSideList(getSide(placement), direction === "start", rtl);
2149 if (alignment) {
2150 list = list.map((side) => side + "-" + alignment);
2151 if (flipAlignment) {
2152 list = list.concat(list.map(getOppositeAlignmentPlacement));
2153 }
2154 }
2155 return list;
2156 }
2157 function getOppositePlacement(placement) {
2158 const side = getSide(placement);
2159 return oppositeSideMap[side] + placement.slice(side.length);
2160 }
2161 function expandPaddingObject(padding) {
2162 return {
2163 top: 0,
2164 right: 0,
2165 bottom: 0,
2166 left: 0,
2167 ...padding
2168 };
2169 }
2170 function getPaddingObject(padding) {
2171 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2172 top: padding,
2173 right: padding,
2174 bottom: padding,
2175 left: padding
2176 };
2177 }
2178 function rectToClientRect(rect) {
2179 const {
2180 x: x2,
2181 y: y2,
2182 width,
2183 height
2184 } = rect;
2185 return {
2186 width,
2187 height,
2188 top: y2,
2189 left: x2,
2190 right: x2 + width,
2191 bottom: y2 + height,
2192 x: x2,
2193 y: y2
2194 };
2195 }
2196
2197 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2198 function isHiddenByStyles(styles) {
2199 return styles.visibility === "hidden" || styles.visibility === "collapse";
2200 }
2201 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2202 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2203 return false;
2204 }
2205 if (typeof element.checkVisibility === "function") {
2206 return element.checkVisibility();
2207 }
2208 return styles.display !== "none" && styles.display !== "contents";
2209 }
2210
2211 // node_modules/@base-ui/utils/esm/owner.js
2212 function ownerDocument(node) {
2213 return node?.ownerDocument || document;
2214 }
2215
2216 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2217 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2218 function getParentElement(element) {
2219 const assignedSlot = element.assignedSlot;
2220 if (assignedSlot) {
2221 return assignedSlot;
2222 }
2223 if (element.parentElement) {
2224 return element.parentElement;
2225 }
2226 const rootNode = element.getRootNode();
2227 return isShadowRoot(rootNode) ? rootNode.host : null;
2228 }
2229 function getDetailsSummary(details) {
2230 for (const child of Array.from(details.children)) {
2231 if (getNodeName(child) === "summary") {
2232 return child;
2233 }
2234 }
2235 return null;
2236 }
2237 function isWithinOpenDetailsSummary(element, details) {
2238 const summary = getDetailsSummary(details);
2239 return !!summary && (element === summary || contains(summary, element));
2240 }
2241 function isFocusableCandidate(element) {
2242 const nodeName = element ? getNodeName(element) : "";
2243 return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden");
2244 }
2245 function isFocusableElement(element) {
2246 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2247 return false;
2248 }
2249 for (let current = element; current; current = getParentElement(current)) {
2250 const isAncestor = current !== element;
2251 const isSlot = getNodeName(current) === "slot";
2252 if (current.hasAttribute("inert")) {
2253 return false;
2254 }
2255 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2256 return false;
2257 }
2258 }
2259 return true;
2260 }
2261 function isVisibleInTabbableTree(element, isAncestor) {
2262 const styles = getComputedStyle2(element);
2263 if (!isAncestor) {
2264 return isElementVisible(element, styles);
2265 }
2266 return styles.display !== "none";
2267 }
2268 function getTabIndex(element) {
2269 const tabIndex = element.tabIndex;
2270 if (tabIndex < 0) {
2271 const nodeName = getNodeName(element);
2272 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2273 return 0;
2274 }
2275 }
2276 return tabIndex;
2277 }
2278 function getNamedRadioInput(element) {
2279 if (getNodeName(element) !== "input") {
2280 return null;
2281 }
2282 const input = element;
2283 return input.type === "radio" && input.name !== "" ? input : null;
2284 }
2285 function isTabbableRadio(element, candidates) {
2286 const input = getNamedRadioInput(element);
2287 if (!input) {
2288 return true;
2289 }
2290 const checkedRadio = candidates.find((candidate) => {
2291 const radio = getNamedRadioInput(candidate);
2292 return radio?.name === input.name && radio.form === input.form && radio.checked;
2293 });
2294 if (checkedRadio) {
2295 return checkedRadio === input;
2296 }
2297 return candidates.find((candidate) => {
2298 const radio = getNamedRadioInput(candidate);
2299 return radio?.name === input.name && radio.form === input.form;
2300 }) === input;
2301 }
2302 function getComposedChildren(container) {
2303 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2304 const assignedElements = container.assignedElements({
2305 flatten: true
2306 });
2307 if (assignedElements.length > 0) {
2308 return assignedElements;
2309 }
2310 }
2311 if (isHTMLElement(container) && container.shadowRoot) {
2312 return Array.from(container.shadowRoot.children);
2313 }
2314 return Array.from(container.children);
2315 }
2316 function appendCandidates(container, list) {
2317 getComposedChildren(container).forEach((child) => {
2318 if (isFocusableCandidate(child)) {
2319 list.push(child);
2320 }
2321 appendCandidates(child, list);
2322 });
2323 }
2324 function appendMatchingElements(container, selector2, list) {
2325 getComposedChildren(container).forEach((child) => {
2326 if (isHTMLElement(child) && child.matches(selector2)) {
2327 list.push(child);
2328 }
2329 appendMatchingElements(child, selector2, list);
2330 });
2331 }
2332 function focusable(container) {
2333 const candidates = [];
2334 appendCandidates(container, candidates);
2335 return candidates.filter(isFocusableElement);
2336 }
2337 function tabbable(container) {
2338 const candidates = focusable(container);
2339 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2340 }
2341 function getTabbableIn(container, dir) {
2342 const list = tabbable(container);
2343 const len = list.length;
2344 if (len === 0) {
2345 return void 0;
2346 }
2347 const active = activeElement(ownerDocument(container));
2348 const index2 = list.indexOf(active);
2349 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2350 return list[nextIndex];
2351 }
2352 function getNextTabbable(referenceElement) {
2353 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2354 }
2355 function getPreviousTabbable(referenceElement) {
2356 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2357 }
2358 function isOutsideEvent(event, container) {
2359 const containerElement = container || event.currentTarget;
2360 const relatedTarget = event.relatedTarget;
2361 return !relatedTarget || !contains(containerElement, relatedTarget);
2362 }
2363 function disableFocusInside(container) {
2364 const tabbableElements = tabbable(container);
2365 tabbableElements.forEach((element) => {
2366 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2367 element.setAttribute("tabindex", "-1");
2368 });
2369 }
2370 function enableFocusInside(container) {
2371 const elements = [];
2372 appendMatchingElements(container, "[data-tabindex]", elements);
2373 elements.forEach((element) => {
2374 const tabindex = element.dataset.tabindex;
2375 delete element.dataset.tabindex;
2376 if (tabindex) {
2377 element.setAttribute("tabindex", tabindex);
2378 } else {
2379 element.removeAttribute("tabindex");
2380 }
2381 });
2382 }
2383
2384 // node_modules/@base-ui/utils/esm/addEventListener.js
2385 function addEventListener(target, type, listener, options) {
2386 target.addEventListener(type, listener, options);
2387 return () => {
2388 target.removeEventListener(type, listener, options);
2389 };
2390 }
2391
2392 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2393 var React12 = __toESM(require_react(), 1);
2394 function useOpenChangeComplete(parameters) {
2395 const {
2396 enabled = true,
2397 open,
2398 ref,
2399 onComplete: onCompleteParam
2400 } = parameters;
2401 const onComplete = useStableCallback(onCompleteParam);
2402 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2403 React12.useEffect(() => {
2404 if (!enabled) {
2405 return void 0;
2406 }
2407 const abortController = new AbortController();
2408 runOnceAnimationsFinish(onComplete, abortController.signal);
2409 return () => {
2410 abortController.abort();
2411 };
2412 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2413 }
2414
2415 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2416 var React13 = __toESM(require_react(), 1);
2417 function useOnFirstRender(fn) {
2418 const ref = React13.useRef(true);
2419 if (ref.current) {
2420 ref.current = false;
2421 fn();
2422 }
2423 }
2424
2425 // node_modules/@base-ui/utils/esm/useTimeout.js
2426 var EMPTY3 = 0;
2427 var Timeout = class _Timeout {
2428 static create() {
2429 return new _Timeout();
2430 }
2431 currentId = EMPTY3;
2432 /**
2433 * Executes `fn` after `delay`, clearing any previously scheduled call.
2434 */
2435 start(delay, fn) {
2436 this.clear();
2437 this.currentId = setTimeout(() => {
2438 this.currentId = EMPTY3;
2439 fn();
2440 }, delay);
2441 }
2442 isStarted() {
2443 return this.currentId !== EMPTY3;
2444 }
2445 clear = () => {
2446 if (this.currentId !== EMPTY3) {
2447 clearTimeout(this.currentId);
2448 this.currentId = EMPTY3;
2449 }
2450 };
2451 disposeEffect = () => {
2452 return this.clear;
2453 };
2454 };
2455 function useTimeout() {
2456 const timeout = useRefWithInit(Timeout.create).current;
2457 useOnMount(timeout.disposeEffect);
2458 return timeout;
2459 }
2460
2461 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2462 var React14 = __toESM(require_react(), 1);
2463
2464 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2465 function resolveValue(value, pointerType) {
2466 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2467 return 0;
2468 }
2469 if (typeof value === "function") {
2470 return value();
2471 }
2472 return value;
2473 }
2474 function getDelay(value, prop, pointerType) {
2475 const result = resolveValue(value, pointerType);
2476 if (typeof result === "number") {
2477 return result;
2478 }
2479 return result?.[prop];
2480 }
2481 function getRestMs(value) {
2482 if (typeof value === "function") {
2483 return value();
2484 }
2485 return value;
2486 }
2487 function isClickLikeOpenEvent(openEventType, interactedInside) {
2488 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2489 }
2490
2491 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2492 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2493 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2494 hasProvider: false,
2495 timeoutMs: 0,
2496 delayRef: {
2497 current: 0
2498 },
2499 initialDelayRef: {
2500 current: 0
2501 },
2502 timeout: new Timeout(),
2503 currentIdRef: {
2504 current: null
2505 },
2506 currentContextRef: {
2507 current: null
2508 }
2509 });
2510 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2511 function FloatingDelayGroup(props) {
2512 const {
2513 children,
2514 delay,
2515 timeoutMs = 0
2516 } = props;
2517 const delayRef = React14.useRef(delay);
2518 const initialDelayRef = React14.useRef(delay);
2519 const currentIdRef = React14.useRef(null);
2520 const currentContextRef = React14.useRef(null);
2521 const timeout = useTimeout();
2522 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2523 value: React14.useMemo(() => ({
2524 hasProvider: true,
2525 delayRef,
2526 initialDelayRef,
2527 currentIdRef,
2528 timeoutMs,
2529 currentContextRef,
2530 timeout
2531 }), [timeoutMs, timeout]),
2532 children
2533 });
2534 }
2535 function useDelayGroup(context, options = {
2536 open: false
2537 }) {
2538 const store = "rootStore" in context ? context.rootStore : context;
2539 const floatingId = store.useState("floatingId");
2540 const {
2541 open
2542 } = options;
2543 const groupContext = React14.useContext(FloatingDelayGroupContext);
2544 const {
2545 currentIdRef,
2546 delayRef,
2547 timeoutMs,
2548 initialDelayRef,
2549 currentContextRef,
2550 hasProvider,
2551 timeout
2552 } = groupContext;
2553 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2554 useIsoLayoutEffect(() => {
2555 function unset() {
2556 setIsInstantPhase(false);
2557 currentContextRef.current?.setIsInstantPhase(false);
2558 currentIdRef.current = null;
2559 currentContextRef.current = null;
2560 delayRef.current = initialDelayRef.current;
2561 }
2562 if (!currentIdRef.current) {
2563 return void 0;
2564 }
2565 if (!open && currentIdRef.current === floatingId) {
2566 setIsInstantPhase(false);
2567 if (timeoutMs) {
2568 const closingId = floatingId;
2569 timeout.start(timeoutMs, () => {
2570 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2571 return;
2572 }
2573 unset();
2574 });
2575 return () => {
2576 timeout.clear();
2577 };
2578 }
2579 unset();
2580 }
2581 return void 0;
2582 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2583 useIsoLayoutEffect(() => {
2584 if (!open) {
2585 return;
2586 }
2587 const prevContext = currentContextRef.current;
2588 const prevId = currentIdRef.current;
2589 timeout.clear();
2590 currentContextRef.current = {
2591 onOpenChange: store.setOpen,
2592 setIsInstantPhase
2593 };
2594 currentIdRef.current = floatingId;
2595 delayRef.current = {
2596 open: 0,
2597 close: getDelay(initialDelayRef.current, "close")
2598 };
2599 if (prevId !== null && prevId !== floatingId) {
2600 setIsInstantPhase(true);
2601 prevContext?.setIsInstantPhase(true);
2602 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2603 } else {
2604 setIsInstantPhase(false);
2605 prevContext?.setIsInstantPhase(false);
2606 }
2607 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
2608 useIsoLayoutEffect(() => {
2609 return () => {
2610 currentContextRef.current = null;
2611 };
2612 }, [currentContextRef]);
2613 return React14.useMemo(() => ({
2614 hasProvider,
2615 delayRef,
2616 isInstantPhase
2617 }), [hasProvider, delayRef, isInstantPhase]);
2618 }
2619
2620 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2621 function mergeCleanups(...cleanups) {
2622 return () => {
2623 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2624 const cleanup = cleanups[i2];
2625 if (cleanup) {
2626 cleanup();
2627 }
2628 }
2629 };
2630 }
2631
2632 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2633 function useValueAsRef(value) {
2634 const latest = useRefWithInit(createLatestRef, value).current;
2635 latest.next = value;
2636 useIsoLayoutEffect(latest.effect);
2637 return latest;
2638 }
2639 function createLatestRef(value) {
2640 const latest = {
2641 current: value,
2642 next: value,
2643 effect: () => {
2644 latest.current = latest.next;
2645 }
2646 };
2647 return latest;
2648 }
2649
2650 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2651 var React15 = __toESM(require_react(), 1);
2652
2653 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2654 var visuallyHiddenBase = {
2655 clipPath: "inset(50%)",
2656 overflow: "hidden",
2657 whiteSpace: "nowrap",
2658 border: 0,
2659 padding: 0,
2660 width: 1,
2661 height: 1,
2662 margin: -1
2663 };
2664 var visuallyHidden = {
2665 ...visuallyHiddenBase,
2666 position: "fixed",
2667 top: 0,
2668 left: 0
2669 };
2670 var visuallyHiddenInput = {
2671 ...visuallyHiddenBase,
2672 position: "absolute"
2673 };
2674
2675 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2676 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2677 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
2678 const [role, setRole] = React15.useState();
2679 useIsoLayoutEffect(() => {
2680 if (isSafari) {
2681 setRole("button");
2682 }
2683 }, []);
2684 const restProps = {
2685 tabIndex: 0,
2686 // Role is only for VoiceOver
2687 role
2688 };
2689 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2690 ...props,
2691 ref,
2692 style: visuallyHidden,
2693 "aria-hidden": role ? void 0 : true,
2694 ...restProps,
2695 "data-base-ui-focus-guard": ""
2696 });
2697 });
2698 if (true) FocusGuard.displayName = "FocusGuard";
2699
2700 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2701 function createAttribute(name) {
2702 return `data-base-ui-${name}`;
2703 }
2704
2705 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2706 var React16 = __toESM(require_react(), 1);
2707 var ReactDOM2 = __toESM(require_react_dom(), 1);
2708
2709 // node_modules/@base-ui/react/esm/internals/constants.js
2710 var DISABLED_TRANSITIONS_STYLE = {
2711 style: {
2712 transition: "none"
2713 }
2714 };
2715 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2716 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2717 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2718 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2719 var POPUP_COLLISION_AVOIDANCE = {
2720 fallbackAxisSide: "end"
2721 };
2722 var ownerVisuallyHidden = {
2723 clipPath: "inset(50%)",
2724 position: "fixed",
2725 top: 0,
2726 left: 0
2727 };
2728
2729 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2730 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2731 var PortalContext = /* @__PURE__ */ React16.createContext(null);
2732 if (true) PortalContext.displayName = "PortalContext";
2733 var usePortalContext = () => React16.useContext(PortalContext);
2734 var attr = createAttribute("portal");
2735 function useFloatingPortalNode(props = {}) {
2736 const {
2737 ref,
2738 container: containerProp,
2739 componentProps = EMPTY_OBJECT,
2740 elementProps
2741 } = props;
2742 const uniqueId = useId();
2743 const portalContext = usePortalContext();
2744 const parentPortalNode = portalContext?.portalNode;
2745 const [containerElement, setContainerElement] = React16.useState(null);
2746 const [portalNode, setPortalNode] = React16.useState(null);
2747 const setPortalNodeRef = useStableCallback((node) => {
2748 if (node !== null) {
2749 setPortalNode(node);
2750 }
2751 });
2752 const containerRef = React16.useRef(null);
2753 useIsoLayoutEffect(() => {
2754 if (containerProp === null) {
2755 if (containerRef.current) {
2756 containerRef.current = null;
2757 setPortalNode(null);
2758 setContainerElement(null);
2759 }
2760 return;
2761 }
2762 if (uniqueId == null) {
2763 return;
2764 }
2765 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2766 if (resolvedContainer == null) {
2767 if (containerRef.current) {
2768 containerRef.current = null;
2769 setPortalNode(null);
2770 setContainerElement(null);
2771 }
2772 return;
2773 }
2774 if (containerRef.current !== resolvedContainer) {
2775 containerRef.current = resolvedContainer;
2776 setPortalNode(null);
2777 setContainerElement(resolvedContainer);
2778 }
2779 }, [containerProp, parentPortalNode, uniqueId]);
2780 const portalElement = useRenderElement("div", componentProps, {
2781 ref: [ref, setPortalNodeRef],
2782 props: [{
2783 id: uniqueId,
2784 [attr]: ""
2785 }, elementProps]
2786 });
2787 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2788 return {
2789 portalNode,
2790 portalSubtree
2791 };
2792 }
2793 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2794 const {
2795 children,
2796 container,
2797 className,
2798 render: render4,
2799 renderGuards,
2800 style,
2801 ...elementProps
2802 } = componentProps;
2803 const {
2804 portalNode,
2805 portalSubtree
2806 } = useFloatingPortalNode({
2807 container,
2808 ref: forwardedRef,
2809 componentProps,
2810 elementProps
2811 });
2812 const beforeOutsideRef = React16.useRef(null);
2813 const afterOutsideRef = React16.useRef(null);
2814 const beforeInsideRef = React16.useRef(null);
2815 const afterInsideRef = React16.useRef(null);
2816 const [focusManagerState, setFocusManagerState] = React16.useState(null);
2817 const focusInsideDisabledRef = React16.useRef(false);
2818 const modal = focusManagerState?.modal;
2819 const open = focusManagerState?.open;
2820 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2821 React16.useEffect(() => {
2822 if (!portalNode || modal) {
2823 return void 0;
2824 }
2825 function onFocus(event) {
2826 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2827 if (event.type === "focusin") {
2828 if (focusInsideDisabledRef.current) {
2829 enableFocusInside(portalNode);
2830 focusInsideDisabledRef.current = false;
2831 }
2832 } else {
2833 disableFocusInside(portalNode);
2834 focusInsideDisabledRef.current = true;
2835 }
2836 }
2837 }
2838 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2839 }, [portalNode, modal]);
2840 React16.useEffect(() => {
2841 if (!portalNode || open !== false) {
2842 return;
2843 }
2844 enableFocusInside(portalNode);
2845 focusInsideDisabledRef.current = false;
2846 }, [open, portalNode]);
2847 const portalContextValue = React16.useMemo(() => ({
2848 beforeOutsideRef,
2849 afterOutsideRef,
2850 beforeInsideRef,
2851 afterInsideRef,
2852 portalNode,
2853 setFocusManagerState
2854 }), [portalNode]);
2855 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
2856 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2857 value: portalContextValue,
2858 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2859 "data-type": "outside",
2860 ref: beforeOutsideRef,
2861 onFocus: (event) => {
2862 if (isOutsideEvent(event, portalNode)) {
2863 beforeInsideRef.current?.focus();
2864 } else {
2865 const domReference = focusManagerState ? focusManagerState.domReference : null;
2866 const prevTabbable = getPreviousTabbable(domReference);
2867 prevTabbable?.focus();
2868 }
2869 }
2870 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2871 "aria-owns": portalNode.id,
2872 style: ownerVisuallyHidden
2873 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2874 "data-type": "outside",
2875 ref: afterOutsideRef,
2876 onFocus: (event) => {
2877 if (isOutsideEvent(event, portalNode)) {
2878 afterInsideRef.current?.focus();
2879 } else {
2880 const domReference = focusManagerState ? focusManagerState.domReference : null;
2881 const nextTabbable = getNextTabbable(domReference);
2882 nextTabbable?.focus();
2883 if (focusManagerState?.closeOnFocusOut) {
2884 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2885 }
2886 }
2887 }
2888 })]
2889 })]
2890 });
2891 });
2892 if (true) FloatingPortal.displayName = "FloatingPortal";
2893
2894 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2895 var React17 = __toESM(require_react(), 1);
2896
2897 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
2898 function createEventEmitter() {
2899 const map = /* @__PURE__ */ new Map();
2900 return {
2901 emit(event, data) {
2902 map.get(event)?.forEach((listener) => listener(data));
2903 },
2904 on(event, listener) {
2905 if (!map.has(event)) {
2906 map.set(event, /* @__PURE__ */ new Set());
2907 }
2908 map.get(event).add(listener);
2909 },
2910 off(event, listener) {
2911 map.get(event)?.delete(listener);
2912 }
2913 };
2914 }
2915
2916 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2917 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2918 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
2919 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
2920 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
2921 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
2922 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
2923 var useFloatingTree = (externalTree) => {
2924 const contextTree = React17.useContext(FloatingTreeContext);
2925 return externalTree ?? contextTree;
2926 };
2927
2928 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
2929 var React18 = __toESM(require_react(), 1);
2930 function createVirtualElement(domElement, data) {
2931 let offsetX = null;
2932 let offsetY = null;
2933 let isAutoUpdateEvent = false;
2934 return {
2935 contextElement: domElement || void 0,
2936 getBoundingClientRect() {
2937 const domRect = domElement?.getBoundingClientRect() || {
2938 width: 0,
2939 height: 0,
2940 x: 0,
2941 y: 0
2942 };
2943 const isXAxis = data.axis === "x" || data.axis === "both";
2944 const isYAxis = data.axis === "y" || data.axis === "both";
2945 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
2946 let width = domRect.width;
2947 let height = domRect.height;
2948 let x2 = domRect.x;
2949 let y2 = domRect.y;
2950 if (offsetX == null && data.x && isXAxis) {
2951 offsetX = domRect.x - data.x;
2952 }
2953 if (offsetY == null && data.y && isYAxis) {
2954 offsetY = domRect.y - data.y;
2955 }
2956 x2 -= offsetX || 0;
2957 y2 -= offsetY || 0;
2958 width = 0;
2959 height = 0;
2960 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
2961 width = data.axis === "y" ? domRect.width : 0;
2962 height = data.axis === "x" ? domRect.height : 0;
2963 x2 = isXAxis && data.x != null ? data.x : x2;
2964 y2 = isYAxis && data.y != null ? data.y : y2;
2965 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
2966 height = data.axis === "x" ? domRect.height : height;
2967 width = data.axis === "y" ? domRect.width : width;
2968 }
2969 isAutoUpdateEvent = true;
2970 return {
2971 width,
2972 height,
2973 x: x2,
2974 y: y2,
2975 top: y2,
2976 right: x2 + width,
2977 bottom: y2 + height,
2978 left: x2
2979 };
2980 }
2981 };
2982 }
2983 function isMouseBasedEvent(event) {
2984 return event != null && event.clientX != null;
2985 }
2986 function useClientPoint(context, props = {}) {
2987 const store = "rootStore" in context ? context.rootStore : context;
2988 const open = store.useState("open");
2989 const floating = store.useState("floatingElement");
2990 const domReference = store.useState("domReferenceElement");
2991 const dataRef = store.context.dataRef;
2992 const {
2993 enabled = true,
2994 axis = "both"
2995 } = props;
2996 const initialRef = React18.useRef(false);
2997 const cleanupListenerRef = React18.useRef(null);
2998 const [pointerType, setPointerType] = React18.useState();
2999 const [reactive, setReactive] = React18.useState([]);
3000 const setReference = useStableCallback((newX, newY, referenceElement) => {
3001 if (initialRef.current) {
3002 return;
3003 }
3004 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3005 return;
3006 }
3007 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3008 x: newX,
3009 y: newY,
3010 axis,
3011 dataRef,
3012 pointerType
3013 }));
3014 });
3015 const handleReferenceEnterOrMove = useStableCallback((event) => {
3016 if (!open) {
3017 setReference(event.clientX, event.clientY, event.currentTarget);
3018 } else if (!cleanupListenerRef.current) {
3019 setReactive([]);
3020 }
3021 });
3022 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3023 const addListener = React18.useCallback(() => {
3024 if (!openCheck || !enabled) {
3025 return void 0;
3026 }
3027 const win = getWindow(floating);
3028 function handleMouseMove(event) {
3029 const target = getTarget(event);
3030 if (!contains(floating, target)) {
3031 setReference(event.clientX, event.clientY);
3032 } else {
3033 cleanupListenerRef.current?.();
3034 cleanupListenerRef.current = null;
3035 }
3036 }
3037 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3038 const cleanup = () => {
3039 cleanupListenerRef.current?.();
3040 cleanupListenerRef.current = null;
3041 };
3042 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3043 return cleanup;
3044 }
3045 store.set("positionReference", domReference);
3046 return void 0;
3047 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
3048 React18.useEffect(() => {
3049 return addListener();
3050 }, [addListener, reactive]);
3051 React18.useEffect(() => {
3052 if (enabled && !floating) {
3053 initialRef.current = false;
3054 }
3055 }, [enabled, floating]);
3056 React18.useEffect(() => {
3057 if (!enabled && open) {
3058 initialRef.current = true;
3059 }
3060 }, [enabled, open]);
3061 const reference = React18.useMemo(() => {
3062 function setPointerTypeRef(event) {
3063 setPointerType(event.pointerType);
3064 }
3065 return {
3066 onPointerDown: setPointerTypeRef,
3067 onPointerEnter: setPointerTypeRef,
3068 onMouseMove: handleReferenceEnterOrMove,
3069 onMouseEnter: handleReferenceEnterOrMove
3070 };
3071 }, [handleReferenceEnterOrMove]);
3072 return React18.useMemo(() => enabled ? {
3073 reference,
3074 trigger: reference
3075 } : {}, [enabled, reference]);
3076 }
3077
3078 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3079 var React19 = __toESM(require_react(), 1);
3080 var bubbleHandlerKeys = {
3081 intentional: "onClick",
3082 sloppy: "onPointerDown"
3083 };
3084 function alwaysFalse() {
3085 return false;
3086 }
3087 function normalizeProp(normalizable) {
3088 return {
3089 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3090 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3091 };
3092 }
3093 function useDismiss(context, props = {}) {
3094 const store = "rootStore" in context ? context.rootStore : context;
3095 const open = store.useState("open");
3096 const floatingElement = store.useState("floatingElement");
3097 const {
3098 dataRef
3099 } = store.context;
3100 const {
3101 enabled = true,
3102 escapeKey: escapeKey2 = true,
3103 outsidePress: outsidePressProp = true,
3104 outsidePressEvent = "sloppy",
3105 referencePress = alwaysFalse,
3106 referencePressEvent = "sloppy",
3107 bubbles,
3108 externalTree
3109 } = props;
3110 const tree = useFloatingTree(externalTree);
3111 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3112 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3113 const outsidePressEnabled = outsidePress2 !== false;
3114 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3115 const pressStartedInsideRef = React19.useRef(false);
3116 const pressStartPreventedRef = React19.useRef(false);
3117 const suppressNextOutsideClickRef = React19.useRef(false);
3118 const {
3119 escapeKey: escapeKeyBubbles,
3120 outsidePress: outsidePressBubbles
3121 } = normalizeProp(bubbles);
3122 const touchStateRef = React19.useRef(null);
3123 const cancelDismissOnEndTimeout = useTimeout();
3124 const clearInsideReactTreeTimeout = useTimeout();
3125 const clearInsideReactTree = useStableCallback(() => {
3126 clearInsideReactTreeTimeout.clear();
3127 dataRef.current.insideReactTree = false;
3128 });
3129 const isComposingRef = React19.useRef(false);
3130 const currentPointerTypeRef = React19.useRef("");
3131 const isReferencePressEnabled = useStableCallback(referencePress);
3132 const closeOnEscapeKeyDown = useStableCallback((event) => {
3133 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3134 return;
3135 }
3136 if (isComposingRef.current) {
3137 return;
3138 }
3139 const nodeId = dataRef.current.floatingContext?.nodeId;
3140 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3141 if (!escapeKeyBubbles) {
3142 if (children.length > 0) {
3143 let shouldDismiss = true;
3144 children.forEach((child) => {
3145 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3146 shouldDismiss = false;
3147 }
3148 });
3149 if (!shouldDismiss) {
3150 return;
3151 }
3152 }
3153 }
3154 const native = isReactEvent(event) ? event.nativeEvent : event;
3155 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3156 store.setOpen(false, eventDetails);
3157 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3158 event.stopPropagation();
3159 }
3160 });
3161 const markInsideReactTree = useStableCallback(() => {
3162 dataRef.current.insideReactTree = true;
3163 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3164 });
3165 React19.useEffect(() => {
3166 if (!open || !enabled) {
3167 return void 0;
3168 }
3169 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3170 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3171 const compositionTimeout = new Timeout();
3172 const preventedPressSuppressionTimeout = new Timeout();
3173 function handleCompositionStart() {
3174 compositionTimeout.clear();
3175 isComposingRef.current = true;
3176 }
3177 function handleCompositionEnd() {
3178 compositionTimeout.start(
3179 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3180 // Only apply to WebKit for the test to remain 0ms.
3181 isWebKit() ? 5 : 0,
3182 () => {
3183 isComposingRef.current = false;
3184 }
3185 );
3186 }
3187 function suppressImmediateOutsideClickAfterPreventedStart() {
3188 suppressNextOutsideClickRef.current = true;
3189 preventedPressSuppressionTimeout.start(0, () => {
3190 suppressNextOutsideClickRef.current = false;
3191 });
3192 }
3193 function resetPressStartState() {
3194 pressStartedInsideRef.current = false;
3195 pressStartPreventedRef.current = false;
3196 }
3197 function getOutsidePressEvent() {
3198 const type = currentPointerTypeRef.current;
3199 const computedType = type === "pen" || !type ? "mouse" : type;
3200 const outsidePressEventValue = getOutsidePressEventProp();
3201 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3202 if (typeof resolved === "string") {
3203 return resolved;
3204 }
3205 return resolved[computedType];
3206 }
3207 function shouldIgnoreEvent(event) {
3208 const computedOutsidePressEvent = getOutsidePressEvent();
3209 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3210 }
3211 function isEventWithinFloatingTree(event) {
3212 const nodeId = dataRef.current.floatingContext?.nodeId;
3213 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3214 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
3215 }
3216 function closeOnPressOutside(event) {
3217 if (shouldIgnoreEvent(event)) {
3218 clearInsideReactTree();
3219 return;
3220 }
3221 if (dataRef.current.insideReactTree) {
3222 clearInsideReactTree();
3223 return;
3224 }
3225 const target = getTarget(event);
3226 const inertSelector = `[${createAttribute("inert")}]`;
3227 const targetRoot = isElement(target) ? target.getRootNode() : null;
3228 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3229 const triggers = store.context.triggerElements;
3230 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3231 return;
3232 }
3233 let targetRootAncestor = isElement(target) ? target : null;
3234 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3235 const nextParent = getParentNode(targetRootAncestor);
3236 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3237 break;
3238 }
3239 targetRootAncestor = nextParent;
3240 }
3241 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3242 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3243 // element was injected after the floating element rendered.
3244 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3245 return;
3246 }
3247 if (isHTMLElement(target) && !("touches" in event)) {
3248 const lastTraversableNode = isLastTraversableNode(target);
3249 const style = getComputedStyle2(target);
3250 const scrollRe = /auto|scroll/;
3251 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3252 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3253 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3254 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3255 const isRTL7 = style.direction === "rtl";
3256 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3257 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3258 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3259 return;
3260 }
3261 }
3262 if (isEventWithinFloatingTree(event)) {
3263 return;
3264 }
3265 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3266 preventedPressSuppressionTimeout.clear();
3267 suppressNextOutsideClickRef.current = false;
3268 return;
3269 }
3270 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3271 return;
3272 }
3273 const nodeId = dataRef.current.floatingContext?.nodeId;
3274 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3275 if (children.length > 0) {
3276 let shouldDismiss = true;
3277 children.forEach((child) => {
3278 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
3279 shouldDismiss = false;
3280 }
3281 });
3282 if (!shouldDismiss) {
3283 return;
3284 }
3285 }
3286 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3287 clearInsideReactTree();
3288 }
3289 function handlePointerDown(event) {
3290 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3291 return;
3292 }
3293 closeOnPressOutside(event);
3294 }
3295 function handleTouchStart(event) {
3296 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3297 return;
3298 }
3299 const touch = event.touches[0];
3300 if (touch) {
3301 touchStateRef.current = {
3302 startTime: Date.now(),
3303 startX: touch.clientX,
3304 startY: touch.clientY,
3305 dismissOnTouchEnd: false,
3306 dismissOnMouseDown: true
3307 };
3308 cancelDismissOnEndTimeout.start(1e3, () => {
3309 if (touchStateRef.current) {
3310 touchStateRef.current.dismissOnTouchEnd = false;
3311 touchStateRef.current.dismissOnMouseDown = false;
3312 }
3313 });
3314 }
3315 }
3316 function addTargetEventListenerOnce(event, listener) {
3317 const target = getTarget(event);
3318 if (!target) {
3319 return;
3320 }
3321 const unsubscribe2 = addEventListener(target, event.type, () => {
3322 listener(event);
3323 unsubscribe2();
3324 });
3325 }
3326 function handleTouchStartCapture(event) {
3327 currentPointerTypeRef.current = "touch";
3328 addTargetEventListenerOnce(event, handleTouchStart);
3329 }
3330 function closeOnPressOutsideCapture(event) {
3331 cancelDismissOnEndTimeout.clear();
3332 if (event.type === "pointerdown") {
3333 currentPointerTypeRef.current = event.pointerType;
3334 }
3335 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3336 return;
3337 }
3338 addTargetEventListenerOnce(event, (targetEvent) => {
3339 if (targetEvent.type === "pointerdown") {
3340 handlePointerDown(targetEvent);
3341 } else {
3342 closeOnPressOutside(targetEvent);
3343 }
3344 });
3345 }
3346 function handlePressEndCapture(event) {
3347 if (!pressStartedInsideRef.current) {
3348 return;
3349 }
3350 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3351 resetPressStartState();
3352 if (getOutsidePressEvent() !== "intentional") {
3353 return;
3354 }
3355 if (event.type === "pointercancel") {
3356 if (pressStartedInsideDefaultPrevented) {
3357 suppressImmediateOutsideClickAfterPreventedStart();
3358 }
3359 return;
3360 }
3361 if (isEventWithinFloatingTree(event)) {
3362 return;
3363 }
3364 if (pressStartedInsideDefaultPrevented) {
3365 suppressImmediateOutsideClickAfterPreventedStart();
3366 return;
3367 }
3368 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3369 return;
3370 }
3371 preventedPressSuppressionTimeout.clear();
3372 suppressNextOutsideClickRef.current = true;
3373 clearInsideReactTree();
3374 }
3375 function handleTouchMove(event) {
3376 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3377 return;
3378 }
3379 const touch = event.touches[0];
3380 if (!touch) {
3381 return;
3382 }
3383 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3384 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3385 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3386 if (distance > 5) {
3387 touchStateRef.current.dismissOnTouchEnd = true;
3388 }
3389 if (distance > 10) {
3390 closeOnPressOutside(event);
3391 cancelDismissOnEndTimeout.clear();
3392 touchStateRef.current = null;
3393 }
3394 }
3395 function handleTouchMoveCapture(event) {
3396 addTargetEventListenerOnce(event, handleTouchMove);
3397 }
3398 function handleTouchEnd(event) {
3399 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3400 return;
3401 }
3402 if (touchStateRef.current.dismissOnTouchEnd) {
3403 closeOnPressOutside(event);
3404 }
3405 cancelDismissOnEndTimeout.clear();
3406 touchStateRef.current = null;
3407 }
3408 function handleTouchEndCapture(event) {
3409 addTargetEventListenerOnce(event, handleTouchEnd);
3410 }
3411 const doc = ownerDocument(floatingElement);
3412 const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true)));
3413 return () => {
3414 unsubscribe();
3415 compositionTimeout.clear();
3416 preventedPressSuppressionTimeout.clear();
3417 resetPressStartState();
3418 suppressNextOutsideClickRef.current = false;
3419 };
3420 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
3421 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3422 const reference = React19.useMemo(() => ({
3423 onKeyDown: closeOnEscapeKeyDown,
3424 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
3425 if (!isReferencePressEnabled()) {
3426 return;
3427 }
3428 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3429 },
3430 ...referencePressEvent !== "intentional" && {
3431 onClick(event) {
3432 if (!isReferencePressEnabled()) {
3433 return;
3434 }
3435 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3436 }
3437 }
3438 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
3439 const markPressStartedInsideReactTree = useStableCallback((event) => {
3440 if (!open || !enabled || event.button !== 0) {
3441 return;
3442 }
3443 const target = getTarget(event.nativeEvent);
3444 if (!contains(store.select("floatingElement"), target)) {
3445 return;
3446 }
3447 if (!pressStartedInsideRef.current) {
3448 pressStartedInsideRef.current = true;
3449 pressStartPreventedRef.current = false;
3450 }
3451 });
3452 const markInsidePressStartPrevented = useStableCallback((event) => {
3453 if (!open || !enabled) {
3454 return;
3455 }
3456 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3457 return;
3458 }
3459 if (pressStartedInsideRef.current) {
3460 pressStartPreventedRef.current = true;
3461 }
3462 });
3463 const floating = React19.useMemo(() => ({
3464 onKeyDown: closeOnEscapeKeyDown,
3465 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3466 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3467 // See https://github.com/mui/base-ui/pull/3379
3468 onPointerDown: markInsidePressStartPrevented,
3469 onMouseDown: markInsidePressStartPrevented,
3470 onClickCapture: markInsideReactTree,
3471 onMouseDownCapture(event) {
3472 markInsideReactTree();
3473 markPressStartedInsideReactTree(event);
3474 },
3475 onPointerDownCapture(event) {
3476 markInsideReactTree();
3477 markPressStartedInsideReactTree(event);
3478 },
3479 onMouseUpCapture: markInsideReactTree,
3480 onTouchEndCapture: markInsideReactTree,
3481 onTouchMoveCapture: markInsideReactTree
3482 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3483 return React19.useMemo(() => enabled ? {
3484 reference,
3485 floating,
3486 trigger: reference
3487 } : {}, [enabled, reference, floating]);
3488 }
3489
3490 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3491 var React25 = __toESM(require_react(), 1);
3492
3493 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3494 function computeCoordsFromPlacement(_ref, placement, rtl) {
3495 let {
3496 reference,
3497 floating
3498 } = _ref;
3499 const sideAxis = getSideAxis(placement);
3500 const alignmentAxis = getAlignmentAxis(placement);
3501 const alignLength = getAxisLength(alignmentAxis);
3502 const side = getSide(placement);
3503 const isVertical = sideAxis === "y";
3504 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3505 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3506 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3507 let coords;
3508 switch (side) {
3509 case "top":
3510 coords = {
3511 x: commonX,
3512 y: reference.y - floating.height
3513 };
3514 break;
3515 case "bottom":
3516 coords = {
3517 x: commonX,
3518 y: reference.y + reference.height
3519 };
3520 break;
3521 case "right":
3522 coords = {
3523 x: reference.x + reference.width,
3524 y: commonY
3525 };
3526 break;
3527 case "left":
3528 coords = {
3529 x: reference.x - floating.width,
3530 y: commonY
3531 };
3532 break;
3533 default:
3534 coords = {
3535 x: reference.x,
3536 y: reference.y
3537 };
3538 }
3539 switch (getAlignment(placement)) {
3540 case "start":
3541 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3542 break;
3543 case "end":
3544 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3545 break;
3546 }
3547 return coords;
3548 }
3549 async function detectOverflow(state, options) {
3550 var _await$platform$isEle;
3551 if (options === void 0) {
3552 options = {};
3553 }
3554 const {
3555 x: x2,
3556 y: y2,
3557 platform: platform3,
3558 rects,
3559 elements,
3560 strategy
3561 } = state;
3562 const {
3563 boundary = "clippingAncestors",
3564 rootBoundary = "viewport",
3565 elementContext = "floating",
3566 altBoundary = false,
3567 padding = 0
3568 } = evaluate(options, state);
3569 const paddingObject = getPaddingObject(padding);
3570 const altContext = elementContext === "floating" ? "reference" : "floating";
3571 const element = elements[altBoundary ? altContext : elementContext];
3572 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3573 element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)),
3574 boundary,
3575 rootBoundary,
3576 strategy
3577 }));
3578 const rect = elementContext === "floating" ? {
3579 x: x2,
3580 y: y2,
3581 width: rects.floating.width,
3582 height: rects.floating.height
3583 } : rects.reference;
3584 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3585 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3586 x: 1,
3587 y: 1
3588 } : {
3589 x: 1,
3590 y: 1
3591 };
3592 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3593 elements,
3594 rect,
3595 offsetParent,
3596 strategy
3597 }) : rect);
3598 return {
3599 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3600 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3601 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3602 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3603 };
3604 }
3605 var MAX_RESET_COUNT = 50;
3606 var computePosition = async (reference, floating, config) => {
3607 const {
3608 placement = "bottom",
3609 strategy = "absolute",
3610 middleware = [],
3611 platform: platform3
3612 } = config;
3613 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3614 ...platform3,
3615 detectOverflow
3616 };
3617 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3618 let rects = await platform3.getElementRects({
3619 reference,
3620 floating,
3621 strategy
3622 });
3623 let {
3624 x: x2,
3625 y: y2
3626 } = computeCoordsFromPlacement(rects, placement, rtl);
3627 let statefulPlacement = placement;
3628 let resetCount = 0;
3629 const middlewareData = {};
3630 for (let i2 = 0; i2 < middleware.length; i2++) {
3631 const currentMiddleware = middleware[i2];
3632 if (!currentMiddleware) {
3633 continue;
3634 }
3635 const {
3636 name,
3637 fn
3638 } = currentMiddleware;
3639 const {
3640 x: nextX,
3641 y: nextY,
3642 data,
3643 reset
3644 } = await fn({
3645 x: x2,
3646 y: y2,
3647 initialPlacement: placement,
3648 placement: statefulPlacement,
3649 strategy,
3650 middlewareData,
3651 rects,
3652 platform: platformWithDetectOverflow,
3653 elements: {
3654 reference,
3655 floating
3656 }
3657 });
3658 x2 = nextX != null ? nextX : x2;
3659 y2 = nextY != null ? nextY : y2;
3660 middlewareData[name] = {
3661 ...middlewareData[name],
3662 ...data
3663 };
3664 if (reset && resetCount < MAX_RESET_COUNT) {
3665 resetCount++;
3666 if (typeof reset === "object") {
3667 if (reset.placement) {
3668 statefulPlacement = reset.placement;
3669 }
3670 if (reset.rects) {
3671 rects = reset.rects === true ? await platform3.getElementRects({
3672 reference,
3673 floating,
3674 strategy
3675 }) : reset.rects;
3676 }
3677 ({
3678 x: x2,
3679 y: y2
3680 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3681 }
3682 i2 = -1;
3683 }
3684 }
3685 return {
3686 x: x2,
3687 y: y2,
3688 placement: statefulPlacement,
3689 strategy,
3690 middlewareData
3691 };
3692 };
3693 var flip = function(options) {
3694 if (options === void 0) {
3695 options = {};
3696 }
3697 return {
3698 name: "flip",
3699 options,
3700 async fn(state) {
3701 var _middlewareData$arrow, _middlewareData$flip;
3702 const {
3703 placement,
3704 middlewareData,
3705 rects,
3706 initialPlacement,
3707 platform: platform3,
3708 elements
3709 } = state;
3710 const {
3711 mainAxis: checkMainAxis = true,
3712 crossAxis: checkCrossAxis = true,
3713 fallbackPlacements: specifiedFallbackPlacements,
3714 fallbackStrategy = "bestFit",
3715 fallbackAxisSideDirection = "none",
3716 flipAlignment = true,
3717 ...detectOverflowOptions
3718 } = evaluate(options, state);
3719 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3720 return {};
3721 }
3722 const side = getSide(placement);
3723 const initialSideAxis = getSideAxis(initialPlacement);
3724 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3725 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3726 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3727 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3728 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3729 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3730 }
3731 const placements2 = [initialPlacement, ...fallbackPlacements];
3732 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3733 const overflows = [];
3734 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3735 if (checkMainAxis) {
3736 overflows.push(overflow[side]);
3737 }
3738 if (checkCrossAxis) {
3739 const sides2 = getAlignmentSides(placement, rects, rtl);
3740 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3741 }
3742 overflowsData = [...overflowsData, {
3743 placement,
3744 overflows
3745 }];
3746 if (!overflows.every((side2) => side2 <= 0)) {
3747 var _middlewareData$flip2, _overflowsData$filter;
3748 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3749 const nextPlacement = placements2[nextIndex];
3750 if (nextPlacement) {
3751 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3752 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3753 // overflows the main axis.
3754 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3755 return {
3756 data: {
3757 index: nextIndex,
3758 overflows: overflowsData
3759 },
3760 reset: {
3761 placement: nextPlacement
3762 }
3763 };
3764 }
3765 }
3766 let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
3767 if (!resetPlacement) {
3768 switch (fallbackStrategy) {
3769 case "bestFit": {
3770 var _overflowsData$filter2;
3771 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3772 if (hasFallbackAxisSideDirection) {
3773 const currentSideAxis = getSideAxis(d2.placement);
3774 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3775 // reading directions favoring greater width.
3776 currentSideAxis === "y";
3777 }
3778 return true;
3779 }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
3780 if (placement2) {
3781 resetPlacement = placement2;
3782 }
3783 break;
3784 }
3785 case "initialPlacement":
3786 resetPlacement = initialPlacement;
3787 break;
3788 }
3789 }
3790 if (placement !== resetPlacement) {
3791 return {
3792 reset: {
3793 placement: resetPlacement
3794 }
3795 };
3796 }
3797 }
3798 return {};
3799 }
3800 };
3801 };
3802 function getSideOffsets(overflow, rect) {
3803 return {
3804 top: overflow.top - rect.height,
3805 right: overflow.right - rect.width,
3806 bottom: overflow.bottom - rect.height,
3807 left: overflow.left - rect.width
3808 };
3809 }
3810 function isAnySideFullyClipped(overflow) {
3811 return sides.some((side) => overflow[side] >= 0);
3812 }
3813 var hide = function(options) {
3814 if (options === void 0) {
3815 options = {};
3816 }
3817 return {
3818 name: "hide",
3819 options,
3820 async fn(state) {
3821 const {
3822 rects,
3823 platform: platform3
3824 } = state;
3825 const {
3826 strategy = "referenceHidden",
3827 ...detectOverflowOptions
3828 } = evaluate(options, state);
3829 switch (strategy) {
3830 case "referenceHidden": {
3831 const overflow = await platform3.detectOverflow(state, {
3832 ...detectOverflowOptions,
3833 elementContext: "reference"
3834 });
3835 const offsets = getSideOffsets(overflow, rects.reference);
3836 return {
3837 data: {
3838 referenceHiddenOffsets: offsets,
3839 referenceHidden: isAnySideFullyClipped(offsets)
3840 }
3841 };
3842 }
3843 case "escaped": {
3844 const overflow = await platform3.detectOverflow(state, {
3845 ...detectOverflowOptions,
3846 altBoundary: true
3847 });
3848 const offsets = getSideOffsets(overflow, rects.floating);
3849 return {
3850 data: {
3851 escapedOffsets: offsets,
3852 escaped: isAnySideFullyClipped(offsets)
3853 }
3854 };
3855 }
3856 default: {
3857 return {};
3858 }
3859 }
3860 }
3861 };
3862 };
3863 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3864 async function convertValueToCoords(state, options) {
3865 const {
3866 placement,
3867 platform: platform3,
3868 elements
3869 } = state;
3870 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3871 const side = getSide(placement);
3872 const alignment = getAlignment(placement);
3873 const isVertical = getSideAxis(placement) === "y";
3874 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3875 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3876 const rawValue = evaluate(options, state);
3877 let {
3878 mainAxis,
3879 crossAxis,
3880 alignmentAxis
3881 } = typeof rawValue === "number" ? {
3882 mainAxis: rawValue,
3883 crossAxis: 0,
3884 alignmentAxis: null
3885 } : {
3886 mainAxis: rawValue.mainAxis || 0,
3887 crossAxis: rawValue.crossAxis || 0,
3888 alignmentAxis: rawValue.alignmentAxis
3889 };
3890 if (alignment && typeof alignmentAxis === "number") {
3891 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3892 }
3893 return isVertical ? {
3894 x: crossAxis * crossAxisMulti,
3895 y: mainAxis * mainAxisMulti
3896 } : {
3897 x: mainAxis * mainAxisMulti,
3898 y: crossAxis * crossAxisMulti
3899 };
3900 }
3901 var offset = function(options) {
3902 if (options === void 0) {
3903 options = 0;
3904 }
3905 return {
3906 name: "offset",
3907 options,
3908 async fn(state) {
3909 var _middlewareData$offse, _middlewareData$arrow;
3910 const {
3911 x: x2,
3912 y: y2,
3913 placement,
3914 middlewareData
3915 } = state;
3916 const diffCoords = await convertValueToCoords(state, options);
3917 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3918 return {};
3919 }
3920 return {
3921 x: x2 + diffCoords.x,
3922 y: y2 + diffCoords.y,
3923 data: {
3924 ...diffCoords,
3925 placement
3926 }
3927 };
3928 }
3929 };
3930 };
3931 var shift = function(options) {
3932 if (options === void 0) {
3933 options = {};
3934 }
3935 return {
3936 name: "shift",
3937 options,
3938 async fn(state) {
3939 const {
3940 x: x2,
3941 y: y2,
3942 placement,
3943 platform: platform3
3944 } = state;
3945 const {
3946 mainAxis: checkMainAxis = true,
3947 crossAxis: checkCrossAxis = false,
3948 limiter = {
3949 fn: (_ref) => {
3950 let {
3951 x: x3,
3952 y: y3
3953 } = _ref;
3954 return {
3955 x: x3,
3956 y: y3
3957 };
3958 }
3959 },
3960 ...detectOverflowOptions
3961 } = evaluate(options, state);
3962 const coords = {
3963 x: x2,
3964 y: y2
3965 };
3966 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3967 const crossAxis = getSideAxis(getSide(placement));
3968 const mainAxis = getOppositeAxis(crossAxis);
3969 let mainAxisCoord = coords[mainAxis];
3970 let crossAxisCoord = coords[crossAxis];
3971 if (checkMainAxis) {
3972 const minSide = mainAxis === "y" ? "top" : "left";
3973 const maxSide = mainAxis === "y" ? "bottom" : "right";
3974 const min2 = mainAxisCoord + overflow[minSide];
3975 const max2 = mainAxisCoord - overflow[maxSide];
3976 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
3977 }
3978 if (checkCrossAxis) {
3979 const minSide = crossAxis === "y" ? "top" : "left";
3980 const maxSide = crossAxis === "y" ? "bottom" : "right";
3981 const min2 = crossAxisCoord + overflow[minSide];
3982 const max2 = crossAxisCoord - overflow[maxSide];
3983 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
3984 }
3985 const limitedCoords = limiter.fn({
3986 ...state,
3987 [mainAxis]: mainAxisCoord,
3988 [crossAxis]: crossAxisCoord
3989 });
3990 return {
3991 ...limitedCoords,
3992 data: {
3993 x: limitedCoords.x - x2,
3994 y: limitedCoords.y - y2,
3995 enabled: {
3996 [mainAxis]: checkMainAxis,
3997 [crossAxis]: checkCrossAxis
3998 }
3999 }
4000 };
4001 }
4002 };
4003 };
4004 var limitShift = function(options) {
4005 if (options === void 0) {
4006 options = {};
4007 }
4008 return {
4009 options,
4010 fn(state) {
4011 const {
4012 x: x2,
4013 y: y2,
4014 placement,
4015 rects,
4016 middlewareData
4017 } = state;
4018 const {
4019 offset: offset4 = 0,
4020 mainAxis: checkMainAxis = true,
4021 crossAxis: checkCrossAxis = true
4022 } = evaluate(options, state);
4023 const coords = {
4024 x: x2,
4025 y: y2
4026 };
4027 const crossAxis = getSideAxis(placement);
4028 const mainAxis = getOppositeAxis(crossAxis);
4029 let mainAxisCoord = coords[mainAxis];
4030 let crossAxisCoord = coords[crossAxis];
4031 const rawOffset = evaluate(offset4, state);
4032 const computedOffset = typeof rawOffset === "number" ? {
4033 mainAxis: rawOffset,
4034 crossAxis: 0
4035 } : {
4036 mainAxis: 0,
4037 crossAxis: 0,
4038 ...rawOffset
4039 };
4040 if (checkMainAxis) {
4041 const len = mainAxis === "y" ? "height" : "width";
4042 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4043 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4044 if (mainAxisCoord < limitMin) {
4045 mainAxisCoord = limitMin;
4046 } else if (mainAxisCoord > limitMax) {
4047 mainAxisCoord = limitMax;
4048 }
4049 }
4050 if (checkCrossAxis) {
4051 var _middlewareData$offse, _middlewareData$offse2;
4052 const len = mainAxis === "y" ? "width" : "height";
4053 const isOriginSide = originSides.has(getSide(placement));
4054 const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
4055 const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
4056 if (crossAxisCoord < limitMin) {
4057 crossAxisCoord = limitMin;
4058 } else if (crossAxisCoord > limitMax) {
4059 crossAxisCoord = limitMax;
4060 }
4061 }
4062 return {
4063 [mainAxis]: mainAxisCoord,
4064 [crossAxis]: crossAxisCoord
4065 };
4066 }
4067 };
4068 };
4069 var size = function(options) {
4070 if (options === void 0) {
4071 options = {};
4072 }
4073 return {
4074 name: "size",
4075 options,
4076 async fn(state) {
4077 var _state$middlewareData, _state$middlewareData2;
4078 const {
4079 placement,
4080 rects,
4081 platform: platform3,
4082 elements
4083 } = state;
4084 const {
4085 apply = () => {
4086 },
4087 ...detectOverflowOptions
4088 } = evaluate(options, state);
4089 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4090 const side = getSide(placement);
4091 const alignment = getAlignment(placement);
4092 const isYAxis = getSideAxis(placement) === "y";
4093 const {
4094 width,
4095 height
4096 } = rects.floating;
4097 let heightSide;
4098 let widthSide;
4099 if (side === "top" || side === "bottom") {
4100 heightSide = side;
4101 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4102 } else {
4103 widthSide = side;
4104 heightSide = alignment === "end" ? "top" : "bottom";
4105 }
4106 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4107 const maximumClippingWidth = width - overflow.left - overflow.right;
4108 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4109 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4110 const noShift = !state.middlewareData.shift;
4111 let availableHeight = overflowAvailableHeight;
4112 let availableWidth = overflowAvailableWidth;
4113 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4114 availableWidth = maximumClippingWidth;
4115 }
4116 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4117 availableHeight = maximumClippingHeight;
4118 }
4119 if (noShift && !alignment) {
4120 const xMin = max(overflow.left, 0);
4121 const xMax = max(overflow.right, 0);
4122 const yMin = max(overflow.top, 0);
4123 const yMax = max(overflow.bottom, 0);
4124 if (isYAxis) {
4125 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4126 } else {
4127 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4128 }
4129 }
4130 await apply({
4131 ...state,
4132 availableWidth,
4133 availableHeight
4134 });
4135 const nextDimensions = await platform3.getDimensions(elements.floating);
4136 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4137 return {
4138 reset: {
4139 rects: true
4140 }
4141 };
4142 }
4143 return {};
4144 }
4145 };
4146 };
4147
4148 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4149 function getCssDimensions(element) {
4150 const css = getComputedStyle2(element);
4151 let width = parseFloat(css.width) || 0;
4152 let height = parseFloat(css.height) || 0;
4153 const hasOffset = isHTMLElement(element);
4154 const offsetWidth = hasOffset ? element.offsetWidth : width;
4155 const offsetHeight = hasOffset ? element.offsetHeight : height;
4156 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4157 if (shouldFallback) {
4158 width = offsetWidth;
4159 height = offsetHeight;
4160 }
4161 return {
4162 width,
4163 height,
4164 $: shouldFallback
4165 };
4166 }
4167 function unwrapElement(element) {
4168 return !isElement(element) ? element.contextElement : element;
4169 }
4170 function getScale(element) {
4171 const domElement = unwrapElement(element);
4172 if (!isHTMLElement(domElement)) {
4173 return createCoords(1);
4174 }
4175 const rect = domElement.getBoundingClientRect();
4176 const {
4177 width,
4178 height,
4179 $: $2
4180 } = getCssDimensions(domElement);
4181 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4182 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4183 if (!x2 || !Number.isFinite(x2)) {
4184 x2 = 1;
4185 }
4186 if (!y2 || !Number.isFinite(y2)) {
4187 y2 = 1;
4188 }
4189 return {
4190 x: x2,
4191 y: y2
4192 };
4193 }
4194 var noOffsets = /* @__PURE__ */ createCoords(0);
4195 function getVisualOffsets(element) {
4196 const win = getWindow(element);
4197 if (!isWebKit() || !win.visualViewport) {
4198 return noOffsets;
4199 }
4200 return {
4201 x: win.visualViewport.offsetLeft,
4202 y: win.visualViewport.offsetTop
4203 };
4204 }
4205 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4206 if (isFixed === void 0) {
4207 isFixed = false;
4208 }
4209 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4210 return false;
4211 }
4212 return isFixed;
4213 }
4214 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4215 if (includeScale === void 0) {
4216 includeScale = false;
4217 }
4218 if (isFixedStrategy === void 0) {
4219 isFixedStrategy = false;
4220 }
4221 const clientRect = element.getBoundingClientRect();
4222 const domElement = unwrapElement(element);
4223 let scale = createCoords(1);
4224 if (includeScale) {
4225 if (offsetParent) {
4226 if (isElement(offsetParent)) {
4227 scale = getScale(offsetParent);
4228 }
4229 } else {
4230 scale = getScale(element);
4231 }
4232 }
4233 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4234 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4235 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4236 let width = clientRect.width / scale.x;
4237 let height = clientRect.height / scale.y;
4238 if (domElement) {
4239 const win = getWindow(domElement);
4240 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4241 let currentWin = win;
4242 let currentIFrame = getFrameElement(currentWin);
4243 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4244 const iframeScale = getScale(currentIFrame);
4245 const iframeRect = currentIFrame.getBoundingClientRect();
4246 const css = getComputedStyle2(currentIFrame);
4247 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4248 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4249 x2 *= iframeScale.x;
4250 y2 *= iframeScale.y;
4251 width *= iframeScale.x;
4252 height *= iframeScale.y;
4253 x2 += left;
4254 y2 += top;
4255 currentWin = getWindow(currentIFrame);
4256 currentIFrame = getFrameElement(currentWin);
4257 }
4258 }
4259 return rectToClientRect({
4260 width,
4261 height,
4262 x: x2,
4263 y: y2
4264 });
4265 }
4266 function getWindowScrollBarX(element, rect) {
4267 const leftScroll = getNodeScroll(element).scrollLeft;
4268 if (!rect) {
4269 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4270 }
4271 return rect.left + leftScroll;
4272 }
4273 function getHTMLOffset(documentElement, scroll) {
4274 const htmlRect = documentElement.getBoundingClientRect();
4275 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4276 const y2 = htmlRect.top + scroll.scrollTop;
4277 return {
4278 x: x2,
4279 y: y2
4280 };
4281 }
4282 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4283 let {
4284 elements,
4285 rect,
4286 offsetParent,
4287 strategy
4288 } = _ref;
4289 const isFixed = strategy === "fixed";
4290 const documentElement = getDocumentElement(offsetParent);
4291 const topLayer = elements ? isTopLayer(elements.floating) : false;
4292 if (offsetParent === documentElement || topLayer && isFixed) {
4293 return rect;
4294 }
4295 let scroll = {
4296 scrollLeft: 0,
4297 scrollTop: 0
4298 };
4299 let scale = createCoords(1);
4300 const offsets = createCoords(0);
4301 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4302 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4303 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4304 scroll = getNodeScroll(offsetParent);
4305 }
4306 if (isOffsetParentAnElement) {
4307 const offsetRect = getBoundingClientRect(offsetParent);
4308 scale = getScale(offsetParent);
4309 offsets.x = offsetRect.x + offsetParent.clientLeft;
4310 offsets.y = offsetRect.y + offsetParent.clientTop;
4311 }
4312 }
4313 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4314 return {
4315 width: rect.width * scale.x,
4316 height: rect.height * scale.y,
4317 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4318 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4319 };
4320 }
4321 function getClientRects(element) {
4322 return Array.from(element.getClientRects());
4323 }
4324 function getDocumentRect(element) {
4325 const html = getDocumentElement(element);
4326 const scroll = getNodeScroll(element);
4327 const body = element.ownerDocument.body;
4328 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4329 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4330 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4331 const y2 = -scroll.scrollTop;
4332 if (getComputedStyle2(body).direction === "rtl") {
4333 x2 += max(html.clientWidth, body.clientWidth) - width;
4334 }
4335 return {
4336 width,
4337 height,
4338 x: x2,
4339 y: y2
4340 };
4341 }
4342 var SCROLLBAR_MAX = 25;
4343 function getViewportRect(element, strategy) {
4344 const win = getWindow(element);
4345 const html = getDocumentElement(element);
4346 const visualViewport = win.visualViewport;
4347 let width = html.clientWidth;
4348 let height = html.clientHeight;
4349 let x2 = 0;
4350 let y2 = 0;
4351 if (visualViewport) {
4352 width = visualViewport.width;
4353 height = visualViewport.height;
4354 const visualViewportBased = isWebKit();
4355 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4356 x2 = visualViewport.offsetLeft;
4357 y2 = visualViewport.offsetTop;
4358 }
4359 }
4360 const windowScrollbarX = getWindowScrollBarX(html);
4361 if (windowScrollbarX <= 0) {
4362 const doc = html.ownerDocument;
4363 const body = doc.body;
4364 const bodyStyles = getComputedStyle(body);
4365 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4366 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4367 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4368 width -= clippingStableScrollbarWidth;
4369 }
4370 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4371 width += windowScrollbarX;
4372 }
4373 return {
4374 width,
4375 height,
4376 x: x2,
4377 y: y2
4378 };
4379 }
4380 function getInnerBoundingClientRect(element, strategy) {
4381 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4382 const top = clientRect.top + element.clientTop;
4383 const left = clientRect.left + element.clientLeft;
4384 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4385 const width = element.clientWidth * scale.x;
4386 const height = element.clientHeight * scale.y;
4387 const x2 = left * scale.x;
4388 const y2 = top * scale.y;
4389 return {
4390 width,
4391 height,
4392 x: x2,
4393 y: y2
4394 };
4395 }
4396 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4397 let rect;
4398 if (clippingAncestor === "viewport") {
4399 rect = getViewportRect(element, strategy);
4400 } else if (clippingAncestor === "document") {
4401 rect = getDocumentRect(getDocumentElement(element));
4402 } else if (isElement(clippingAncestor)) {
4403 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4404 } else {
4405 const visualOffsets = getVisualOffsets(element);
4406 rect = {
4407 x: clippingAncestor.x - visualOffsets.x,
4408 y: clippingAncestor.y - visualOffsets.y,
4409 width: clippingAncestor.width,
4410 height: clippingAncestor.height
4411 };
4412 }
4413 return rectToClientRect(rect);
4414 }
4415 function hasFixedPositionAncestor(element, stopNode) {
4416 const parentNode = getParentNode(element);
4417 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4418 return false;
4419 }
4420 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4421 }
4422 function getClippingElementAncestors(element, cache) {
4423 const cachedResult = cache.get(element);
4424 if (cachedResult) {
4425 return cachedResult;
4426 }
4427 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4428 let currentContainingBlockComputedStyle = null;
4429 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4430 let currentNode = elementIsFixed ? getParentNode(element) : element;
4431 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4432 const computedStyle = getComputedStyle2(currentNode);
4433 const currentNodeIsContaining = isContainingBlock(currentNode);
4434 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4435 currentContainingBlockComputedStyle = null;
4436 }
4437 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4438 if (shouldDropCurrentNode) {
4439 result = result.filter((ancestor) => ancestor !== currentNode);
4440 } else {
4441 currentContainingBlockComputedStyle = computedStyle;
4442 }
4443 currentNode = getParentNode(currentNode);
4444 }
4445 cache.set(element, result);
4446 return result;
4447 }
4448 function getClippingRect(_ref) {
4449 let {
4450 element,
4451 boundary,
4452 rootBoundary,
4453 strategy
4454 } = _ref;
4455 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4456 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4457 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4458 let top = firstRect.top;
4459 let right = firstRect.right;
4460 let bottom = firstRect.bottom;
4461 let left = firstRect.left;
4462 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4463 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4464 top = max(rect.top, top);
4465 right = min(rect.right, right);
4466 bottom = min(rect.bottom, bottom);
4467 left = max(rect.left, left);
4468 }
4469 return {
4470 width: right - left,
4471 height: bottom - top,
4472 x: left,
4473 y: top
4474 };
4475 }
4476 function getDimensions(element) {
4477 const {
4478 width,
4479 height
4480 } = getCssDimensions(element);
4481 return {
4482 width,
4483 height
4484 };
4485 }
4486 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4487 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4488 const documentElement = getDocumentElement(offsetParent);
4489 const isFixed = strategy === "fixed";
4490 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4491 let scroll = {
4492 scrollLeft: 0,
4493 scrollTop: 0
4494 };
4495 const offsets = createCoords(0);
4496 function setLeftRTLScrollbarOffset() {
4497 offsets.x = getWindowScrollBarX(documentElement);
4498 }
4499 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4500 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4501 scroll = getNodeScroll(offsetParent);
4502 }
4503 if (isOffsetParentAnElement) {
4504 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4505 offsets.x = offsetRect.x + offsetParent.clientLeft;
4506 offsets.y = offsetRect.y + offsetParent.clientTop;
4507 } else if (documentElement) {
4508 setLeftRTLScrollbarOffset();
4509 }
4510 }
4511 if (isFixed && !isOffsetParentAnElement && documentElement) {
4512 setLeftRTLScrollbarOffset();
4513 }
4514 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4515 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4516 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4517 return {
4518 x: x2,
4519 y: y2,
4520 width: rect.width,
4521 height: rect.height
4522 };
4523 }
4524 function isStaticPositioned(element) {
4525 return getComputedStyle2(element).position === "static";
4526 }
4527 function getTrueOffsetParent(element, polyfill) {
4528 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4529 return null;
4530 }
4531 if (polyfill) {
4532 return polyfill(element);
4533 }
4534 let rawOffsetParent = element.offsetParent;
4535 if (getDocumentElement(element) === rawOffsetParent) {
4536 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4537 }
4538 return rawOffsetParent;
4539 }
4540 function getOffsetParent(element, polyfill) {
4541 const win = getWindow(element);
4542 if (isTopLayer(element)) {
4543 return win;
4544 }
4545 if (!isHTMLElement(element)) {
4546 let svgOffsetParent = getParentNode(element);
4547 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4548 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4549 return svgOffsetParent;
4550 }
4551 svgOffsetParent = getParentNode(svgOffsetParent);
4552 }
4553 return win;
4554 }
4555 let offsetParent = getTrueOffsetParent(element, polyfill);
4556 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4557 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4558 }
4559 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4560 return win;
4561 }
4562 return offsetParent || getContainingBlock(element) || win;
4563 }
4564 var getElementRects = async function(data) {
4565 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4566 const getDimensionsFn = this.getDimensions;
4567 const floatingDimensions = await getDimensionsFn(data.floating);
4568 return {
4569 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4570 floating: {
4571 x: 0,
4572 y: 0,
4573 width: floatingDimensions.width,
4574 height: floatingDimensions.height
4575 }
4576 };
4577 };
4578 function isRTL(element) {
4579 return getComputedStyle2(element).direction === "rtl";
4580 }
4581 var platform2 = {
4582 convertOffsetParentRelativeRectToViewportRelativeRect,
4583 getDocumentElement,
4584 getClippingRect,
4585 getOffsetParent,
4586 getElementRects,
4587 getClientRects,
4588 getDimensions,
4589 getScale,
4590 isElement,
4591 isRTL
4592 };
4593 function rectsAreEqual(a2, b2) {
4594 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4595 }
4596 function observeMove(element, onMove) {
4597 let io = null;
4598 let timeoutId;
4599 const root = getDocumentElement(element);
4600 function cleanup() {
4601 var _io;
4602 clearTimeout(timeoutId);
4603 (_io = io) == null || _io.disconnect();
4604 io = null;
4605 }
4606 function refresh(skip, threshold) {
4607 if (skip === void 0) {
4608 skip = false;
4609 }
4610 if (threshold === void 0) {
4611 threshold = 1;
4612 }
4613 cleanup();
4614 const elementRectForRootMargin = element.getBoundingClientRect();
4615 const {
4616 left,
4617 top,
4618 width,
4619 height
4620 } = elementRectForRootMargin;
4621 if (!skip) {
4622 onMove();
4623 }
4624 if (!width || !height) {
4625 return;
4626 }
4627 const insetTop = floor(top);
4628 const insetRight = floor(root.clientWidth - (left + width));
4629 const insetBottom = floor(root.clientHeight - (top + height));
4630 const insetLeft = floor(left);
4631 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4632 const options = {
4633 rootMargin,
4634 threshold: max(0, min(1, threshold)) || 1
4635 };
4636 let isFirstUpdate = true;
4637 function handleObserve(entries) {
4638 const ratio = entries[0].intersectionRatio;
4639 if (ratio !== threshold) {
4640 if (!isFirstUpdate) {
4641 return refresh();
4642 }
4643 if (!ratio) {
4644 timeoutId = setTimeout(() => {
4645 refresh(false, 1e-7);
4646 }, 1e3);
4647 } else {
4648 refresh(false, ratio);
4649 }
4650 }
4651 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4652 refresh();
4653 }
4654 isFirstUpdate = false;
4655 }
4656 try {
4657 io = new IntersectionObserver(handleObserve, {
4658 ...options,
4659 // Handle <iframe>s
4660 root: root.ownerDocument
4661 });
4662 } catch (_e) {
4663 io = new IntersectionObserver(handleObserve, options);
4664 }
4665 io.observe(element);
4666 }
4667 refresh(true);
4668 return cleanup;
4669 }
4670 function autoUpdate(reference, floating, update2, options) {
4671 if (options === void 0) {
4672 options = {};
4673 }
4674 const {
4675 ancestorScroll = true,
4676 ancestorResize = true,
4677 elementResize = typeof ResizeObserver === "function",
4678 layoutShift = typeof IntersectionObserver === "function",
4679 animationFrame = false
4680 } = options;
4681 const referenceEl = unwrapElement(reference);
4682 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4683 ancestors.forEach((ancestor) => {
4684 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4685 passive: true
4686 });
4687 ancestorResize && ancestor.addEventListener("resize", update2);
4688 });
4689 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4690 let reobserveFrame = -1;
4691 let resizeObserver = null;
4692 if (elementResize) {
4693 resizeObserver = new ResizeObserver((_ref) => {
4694 let [firstEntry] = _ref;
4695 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4696 resizeObserver.unobserve(floating);
4697 cancelAnimationFrame(reobserveFrame);
4698 reobserveFrame = requestAnimationFrame(() => {
4699 var _resizeObserver;
4700 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4701 });
4702 }
4703 update2();
4704 });
4705 if (referenceEl && !animationFrame) {
4706 resizeObserver.observe(referenceEl);
4707 }
4708 if (floating) {
4709 resizeObserver.observe(floating);
4710 }
4711 }
4712 let frameId;
4713 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4714 if (animationFrame) {
4715 frameLoop();
4716 }
4717 function frameLoop() {
4718 const nextRefRect = getBoundingClientRect(reference);
4719 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4720 update2();
4721 }
4722 prevRefRect = nextRefRect;
4723 frameId = requestAnimationFrame(frameLoop);
4724 }
4725 update2();
4726 return () => {
4727 var _resizeObserver2;
4728 ancestors.forEach((ancestor) => {
4729 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4730 ancestorResize && ancestor.removeEventListener("resize", update2);
4731 });
4732 cleanupIo == null || cleanupIo();
4733 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4734 resizeObserver = null;
4735 if (animationFrame) {
4736 cancelAnimationFrame(frameId);
4737 }
4738 };
4739 }
4740 var offset2 = offset;
4741 var shift2 = shift;
4742 var flip2 = flip;
4743 var size2 = size;
4744 var hide2 = hide;
4745 var limitShift2 = limitShift;
4746 var computePosition2 = (reference, floating, options) => {
4747 const cache = /* @__PURE__ */ new Map();
4748 const mergedOptions = {
4749 platform: platform2,
4750 ...options
4751 };
4752 const platformWithCache = {
4753 ...mergedOptions.platform,
4754 _c: cache
4755 };
4756 return computePosition(reference, floating, {
4757 ...mergedOptions,
4758 platform: platformWithCache
4759 });
4760 };
4761
4762 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4763 var React20 = __toESM(require_react(), 1);
4764 var import_react2 = __toESM(require_react(), 1);
4765 var ReactDOM3 = __toESM(require_react_dom(), 1);
4766 var isClient = typeof document !== "undefined";
4767 var noop2 = function noop3() {
4768 };
4769 var index = isClient ? import_react2.useLayoutEffect : noop2;
4770 function deepEqual(a2, b2) {
4771 if (a2 === b2) {
4772 return true;
4773 }
4774 if (typeof a2 !== typeof b2) {
4775 return false;
4776 }
4777 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4778 return true;
4779 }
4780 let length;
4781 let i2;
4782 let keys;
4783 if (a2 && b2 && typeof a2 === "object") {
4784 if (Array.isArray(a2)) {
4785 length = a2.length;
4786 if (length !== b2.length) return false;
4787 for (i2 = length; i2-- !== 0; ) {
4788 if (!deepEqual(a2[i2], b2[i2])) {
4789 return false;
4790 }
4791 }
4792 return true;
4793 }
4794 keys = Object.keys(a2);
4795 length = keys.length;
4796 if (length !== Object.keys(b2).length) {
4797 return false;
4798 }
4799 for (i2 = length; i2-- !== 0; ) {
4800 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4801 return false;
4802 }
4803 }
4804 for (i2 = length; i2-- !== 0; ) {
4805 const key = keys[i2];
4806 if (key === "_owner" && a2.$$typeof) {
4807 continue;
4808 }
4809 if (!deepEqual(a2[key], b2[key])) {
4810 return false;
4811 }
4812 }
4813 return true;
4814 }
4815 return a2 !== a2 && b2 !== b2;
4816 }
4817 function getDPR(element) {
4818 if (typeof window === "undefined") {
4819 return 1;
4820 }
4821 const win = element.ownerDocument.defaultView || window;
4822 return win.devicePixelRatio || 1;
4823 }
4824 function roundByDPR(element, value) {
4825 const dpr = getDPR(element);
4826 return Math.round(value * dpr) / dpr;
4827 }
4828 function useLatestRef(value) {
4829 const ref = React20.useRef(value);
4830 index(() => {
4831 ref.current = value;
4832 });
4833 return ref;
4834 }
4835 function useFloating(options) {
4836 if (options === void 0) {
4837 options = {};
4838 }
4839 const {
4840 placement = "bottom",
4841 strategy = "absolute",
4842 middleware = [],
4843 platform: platform3,
4844 elements: {
4845 reference: externalReference,
4846 floating: externalFloating
4847 } = {},
4848 transform = true,
4849 whileElementsMounted,
4850 open
4851 } = options;
4852 const [data, setData] = React20.useState({
4853 x: 0,
4854 y: 0,
4855 strategy,
4856 placement,
4857 middlewareData: {},
4858 isPositioned: false
4859 });
4860 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
4861 if (!deepEqual(latestMiddleware, middleware)) {
4862 setLatestMiddleware(middleware);
4863 }
4864 const [_reference, _setReference] = React20.useState(null);
4865 const [_floating, _setFloating] = React20.useState(null);
4866 const setReference = React20.useCallback((node) => {
4867 if (node !== referenceRef.current) {
4868 referenceRef.current = node;
4869 _setReference(node);
4870 }
4871 }, []);
4872 const setFloating = React20.useCallback((node) => {
4873 if (node !== floatingRef.current) {
4874 floatingRef.current = node;
4875 _setFloating(node);
4876 }
4877 }, []);
4878 const referenceEl = externalReference || _reference;
4879 const floatingEl = externalFloating || _floating;
4880 const referenceRef = React20.useRef(null);
4881 const floatingRef = React20.useRef(null);
4882 const dataRef = React20.useRef(data);
4883 const hasWhileElementsMounted = whileElementsMounted != null;
4884 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4885 const platformRef = useLatestRef(platform3);
4886 const openRef = useLatestRef(open);
4887 const update2 = React20.useCallback(() => {
4888 if (!referenceRef.current || !floatingRef.current) {
4889 return;
4890 }
4891 const config = {
4892 placement,
4893 strategy,
4894 middleware: latestMiddleware
4895 };
4896 if (platformRef.current) {
4897 config.platform = platformRef.current;
4898 }
4899 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4900 const fullData = {
4901 ...data2,
4902 // The floating element's position may be recomputed while it's closed
4903 // but still mounted (such as when transitioning out). To ensure
4904 // `isPositioned` will be `false` initially on the next open, avoid
4905 // setting it to `true` when `open === false` (must be specified).
4906 isPositioned: openRef.current !== false
4907 };
4908 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
4909 dataRef.current = fullData;
4910 ReactDOM3.flushSync(() => {
4911 setData(fullData);
4912 });
4913 }
4914 });
4915 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
4916 index(() => {
4917 if (open === false && dataRef.current.isPositioned) {
4918 dataRef.current.isPositioned = false;
4919 setData((data2) => ({
4920 ...data2,
4921 isPositioned: false
4922 }));
4923 }
4924 }, [open]);
4925 const isMountedRef = React20.useRef(false);
4926 index(() => {
4927 isMountedRef.current = true;
4928 return () => {
4929 isMountedRef.current = false;
4930 };
4931 }, []);
4932 index(() => {
4933 if (referenceEl) referenceRef.current = referenceEl;
4934 if (floatingEl) floatingRef.current = floatingEl;
4935 if (referenceEl && floatingEl) {
4936 if (whileElementsMountedRef.current) {
4937 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
4938 }
4939 update2();
4940 }
4941 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
4942 const refs = React20.useMemo(() => ({
4943 reference: referenceRef,
4944 floating: floatingRef,
4945 setReference,
4946 setFloating
4947 }), [setReference, setFloating]);
4948 const elements = React20.useMemo(() => ({
4949 reference: referenceEl,
4950 floating: floatingEl
4951 }), [referenceEl, floatingEl]);
4952 const floatingStyles = React20.useMemo(() => {
4953 const initialStyles = {
4954 position: strategy,
4955 left: 0,
4956 top: 0
4957 };
4958 if (!elements.floating) {
4959 return initialStyles;
4960 }
4961 const x2 = roundByDPR(elements.floating, data.x);
4962 const y2 = roundByDPR(elements.floating, data.y);
4963 if (transform) {
4964 return {
4965 ...initialStyles,
4966 transform: "translate(" + x2 + "px, " + y2 + "px)",
4967 ...getDPR(elements.floating) >= 1.5 && {
4968 willChange: "transform"
4969 }
4970 };
4971 }
4972 return {
4973 position: strategy,
4974 left: x2,
4975 top: y2
4976 };
4977 }, [strategy, transform, elements.floating, data.x, data.y]);
4978 return React20.useMemo(() => ({
4979 ...data,
4980 update: update2,
4981 refs,
4982 elements,
4983 floatingStyles
4984 }), [data, update2, refs, elements, floatingStyles]);
4985 }
4986 var offset3 = (options, deps) => {
4987 const result = offset2(options);
4988 return {
4989 name: result.name,
4990 fn: result.fn,
4991 options: [options, deps]
4992 };
4993 };
4994 var shift3 = (options, deps) => {
4995 const result = shift2(options);
4996 return {
4997 name: result.name,
4998 fn: result.fn,
4999 options: [options, deps]
5000 };
5001 };
5002 var limitShift3 = (options, deps) => {
5003 const result = limitShift2(options);
5004 return {
5005 fn: result.fn,
5006 options: [options, deps]
5007 };
5008 };
5009 var flip3 = (options, deps) => {
5010 const result = flip2(options);
5011 return {
5012 name: result.name,
5013 fn: result.fn,
5014 options: [options, deps]
5015 };
5016 };
5017 var size3 = (options, deps) => {
5018 const result = size2(options);
5019 return {
5020 name: result.name,
5021 fn: result.fn,
5022 options: [options, deps]
5023 };
5024 };
5025 var hide3 = (options, deps) => {
5026 const result = hide2(options);
5027 return {
5028 name: result.name,
5029 fn: result.fn,
5030 options: [options, deps]
5031 };
5032 };
5033
5034 // node_modules/@base-ui/utils/esm/store/createSelector.js
5035 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5036 if (other.length > 0) {
5037 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5038 }
5039 let selector2;
5040 if (a2 && b2 && c2 && d2 && e2 && f2) {
5041 selector2 = (state, a1, a22, a3) => {
5042 const va = a2(state, a1, a22, a3);
5043 const vb = b2(state, a1, a22, a3);
5044 const vc = c2(state, a1, a22, a3);
5045 const vd = d2(state, a1, a22, a3);
5046 const ve = e2(state, a1, a22, a3);
5047 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5048 };
5049 } else if (a2 && b2 && c2 && d2 && e2) {
5050 selector2 = (state, a1, a22, a3) => {
5051 const va = a2(state, a1, a22, a3);
5052 const vb = b2(state, a1, a22, a3);
5053 const vc = c2(state, a1, a22, a3);
5054 const vd = d2(state, a1, a22, a3);
5055 return e2(va, vb, vc, vd, a1, a22, a3);
5056 };
5057 } else if (a2 && b2 && c2 && d2) {
5058 selector2 = (state, a1, a22, a3) => {
5059 const va = a2(state, a1, a22, a3);
5060 const vb = b2(state, a1, a22, a3);
5061 const vc = c2(state, a1, a22, a3);
5062 return d2(va, vb, vc, a1, a22, a3);
5063 };
5064 } else if (a2 && b2 && c2) {
5065 selector2 = (state, a1, a22, a3) => {
5066 const va = a2(state, a1, a22, a3);
5067 const vb = b2(state, a1, a22, a3);
5068 return c2(va, vb, a1, a22, a3);
5069 };
5070 } else if (a2 && b2) {
5071 selector2 = (state, a1, a22, a3) => {
5072 const va = a2(state, a1, a22, a3);
5073 return b2(va, a1, a22, a3);
5074 };
5075 } else if (a2) {
5076 selector2 = a2;
5077 } else {
5078 throw (
5079 /* minify-error-disabled */
5080 new Error("Missing arguments")
5081 );
5082 }
5083 return selector2;
5084 };
5085
5086 // node_modules/@base-ui/utils/esm/store/useStore.js
5087 var React22 = __toESM(require_react(), 1);
5088 var import_shim = __toESM(require_shim(), 1);
5089 var import_with_selector = __toESM(require_with_selector(), 1);
5090
5091 // node_modules/@base-ui/utils/esm/fastHooks.js
5092 var React21 = __toESM(require_react(), 1);
5093 var hooks = [];
5094 var currentInstance = void 0;
5095 function getInstance() {
5096 return currentInstance;
5097 }
5098 function register(hook) {
5099 hooks.push(hook);
5100 }
5101 function fastComponent(fn) {
5102 const FastComponent = (props, forwardedRef) => {
5103 const instance = useRefWithInit(createInstance).current;
5104 let result;
5105 try {
5106 currentInstance = instance;
5107 for (const hook of hooks) {
5108 hook.before(instance);
5109 }
5110 result = fn(props, forwardedRef);
5111 for (const hook of hooks) {
5112 hook.after(instance);
5113 }
5114 instance.didInitialize = true;
5115 } finally {
5116 currentInstance = void 0;
5117 }
5118 return result;
5119 };
5120 FastComponent.displayName = fn.displayName || fn.name;
5121 return FastComponent;
5122 }
5123 function fastComponentRef(fn) {
5124 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5125 }
5126 function createInstance() {
5127 return {
5128 didInitialize: false
5129 };
5130 }
5131
5132 // node_modules/@base-ui/utils/esm/store/useStore.js
5133 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5134 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5135 function useStore(store, selector2, a1, a2, a3) {
5136 return useStoreImplementation(store, selector2, a1, a2, a3);
5137 }
5138 function useStoreR19(store, selector2, a1, a2, a3) {
5139 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5140 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5141 }
5142 register({
5143 before(instance) {
5144 instance.syncIndex = 0;
5145 if (!instance.didInitialize) {
5146 instance.syncTick = 1;
5147 instance.syncHooks = [];
5148 instance.didChangeStore = true;
5149 instance.getSnapshot = () => {
5150 let didChange2 = false;
5151 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5152 const hook = instance.syncHooks[i2];
5153 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5154 if (hook.didChange || !Object.is(hook.value, value)) {
5155 didChange2 = true;
5156 hook.value = value;
5157 hook.didChange = false;
5158 }
5159 }
5160 if (didChange2) {
5161 instance.syncTick += 1;
5162 }
5163 return instance.syncTick;
5164 };
5165 }
5166 },
5167 after(instance) {
5168 if (instance.syncHooks.length > 0) {
5169 if (instance.didChangeStore) {
5170 instance.didChangeStore = false;
5171 instance.subscribe = (onStoreChange) => {
5172 const stores = /* @__PURE__ */ new Set();
5173 for (const hook of instance.syncHooks) {
5174 stores.add(hook.store);
5175 }
5176 const unsubscribes = [];
5177 for (const store of stores) {
5178 unsubscribes.push(store.subscribe(onStoreChange));
5179 }
5180 return () => {
5181 for (const unsubscribe of unsubscribes) {
5182 unsubscribe();
5183 }
5184 };
5185 };
5186 }
5187 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5188 }
5189 }
5190 });
5191 function useStoreFast(store, selector2, a1, a2, a3) {
5192 const instance = getInstance();
5193 if (!instance) {
5194 return useStoreR19(store, selector2, a1, a2, a3);
5195 }
5196 const index2 = instance.syncIndex;
5197 instance.syncIndex += 1;
5198 let hook;
5199 if (!instance.didInitialize) {
5200 hook = {
5201 store,
5202 selector: selector2,
5203 a1,
5204 a2,
5205 a3,
5206 value: selector2(store.getSnapshot(), a1, a2, a3),
5207 didChange: false
5208 };
5209 instance.syncHooks.push(hook);
5210 } else {
5211 hook = instance.syncHooks[index2];
5212 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5213 if (hook.store !== store) {
5214 instance.didChangeStore = true;
5215 }
5216 hook.store = store;
5217 hook.selector = selector2;
5218 hook.a1 = a1;
5219 hook.a2 = a2;
5220 hook.a3 = a3;
5221 hook.didChange = true;
5222 }
5223 }
5224 return hook.value;
5225 }
5226 function useStoreLegacy(store, selector2, a1, a2, a3) {
5227 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5228 }
5229
5230 // node_modules/@base-ui/utils/esm/store/Store.js
5231 var Store = class {
5232 /**
5233 * The current state of the store.
5234 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5235 * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
5236 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5237 *
5238 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5239 */
5240 // Internal state to handle recursive `setState()` calls
5241 constructor(state) {
5242 this.state = state;
5243 this.listeners = /* @__PURE__ */ new Set();
5244 this.updateTick = 0;
5245 }
5246 /**
5247 * Registers a listener that will be called whenever the store's state changes.
5248 *
5249 * @param fn The listener function to be called on state changes.
5250 * @returns A function to unsubscribe the listener.
5251 */
5252 subscribe = (fn) => {
5253 this.listeners.add(fn);
5254 return () => {
5255 this.listeners.delete(fn);
5256 };
5257 };
5258 /**
5259 * Returns the current state of the store.
5260 */
5261 getSnapshot = () => {
5262 return this.state;
5263 };
5264 /**
5265 * Updates the entire store's state and notifies all registered listeners.
5266 *
5267 * @param newState The new state to set for the store.
5268 */
5269 setState(newState) {
5270 if (this.state === newState) {
5271 return;
5272 }
5273 this.state = newState;
5274 this.updateTick += 1;
5275 const currentTick = this.updateTick;
5276 for (const listener of this.listeners) {
5277 if (currentTick !== this.updateTick) {
5278 return;
5279 }
5280 listener(newState);
5281 }
5282 }
5283 /**
5284 * Merges the provided changes into the current state and notifies listeners if there are changes.
5285 *
5286 * @param changes An object containing the changes to apply to the current state.
5287 */
5288 update(changes) {
5289 for (const key in changes) {
5290 if (!Object.is(this.state[key], changes[key])) {
5291 this.setState({
5292 ...this.state,
5293 ...changes
5294 });
5295 return;
5296 }
5297 }
5298 }
5299 /**
5300 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5301 *
5302 * @param key The key in the store's state to update.
5303 * @param value The new value to set for the specified key.
5304 */
5305 set(key, value) {
5306 if (!Object.is(this.state[key], value)) {
5307 this.setState({
5308 ...this.state,
5309 [key]: value
5310 });
5311 }
5312 }
5313 /**
5314 * Gives the state a new reference and updates all registered listeners.
5315 */
5316 notifyAll() {
5317 const newState = {
5318 ...this.state
5319 };
5320 this.setState(newState);
5321 }
5322 use(selector2, a1, a2, a3) {
5323 return useStore(this, selector2, a1, a2, a3);
5324 }
5325 };
5326
5327 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5328 var React23 = __toESM(require_react(), 1);
5329 var ReactStore = class extends Store {
5330 /**
5331 * Creates a new ReactStore instance.
5332 *
5333 * @param state Initial state of the store.
5334 * @param context Non-reactive context values.
5335 * @param selectors Optional selectors for use with `useState`.
5336 */
5337 constructor(state, context = {}, selectors3) {
5338 super(state);
5339 this.context = context;
5340 this.selectors = selectors3;
5341 }
5342 /**
5343 * Non-reactive values such as refs, callbacks, etc.
5344 */
5345 /**
5346 * Synchronizes a single external value into the store.
5347 *
5348 * Note that the while the value in `state` is updated immediately, the value returned
5349 * by `useState` is updated before the next render (similarly to React's `useState`).
5350 */
5351 useSyncedValue(key, value) {
5352 React23.useDebugValue(key);
5353 useIsoLayoutEffect(() => {
5354 if (this.state[key] !== value) {
5355 this.set(key, value);
5356 }
5357 }, [key, value]);
5358 }
5359 /**
5360 * Synchronizes a single external value into the store and
5361 * cleans it up (sets to `undefined`) on unmount.
5362 *
5363 * Note that the while the value in `state` is updated immediately, the value returned
5364 * by `useState` is updated before the next render (similarly to React's `useState`).
5365 */
5366 useSyncedValueWithCleanup(key, value) {
5367 const store = this;
5368 useIsoLayoutEffect(() => {
5369 if (store.state[key] !== value) {
5370 store.set(key, value);
5371 }
5372 return () => {
5373 store.set(key, void 0);
5374 };
5375 }, [store, key, value]);
5376 }
5377 /**
5378 * Synchronizes multiple external values into the store.
5379 *
5380 * Note that the while the values in `state` are updated immediately, the values returned
5381 * by `useState` are updated before the next render (similarly to React's `useState`).
5382 */
5383 useSyncedValues(statePart) {
5384 const store = this;
5385 if (true) {
5386 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5387 const keys = React23.useRef(Object.keys(statePart)).current;
5388 const nextKeys = Object.keys(statePart);
5389 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5390 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5391 }
5392 }
5393 const dependencies = Object.values(statePart);
5394 useIsoLayoutEffect(() => {
5395 store.update(statePart);
5396 }, [store, ...dependencies]);
5397 }
5398 /**
5399 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5400 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5401 */
5402 useControlledProp(key, controlled) {
5403 React23.useDebugValue(key);
5404 const isControlled = controlled !== void 0;
5405 useIsoLayoutEffect(() => {
5406 if (isControlled && !Object.is(this.state[key], controlled)) {
5407 super.setState({
5408 ...this.state,
5409 [key]: controlled
5410 });
5411 }
5412 }, [key, controlled, isControlled]);
5413 if (true) {
5414 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5415 if (!cache.has(key)) {
5416 cache.set(key, isControlled);
5417 }
5418 const previouslyControlled = cache.get(key);
5419 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5420 console.error(`A component is changing the ${isControlled ? "" : "un"}controlled state of ${key.toString()} to be ${isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
5421 }
5422 }
5423 }
5424 /** Gets the current value from the store using a selector with the provided key.
5425 *
5426 * @param key Key of the selector to use.
5427 */
5428 select(key, a1, a2, a3) {
5429 const selector2 = this.selectors[key];
5430 return selector2(this.state, a1, a2, a3);
5431 }
5432 /**
5433 * Returns a value from the store's state using a selector function.
5434 * Used to subscribe to specific parts of the state.
5435 * This methods causes a rerender whenever the selected state changes.
5436 *
5437 * @param key Key of the selector to use.
5438 */
5439 useState(key, a1, a2, a3) {
5440 React23.useDebugValue(key);
5441 return useStore(this, this.selectors[key], a1, a2, a3);
5442 }
5443 /**
5444 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5445 * and assigns it to the context.
5446 *
5447 * @param key Key of the event callback. Must be a function in the context.
5448 * @param fn Function to assign.
5449 */
5450 useContextCallback(key, fn) {
5451 React23.useDebugValue(key);
5452 const stableFunction = useStableCallback(fn ?? NOOP);
5453 this.context[key] = stableFunction;
5454 }
5455 /**
5456 * Returns a stable setter function for a specific key in the store's state.
5457 * It's commonly used to pass as a ref callback to React elements.
5458 *
5459 * @param key Key of the state to set.
5460 */
5461 useStateSetter(key) {
5462 const ref = React23.useRef(void 0);
5463 if (ref.current === void 0) {
5464 ref.current = (value) => {
5465 this.set(key, value);
5466 };
5467 }
5468 return ref.current;
5469 }
5470 /**
5471 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5472 *
5473 * @param key Key of the selector to observe.
5474 * @param listener Listener function called when the selector result changes.
5475 */
5476 observe(selector2, listener) {
5477 let selectFn;
5478 if (typeof selector2 === "function") {
5479 selectFn = selector2;
5480 } else {
5481 selectFn = this.selectors[selector2];
5482 }
5483 let prevValue = selectFn(this.state);
5484 listener(prevValue, prevValue, this);
5485 return this.subscribe((nextState) => {
5486 const nextValue = selectFn(nextState);
5487 if (!Object.is(prevValue, nextValue)) {
5488 const oldValue = prevValue;
5489 prevValue = nextValue;
5490 listener(nextValue, oldValue, this);
5491 }
5492 });
5493 }
5494 };
5495
5496 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5497 var selectors = {
5498 open: createSelector((state) => state.open),
5499 transitionStatus: createSelector((state) => state.transitionStatus),
5500 domReferenceElement: createSelector((state) => state.domReferenceElement),
5501 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5502 floatingElement: createSelector((state) => state.floatingElement),
5503 floatingId: createSelector((state) => state.floatingId)
5504 };
5505 var FloatingRootStore = class extends ReactStore {
5506 constructor(options) {
5507 const {
5508 syncOnly,
5509 nested,
5510 onOpenChange,
5511 triggerElements,
5512 ...initialState
5513 } = options;
5514 super({
5515 ...initialState,
5516 positionReference: initialState.referenceElement,
5517 domReferenceElement: initialState.referenceElement
5518 }, {
5519 onOpenChange,
5520 dataRef: {
5521 current: {}
5522 },
5523 events: createEventEmitter(),
5524 nested,
5525 triggerElements
5526 }, selectors);
5527 this.syncOnly = syncOnly;
5528 }
5529 /**
5530 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5531 */
5532 syncOpenEvent = (newOpen, event) => {
5533 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5534 // click events to upgrade a hover-open.
5535 event != null && isClickLikeEvent(event)) {
5536 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5537 }
5538 };
5539 /**
5540 * Runs the root-owned side effects for an open state change.
5541 */
5542 dispatchOpenChange = (newOpen, eventDetails) => {
5543 this.syncOpenEvent(newOpen, eventDetails.event);
5544 const details = {
5545 open: newOpen,
5546 reason: eventDetails.reason,
5547 nativeEvent: eventDetails.event,
5548 nested: this.context.nested,
5549 triggerElement: eventDetails.trigger
5550 };
5551 this.context.events.emit("openchange", details);
5552 };
5553 /**
5554 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5555 *
5556 * @param newOpen The new open state.
5557 * @param eventDetails Details about the event that triggered the open state change.
5558 */
5559 setOpen = (newOpen, eventDetails) => {
5560 if (this.syncOnly) {
5561 this.context.onOpenChange?.(newOpen, eventDetails);
5562 return;
5563 }
5564 this.dispatchOpenChange(newOpen, eventDetails);
5565 this.context.onOpenChange?.(newOpen, eventDetails);
5566 };
5567 };
5568
5569 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5570 var React24 = __toESM(require_react(), 1);
5571 function useTriggerRegistration(id, store) {
5572 const registeredElementIdRef = React24.useRef(null);
5573 const registeredElementRef = React24.useRef(null);
5574 return React24.useCallback((element) => {
5575 if (id === void 0) {
5576 return;
5577 }
5578 if (registeredElementIdRef.current !== null) {
5579 const registeredId = registeredElementIdRef.current;
5580 const registeredElement = registeredElementRef.current;
5581 const currentElement = store.context.triggerElements.getById(registeredId);
5582 if (registeredElement && currentElement === registeredElement) {
5583 store.context.triggerElements.delete(registeredId);
5584 }
5585 registeredElementIdRef.current = null;
5586 registeredElementRef.current = null;
5587 }
5588 if (element !== null) {
5589 registeredElementIdRef.current = id;
5590 registeredElementRef.current = element;
5591 store.context.triggerElements.add(id, element);
5592 }
5593 }, [store, id]);
5594 }
5595 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5596 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5597 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5598 const registerTrigger = useStableCallback((element) => {
5599 baseRegisterTrigger(element);
5600 if (!element || !store.select("open")) {
5601 return;
5602 }
5603 const activeTriggerId = store.select("activeTriggerId");
5604 if (activeTriggerId === triggerId) {
5605 store.update({
5606 activeTriggerElement: element,
5607 ...stateUpdates
5608 });
5609 return;
5610 }
5611 if (activeTriggerId == null) {
5612 store.update({
5613 activeTriggerId: triggerId,
5614 activeTriggerElement: element,
5615 ...stateUpdates
5616 });
5617 }
5618 });
5619 useIsoLayoutEffect(() => {
5620 if (isMountedByThisTrigger) {
5621 store.update({
5622 activeTriggerElement: triggerElementRef.current,
5623 ...stateUpdates
5624 });
5625 }
5626 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5627 return {
5628 registerTrigger,
5629 isMountedByThisTrigger
5630 };
5631 }
5632 function useImplicitActiveTrigger(store) {
5633 const open = store.useState("open");
5634 useIsoLayoutEffect(() => {
5635 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
5636 const iteratorResult = store.context.triggerElements.entries().next();
5637 if (!iteratorResult.done) {
5638 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5639 store.update({
5640 activeTriggerId: implicitTriggerId,
5641 activeTriggerElement: implicitTriggerElement
5642 });
5643 }
5644 }
5645 }, [open, store]);
5646 }
5647 function useOpenStateTransitions(open, store, onUnmount) {
5648 const {
5649 mounted,
5650 setMounted,
5651 transitionStatus
5652 } = useTransitionStatus(open);
5653 store.useSyncedValues({
5654 mounted,
5655 transitionStatus
5656 });
5657 const forceUnmount = useStableCallback(() => {
5658 setMounted(false);
5659 store.update({
5660 activeTriggerId: null,
5661 activeTriggerElement: null,
5662 mounted: false
5663 });
5664 onUnmount?.();
5665 store.context.onOpenChangeComplete?.(false);
5666 });
5667 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5668 useOpenChangeComplete({
5669 enabled: !preventUnmountingOnClose,
5670 open,
5671 ref: store.context.popupRef,
5672 onComplete() {
5673 if (!open) {
5674 forceUnmount();
5675 }
5676 }
5677 });
5678 return {
5679 forceUnmount,
5680 transitionStatus
5681 };
5682 }
5683
5684 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5685 var PopupTriggerMap = class {
5686 constructor() {
5687 this.elementsSet = /* @__PURE__ */ new Set();
5688 this.idMap = /* @__PURE__ */ new Map();
5689 }
5690 /**
5691 * Adds a trigger element with the given ID.
5692 *
5693 * Note: The provided element is assumed to not be registered under multiple IDs.
5694 */
5695 add(id, element) {
5696 const existingElement = this.idMap.get(id);
5697 if (existingElement === element) {
5698 return;
5699 }
5700 if (existingElement !== void 0) {
5701 this.elementsSet.delete(existingElement);
5702 }
5703 this.elementsSet.add(element);
5704 this.idMap.set(id, element);
5705 if (true) {
5706 if (this.elementsSet.size !== this.idMap.size) {
5707 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5708 }
5709 }
5710 }
5711 /**
5712 * Removes the trigger element with the given ID.
5713 */
5714 delete(id) {
5715 const element = this.idMap.get(id);
5716 if (element) {
5717 this.elementsSet.delete(element);
5718 this.idMap.delete(id);
5719 }
5720 }
5721 /**
5722 * Whether the given element is registered as a trigger.
5723 */
5724 hasElement(element) {
5725 return this.elementsSet.has(element);
5726 }
5727 /**
5728 * Whether there is a registered trigger element matching the given predicate.
5729 */
5730 hasMatchingElement(predicate) {
5731 for (const element of this.elementsSet) {
5732 if (predicate(element)) {
5733 return true;
5734 }
5735 }
5736 return false;
5737 }
5738 /**
5739 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5740 */
5741 getById(id) {
5742 return this.idMap.get(id);
5743 }
5744 /**
5745 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5746 */
5747 entries() {
5748 return this.idMap.entries();
5749 }
5750 /**
5751 * Returns an iterable of all registered trigger elements.
5752 */
5753 elements() {
5754 return this.elementsSet.values();
5755 }
5756 /**
5757 * Returns the number of registered trigger elements.
5758 */
5759 get size() {
5760 return this.idMap.size;
5761 }
5762 };
5763
5764 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5765 function getEmptyRootContext() {
5766 return new FloatingRootStore({
5767 open: false,
5768 transitionStatus: void 0,
5769 floatingElement: null,
5770 referenceElement: null,
5771 triggerElements: new PopupTriggerMap(),
5772 floatingId: "",
5773 syncOnly: false,
5774 nested: false,
5775 onOpenChange: void 0
5776 });
5777 }
5778
5779 // node_modules/@base-ui/react/esm/utils/popups/store.js
5780 function createInitialPopupStoreState() {
5781 return {
5782 open: false,
5783 openProp: void 0,
5784 mounted: false,
5785 transitionStatus: void 0,
5786 floatingRootContext: getEmptyRootContext(),
5787 preventUnmountingOnClose: false,
5788 payload: void 0,
5789 activeTriggerId: null,
5790 activeTriggerElement: null,
5791 triggerIdProp: void 0,
5792 popupElement: null,
5793 positionerElement: null,
5794 activeTriggerProps: EMPTY_OBJECT,
5795 inactiveTriggerProps: EMPTY_OBJECT,
5796 popupProps: EMPTY_OBJECT
5797 };
5798 }
5799 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5800 var popupStoreSelectors = {
5801 open: createSelector((state) => state.openProp ?? state.open),
5802 mounted: createSelector((state) => state.mounted),
5803 transitionStatus: createSelector((state) => state.transitionStatus),
5804 floatingRootContext: createSelector((state) => state.floatingRootContext),
5805 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5806 payload: createSelector((state) => state.payload),
5807 activeTriggerId: activeTriggerIdSelector,
5808 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5809 /**
5810 * Whether the trigger with the given ID was used to open the popup.
5811 */
5812 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5813 /**
5814 * Whether the popup is open and was activated by a trigger with the given ID.
5815 */
5816 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
5817 /**
5818 * Whether the popup is mounted and was activated by a trigger with the given ID.
5819 */
5820 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5821 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5822 popupProps: createSelector((state) => state.popupProps),
5823 popupElement: createSelector((state) => state.popupElement),
5824 positionerElement: createSelector((state) => state.positionerElement)
5825 };
5826
5827 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5828 function useFloatingRootContext(options) {
5829 const {
5830 open = false,
5831 onOpenChange,
5832 elements = {}
5833 } = options;
5834 const floatingId = useId();
5835 const nested = useFloatingParentNodeId() != null;
5836 if (true) {
5837 const optionDomReference = elements.reference;
5838 if (optionDomReference && !isElement(optionDomReference)) {
5839 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
5840 }
5841 }
5842 const store = useRefWithInit(() => new FloatingRootStore({
5843 open,
5844 transitionStatus: void 0,
5845 onOpenChange,
5846 referenceElement: elements.reference ?? null,
5847 floatingElement: elements.floating ?? null,
5848 triggerElements: new PopupTriggerMap(),
5849 floatingId,
5850 syncOnly: false,
5851 nested
5852 })).current;
5853 useIsoLayoutEffect(() => {
5854 const valuesToSync = {
5855 open,
5856 floatingId
5857 };
5858 if (elements.reference !== void 0) {
5859 valuesToSync.referenceElement = elements.reference;
5860 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
5861 }
5862 if (elements.floating !== void 0) {
5863 valuesToSync.floatingElement = elements.floating;
5864 }
5865 store.update(valuesToSync);
5866 }, [open, floatingId, elements.reference, elements.floating, store]);
5867 store.context.onOpenChange = onOpenChange;
5868 store.context.nested = nested;
5869 return store;
5870 }
5871
5872 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
5873 function useFloating2(options = {}) {
5874 const {
5875 nodeId,
5876 externalTree
5877 } = options;
5878 const internalRootStore = useFloatingRootContext(options);
5879 const rootContext = options.rootContext || internalRootStore;
5880 const rootContextElements = {
5881 reference: rootContext.useState("referenceElement"),
5882 floating: rootContext.useState("floatingElement"),
5883 domReference: rootContext.useState("domReferenceElement")
5884 };
5885 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
5886 const domReferenceRef = React25.useRef(null);
5887 const tree = useFloatingTree(externalTree);
5888 useIsoLayoutEffect(() => {
5889 if (rootContextElements.domReference) {
5890 domReferenceRef.current = rootContextElements.domReference;
5891 }
5892 }, [rootContextElements.domReference]);
5893 const position = useFloating({
5894 ...options,
5895 elements: {
5896 ...rootContextElements,
5897 ...positionReference && {
5898 reference: positionReference
5899 }
5900 }
5901 });
5902 const setPositionReference = React25.useCallback((node) => {
5903 const computedPositionReference = isElement(node) ? {
5904 getBoundingClientRect: () => node.getBoundingClientRect(),
5905 getClientRects: () => node.getClientRects(),
5906 contextElement: node
5907 } : node;
5908 setPositionReferenceRaw(computedPositionReference);
5909 position.refs.setReference(computedPositionReference);
5910 }, [position.refs]);
5911 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
5912 const [localFloatingElement, setLocalFloatingElement] = React25.useState(null);
5913 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
5914 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
5915 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
5916 rootContext.useSyncedValue("floatingElement", localFloatingElement);
5917 const setReference = React25.useCallback((node) => {
5918 if (isElement(node) || node === null) {
5919 domReferenceRef.current = node;
5920 setLocalDomReference(node);
5921 }
5922 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
5923 // `null` to support `positionReference` + an unstable `reference`
5924 // callback ref.
5925 node !== null && !isElement(node)) {
5926 position.refs.setReference(node);
5927 }
5928 }, [position.refs, setLocalDomReference]);
5929 const setFloating = React25.useCallback((node) => {
5930 setLocalFloatingElement(node);
5931 position.refs.setFloating(node);
5932 }, [position.refs]);
5933 const refs = React25.useMemo(() => ({
5934 ...position.refs,
5935 setReference,
5936 setFloating,
5937 setPositionReference,
5938 domReference: domReferenceRef
5939 }), [position.refs, setReference, setFloating, setPositionReference]);
5940 const elements = React25.useMemo(() => ({
5941 ...position.elements,
5942 domReference: rootContextElements.domReference
5943 }), [position.elements, rootContextElements.domReference]);
5944 const open = rootContext.useState("open");
5945 const floatingId = rootContext.useState("floatingId");
5946 const context = React25.useMemo(() => ({
5947 ...position,
5948 dataRef: rootContext.context.dataRef,
5949 open,
5950 onOpenChange: rootContext.setOpen,
5951 events: rootContext.context.events,
5952 floatingId,
5953 refs,
5954 elements,
5955 nodeId,
5956 rootStore: rootContext
5957 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
5958 useIsoLayoutEffect(() => {
5959 rootContext.context.dataRef.current.floatingContext = context;
5960 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
5961 if (node) {
5962 node.context = context;
5963 }
5964 });
5965 return React25.useMemo(() => ({
5966 ...position,
5967 context,
5968 refs,
5969 elements,
5970 rootStore: rootContext
5971 }), [position, refs, elements, context, rootContext]);
5972 }
5973
5974 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5975 function useSyncedFloatingRootContext(options) {
5976 const {
5977 popupStore,
5978 treatPopupAsFloatingElement = false,
5979 onOpenChange
5980 } = options;
5981 const floatingId = useId();
5982 const nested = useFloatingParentNodeId() != null;
5983 const open = popupStore.useState("open");
5984 const referenceElement = popupStore.useState("activeTriggerElement");
5985 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5986 const triggerElements = popupStore.context.triggerElements;
5987 const store = useRefWithInit(() => new FloatingRootStore({
5988 open,
5989 transitionStatus: void 0,
5990 referenceElement,
5991 floatingElement,
5992 triggerElements,
5993 onOpenChange,
5994 floatingId,
5995 syncOnly: true,
5996 nested
5997 })).current;
5998 useIsoLayoutEffect(() => {
5999 const valuesToSync = {
6000 open,
6001 floatingId,
6002 referenceElement,
6003 floatingElement
6004 };
6005 if (isElement(referenceElement)) {
6006 valuesToSync.domReferenceElement = referenceElement;
6007 }
6008 if (store.state.positionReference === store.state.referenceElement) {
6009 valuesToSync.positionReference = referenceElement;
6010 }
6011 store.update(valuesToSync);
6012 }, [open, floatingId, referenceElement, floatingElement, store]);
6013 store.context.onOpenChange = onOpenChange;
6014 store.context.nested = nested;
6015 return store;
6016 }
6017
6018 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6019 var React26 = __toESM(require_react(), 1);
6020 var isMacSafari = isMac && isSafari;
6021 function useFocus(context, props = {}) {
6022 const store = "rootStore" in context ? context.rootStore : context;
6023 const {
6024 events,
6025 dataRef
6026 } = store.context;
6027 const {
6028 enabled = true,
6029 delay
6030 } = props;
6031 const blockFocusRef = React26.useRef(false);
6032 const blockedReferenceRef = React26.useRef(null);
6033 const timeout = useTimeout();
6034 const keyboardModalityRef = React26.useRef(true);
6035 React26.useEffect(() => {
6036 const domReference = store.select("domReferenceElement");
6037 if (!enabled) {
6038 return void 0;
6039 }
6040 const win = getWindow(domReference);
6041 function onBlur() {
6042 const currentDomReference = store.select("domReferenceElement");
6043 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6044 blockFocusRef.current = true;
6045 }
6046 }
6047 function onKeyDown() {
6048 keyboardModalityRef.current = true;
6049 }
6050 function onPointerDown() {
6051 keyboardModalityRef.current = false;
6052 }
6053 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6054 }, [store, enabled]);
6055 React26.useEffect(() => {
6056 if (!enabled) {
6057 return void 0;
6058 }
6059 function onOpenChangeLocal(details) {
6060 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6061 const referenceElement = store.select("domReferenceElement");
6062 if (isElement(referenceElement)) {
6063 blockedReferenceRef.current = referenceElement;
6064 blockFocusRef.current = true;
6065 }
6066 }
6067 }
6068 events.on("openchange", onOpenChangeLocal);
6069 return () => {
6070 events.off("openchange", onOpenChangeLocal);
6071 };
6072 }, [events, enabled, store]);
6073 const reference = React26.useMemo(() => ({
6074 onMouseLeave() {
6075 blockFocusRef.current = false;
6076 blockedReferenceRef.current = null;
6077 },
6078 onFocus(event) {
6079 const focusTarget = event.currentTarget;
6080 if (blockFocusRef.current) {
6081 if (blockedReferenceRef.current === focusTarget) {
6082 return;
6083 }
6084 blockFocusRef.current = false;
6085 blockedReferenceRef.current = null;
6086 }
6087 const target = getTarget(event.nativeEvent);
6088 if (isElement(target)) {
6089 if (isMacSafari && !event.relatedTarget) {
6090 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6091 return;
6092 }
6093 } else if (!matchesFocusVisible(target)) {
6094 return;
6095 }
6096 }
6097 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6098 const {
6099 nativeEvent,
6100 currentTarget
6101 } = event;
6102 const delayValue = typeof delay === "function" ? delay() : delay;
6103 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6104 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6105 return;
6106 }
6107 timeout.start(delayValue, () => {
6108 if (blockFocusRef.current) {
6109 return;
6110 }
6111 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6112 });
6113 },
6114 onBlur(event) {
6115 blockFocusRef.current = false;
6116 blockedReferenceRef.current = null;
6117 const relatedTarget = event.relatedTarget;
6118 const nativeEvent = event.nativeEvent;
6119 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6120 timeout.start(0, () => {
6121 const domReference = store.select("domReferenceElement");
6122 const activeEl = activeElement(ownerDocument(domReference));
6123 if (!relatedTarget && activeEl === domReference) {
6124 return;
6125 }
6126 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6127 return;
6128 }
6129 const nextFocusedElement = relatedTarget ?? activeEl;
6130 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6131 return;
6132 }
6133 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6134 });
6135 }
6136 }), [dataRef, store, timeout, delay]);
6137 return React26.useMemo(() => enabled ? {
6138 reference,
6139 trigger: reference
6140 } : {}, [enabled, reference]);
6141 }
6142
6143 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6144 var React27 = __toESM(require_react(), 1);
6145
6146 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6147 var HoverInteraction = class _HoverInteraction {
6148 constructor() {
6149 this.pointerType = void 0;
6150 this.interactedInside = false;
6151 this.handler = void 0;
6152 this.blockMouseMove = true;
6153 this.performedPointerEventsMutation = false;
6154 this.pointerEventsScopeElement = null;
6155 this.pointerEventsReferenceElement = null;
6156 this.pointerEventsFloatingElement = null;
6157 this.restTimeoutPending = false;
6158 this.openChangeTimeout = new Timeout();
6159 this.restTimeout = new Timeout();
6160 this.handleCloseOptions = void 0;
6161 }
6162 static create() {
6163 return new _HoverInteraction();
6164 }
6165 dispose = () => {
6166 this.openChangeTimeout.clear();
6167 this.restTimeout.clear();
6168 };
6169 disposeEffect = () => {
6170 return this.dispose;
6171 };
6172 };
6173 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6174 function clearSafePolygonPointerEventsMutation(instance) {
6175 if (!instance.performedPointerEventsMutation) {
6176 return;
6177 }
6178 const scopeElement = instance.pointerEventsScopeElement;
6179 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6180 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6181 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6182 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6183 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6184 }
6185 instance.performedPointerEventsMutation = false;
6186 instance.pointerEventsScopeElement = null;
6187 instance.pointerEventsReferenceElement = null;
6188 instance.pointerEventsFloatingElement = null;
6189 }
6190 function applySafePolygonPointerEventsMutation(instance, options) {
6191 const {
6192 scopeElement,
6193 referenceElement,
6194 floatingElement
6195 } = options;
6196 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6197 if (existingOwner && existingOwner !== instance) {
6198 clearSafePolygonPointerEventsMutation(existingOwner);
6199 }
6200 clearSafePolygonPointerEventsMutation(instance);
6201 instance.performedPointerEventsMutation = true;
6202 instance.pointerEventsScopeElement = scopeElement;
6203 instance.pointerEventsReferenceElement = referenceElement;
6204 instance.pointerEventsFloatingElement = floatingElement;
6205 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6206 scopeElement.style.pointerEvents = "none";
6207 referenceElement.style.pointerEvents = "auto";
6208 floatingElement.style.pointerEvents = "auto";
6209 }
6210 function useHoverInteractionSharedState(store) {
6211 const instance = useRefWithInit(HoverInteraction.create).current;
6212 const data = store.context.dataRef.current;
6213 if (!data.hoverInteractionState) {
6214 data.hoverInteractionState = instance;
6215 }
6216 useOnMount(data.hoverInteractionState.disposeEffect);
6217 return data.hoverInteractionState;
6218 }
6219
6220 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6221 function useHoverFloatingInteraction(context, parameters = {}) {
6222 const store = "rootStore" in context ? context.rootStore : context;
6223 const open = store.useState("open");
6224 const floatingElement = store.useState("floatingElement");
6225 const domReferenceElement = store.useState("domReferenceElement");
6226 const {
6227 dataRef
6228 } = store.context;
6229 const {
6230 enabled = true,
6231 closeDelay: closeDelayProp = 0,
6232 nodeId: nodeIdProp
6233 } = parameters;
6234 const instance = useHoverInteractionSharedState(store);
6235 const tree = useFloatingTree();
6236 const parentId = useFloatingParentNodeId();
6237 const isClickLikeOpenEvent2 = useStableCallback(() => {
6238 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6239 });
6240 const isHoverOpen = useStableCallback(() => {
6241 const type = dataRef.current.openEvent?.type;
6242 return type?.includes("mouse") && type !== "mousedown";
6243 });
6244 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6245 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6246 });
6247 const closeWithDelay = React27.useCallback((event) => {
6248 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6249 const close = () => {
6250 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6251 tree?.events.emit("floating.closed", event);
6252 };
6253 if (closeDelay) {
6254 instance.openChangeTimeout.start(closeDelay, close);
6255 } else {
6256 instance.openChangeTimeout.clear();
6257 close();
6258 }
6259 }, [closeDelayProp, store, instance, tree]);
6260 const clearPointerEvents = useStableCallback(() => {
6261 clearSafePolygonPointerEventsMutation(instance);
6262 });
6263 const handleInteractInside = useStableCallback((event) => {
6264 const target = getTarget(event);
6265 if (!isInteractiveElement(target)) {
6266 instance.interactedInside = false;
6267 return;
6268 }
6269 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6270 });
6271 useIsoLayoutEffect(() => {
6272 if (!open) {
6273 instance.pointerType = void 0;
6274 instance.restTimeoutPending = false;
6275 instance.interactedInside = false;
6276 clearPointerEvents();
6277 }
6278 }, [open, instance, clearPointerEvents]);
6279 React27.useEffect(() => {
6280 return clearPointerEvents;
6281 }, [clearPointerEvents]);
6282 useIsoLayoutEffect(() => {
6283 if (!enabled) {
6284 return void 0;
6285 }
6286 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6287 const ref = domReferenceElement;
6288 const floatingEl = floatingElement;
6289 const doc = ownerDocument(floatingElement);
6290 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6291 if (parentFloating) {
6292 parentFloating.style.pointerEvents = "";
6293 }
6294 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
6295 applySafePolygonPointerEventsMutation(instance, {
6296 scopeElement,
6297 referenceElement: ref,
6298 floatingElement: floatingEl
6299 });
6300 return () => {
6301 clearPointerEvents();
6302 };
6303 }
6304 return void 0;
6305 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6306 const childClosedTimeout = useTimeout();
6307 React27.useEffect(() => {
6308 if (!enabled) {
6309 return void 0;
6310 }
6311 function onFloatingMouseEnter() {
6312 instance.openChangeTimeout.clear();
6313 childClosedTimeout.clear();
6314 tree?.events.off("floating.closed", onNodeClosed);
6315 clearPointerEvents();
6316 }
6317 function onFloatingMouseLeave(event) {
6318 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6319 tree.events.on("floating.closed", onNodeClosed);
6320 return;
6321 }
6322 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
6323 return;
6324 }
6325 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6326 const relatedTarget = event.relatedTarget;
6327 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6328 if (isMovingIntoDescendantFloating) {
6329 return;
6330 }
6331 if (instance.handler) {
6332 instance.handler(event);
6333 return;
6334 }
6335 clearPointerEvents();
6336 if (!isClickLikeOpenEvent2()) {
6337 closeWithDelay(event);
6338 }
6339 }
6340 function onNodeClosed(event) {
6341 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6342 return;
6343 }
6344 childClosedTimeout.start(0, () => {
6345 tree.events.off("floating.closed", onNodeClosed);
6346 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6347 tree.events.emit("floating.closed", event);
6348 });
6349 }
6350 const floating = floatingElement;
6351 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6352 tree?.events.off("floating.closed", onNodeClosed);
6353 });
6354 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
6355 }
6356
6357 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6358 var React28 = __toESM(require_react(), 1);
6359 var ReactDOM4 = __toESM(require_react_dom(), 1);
6360 var EMPTY_REF = {
6361 current: null
6362 };
6363 function useHoverReferenceInteraction(context, props = {}) {
6364 const store = "rootStore" in context ? context.rootStore : context;
6365 const {
6366 dataRef,
6367 events
6368 } = store.context;
6369 const {
6370 enabled = true,
6371 delay = 0,
6372 handleClose = null,
6373 mouseOnly = false,
6374 restMs = 0,
6375 move = true,
6376 triggerElementRef = EMPTY_REF,
6377 externalTree,
6378 isActiveTrigger = true,
6379 getHandleCloseContext,
6380 isClosing
6381 } = props;
6382 const tree = useFloatingTree(externalTree);
6383 const instance = useHoverInteractionSharedState(store);
6384 const isHoverCloseActiveRef = React28.useRef(false);
6385 const handleCloseRef = useValueAsRef(handleClose);
6386 const delayRef = useValueAsRef(delay);
6387 const restMsRef = useValueAsRef(restMs);
6388 const enabledRef = useValueAsRef(enabled);
6389 const isClosingRef = useValueAsRef(isClosing);
6390 if (isActiveTrigger) {
6391 instance.handleCloseOptions = handleCloseRef.current?.__options;
6392 }
6393 const isClickLikeOpenEvent2 = useStableCallback(() => {
6394 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6395 });
6396 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6397 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6398 });
6399 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6400 const allTriggers = store.context.triggerElements;
6401 if (allTriggers.hasElement(currentTarget)) {
6402 return !currentDomReference || !contains(currentDomReference, currentTarget);
6403 }
6404 if (!isElement(target)) {
6405 return false;
6406 }
6407 const targetElement = target;
6408 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6409 });
6410 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
6411 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6412 if (closeDelay) {
6413 instance.openChangeTimeout.start(closeDelay, () => {
6414 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6415 tree?.events.emit("floating.closed", event);
6416 });
6417 } else if (runElseBranch) {
6418 instance.openChangeTimeout.clear();
6419 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6420 tree?.events.emit("floating.closed", event);
6421 }
6422 });
6423 const cleanupMouseMoveHandler = useStableCallback(() => {
6424 if (!instance.handler) {
6425 return;
6426 }
6427 const doc = ownerDocument(store.select("domReferenceElement"));
6428 doc.removeEventListener("mousemove", instance.handler);
6429 instance.handler = void 0;
6430 });
6431 const clearPointerEvents = useStableCallback(() => {
6432 clearSafePolygonPointerEventsMutation(instance);
6433 });
6434 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6435 React28.useEffect(() => {
6436 if (!enabled) {
6437 return void 0;
6438 }
6439 function onOpenChangeLocal(details) {
6440 if (!details.open) {
6441 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6442 cleanupMouseMoveHandler();
6443 instance.openChangeTimeout.clear();
6444 instance.restTimeout.clear();
6445 instance.blockMouseMove = true;
6446 instance.restTimeoutPending = false;
6447 } else {
6448 isHoverCloseActiveRef.current = false;
6449 }
6450 }
6451 events.on("openchange", onOpenChangeLocal);
6452 return () => {
6453 events.off("openchange", onOpenChangeLocal);
6454 };
6455 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6456 React28.useEffect(() => {
6457 if (!enabled) {
6458 return void 0;
6459 }
6460 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6461 if (!isElement(trigger)) {
6462 return void 0;
6463 }
6464 function onMouseEnter(event) {
6465 instance.openChangeTimeout.clear();
6466 instance.blockMouseMove = false;
6467 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6468 return;
6469 }
6470 const restMsValue = getRestMs(restMsRef.current);
6471 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6472 const eventTarget = getTarget(event);
6473 const currentTarget = event.currentTarget ?? null;
6474 const currentDomReference = store.select("domReferenceElement");
6475 let triggerNode = currentTarget;
6476 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6477 for (const triggerElement of store.context.triggerElements.elements()) {
6478 if (contains(triggerElement, eventTarget)) {
6479 triggerNode = triggerElement;
6480 break;
6481 }
6482 }
6483 }
6484 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6485 triggerNode = currentDomReference;
6486 }
6487 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6488 const isOpen = store.select("open");
6489 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6490 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6491 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6492 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6493 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6494 const shouldOpen = !isOpen || isOverInactive;
6495 if (shouldOpenImmediately) {
6496 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6497 return;
6498 }
6499 if (isRestOnlyDelay) {
6500 return;
6501 }
6502 if (openDelay) {
6503 instance.openChangeTimeout.start(openDelay, () => {
6504 if (shouldOpen) {
6505 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6506 }
6507 });
6508 } else if (shouldOpen) {
6509 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6510 }
6511 }
6512 function onMouseLeave(event) {
6513 if (isClickLikeOpenEvent2()) {
6514 clearPointerEvents();
6515 return;
6516 }
6517 cleanupMouseMoveHandler();
6518 const domReferenceElement = store.select("domReferenceElement");
6519 const doc = ownerDocument(domReferenceElement);
6520 instance.restTimeout.clear();
6521 instance.restTimeoutPending = false;
6522 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6523 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
6524 if (ignoreRelatedTargetTrigger) {
6525 return;
6526 }
6527 if (handleCloseRef.current && handleCloseContextBase) {
6528 if (!store.select("open")) {
6529 instance.openChangeTimeout.clear();
6530 }
6531 const currentTrigger = triggerElementRef.current;
6532 instance.handler = handleCloseRef.current({
6533 ...handleCloseContextBase,
6534 tree,
6535 x: event.clientX,
6536 y: event.clientY,
6537 onClose() {
6538 clearPointerEvents();
6539 cleanupMouseMoveHandler();
6540 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6541 closeWithDelay(event, true);
6542 }
6543 }
6544 });
6545 doc.addEventListener("mousemove", instance.handler);
6546 instance.handler(event);
6547 return;
6548 }
6549 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6550 if (shouldClose) {
6551 closeWithDelay(event);
6552 }
6553 }
6554 if (move) {
6555 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6556 once: true
6557 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6558 }
6559 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6560 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
6561 return React28.useMemo(() => {
6562 if (!enabled) {
6563 return void 0;
6564 }
6565 function setPointerRef(event) {
6566 instance.pointerType = event.pointerType;
6567 }
6568 return {
6569 onPointerDown: setPointerRef,
6570 onPointerEnter: setPointerRef,
6571 onMouseMove(event) {
6572 const {
6573 nativeEvent
6574 } = event;
6575 const trigger = event.currentTarget;
6576 const currentDomReference = store.select("domReferenceElement");
6577 const currentOpen = store.select("open");
6578 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6579 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6580 return;
6581 }
6582 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6583 const floatingElement = store.select("floatingElement");
6584 if (floatingElement) {
6585 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6586 applySafePolygonPointerEventsMutation(instance, {
6587 scopeElement,
6588 referenceElement: trigger,
6589 floatingElement
6590 });
6591 }
6592 }
6593 const restMsValue = getRestMs(restMsRef.current);
6594 if (currentOpen && !isOverInactive || restMsValue === 0) {
6595 return;
6596 }
6597 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6598 return;
6599 }
6600 instance.restTimeout.clear();
6601 function handleMouseMove() {
6602 instance.restTimeoutPending = false;
6603 if (isClickLikeOpenEvent2()) {
6604 return;
6605 }
6606 const latestOpen = store.select("open");
6607 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
6608 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6609 }
6610 }
6611 if (instance.pointerType === "touch") {
6612 ReactDOM4.flushSync(() => {
6613 handleMouseMove();
6614 });
6615 } else if (isOverInactive && currentOpen) {
6616 handleMouseMove();
6617 } else {
6618 instance.restTimeoutPending = true;
6619 instance.restTimeout.start(restMsValue, handleMouseMove);
6620 }
6621 }
6622 };
6623 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
6624 }
6625
6626 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
6627 var React29 = __toESM(require_react(), 1);
6628 function useInteractions(propsList = []) {
6629 const referenceDeps = propsList.map((key) => key?.reference);
6630 const floatingDeps = propsList.map((key) => key?.floating);
6631 const itemDeps = propsList.map((key) => key?.item);
6632 const triggerDeps = propsList.map((key) => key?.trigger);
6633 const getReferenceProps = React29.useCallback(
6634 (userProps) => mergeProps2(userProps, propsList, "reference"),
6635 // eslint-disable-next-line react-hooks/exhaustive-deps
6636 referenceDeps
6637 );
6638 const getFloatingProps = React29.useCallback(
6639 (userProps) => mergeProps2(userProps, propsList, "floating"),
6640 // eslint-disable-next-line react-hooks/exhaustive-deps
6641 floatingDeps
6642 );
6643 const getItemProps = React29.useCallback(
6644 (userProps) => mergeProps2(userProps, propsList, "item"),
6645 // eslint-disable-next-line react-hooks/exhaustive-deps
6646 itemDeps
6647 );
6648 const getTriggerProps = React29.useCallback(
6649 (userProps) => mergeProps2(userProps, propsList, "trigger"),
6650 // eslint-disable-next-line react-hooks/exhaustive-deps
6651 triggerDeps
6652 );
6653 return React29.useMemo(() => ({
6654 getReferenceProps,
6655 getFloatingProps,
6656 getItemProps,
6657 getTriggerProps
6658 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
6659 }
6660 function mergeProps2(userProps, propsList, elementKey) {
6661 const eventHandlers = /* @__PURE__ */ new Map();
6662 const isItem2 = elementKey === "item";
6663 const outputProps = {};
6664 if (elementKey === "floating") {
6665 outputProps.tabIndex = -1;
6666 outputProps[FOCUSABLE_ATTRIBUTE] = "";
6667 }
6668 for (const key in userProps) {
6669 if (isItem2 && userProps) {
6670 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
6671 continue;
6672 }
6673 }
6674 outputProps[key] = userProps[key];
6675 }
6676 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
6677 let props;
6678 const propsOrGetProps = propsList[i2]?.[elementKey];
6679 if (typeof propsOrGetProps === "function") {
6680 props = userProps ? propsOrGetProps(userProps) : null;
6681 } else {
6682 props = propsOrGetProps;
6683 }
6684 if (!props) {
6685 continue;
6686 }
6687 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
6688 }
6689 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
6690 return outputProps;
6691 }
6692 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
6693 for (const key in props) {
6694 const value = props[key];
6695 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
6696 continue;
6697 }
6698 if (!key.startsWith("on")) {
6699 outputProps[key] = value;
6700 } else {
6701 if (!eventHandlers.has(key)) {
6702 eventHandlers.set(key, []);
6703 }
6704 if (typeof value === "function") {
6705 eventHandlers.get(key)?.push(value);
6706 outputProps[key] = (...args) => {
6707 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
6708 };
6709 }
6710 }
6711 }
6712 }
6713
6714 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6715 var CURSOR_SPEED_THRESHOLD = 0.1;
6716 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6717 var POLYGON_BUFFER = 0.5;
6718 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6719 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6720 }
6721 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6722 let isInsideValue = false;
6723 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6724 isInsideValue = !isInsideValue;
6725 }
6726 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6727 isInsideValue = !isInsideValue;
6728 }
6729 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6730 isInsideValue = !isInsideValue;
6731 }
6732 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6733 isInsideValue = !isInsideValue;
6734 }
6735 return isInsideValue;
6736 }
6737 function isInsideRect(pointX, pointY, rect) {
6738 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6739 }
6740 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6741 const minX = Math.min(x1, x2);
6742 const maxX = Math.max(x1, x2);
6743 const minY = Math.min(y1, y2);
6744 const maxY = Math.max(y1, y2);
6745 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6746 }
6747 function safePolygon(options = {}) {
6748 const {
6749 blockPointerEvents = false
6750 } = options;
6751 const timeout = new Timeout();
6752 const fn = ({
6753 x: x2,
6754 y: y2,
6755 placement,
6756 elements,
6757 onClose,
6758 nodeId,
6759 tree
6760 }) => {
6761 const side = placement?.split("-")[0];
6762 let hasLanded = false;
6763 let lastX = null;
6764 let lastY = null;
6765 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6766 function isCursorMovingSlowly(nextX, nextY) {
6767 const currentTime = performance.now();
6768 const elapsedTime = currentTime - lastCursorTime;
6769 if (lastX === null || lastY === null || elapsedTime === 0) {
6770 lastX = nextX;
6771 lastY = nextY;
6772 lastCursorTime = currentTime;
6773 return false;
6774 }
6775 const deltaX = nextX - lastX;
6776 const deltaY = nextY - lastY;
6777 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6778 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6779 lastX = nextX;
6780 lastY = nextY;
6781 lastCursorTime = currentTime;
6782 return distanceSquared < thresholdSquared;
6783 }
6784 function close() {
6785 timeout.clear();
6786 onClose();
6787 }
6788 return function onMouseMove(event) {
6789 timeout.clear();
6790 const domReference = elements.domReference;
6791 const floating = elements.floating;
6792 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6793 return void 0;
6794 }
6795 const {
6796 clientX,
6797 clientY
6798 } = event;
6799 const target = getTarget(event);
6800 const isLeave = event.type === "mouseleave";
6801 const isOverFloatingEl = contains(floating, target);
6802 const isOverReferenceEl = contains(domReference, target);
6803 if (isOverFloatingEl) {
6804 hasLanded = true;
6805 if (!isLeave) {
6806 return void 0;
6807 }
6808 }
6809 if (isOverReferenceEl) {
6810 hasLanded = false;
6811 if (!isLeave) {
6812 hasLanded = true;
6813 return void 0;
6814 }
6815 }
6816 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6817 return void 0;
6818 }
6819 function hasOpenChildNode() {
6820 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6821 }
6822 function closeIfNoOpenChild() {
6823 if (!hasOpenChildNode()) {
6824 close();
6825 }
6826 }
6827 if (hasOpenChildNode()) {
6828 return void 0;
6829 }
6830 const refRect = domReference.getBoundingClientRect();
6831 const rect = floating.getBoundingClientRect();
6832 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
6833 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
6834 const isFloatingWider = rect.width > refRect.width;
6835 const isFloatingTaller = rect.height > refRect.height;
6836 const left = (isFloatingWider ? refRect : rect).left;
6837 const right = (isFloatingWider ? refRect : rect).right;
6838 const top = (isFloatingTaller ? refRect : rect).top;
6839 const bottom = (isFloatingTaller ? refRect : rect).bottom;
6840 if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) {
6841 closeIfNoOpenChild();
6842 return void 0;
6843 }
6844 let isInsideTroughRect = false;
6845 switch (side) {
6846 case "top":
6847 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
6848 break;
6849 case "bottom":
6850 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
6851 break;
6852 case "left":
6853 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
6854 break;
6855 case "right":
6856 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
6857 break;
6858 default:
6859 }
6860 if (isInsideTroughRect) {
6861 return void 0;
6862 }
6863 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
6864 closeIfNoOpenChild();
6865 return void 0;
6866 }
6867 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
6868 closeIfNoOpenChild();
6869 return void 0;
6870 }
6871 let isInsidePolygon = false;
6872 switch (side) {
6873 case "top": {
6874 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6875 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6876 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6877 const cursorPointY = y2 + POLYGON_BUFFER + 1;
6878 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
6879 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
6880 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6881 break;
6882 }
6883 case "bottom": {
6884 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6885 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6886 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6887 const cursorPointY = y2 - POLYGON_BUFFER;
6888 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
6889 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
6890 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6891 break;
6892 }
6893 case "left": {
6894 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6895 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6896 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6897 const cursorPointX = x2 + POLYGON_BUFFER + 1;
6898 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
6899 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
6900 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
6901 break;
6902 }
6903 case "right": {
6904 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6905 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6906 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6907 const cursorPointX = x2 - POLYGON_BUFFER;
6908 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
6909 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
6910 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
6911 break;
6912 }
6913 default:
6914 }
6915 if (!isInsidePolygon) {
6916 closeIfNoOpenChild();
6917 } else if (!hasLanded) {
6918 timeout.start(40, closeIfNoOpenChild);
6919 }
6920 return void 0;
6921 };
6922 };
6923 fn.__options = {
6924 ...options,
6925 blockPointerEvents
6926 };
6927 return fn;
6928 }
6929
6930 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
6931 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
6932 CommonPopupDataAttributes2["open"] = "data-open";
6933 CommonPopupDataAttributes2["closed"] = "data-closed";
6934 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
6935 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
6936 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
6937 CommonPopupDataAttributes2["side"] = "data-side";
6938 CommonPopupDataAttributes2["align"] = "data-align";
6939 return CommonPopupDataAttributes2;
6940 })({});
6941 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
6942 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
6943 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
6944 return CommonTriggerDataAttributes2;
6945 })({});
6946 var TRIGGER_HOOK = {
6947 [CommonTriggerDataAttributes.popupOpen]: ""
6948 };
6949 var PRESSABLE_TRIGGER_HOOK = {
6950 [CommonTriggerDataAttributes.popupOpen]: "",
6951 [CommonTriggerDataAttributes.pressed]: ""
6952 };
6953 var POPUP_OPEN_HOOK = {
6954 [CommonPopupDataAttributes.open]: ""
6955 };
6956 var POPUP_CLOSED_HOOK = {
6957 [CommonPopupDataAttributes.closed]: ""
6958 };
6959 var ANCHOR_HIDDEN_HOOK = {
6960 [CommonPopupDataAttributes.anchorHidden]: ""
6961 };
6962 var triggerOpenStateMapping = {
6963 open(value) {
6964 if (value) {
6965 return TRIGGER_HOOK;
6966 }
6967 return null;
6968 }
6969 };
6970 var popupStateMapping = {
6971 open(value) {
6972 if (value) {
6973 return POPUP_OPEN_HOOK;
6974 }
6975 return POPUP_CLOSED_HOOK;
6976 },
6977 anchorHidden(value) {
6978 if (value) {
6979 return ANCHOR_HIDDEN_HOOK;
6980 }
6981 return null;
6982 }
6983 };
6984
6985 // node_modules/@base-ui/utils/esm/inertValue.js
6986 function inertValue(value) {
6987 if (isReactVersionAtLeast(19)) {
6988 return value;
6989 }
6990 return value ? "true" : void 0;
6991 }
6992
6993 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
6994 var React30 = __toESM(require_react(), 1);
6995
6996 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
6997 var baseArrow = (options) => ({
6998 name: "arrow",
6999 options,
7000 async fn(state) {
7001 const {
7002 x: x2,
7003 y: y2,
7004 placement,
7005 rects,
7006 platform: platform3,
7007 elements,
7008 middlewareData
7009 } = state;
7010 const {
7011 element,
7012 padding = 0,
7013 offsetParent = "real"
7014 } = evaluate(options, state) || {};
7015 if (element == null) {
7016 return {};
7017 }
7018 const paddingObject = getPaddingObject(padding);
7019 const coords = {
7020 x: x2,
7021 y: y2
7022 };
7023 const axis = getAlignmentAxis(placement);
7024 const length = getAxisLength(axis);
7025 const arrowDimensions = await platform3.getDimensions(element);
7026 const isYAxis = axis === "y";
7027 const minProp = isYAxis ? "top" : "left";
7028 const maxProp = isYAxis ? "bottom" : "right";
7029 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7030 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7031 const startDiff = coords[axis] - rects.reference[axis];
7032 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7033 let clientSize = elements.floating[clientProp] || rects.floating[length];
7034 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7035 clientSize = elements.floating[clientProp] || rects.floating[length];
7036 }
7037 const centerToReference = endDiff / 2 - startDiff / 2;
7038 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7039 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7040 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7041 const min2 = minPadding;
7042 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7043 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7044 const offset4 = clamp(min2, center, max2);
7045 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7046 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7047 return {
7048 [axis]: coords[axis] + alignmentOffset,
7049 data: {
7050 [axis]: offset4,
7051 centerOffset: center - offset4 - alignmentOffset,
7052 ...shouldAddOffset && {
7053 alignmentOffset
7054 }
7055 },
7056 reset: shouldAddOffset
7057 };
7058 }
7059 });
7060 var arrow4 = (options, deps) => ({
7061 ...baseArrow(options),
7062 options: [options, deps]
7063 });
7064
7065 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7066 var hide4 = {
7067 name: "hide",
7068 async fn(state) {
7069 const {
7070 width,
7071 height,
7072 x: x2,
7073 y: y2
7074 } = state.rects.reference;
7075 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7076 const nativeHideResult = await hide3().fn(state);
7077 return {
7078 data: {
7079 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7080 }
7081 };
7082 }
7083 };
7084
7085 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7086 var DEFAULT_SIDES = {
7087 sideX: "left",
7088 sideY: "top"
7089 };
7090 var adaptiveOrigin = {
7091 name: "adaptiveOrigin",
7092 async fn(state) {
7093 const {
7094 x: rawX,
7095 y: rawY,
7096 rects: {
7097 floating: floatRect
7098 },
7099 elements: {
7100 floating
7101 },
7102 platform: platform3,
7103 strategy,
7104 placement
7105 } = state;
7106 const win = getWindow(floating);
7107 const styles = win.getComputedStyle(floating);
7108 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7109 if (!hasTransition) {
7110 return {
7111 x: rawX,
7112 y: rawY,
7113 data: DEFAULT_SIDES
7114 };
7115 }
7116 const offsetParent = await platform3.getOffsetParent?.(floating);
7117 let offsetDimensions = {
7118 width: 0,
7119 height: 0
7120 };
7121 if (strategy === "fixed" && win?.visualViewport) {
7122 offsetDimensions = {
7123 width: win.visualViewport.width,
7124 height: win.visualViewport.height
7125 };
7126 } else if (offsetParent === win) {
7127 const doc = ownerDocument(floating);
7128 offsetDimensions = {
7129 width: doc.documentElement.clientWidth,
7130 height: doc.documentElement.clientHeight
7131 };
7132 } else if (await platform3.isElement?.(offsetParent)) {
7133 offsetDimensions = await platform3.getDimensions(offsetParent);
7134 }
7135 const currentSide = getSide(placement);
7136 let x2 = rawX;
7137 let y2 = rawY;
7138 if (currentSide === "left") {
7139 x2 = offsetDimensions.width - (rawX + floatRect.width);
7140 }
7141 if (currentSide === "top") {
7142 y2 = offsetDimensions.height - (rawY + floatRect.height);
7143 }
7144 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7145 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7146 return {
7147 x: x2,
7148 y: y2,
7149 data: {
7150 sideX,
7151 sideY
7152 }
7153 };
7154 }
7155 };
7156
7157 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7158 function getLogicalSide(sideParam, renderedSide, isRtl) {
7159 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7160 const logicalRight = isRtl ? "inline-start" : "inline-end";
7161 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7162 return {
7163 top: "top",
7164 right: isLogicalSideParam ? logicalRight : "right",
7165 bottom: "bottom",
7166 left: isLogicalSideParam ? logicalLeft : "left"
7167 }[renderedSide];
7168 }
7169 function getOffsetData(state, sideParam, isRtl) {
7170 const {
7171 rects,
7172 placement
7173 } = state;
7174 const data = {
7175 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7176 align: getAlignment(placement) || "center",
7177 anchor: {
7178 width: rects.reference.width,
7179 height: rects.reference.height
7180 },
7181 positioner: {
7182 width: rects.floating.width,
7183 height: rects.floating.height
7184 }
7185 };
7186 return data;
7187 }
7188 function useAnchorPositioning(params) {
7189 const {
7190 // Public parameters
7191 anchor,
7192 positionMethod = "absolute",
7193 side: sideParam = "bottom",
7194 sideOffset = 0,
7195 align = "center",
7196 alignOffset = 0,
7197 collisionBoundary,
7198 collisionPadding: collisionPaddingParam = 5,
7199 sticky = false,
7200 arrowPadding = 5,
7201 disableAnchorTracking = false,
7202 // Private parameters
7203 keepMounted = false,
7204 floatingRootContext,
7205 mounted,
7206 collisionAvoidance,
7207 shiftCrossAxis = false,
7208 nodeId,
7209 adaptiveOrigin: adaptiveOrigin2,
7210 lazyFlip = false,
7211 externalTree
7212 } = params;
7213 const [mountSide, setMountSide] = React30.useState(null);
7214 if (!mounted && mountSide !== null) {
7215 setMountSide(null);
7216 }
7217 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7218 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7219 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7220 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7221 const anchorFnCallback = useStableCallback(anchorFn);
7222 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7223 const anchorValueRef = useValueAsRef(anchor);
7224 const mountedRef = useValueAsRef(mounted);
7225 const direction = useDirection();
7226 const isRtl = direction === "rtl";
7227 const side = mountSide || {
7228 top: "top",
7229 right: "right",
7230 bottom: "bottom",
7231 left: "left",
7232 "inline-end": isRtl ? "left" : "right",
7233 "inline-start": isRtl ? "right" : "left"
7234 }[sideParam];
7235 const placement = align === "center" ? side : `${side}-${align}`;
7236 let collisionPadding = collisionPaddingParam;
7237 const bias = 1;
7238 const biasTop = sideParam === "bottom" ? bias : 0;
7239 const biasBottom = sideParam === "top" ? bias : 0;
7240 const biasLeft = sideParam === "right" ? bias : 0;
7241 const biasRight = sideParam === "left" ? bias : 0;
7242 if (typeof collisionPadding === "number") {
7243 collisionPadding = {
7244 top: collisionPadding + biasTop,
7245 right: collisionPadding + biasRight,
7246 bottom: collisionPadding + biasBottom,
7247 left: collisionPadding + biasLeft
7248 };
7249 } else if (collisionPadding) {
7250 collisionPadding = {
7251 top: (collisionPadding.top || 0) + biasTop,
7252 right: (collisionPadding.right || 0) + biasRight,
7253 bottom: (collisionPadding.bottom || 0) + biasBottom,
7254 left: (collisionPadding.left || 0) + biasLeft
7255 };
7256 }
7257 const commonCollisionProps = {
7258 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7259 padding: collisionPadding
7260 };
7261 const arrowRef = React30.useRef(null);
7262 const sideOffsetRef = useValueAsRef(sideOffset);
7263 const alignOffsetRef = useValueAsRef(alignOffset);
7264 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7265 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7266 const middleware = [offset3((state) => {
7267 const data = getOffsetData(state, sideParam, isRtl);
7268 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7269 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7270 return {
7271 mainAxis: sideAxis,
7272 crossAxis: alignAxis,
7273 alignmentAxis: alignAxis
7274 };
7275 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
7276 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7277 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7278 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7279 ...commonCollisionProps,
7280 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7281 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7282 padding: {
7283 top: collisionPadding.top + bias,
7284 right: collisionPadding.right + bias,
7285 bottom: collisionPadding.bottom + bias,
7286 left: collisionPadding.left + bias
7287 },
7288 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7289 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7290 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7291 });
7292 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7293 const html = ownerDocument(data.elements.floating).documentElement;
7294 return {
7295 ...commonCollisionProps,
7296 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7297 // for context menus.
7298 rootBoundary: shiftCrossAxis ? {
7299 x: 0,
7300 y: 0,
7301 width: html.clientWidth,
7302 height: html.clientHeight
7303 } : void 0,
7304 mainAxis: collisionAvoidanceAlign !== "none",
7305 crossAxis: crossAxisShiftEnabled,
7306 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7307 if (!arrowRef.current) {
7308 return {};
7309 }
7310 const {
7311 width,
7312 height
7313 } = arrowRef.current.getBoundingClientRect();
7314 const sideAxis = getSideAxis(getSide(limitData.placement));
7315 const arrowSize = sideAxis === "y" ? width : height;
7316 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7317 return {
7318 offset: arrowSize / 2 + offsetAmount / 2
7319 };
7320 })
7321 };
7322 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7323 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7324 middleware.push(shiftMiddleware, flipMiddleware);
7325 } else {
7326 middleware.push(flipMiddleware, shiftMiddleware);
7327 }
7328 middleware.push(size3({
7329 ...commonCollisionProps,
7330 apply({
7331 elements: {
7332 floating
7333 },
7334 availableWidth,
7335 availableHeight,
7336 rects
7337 }) {
7338 if (!mountedRef.current) {
7339 return;
7340 }
7341 const floatingStyle = floating.style;
7342 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7343 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7344 const dpr = getWindow(floating).devicePixelRatio || 1;
7345 const {
7346 x: x3,
7347 y: y3,
7348 width,
7349 height
7350 } = rects.reference;
7351 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7352 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7353 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7354 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7355 }
7356 }), arrow4(() => ({
7357 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7358 // we'll create a fake element.
7359 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
7360 padding: arrowPadding,
7361 offsetParent: "floating"
7362 }), [arrowPadding]), {
7363 name: "transformOrigin",
7364 fn(state) {
7365 const {
7366 elements: elements2,
7367 middlewareData: middlewareData2,
7368 placement: renderedPlacement2,
7369 rects,
7370 y: y3
7371 } = state;
7372 const currentRenderedSide = getSide(renderedPlacement2);
7373 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7374 const arrowEl = arrowRef.current;
7375 const arrowX = middlewareData2.arrow?.x || 0;
7376 const arrowY = middlewareData2.arrow?.y || 0;
7377 const arrowWidth = arrowEl?.clientWidth || 0;
7378 const arrowHeight = arrowEl?.clientHeight || 0;
7379 const transformX = arrowX + arrowWidth / 2;
7380 const transformY = arrowY + arrowHeight / 2;
7381 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7382 const halfAnchorHeight = rects.reference.height / 2;
7383 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7384 const isOverlappingAnchor = shiftY > sideOffsetValue;
7385 const adjacentTransformOrigin = {
7386 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7387 bottom: `${transformX}px ${-sideOffsetValue}px`,
7388 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7389 right: `${-sideOffsetValue}px ${transformY}px`
7390 }[currentRenderedSide];
7391 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7392 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7393 return {};
7394 }
7395 }, hide4, adaptiveOrigin2);
7396 useIsoLayoutEffect(() => {
7397 if (!mounted && floatingRootContext) {
7398 floatingRootContext.update({
7399 referenceElement: null,
7400 floatingElement: null,
7401 domReferenceElement: null,
7402 positionReference: null
7403 });
7404 }
7405 }, [mounted, floatingRootContext]);
7406 const autoUpdateOptions = React30.useMemo(() => ({
7407 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7408 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7409 }), [disableAnchorTracking]);
7410 const {
7411 refs,
7412 elements,
7413 x: x2,
7414 y: y2,
7415 middlewareData,
7416 update: update2,
7417 placement: renderedPlacement,
7418 context,
7419 isPositioned,
7420 floatingStyles: originalFloatingStyles
7421 } = useFloating2({
7422 rootContext: floatingRootContext,
7423 open: keepMounted ? mounted : void 0,
7424 placement,
7425 middleware,
7426 strategy: positionMethod,
7427 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7428 nodeId,
7429 externalTree
7430 });
7431 const {
7432 sideX,
7433 sideY
7434 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7435 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7436 const floatingStyles = React30.useMemo(() => {
7437 const base = adaptiveOrigin2 ? {
7438 position: resolvedPosition,
7439 [sideX]: x2,
7440 [sideY]: y2
7441 } : {
7442 position: resolvedPosition,
7443 ...originalFloatingStyles
7444 };
7445 if (!isPositioned) {
7446 base.opacity = 0;
7447 }
7448 return base;
7449 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7450 const registeredPositionReferenceRef = React30.useRef(null);
7451 useIsoLayoutEffect(() => {
7452 if (!mounted) {
7453 return;
7454 }
7455 const anchorValue = anchorValueRef.current;
7456 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7457 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7458 const finalAnchor = unwrappedElement || null;
7459 if (finalAnchor !== registeredPositionReferenceRef.current) {
7460 refs.setPositionReference(finalAnchor);
7461 registeredPositionReferenceRef.current = finalAnchor;
7462 }
7463 }, [mounted, refs, anchorDep, anchorValueRef]);
7464 React30.useEffect(() => {
7465 if (!mounted) {
7466 return;
7467 }
7468 const anchorValue = anchorValueRef.current;
7469 if (typeof anchorValue === "function") {
7470 return;
7471 }
7472 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7473 refs.setPositionReference(anchorValue.current);
7474 registeredPositionReferenceRef.current = anchorValue.current;
7475 }
7476 }, [mounted, refs, anchorDep, anchorValueRef]);
7477 React30.useEffect(() => {
7478 if (keepMounted && mounted && elements.domReference && elements.floating) {
7479 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7480 }
7481 return void 0;
7482 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7483 const renderedSide = getSide(renderedPlacement);
7484 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7485 const renderedAlign = getAlignment(renderedPlacement) || "center";
7486 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7487 useIsoLayoutEffect(() => {
7488 if (lazyFlip && mounted && isPositioned) {
7489 setMountSide(renderedSide);
7490 }
7491 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7492 const arrowStyles = React30.useMemo(() => ({
7493 position: "absolute",
7494 top: middlewareData.arrow?.y,
7495 left: middlewareData.arrow?.x
7496 }), [middlewareData.arrow]);
7497 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7498 return React30.useMemo(() => ({
7499 positionerStyles: floatingStyles,
7500 arrowStyles,
7501 arrowRef,
7502 arrowUncentered,
7503 side: logicalRenderedSide,
7504 align: renderedAlign,
7505 physicalSide: renderedSide,
7506 anchorHidden,
7507 refs,
7508 context,
7509 isPositioned,
7510 update: update2
7511 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7512 }
7513 function isRef(param) {
7514 return param != null && "current" in param;
7515 }
7516
7517 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7518 function getDisabledMountTransitionStyles(transitionStatus) {
7519 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7520 }
7521
7522 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7523 function usePositioner(componentProps, state, {
7524 styles,
7525 transitionStatus,
7526 props,
7527 refs,
7528 hidden,
7529 inert = false
7530 }) {
7531 const style = {
7532 ...styles
7533 };
7534 if (inert) {
7535 style.pointerEvents = "none";
7536 }
7537 return useRenderElement("div", componentProps, {
7538 state,
7539 ref: refs,
7540 props: [{
7541 role: "presentation",
7542 hidden,
7543 style
7544 }, getDisabledMountTransitionStyles(transitionStatus), props],
7545 stateAttributesMapping: popupStateMapping
7546 });
7547 }
7548
7549 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7550 var React33 = __toESM(require_react(), 1);
7551 var ReactDOM5 = __toESM(require_react_dom(), 1);
7552
7553 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7554 var React31 = __toESM(require_react(), 1);
7555 function usePreviousValue(value) {
7556 const [state, setState] = React31.useState({
7557 current: value,
7558 previous: null
7559 });
7560 if (value !== state.current) {
7561 setState({
7562 current: value,
7563 previous: state.current
7564 });
7565 }
7566 return state.previous;
7567 }
7568
7569 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7570 var React32 = __toESM(require_react(), 1);
7571
7572 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7573 function getCssDimensions2(element) {
7574 const css = getComputedStyle2(element);
7575 let width = parseFloat(css.width) || 0;
7576 let height = parseFloat(css.height) || 0;
7577 const hasOffset = isHTMLElement(element);
7578 const offsetWidth = hasOffset ? element.offsetWidth : width;
7579 const offsetHeight = hasOffset ? element.offsetHeight : height;
7580 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7581 if (shouldFallback) {
7582 width = offsetWidth;
7583 height = offsetHeight;
7584 }
7585 return {
7586 width,
7587 height
7588 };
7589 }
7590
7591 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7592 var DEFAULT_ENABLED = () => true;
7593 function usePopupAutoResize(parameters) {
7594 const {
7595 popupElement,
7596 positionerElement,
7597 content,
7598 mounted,
7599 enabled = DEFAULT_ENABLED,
7600 onMeasureLayout: onMeasureLayoutParam,
7601 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7602 side,
7603 direction
7604 } = parameters;
7605 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7606 const animationFrame = useAnimationFrame();
7607 const committedDimensionsRef = React32.useRef(null);
7608 const liveDimensionsRef = React32.useRef(null);
7609 const isInitialRenderRef = React32.useRef(true);
7610 const restoreAnchoringStylesRef = React32.useRef(NOOP);
7611 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7612 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7613 const anchoringStyles = React32.useMemo(() => {
7614 let isOriginSide = side === "top";
7615 let isPhysicalLeft = side === "left";
7616 if (direction === "rtl") {
7617 isOriginSide = isOriginSide || side === "inline-end";
7618 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7619 } else {
7620 isOriginSide = isOriginSide || side === "inline-start";
7621 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7622 }
7623 return isOriginSide ? {
7624 position: "absolute",
7625 [side === "top" ? "bottom" : "top"]: "0",
7626 [isPhysicalLeft ? "right" : "left"]: "0"
7627 } : EMPTY_OBJECT;
7628 }, [side, direction]);
7629 useIsoLayoutEffect(() => {
7630 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7631 restoreAnchoringStylesRef.current = NOOP;
7632 isInitialRenderRef.current = true;
7633 committedDimensionsRef.current = null;
7634 liveDimensionsRef.current = null;
7635 return void 0;
7636 }
7637 if (!popupElement || !positionerElement) {
7638 return void 0;
7639 }
7640 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7641 const observer = new ResizeObserver((entries) => {
7642 const entry = entries[0];
7643 if (entry) {
7644 liveDimensionsRef.current = {
7645 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7646 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7647 };
7648 }
7649 });
7650 observer.observe(popupElement);
7651 setPopupCssSize(popupElement, "auto");
7652 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7653 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7654 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7655 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7656 "--available-width": "max-content",
7657 "--available-height": "max-content"
7658 });
7659 function restoreMeasurementOverrides() {
7660 restorePopupPosition();
7661 restorePopupTransform();
7662 restorePositionerAvailableSize();
7663 }
7664 function restoreMeasurementOverridesIncludingScale() {
7665 restoreMeasurementOverrides();
7666 restorePopupScale();
7667 }
7668 onMeasureLayout?.();
7669 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7670 setPositionerCssSize(positionerElement, "max-content");
7671 const dimensions = getCssDimensions2(popupElement);
7672 committedDimensionsRef.current = dimensions;
7673 setPositionerCssSize(positionerElement, dimensions);
7674 restoreMeasurementOverridesIncludingScale();
7675 onMeasureLayoutComplete?.(null, dimensions);
7676 isInitialRenderRef.current = false;
7677 return () => {
7678 observer.disconnect();
7679 restoreAnchoringStylesRef.current();
7680 restoreAnchoringStylesRef.current = NOOP;
7681 };
7682 }
7683 setPopupCssSize(popupElement, "auto");
7684 setPositionerCssSize(positionerElement, "max-content");
7685 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7686 const newDimensions = getCssDimensions2(popupElement);
7687 committedDimensionsRef.current = newDimensions;
7688 if (!previousDimensions) {
7689 setPositionerCssSize(positionerElement, newDimensions);
7690 restoreMeasurementOverridesIncludingScale();
7691 onMeasureLayoutComplete?.(null, newDimensions);
7692 return () => {
7693 observer.disconnect();
7694 animationFrame.cancel();
7695 restoreAnchoringStylesRef.current();
7696 restoreAnchoringStylesRef.current = NOOP;
7697 };
7698 }
7699 setPopupCssSize(popupElement, previousDimensions);
7700 restoreMeasurementOverridesIncludingScale();
7701 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7702 setPositionerCssSize(positionerElement, newDimensions);
7703 const abortController = new AbortController();
7704 animationFrame.request(() => {
7705 setPopupCssSize(popupElement, newDimensions);
7706 runOnceAnimationsFinish(() => {
7707 popupElement.style.setProperty("--popup-width", "auto");
7708 popupElement.style.setProperty("--popup-height", "auto");
7709 }, abortController.signal);
7710 });
7711 return () => {
7712 observer.disconnect();
7713 abortController.abort();
7714 animationFrame.cancel();
7715 restoreAnchoringStylesRef.current();
7716 restoreAnchoringStylesRef.current = NOOP;
7717 };
7718 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7719 }
7720 function overrideElementStyle(element, property, value) {
7721 const originalValue = element.style.getPropertyValue(property);
7722 element.style.setProperty(property, value);
7723 return () => {
7724 element.style.setProperty(property, originalValue);
7725 };
7726 }
7727 function applyElementStyles(element, styles) {
7728 const restorers = [];
7729 for (const [key, value] of Object.entries(styles)) {
7730 restorers.push(overrideElementStyle(element, key, value));
7731 }
7732 return restorers.length ? () => {
7733 restorers.forEach((restore) => restore());
7734 } : NOOP;
7735 }
7736 function setPopupCssSize(popupElement, size4) {
7737 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7738 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7739 popupElement.style.setProperty("--popup-width", width);
7740 popupElement.style.setProperty("--popup-height", height);
7741 }
7742 function setPositionerCssSize(positionerElement, size4) {
7743 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7744 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7745 positionerElement.style.setProperty("--positioner-width", width);
7746 positionerElement.style.setProperty("--positioner-height", height);
7747 }
7748
7749 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7750 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7751 function usePopupViewport(parameters) {
7752 const {
7753 store,
7754 side,
7755 cssVars,
7756 children
7757 } = parameters;
7758 const direction = useDirection();
7759 const activeTrigger = store.useState("activeTriggerElement");
7760 const activeTriggerId = store.useState("activeTriggerId");
7761 const open = store.useState("open");
7762 const payload = store.useState("payload");
7763 const mounted = store.useState("mounted");
7764 const popupElement = store.useState("popupElement");
7765 const positionerElement = store.useState("positionerElement");
7766 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7767 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7768 const capturedNodeRef = React33.useRef(null);
7769 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
7770 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
7771 const currentContainerRef = React33.useRef(null);
7772 const previousContainerRef = React33.useRef(null);
7773 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7774 const cleanupFrame = useAnimationFrame();
7775 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
7776 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
7777 useIsoLayoutEffect(() => {
7778 store.set("hasViewport", true);
7779 return () => {
7780 store.set("hasViewport", false);
7781 };
7782 }, [store]);
7783 const handleMeasureLayout = useStableCallback(() => {
7784 currentContainerRef.current?.style.setProperty("animation", "none");
7785 currentContainerRef.current?.style.setProperty("transition", "none");
7786 previousContainerRef.current?.style.setProperty("display", "none");
7787 });
7788 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7789 currentContainerRef.current?.style.removeProperty("animation");
7790 currentContainerRef.current?.style.removeProperty("transition");
7791 previousContainerRef.current?.style.removeProperty("display");
7792 if (previousDimensions) {
7793 setPreviousContentDimensions(previousDimensions);
7794 }
7795 });
7796 const lastHandledTriggerRef = React33.useRef(null);
7797 useIsoLayoutEffect(() => {
7798 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7799 setPreviousContentNode(capturedNodeRef.current);
7800 setShowStartingStyleAttribute(true);
7801 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7802 setNewTriggerOffset(offset4);
7803 cleanupFrame.request(() => {
7804 ReactDOM5.flushSync(() => {
7805 setShowStartingStyleAttribute(false);
7806 });
7807 onAnimationsFinished(() => {
7808 setPreviousContentNode(null);
7809 setPreviousContentDimensions(null);
7810 capturedNodeRef.current = null;
7811 });
7812 });
7813 lastHandledTriggerRef.current = activeTrigger;
7814 }
7815 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7816 useIsoLayoutEffect(() => {
7817 const source = currentContainerRef.current;
7818 if (!source) {
7819 return;
7820 }
7821 const wrapper = ownerDocument(source).createElement("div");
7822 for (const child of Array.from(source.childNodes)) {
7823 wrapper.appendChild(child.cloneNode(true));
7824 }
7825 capturedNodeRef.current = wrapper;
7826 });
7827 const isTransitioning = previousContentNode != null;
7828 let childrenToRender;
7829 if (!isTransitioning) {
7830 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7831 "data-current": true,
7832 ref: currentContainerRef,
7833 children
7834 }, currentContentKey);
7835 } else {
7836 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
7837 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7838 "data-previous": true,
7839 inert: inertValue(true),
7840 ref: previousContainerRef,
7841 style: {
7842 ...previousContentDimensions ? {
7843 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
7844 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
7845 } : null,
7846 position: "absolute"
7847 },
7848 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
7849 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7850 "data-current": true,
7851 ref: currentContainerRef,
7852 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
7853 children
7854 }, currentContentKey)]
7855 });
7856 }
7857 useIsoLayoutEffect(() => {
7858 const container = previousContainerRef.current;
7859 if (!container || !previousContentNode) {
7860 return;
7861 }
7862 container.replaceChildren(...Array.from(previousContentNode.childNodes));
7863 }, [previousContentNode]);
7864 usePopupAutoResize({
7865 popupElement,
7866 positionerElement,
7867 mounted,
7868 content: payload,
7869 onMeasureLayout: handleMeasureLayout,
7870 onMeasureLayoutComplete: handleMeasureLayoutComplete,
7871 side,
7872 direction
7873 });
7874 const state = {
7875 activationDirection: getActivationDirection(newTriggerOffset),
7876 transitioning: isTransitioning
7877 };
7878 return {
7879 children: childrenToRender,
7880 state
7881 };
7882 }
7883 function getActivationDirection(offset4) {
7884 if (!offset4) {
7885 return void 0;
7886 }
7887 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
7888 }
7889 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
7890 if (value > tolerance) {
7891 return positiveLabel;
7892 }
7893 if (value < -tolerance) {
7894 return negativeLabel;
7895 }
7896 return "";
7897 }
7898 function calculateRelativePosition(from, to) {
7899 const fromRect = from.getBoundingClientRect();
7900 const toRect = to.getBoundingClientRect();
7901 const fromCenter = {
7902 x: fromRect.left + fromRect.width / 2,
7903 y: fromRect.top + fromRect.height / 2
7904 };
7905 const toCenter = {
7906 x: toRect.left + toRect.width / 2,
7907 y: toRect.top + toRect.height / 2
7908 };
7909 return {
7910 horizontal: toCenter.x - fromCenter.x,
7911 vertical: toCenter.y - fromCenter.y
7912 };
7913 }
7914 function usePopupContentKey(activeTriggerId, payload) {
7915 const [contentKey, setContentKey] = React33.useState(0);
7916 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
7917 const previousPayloadRef = React33.useRef(payload);
7918 const pendingPayloadUpdateRef = React33.useRef(false);
7919 useIsoLayoutEffect(() => {
7920 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
7921 const previousPayload = previousPayloadRef.current;
7922 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
7923 const payloadChanged = payload !== previousPayload;
7924 if (triggerIdChanged) {
7925 setContentKey((value) => value + 1);
7926 pendingPayloadUpdateRef.current = !payloadChanged;
7927 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
7928 setContentKey((value) => value + 1);
7929 pendingPayloadUpdateRef.current = false;
7930 }
7931 previousActiveTriggerIdRef.current = activeTriggerId;
7932 previousPayloadRef.current = payload;
7933 }, [activeTriggerId, payload]);
7934 return `${activeTriggerId ?? "current"}-${contentKey}`;
7935 }
7936
7937 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
7938 var React34 = __toESM(require_react(), 1);
7939 var ReactDOM6 = __toESM(require_react_dom(), 1);
7940 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
7941 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
7942 const {
7943 children,
7944 container,
7945 className,
7946 render: render4,
7947 style,
7948 ...elementProps
7949 } = componentProps;
7950 const {
7951 portalNode,
7952 portalSubtree
7953 } = useFloatingPortalNode({
7954 container,
7955 ref: forwardedRef,
7956 componentProps,
7957 elementProps
7958 });
7959 if (!portalSubtree && !portalNode) {
7960 return null;
7961 }
7962 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
7963 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
7964 });
7965 });
7966 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
7967
7968 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
7969 var index_parts_exports = {};
7970 __export(index_parts_exports, {
7971 Arrow: () => TooltipArrow,
7972 Handle: () => TooltipHandle,
7973 Popup: () => TooltipPopup,
7974 Portal: () => TooltipPortal,
7975 Positioner: () => TooltipPositioner,
7976 Provider: () => TooltipProvider,
7977 Root: () => TooltipRoot,
7978 Trigger: () => TooltipTrigger,
7979 Viewport: () => TooltipViewport,
7980 createHandle: () => createTooltipHandle
7981 });
7982
7983 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
7984 var React37 = __toESM(require_react(), 1);
7985
7986 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
7987 var React35 = __toESM(require_react(), 1);
7988 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
7989 if (true) TooltipRootContext.displayName = "TooltipRootContext";
7990 function useTooltipRootContext(optional) {
7991 const context = React35.useContext(TooltipRootContext);
7992 if (context === void 0 && !optional) {
7993 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
7994 }
7995 return context;
7996 }
7997
7998 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
7999 var React36 = __toESM(require_react(), 1);
8000 var ReactDOM7 = __toESM(require_react_dom(), 1);
8001 var selectors2 = {
8002 ...popupStoreSelectors,
8003 disabled: createSelector((state) => state.disabled),
8004 instantType: createSelector((state) => state.instantType),
8005 isInstantPhase: createSelector((state) => state.isInstantPhase),
8006 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8007 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8008 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8009 closeOnClick: createSelector((state) => state.closeOnClick),
8010 closeDelay: createSelector((state) => state.closeDelay),
8011 hasViewport: createSelector((state) => state.hasViewport)
8012 };
8013 var TooltipStore = class _TooltipStore extends ReactStore {
8014 constructor(initialState) {
8015 super({
8016 ...createInitialState(),
8017 ...initialState
8018 }, {
8019 popupRef: /* @__PURE__ */ React36.createRef(),
8020 onOpenChange: void 0,
8021 onOpenChangeComplete: void 0,
8022 triggerElements: new PopupTriggerMap()
8023 }, selectors2);
8024 }
8025 setOpen = (nextOpen, eventDetails) => {
8026 const reason = eventDetails.reason;
8027 const isHover = reason === reason_parts_exports.triggerHover;
8028 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8029 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8030 eventDetails.preventUnmountOnClose = () => {
8031 this.set("preventUnmountingOnClose", true);
8032 };
8033 this.context.onOpenChange?.(nextOpen, eventDetails);
8034 if (eventDetails.isCanceled) {
8035 return;
8036 }
8037 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8038 const changeState = () => {
8039 const updatedState = {
8040 open: nextOpen,
8041 openChangeReason: reason
8042 };
8043 if (isFocusOpen) {
8044 updatedState.instantType = "focus";
8045 } else if (isDismissClose) {
8046 updatedState.instantType = "dismiss";
8047 } else if (reason === reason_parts_exports.triggerHover) {
8048 updatedState.instantType = void 0;
8049 }
8050 const newTriggerId = eventDetails.trigger?.id ?? null;
8051 if (newTriggerId || nextOpen) {
8052 updatedState.activeTriggerId = newTriggerId;
8053 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8054 }
8055 this.update(updatedState);
8056 };
8057 if (isHover) {
8058 ReactDOM7.flushSync(changeState);
8059 } else {
8060 changeState();
8061 }
8062 };
8063 static useStore(externalStore, initialState) {
8064 const internalStore = useRefWithInit(() => {
8065 return new _TooltipStore(initialState);
8066 }).current;
8067 const store = externalStore ?? internalStore;
8068 const floatingRootContext = useSyncedFloatingRootContext({
8069 popupStore: store,
8070 onOpenChange: store.setOpen
8071 });
8072 store.state.floatingRootContext = floatingRootContext;
8073 return store;
8074 }
8075 };
8076 function createInitialState() {
8077 return {
8078 ...createInitialPopupStoreState(),
8079 disabled: false,
8080 instantType: void 0,
8081 isInstantPhase: false,
8082 trackCursorAxis: "none",
8083 disableHoverablePopup: false,
8084 openChangeReason: null,
8085 closeOnClick: true,
8086 closeDelay: 0,
8087 hasViewport: false
8088 };
8089 }
8090
8091 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8092 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8093 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8094 const {
8095 disabled: disabled2 = false,
8096 defaultOpen = false,
8097 open: openProp,
8098 disableHoverablePopup = false,
8099 trackCursorAxis = "none",
8100 actionsRef,
8101 onOpenChange,
8102 onOpenChangeComplete,
8103 handle,
8104 triggerId: triggerIdProp,
8105 defaultTriggerId: defaultTriggerIdProp = null,
8106 children
8107 } = props;
8108 const store = TooltipStore.useStore(handle?.store, {
8109 open: defaultOpen,
8110 openProp,
8111 activeTriggerId: defaultTriggerIdProp,
8112 triggerIdProp
8113 });
8114 useOnFirstRender(() => {
8115 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8116 store.update({
8117 open: true,
8118 activeTriggerId: defaultTriggerIdProp
8119 });
8120 }
8121 });
8122 store.useControlledProp("openProp", openProp);
8123 store.useControlledProp("triggerIdProp", triggerIdProp);
8124 store.useContextCallback("onOpenChange", onOpenChange);
8125 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8126 const openState = store.useState("open");
8127 const open = !disabled2 && openState;
8128 const activeTriggerId = store.useState("activeTriggerId");
8129 const payload = store.useState("payload");
8130 store.useSyncedValues({
8131 trackCursorAxis,
8132 disableHoverablePopup
8133 });
8134 useIsoLayoutEffect(() => {
8135 if (openState && disabled2) {
8136 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8137 }
8138 }, [openState, disabled2, store]);
8139 store.useSyncedValue("disabled", disabled2);
8140 useImplicitActiveTrigger(store);
8141 const {
8142 forceUnmount,
8143 transitionStatus
8144 } = useOpenStateTransitions(open, store);
8145 const floatingRootContext = store.select("floatingRootContext");
8146 const isInstantPhase = store.useState("isInstantPhase");
8147 const instantType = store.useState("instantType");
8148 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8149 const previousInstantTypeRef = React37.useRef(null);
8150 useIsoLayoutEffect(() => {
8151 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8152 if (instantType !== "delay") {
8153 previousInstantTypeRef.current = instantType;
8154 }
8155 store.set("instantType", "delay");
8156 } else if (previousInstantTypeRef.current !== null) {
8157 store.set("instantType", previousInstantTypeRef.current);
8158 previousInstantTypeRef.current = null;
8159 }
8160 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8161 useIsoLayoutEffect(() => {
8162 if (open) {
8163 if (activeTriggerId == null) {
8164 store.set("payload", void 0);
8165 }
8166 }
8167 }, [store, activeTriggerId, open]);
8168 const handleImperativeClose = React37.useCallback(() => {
8169 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8170 }, [store]);
8171 React37.useImperativeHandle(actionsRef, () => ({
8172 unmount: forceUnmount,
8173 close: handleImperativeClose
8174 }), [forceUnmount, handleImperativeClose]);
8175 const dismiss = useDismiss(floatingRootContext, {
8176 enabled: !disabled2,
8177 referencePress: () => store.select("closeOnClick")
8178 });
8179 const clientPoint = useClientPoint(floatingRootContext, {
8180 enabled: !disabled2 && trackCursorAxis !== "none",
8181 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8182 });
8183 const {
8184 getReferenceProps,
8185 getFloatingProps,
8186 getTriggerProps
8187 } = useInteractions([dismiss, clientPoint]);
8188 const activeTriggerProps = React37.useMemo(() => getReferenceProps(), [getReferenceProps]);
8189 const inactiveTriggerProps = React37.useMemo(() => getTriggerProps(), [getTriggerProps]);
8190 const popupProps = React37.useMemo(() => getFloatingProps(), [getFloatingProps]);
8191 store.useSyncedValues({
8192 activeTriggerProps,
8193 inactiveTriggerProps,
8194 popupProps
8195 });
8196 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipRootContext.Provider, {
8197 value: store,
8198 children: typeof children === "function" ? children({
8199 payload
8200 }) : children
8201 });
8202 });
8203 if (true) TooltipRoot.displayName = "TooltipRoot";
8204
8205 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8206 var React39 = __toESM(require_react(), 1);
8207
8208 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8209 var React38 = __toESM(require_react(), 1);
8210 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8211 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8212 function useTooltipProviderContext() {
8213 return React38.useContext(TooltipProviderContext);
8214 }
8215
8216 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8217 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8218 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8219 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8220 return TooltipTriggerDataAttributes2;
8221 })({});
8222
8223 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8224 var OPEN_DELAY = 600;
8225
8226 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8227 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8228 const {
8229 className,
8230 render: render4,
8231 handle,
8232 payload,
8233 disabled: disabledProp,
8234 delay,
8235 closeOnClick = true,
8236 closeDelay,
8237 id: idProp,
8238 style,
8239 ...elementProps
8240 } = componentProps;
8241 const rootContext = useTooltipRootContext(true);
8242 const store = handle?.store ?? rootContext;
8243 if (!store) {
8244 throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82));
8245 }
8246 const thisTriggerId = useBaseUiId(idProp);
8247 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8248 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8249 const floatingRootContext = store.useState("floatingRootContext");
8250 const triggerElementRef = React39.useRef(null);
8251 const delayWithDefault = delay ?? OPEN_DELAY;
8252 const closeDelayWithDefault = closeDelay ?? 0;
8253 const {
8254 registerTrigger,
8255 isMountedByThisTrigger
8256 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8257 payload,
8258 closeOnClick,
8259 closeDelay: closeDelayWithDefault
8260 });
8261 const providerContext = useTooltipProviderContext();
8262 const {
8263 delayRef,
8264 isInstantPhase,
8265 hasProvider
8266 } = useDelayGroup(floatingRootContext, {
8267 open: isOpenedByThisTrigger
8268 });
8269 store.useSyncedValue("isInstantPhase", isInstantPhase);
8270 const rootDisabled = store.useState("disabled");
8271 const disabled2 = disabledProp ?? rootDisabled;
8272 const trackCursorAxis = store.useState("trackCursorAxis");
8273 const disableHoverablePopup = store.useState("disableHoverablePopup");
8274 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8275 enabled: !disabled2,
8276 mouseOnly: true,
8277 move: false,
8278 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8279 restMs() {
8280 const providerDelay = providerContext?.delay;
8281 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8282 let computedRestMs = delayWithDefault;
8283 if (hasProvider) {
8284 if (groupOpenValue !== 0) {
8285 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
8286 } else {
8287 computedRestMs = 0;
8288 }
8289 }
8290 return computedRestMs;
8291 },
8292 delay() {
8293 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8294 let computedCloseDelay = closeDelayWithDefault;
8295 if (closeDelay == null && hasProvider) {
8296 computedCloseDelay = closeValue;
8297 }
8298 return {
8299 close: computedCloseDelay
8300 };
8301 },
8302 triggerElementRef,
8303 isActiveTrigger: isTriggerActive,
8304 isClosing: () => store.select("transitionStatus") === "ending"
8305 });
8306 const focusProps = useFocus(floatingRootContext, {
8307 enabled: !disabled2
8308 }).reference;
8309 const state = {
8310 open: isOpenedByThisTrigger
8311 };
8312 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8313 const element = useRenderElement("button", componentProps, {
8314 state,
8315 ref: [forwardedRef, registerTrigger, triggerElementRef],
8316 props: [hoverProps, focusProps, rootTriggerProps, {
8317 onPointerDown() {
8318 store.set("closeOnClick", closeOnClick);
8319 },
8320 id: thisTriggerId,
8321 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
8322 }, elementProps],
8323 stateAttributesMapping: triggerOpenStateMapping
8324 });
8325 return element;
8326 });
8327 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8328
8329 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8330 var React41 = __toESM(require_react(), 1);
8331
8332 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8333 var React40 = __toESM(require_react(), 1);
8334 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8335 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8336 function useTooltipPortalContext() {
8337 const value = React40.useContext(TooltipPortalContext);
8338 if (value === void 0) {
8339 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8340 }
8341 return value;
8342 }
8343
8344 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8345 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8346 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8347 const {
8348 keepMounted = false,
8349 ...portalProps
8350 } = props;
8351 const store = useTooltipRootContext();
8352 const mounted = store.useState("mounted");
8353 const shouldRender = mounted || keepMounted;
8354 if (!shouldRender) {
8355 return null;
8356 }
8357 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8358 value: keepMounted,
8359 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8360 ref: forwardedRef,
8361 ...portalProps
8362 })
8363 });
8364 });
8365 if (true) TooltipPortal.displayName = "TooltipPortal";
8366
8367 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8368 var React43 = __toESM(require_react(), 1);
8369
8370 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8371 var React42 = __toESM(require_react(), 1);
8372 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8373 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8374 function useTooltipPositionerContext() {
8375 const context = React42.useContext(TooltipPositionerContext);
8376 if (context === void 0) {
8377 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8378 }
8379 return context;
8380 }
8381
8382 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8383 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8384 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8385 const {
8386 render: render4,
8387 className,
8388 anchor,
8389 positionMethod = "absolute",
8390 side = "top",
8391 align = "center",
8392 sideOffset = 0,
8393 alignOffset = 0,
8394 collisionBoundary = "clipping-ancestors",
8395 collisionPadding = 5,
8396 arrowPadding = 5,
8397 sticky = false,
8398 disableAnchorTracking = false,
8399 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8400 style,
8401 ...elementProps
8402 } = componentProps;
8403 const store = useTooltipRootContext();
8404 const keepMounted = useTooltipPortalContext();
8405 const open = store.useState("open");
8406 const mounted = store.useState("mounted");
8407 const trackCursorAxis = store.useState("trackCursorAxis");
8408 const disableHoverablePopup = store.useState("disableHoverablePopup");
8409 const floatingRootContext = store.useState("floatingRootContext");
8410 const instantType = store.useState("instantType");
8411 const transitionStatus = store.useState("transitionStatus");
8412 const hasViewport = store.useState("hasViewport");
8413 const positioning = useAnchorPositioning({
8414 anchor,
8415 positionMethod,
8416 floatingRootContext,
8417 mounted,
8418 side,
8419 sideOffset,
8420 align,
8421 alignOffset,
8422 collisionBoundary,
8423 collisionPadding,
8424 sticky,
8425 arrowPadding,
8426 disableAnchorTracking,
8427 keepMounted,
8428 collisionAvoidance,
8429 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8430 });
8431 const state = React43.useMemo(() => ({
8432 open,
8433 side: positioning.side,
8434 align: positioning.align,
8435 anchorHidden: positioning.anchorHidden,
8436 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8437 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8438 const element = usePositioner(componentProps, state, {
8439 styles: positioning.positionerStyles,
8440 transitionStatus,
8441 props: elementProps,
8442 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8443 hidden: !mounted,
8444 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8445 });
8446 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8447 value: positioning,
8448 children: element
8449 });
8450 });
8451 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8452
8453 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8454 var React44 = __toESM(require_react(), 1);
8455 var stateAttributesMapping = {
8456 ...popupStateMapping,
8457 ...transitionStatusMapping
8458 };
8459 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8460 const {
8461 className,
8462 render: render4,
8463 style,
8464 ...elementProps
8465 } = componentProps;
8466 const store = useTooltipRootContext();
8467 const {
8468 side,
8469 align
8470 } = useTooltipPositionerContext();
8471 const open = store.useState("open");
8472 const instantType = store.useState("instantType");
8473 const transitionStatus = store.useState("transitionStatus");
8474 const popupProps = store.useState("popupProps");
8475 const floatingContext = store.useState("floatingRootContext");
8476 useOpenChangeComplete({
8477 open,
8478 ref: store.context.popupRef,
8479 onComplete() {
8480 if (open) {
8481 store.context.onOpenChangeComplete?.(true);
8482 }
8483 }
8484 });
8485 const disabled2 = store.useState("disabled");
8486 const closeDelay = store.useState("closeDelay");
8487 useHoverFloatingInteraction(floatingContext, {
8488 enabled: !disabled2,
8489 closeDelay
8490 });
8491 const state = {
8492 open,
8493 side,
8494 align,
8495 instant: instantType,
8496 transitionStatus
8497 };
8498 const element = useRenderElement("div", componentProps, {
8499 state,
8500 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
8501 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8502 stateAttributesMapping
8503 });
8504 return element;
8505 });
8506 if (true) TooltipPopup.displayName = "TooltipPopup";
8507
8508 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8509 var React45 = __toESM(require_react(), 1);
8510 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8511 const {
8512 className,
8513 render: render4,
8514 style,
8515 ...elementProps
8516 } = componentProps;
8517 const store = useTooltipRootContext();
8518 const open = store.useState("open");
8519 const instantType = store.useState("instantType");
8520 const {
8521 arrowRef,
8522 side,
8523 align,
8524 arrowUncentered,
8525 arrowStyles
8526 } = useTooltipPositionerContext();
8527 const state = {
8528 open,
8529 side,
8530 align,
8531 uncentered: arrowUncentered,
8532 instant: instantType
8533 };
8534 const element = useRenderElement("div", componentProps, {
8535 state,
8536 ref: [forwardedRef, arrowRef],
8537 props: [{
8538 style: arrowStyles,
8539 "aria-hidden": true
8540 }, elementProps],
8541 stateAttributesMapping: popupStateMapping
8542 });
8543 return element;
8544 });
8545 if (true) TooltipArrow.displayName = "TooltipArrow";
8546
8547 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8548 var React46 = __toESM(require_react(), 1);
8549 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8550 var TooltipProvider = function TooltipProvider2(props) {
8551 const {
8552 delay,
8553 closeDelay,
8554 timeout = 400
8555 } = props;
8556 const contextValue = React46.useMemo(() => ({
8557 delay,
8558 closeDelay
8559 }), [delay, closeDelay]);
8560 const delayValue = React46.useMemo(() => ({
8561 open: delay,
8562 close: closeDelay
8563 }), [delay, closeDelay]);
8564 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8565 value: contextValue,
8566 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8567 delay: delayValue,
8568 timeoutMs: timeout,
8569 children: props.children
8570 })
8571 });
8572 };
8573 if (true) TooltipProvider.displayName = "TooltipProvider";
8574
8575 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8576 var React47 = __toESM(require_react(), 1);
8577
8578 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8579 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8580 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8581 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8582 return TooltipViewportCssVars2;
8583 })({});
8584
8585 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8586 var stateAttributesMapping2 = {
8587 activationDirection: (value) => value ? {
8588 "data-activation-direction": value
8589 } : null
8590 };
8591 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8592 const {
8593 render: render4,
8594 className,
8595 style,
8596 children,
8597 ...elementProps
8598 } = componentProps;
8599 const store = useTooltipRootContext();
8600 const positioner = useTooltipPositionerContext();
8601 const instantType = store.useState("instantType");
8602 const {
8603 children: childrenToRender,
8604 state: viewportState
8605 } = usePopupViewport({
8606 store,
8607 side: positioner.side,
8608 cssVars: TooltipViewportCssVars,
8609 children
8610 });
8611 const state = {
8612 activationDirection: viewportState.activationDirection,
8613 transitioning: viewportState.transitioning,
8614 instant: instantType
8615 };
8616 return useRenderElement("div", componentProps, {
8617 state,
8618 ref: forwardedRef,
8619 props: [elementProps, {
8620 children: childrenToRender
8621 }],
8622 stateAttributesMapping: stateAttributesMapping2
8623 });
8624 });
8625 if (true) TooltipViewport.displayName = "TooltipViewport";
8626
8627 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8628 var TooltipHandle = class {
8629 /**
8630 * Internal store holding the tooltip state.
8631 * @internal
8632 */
8633 constructor() {
8634 this.store = new TooltipStore();
8635 }
8636 /**
8637 * Opens the tooltip and associates it with the trigger with the given ID.
8638 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8639 *
8640 * This method should only be called in an event handler or an effect (not during rendering).
8641 *
8642 * @param triggerId ID of the trigger to associate with the tooltip.
8643 */
8644 open(triggerId) {
8645 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8646 if (triggerId && !triggerElement) {
8647 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8648 }
8649 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8650 }
8651 /**
8652 * Closes the tooltip.
8653 */
8654 close() {
8655 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8656 }
8657 /**
8658 * Indicates whether the tooltip is currently open.
8659 */
8660 get isOpen() {
8661 return this.store.state.open;
8662 }
8663 };
8664 function createTooltipHandle() {
8665 return new TooltipHandle();
8666 }
8667
8668 // node_modules/@base-ui/react/esm/use-render/useRender.js
8669 function useRender(params) {
8670 return useRenderElement(params.defaultTagName ?? "div", params, params);
8671 }
8672
8673 // packages/ui/build-module/text/text.mjs
8674 var import_element8 = __toESM(require_element(), 1);
8675 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8676 function getRuntime() {
8677 const globalScope = globalThis;
8678 if (globalScope.__wpStyleRuntime) {
8679 return globalScope.__wpStyleRuntime;
8680 }
8681 globalScope.__wpStyleRuntime = {
8682 documents: /* @__PURE__ */ new Map(),
8683 styles: /* @__PURE__ */ new Map(),
8684 injectedStyles: /* @__PURE__ */ new WeakMap()
8685 };
8686 if (typeof document !== "undefined") {
8687 registerDocument(document);
8688 }
8689 return globalScope.__wpStyleRuntime;
8690 }
8691 function documentContainsStyleHash(targetDocument, hash) {
8692 if (!targetDocument.head) {
8693 return false;
8694 }
8695 for (const style of targetDocument.head.querySelectorAll(
8696 `style[${STYLE_HASH_ATTRIBUTE}]`
8697 )) {
8698 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8699 return true;
8700 }
8701 }
8702 return false;
8703 }
8704 function injectStyle(targetDocument, hash, css) {
8705 if (!targetDocument.head) {
8706 return;
8707 }
8708 const runtime = getRuntime();
8709 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8710 if (!injectedStyles) {
8711 injectedStyles = /* @__PURE__ */ new Set();
8712 runtime.injectedStyles.set(targetDocument, injectedStyles);
8713 }
8714 if (injectedStyles.has(hash)) {
8715 return;
8716 }
8717 if (documentContainsStyleHash(targetDocument, hash)) {
8718 injectedStyles.add(hash);
8719 return;
8720 }
8721 const style = targetDocument.createElement("style");
8722 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8723 style.appendChild(targetDocument.createTextNode(css));
8724 targetDocument.head.appendChild(style);
8725 injectedStyles.add(hash);
8726 }
8727 function registerDocument(targetDocument) {
8728 const runtime = getRuntime();
8729 runtime.documents.set(
8730 targetDocument,
8731 (runtime.documents.get(targetDocument) ?? 0) + 1
8732 );
8733 for (const [hash, css] of runtime.styles) {
8734 injectStyle(targetDocument, hash, css);
8735 }
8736 return () => {
8737 const count = runtime.documents.get(targetDocument);
8738 if (count === void 0) {
8739 return;
8740 }
8741 if (count <= 1) {
8742 runtime.documents.delete(targetDocument);
8743 return;
8744 }
8745 runtime.documents.set(targetDocument, count - 1);
8746 };
8747 }
8748 function registerStyle(hash, css) {
8749 const runtime = getRuntime();
8750 runtime.styles.set(hash, css);
8751 for (const targetDocument of runtime.documents.keys()) {
8752 injectStyle(targetDocument, hash, css);
8753 }
8754 }
8755 if (typeof process === "undefined" || true) {
8756 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)}}');
8757 }
8758 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" };
8759 if (typeof process === "undefined" || true) {
8760 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)}");
8761 }
8762 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" };
8763 var Text = (0, import_element8.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
8764 const element = useRender({
8765 render: render4,
8766 defaultTagName: "span",
8767 ref,
8768 props: mergeProps(props, {
8769 className: clsx_default(
8770 style_default.text,
8771 global_css_defense_default.heading,
8772 global_css_defense_default.p,
8773 style_default[variant],
8774 className
8775 )
8776 })
8777 });
8778 return element;
8779 });
8780
8781 // packages/ui/build-module/icon/icon.mjs
8782 var import_element9 = __toESM(require_element(), 1);
8783 var import_primitives = __toESM(require_primitives(), 1);
8784 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
8785 var Icon = (0, import_element9.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
8786 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
8787 import_primitives.SVG,
8788 {
8789 ref,
8790 fill: "currentColor",
8791 ...icon.props,
8792 ...restProps,
8793 width: size4,
8794 height: size4
8795 }
8796 );
8797 });
8798
8799 // packages/icons/build-module/library/arrow-down.mjs
8800 var import_primitives2 = __toESM(require_primitives(), 1);
8801 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
8802 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.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" }) });
8803
8804 // packages/icons/build-module/library/arrow-left.mjs
8805 var import_primitives3 = __toESM(require_primitives(), 1);
8806 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
8807 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.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" }) });
8808
8809 // packages/icons/build-module/library/arrow-right.mjs
8810 var import_primitives4 = __toESM(require_primitives(), 1);
8811 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
8812 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.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" }) });
8813
8814 // packages/icons/build-module/library/arrow-up.mjs
8815 var import_primitives5 = __toESM(require_primitives(), 1);
8816 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
8817 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
8818
8819 // packages/icons/build-module/library/block-table.mjs
8820 var import_primitives6 = __toESM(require_primitives(), 1);
8821 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
8822 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
8823
8824 // packages/icons/build-module/library/category.mjs
8825 var import_primitives7 = __toESM(require_primitives(), 1);
8826 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
8827 var category_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
8828
8829 // packages/icons/build-module/library/check.mjs
8830 var import_primitives8 = __toESM(require_primitives(), 1);
8831 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
8832 var check_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
8833
8834 // packages/icons/build-module/library/close-small.mjs
8835 var import_primitives9 = __toESM(require_primitives(), 1);
8836 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
8837 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
8838
8839 // packages/icons/build-module/library/cog.mjs
8840 var import_primitives10 = __toESM(require_primitives(), 1);
8841 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
8842 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
8843
8844 // packages/icons/build-module/library/envelope.mjs
8845 var import_primitives11 = __toESM(require_primitives(), 1);
8846 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
8847 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.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" }) });
8848
8849 // packages/icons/build-module/library/error.mjs
8850 var import_primitives12 = __toESM(require_primitives(), 1);
8851 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
8852 var error_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.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" }) });
8853
8854 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
8855 var import_primitives13 = __toESM(require_primitives(), 1);
8856 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
8857 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.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" }) });
8858
8859 // packages/icons/build-module/library/format-list-bullets.mjs
8860 var import_primitives14 = __toESM(require_primitives(), 1);
8861 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
8862 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.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" }) });
8863
8864 // packages/icons/build-module/library/funnel.mjs
8865 var import_primitives15 = __toESM(require_primitives(), 1);
8866 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
8867 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
8868
8869 // packages/icons/build-module/library/globe.mjs
8870 var import_primitives16 = __toESM(require_primitives(), 1);
8871 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
8872 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z" }) });
8873
8874 // packages/icons/build-module/library/link.mjs
8875 var import_primitives17 = __toESM(require_primitives(), 1);
8876 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
8877 var link_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.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" }) });
8878
8879 // packages/icons/build-module/library/mobile.mjs
8880 var import_primitives18 = __toESM(require_primitives(), 1);
8881 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
8882 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.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" }) });
8883
8884 // packages/icons/build-module/library/more-vertical.mjs
8885 var import_primitives19 = __toESM(require_primitives(), 1);
8886 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
8887 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
8888
8889 // packages/icons/build-module/library/next.mjs
8890 var import_primitives20 = __toESM(require_primitives(), 1);
8891 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
8892 var next_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.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" }) });
8893
8894 // packages/icons/build-module/library/post-list.mjs
8895 var import_primitives21 = __toESM(require_primitives(), 1);
8896 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
8897 var post_list_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.Path, { d: "M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z" }) });
8898
8899 // packages/icons/build-module/library/previous.mjs
8900 var import_primitives22 = __toESM(require_primitives(), 1);
8901 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
8902 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.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" }) });
8903
8904 // packages/icons/build-module/library/scheduled.mjs
8905 var import_primitives23 = __toESM(require_primitives(), 1);
8906 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
8907 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.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" }) });
8908
8909 // packages/icons/build-module/library/search.mjs
8910 var import_primitives24 = __toESM(require_primitives(), 1);
8911 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
8912 var search_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives24.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" }) });
8913
8914 // packages/icons/build-module/library/seen.mjs
8915 var import_primitives25 = __toESM(require_primitives(), 1);
8916 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8917 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives25.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" }) });
8918
8919 // packages/icons/build-module/library/unseen.mjs
8920 var import_primitives26 = __toESM(require_primitives(), 1);
8921 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
8922 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives26.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" }) });
8923
8924 // packages/icons/build-module/library/wordpress.mjs
8925 var import_primitives27 = __toESM(require_primitives(), 1);
8926 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
8927 var wordpress_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -2 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives27.Path, { d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" }) });
8928
8929 // packages/ui/build-module/utils/render-slot-with-children.mjs
8930 var import_element10 = __toESM(require_element(), 1);
8931 function renderSlotWithChildren(slot, defaultSlot, children) {
8932 return (0, import_element10.cloneElement)(
8933 slot ?? defaultSlot,
8934 { children }
8935 );
8936 }
8937
8938 // packages/ui/build-module/lock-unlock.mjs
8939 var import_private_apis = __toESM(require_private_apis(), 1);
8940 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
8941 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
8942 "@wordpress/ui"
8943 );
8944
8945 // packages/ui/build-module/stack/stack.mjs
8946 var import_element11 = __toESM(require_element(), 1);
8947 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
8948 function getRuntime2() {
8949 const globalScope = globalThis;
8950 if (globalScope.__wpStyleRuntime) {
8951 return globalScope.__wpStyleRuntime;
8952 }
8953 globalScope.__wpStyleRuntime = {
8954 documents: /* @__PURE__ */ new Map(),
8955 styles: /* @__PURE__ */ new Map(),
8956 injectedStyles: /* @__PURE__ */ new WeakMap()
8957 };
8958 if (typeof document !== "undefined") {
8959 registerDocument2(document);
8960 }
8961 return globalScope.__wpStyleRuntime;
8962 }
8963 function documentContainsStyleHash2(targetDocument, hash) {
8964 if (!targetDocument.head) {
8965 return false;
8966 }
8967 for (const style of targetDocument.head.querySelectorAll(
8968 `style[${STYLE_HASH_ATTRIBUTE2}]`
8969 )) {
8970 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
8971 return true;
8972 }
8973 }
8974 return false;
8975 }
8976 function injectStyle2(targetDocument, hash, css) {
8977 if (!targetDocument.head) {
8978 return;
8979 }
8980 const runtime = getRuntime2();
8981 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8982 if (!injectedStyles) {
8983 injectedStyles = /* @__PURE__ */ new Set();
8984 runtime.injectedStyles.set(targetDocument, injectedStyles);
8985 }
8986 if (injectedStyles.has(hash)) {
8987 return;
8988 }
8989 if (documentContainsStyleHash2(targetDocument, hash)) {
8990 injectedStyles.add(hash);
8991 return;
8992 }
8993 const style = targetDocument.createElement("style");
8994 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
8995 style.appendChild(targetDocument.createTextNode(css));
8996 targetDocument.head.appendChild(style);
8997 injectedStyles.add(hash);
8998 }
8999 function registerDocument2(targetDocument) {
9000 const runtime = getRuntime2();
9001 runtime.documents.set(
9002 targetDocument,
9003 (runtime.documents.get(targetDocument) ?? 0) + 1
9004 );
9005 for (const [hash, css] of runtime.styles) {
9006 injectStyle2(targetDocument, hash, css);
9007 }
9008 return () => {
9009 const count = runtime.documents.get(targetDocument);
9010 if (count === void 0) {
9011 return;
9012 }
9013 if (count <= 1) {
9014 runtime.documents.delete(targetDocument);
9015 return;
9016 }
9017 runtime.documents.set(targetDocument, count - 1);
9018 };
9019 }
9020 function registerStyle2(hash, css) {
9021 const runtime = getRuntime2();
9022 runtime.styles.set(hash, css);
9023 for (const targetDocument of runtime.documents.keys()) {
9024 injectStyle2(targetDocument, hash, css);
9025 }
9026 }
9027 if (typeof process === "undefined" || true) {
9028 registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
9029 }
9030 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9031 var gapTokens = {
9032 xs: "var(--wpds-dimension-gap-xs, 4px)",
9033 sm: "var(--wpds-dimension-gap-sm, 8px)",
9034 md: "var(--wpds-dimension-gap-md, 12px)",
9035 lg: "var(--wpds-dimension-gap-lg, 16px)",
9036 xl: "var(--wpds-dimension-gap-xl, 24px)",
9037 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9038 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9039 };
9040 var Stack = (0, import_element11.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9041 const style = {
9042 gap: gap && gapTokens[gap],
9043 alignItems: align,
9044 justifyContent: justify,
9045 flexDirection: direction,
9046 flexWrap: wrap
9047 };
9048 const element = useRender({
9049 render: render4,
9050 ref,
9051 props: mergeProps(props, { style, className: style_default2.stack })
9052 });
9053 return element;
9054 });
9055
9056 // packages/ui/build-module/tooltip/index.mjs
9057 var tooltip_exports = {};
9058 __export(tooltip_exports, {
9059 Popup: () => Popup,
9060 Portal: () => Portal,
9061 Positioner: () => Positioner,
9062 Provider: () => Provider,
9063 Root: () => Root,
9064 Trigger: () => Trigger
9065 });
9066
9067 // packages/ui/build-module/tooltip/popup.mjs
9068 var import_element14 = __toESM(require_element(), 1);
9069 var import_theme = __toESM(require_theme(), 1);
9070
9071 // packages/ui/build-module/tooltip/portal.mjs
9072 var import_element12 = __toESM(require_element(), 1);
9073
9074 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9075 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9076 function getRuntime3() {
9077 const globalScope = globalThis;
9078 if (globalScope.__wpStyleRuntime) {
9079 return globalScope.__wpStyleRuntime;
9080 }
9081 globalScope.__wpStyleRuntime = {
9082 documents: /* @__PURE__ */ new Map(),
9083 styles: /* @__PURE__ */ new Map(),
9084 injectedStyles: /* @__PURE__ */ new WeakMap()
9085 };
9086 if (typeof document !== "undefined") {
9087 registerDocument3(document);
9088 }
9089 return globalScope.__wpStyleRuntime;
9090 }
9091 function documentContainsStyleHash3(targetDocument, hash) {
9092 if (!targetDocument.head) {
9093 return false;
9094 }
9095 for (const style of targetDocument.head.querySelectorAll(
9096 `style[${STYLE_HASH_ATTRIBUTE3}]`
9097 )) {
9098 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9099 return true;
9100 }
9101 }
9102 return false;
9103 }
9104 function injectStyle3(targetDocument, hash, css) {
9105 if (!targetDocument.head) {
9106 return;
9107 }
9108 const runtime = getRuntime3();
9109 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9110 if (!injectedStyles) {
9111 injectedStyles = /* @__PURE__ */ new Set();
9112 runtime.injectedStyles.set(targetDocument, injectedStyles);
9113 }
9114 if (injectedStyles.has(hash)) {
9115 return;
9116 }
9117 if (documentContainsStyleHash3(targetDocument, hash)) {
9118 injectedStyles.add(hash);
9119 return;
9120 }
9121 const style = targetDocument.createElement("style");
9122 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9123 style.appendChild(targetDocument.createTextNode(css));
9124 targetDocument.head.appendChild(style);
9125 injectedStyles.add(hash);
9126 }
9127 function registerDocument3(targetDocument) {
9128 const runtime = getRuntime3();
9129 runtime.documents.set(
9130 targetDocument,
9131 (runtime.documents.get(targetDocument) ?? 0) + 1
9132 );
9133 for (const [hash, css] of runtime.styles) {
9134 injectStyle3(targetDocument, hash, css);
9135 }
9136 return () => {
9137 const count = runtime.documents.get(targetDocument);
9138 if (count === void 0) {
9139 return;
9140 }
9141 if (count <= 1) {
9142 runtime.documents.delete(targetDocument);
9143 return;
9144 }
9145 runtime.documents.set(targetDocument, count - 1);
9146 };
9147 }
9148 function registerStyle3(hash, css) {
9149 const runtime = getRuntime3();
9150 runtime.styles.set(hash, css);
9151 for (const targetDocument of runtime.documents.keys()) {
9152 injectStyle3(targetDocument, hash, css);
9153 }
9154 }
9155 if (typeof process === "undefined" || true) {
9156 registerStyle3("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}");
9157 }
9158 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9159 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9160 function resolveOwnerDocument() {
9161 return typeof document === "undefined" ? null : document;
9162 }
9163 function isInWordPressEnvironment() {
9164 let topWp;
9165 try {
9166 topWp = window.top?.wp;
9167 } catch {
9168 }
9169 const wp = topWp ?? window.wp;
9170 return typeof wp?.components === "object" && wp.components !== null;
9171 }
9172 var cachedSlot = null;
9173 function createSlot(ownerDocument2) {
9174 const element = ownerDocument2.createElement("div");
9175 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9176 if (wp_compat_overlay_slot_default.slot) {
9177 element.classList.add(wp_compat_overlay_slot_default.slot);
9178 }
9179 ownerDocument2.body.appendChild(element);
9180 return element;
9181 }
9182 function getWpCompatOverlaySlot() {
9183 if (typeof window === "undefined") {
9184 return void 0;
9185 }
9186 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9187 return void 0;
9188 }
9189 const ownerDocument2 = resolveOwnerDocument();
9190 if (!ownerDocument2 || !ownerDocument2.body) {
9191 return void 0;
9192 }
9193 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9194 return cachedSlot;
9195 }
9196 const existing = ownerDocument2.querySelector(
9197 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9198 );
9199 if (existing instanceof HTMLDivElement) {
9200 cachedSlot = existing;
9201 return existing;
9202 }
9203 if (cachedSlot?.isConnected) {
9204 cachedSlot.remove();
9205 }
9206 cachedSlot = createSlot(ownerDocument2);
9207 return cachedSlot;
9208 }
9209
9210 // packages/ui/build-module/tooltip/portal.mjs
9211 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9212 var Portal = (0, import_element12.forwardRef)(
9213 function TooltipPortal3({ container, ...restProps }, ref) {
9214 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9215 index_parts_exports.Portal,
9216 {
9217 container: container ?? getWpCompatOverlaySlot(),
9218 ...restProps,
9219 ref
9220 }
9221 );
9222 }
9223 );
9224
9225 // packages/ui/build-module/tooltip/positioner.mjs
9226 var import_element13 = __toESM(require_element(), 1);
9227 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9228 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9229 function getRuntime4() {
9230 const globalScope = globalThis;
9231 if (globalScope.__wpStyleRuntime) {
9232 return globalScope.__wpStyleRuntime;
9233 }
9234 globalScope.__wpStyleRuntime = {
9235 documents: /* @__PURE__ */ new Map(),
9236 styles: /* @__PURE__ */ new Map(),
9237 injectedStyles: /* @__PURE__ */ new WeakMap()
9238 };
9239 if (typeof document !== "undefined") {
9240 registerDocument4(document);
9241 }
9242 return globalScope.__wpStyleRuntime;
9243 }
9244 function documentContainsStyleHash4(targetDocument, hash) {
9245 if (!targetDocument.head) {
9246 return false;
9247 }
9248 for (const style of targetDocument.head.querySelectorAll(
9249 `style[${STYLE_HASH_ATTRIBUTE4}]`
9250 )) {
9251 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9252 return true;
9253 }
9254 }
9255 return false;
9256 }
9257 function injectStyle4(targetDocument, hash, css) {
9258 if (!targetDocument.head) {
9259 return;
9260 }
9261 const runtime = getRuntime4();
9262 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9263 if (!injectedStyles) {
9264 injectedStyles = /* @__PURE__ */ new Set();
9265 runtime.injectedStyles.set(targetDocument, injectedStyles);
9266 }
9267 if (injectedStyles.has(hash)) {
9268 return;
9269 }
9270 if (documentContainsStyleHash4(targetDocument, hash)) {
9271 injectedStyles.add(hash);
9272 return;
9273 }
9274 const style = targetDocument.createElement("style");
9275 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9276 style.appendChild(targetDocument.createTextNode(css));
9277 targetDocument.head.appendChild(style);
9278 injectedStyles.add(hash);
9279 }
9280 function registerDocument4(targetDocument) {
9281 const runtime = getRuntime4();
9282 runtime.documents.set(
9283 targetDocument,
9284 (runtime.documents.get(targetDocument) ?? 0) + 1
9285 );
9286 for (const [hash, css] of runtime.styles) {
9287 injectStyle4(targetDocument, hash, css);
9288 }
9289 return () => {
9290 const count = runtime.documents.get(targetDocument);
9291 if (count === void 0) {
9292 return;
9293 }
9294 if (count <= 1) {
9295 runtime.documents.delete(targetDocument);
9296 return;
9297 }
9298 runtime.documents.set(targetDocument, count - 1);
9299 };
9300 }
9301 function registerStyle4(hash, css) {
9302 const runtime = getRuntime4();
9303 runtime.styles.set(hash, css);
9304 for (const targetDocument of runtime.documents.keys()) {
9305 injectStyle4(targetDocument, hash, css);
9306 }
9307 }
9308 if (typeof process === "undefined" || true) {
9309 registerStyle4("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}}}");
9310 }
9311 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9312 if (typeof process === "undefined" || true) {
9313 registerStyle4("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9314 }
9315 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9316 var Positioner = (0, import_element13.forwardRef)(
9317 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9318 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9319 index_parts_exports.Positioner,
9320 {
9321 ref,
9322 align,
9323 side,
9324 sideOffset,
9325 ...props,
9326 className: clsx_default(
9327 resets_default["box-sizing"],
9328 style_default3.positioner,
9329 className
9330 )
9331 }
9332 );
9333 }
9334 );
9335
9336 // packages/ui/build-module/tooltip/popup.mjs
9337 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9338 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9339 function getRuntime5() {
9340 const globalScope = globalThis;
9341 if (globalScope.__wpStyleRuntime) {
9342 return globalScope.__wpStyleRuntime;
9343 }
9344 globalScope.__wpStyleRuntime = {
9345 documents: /* @__PURE__ */ new Map(),
9346 styles: /* @__PURE__ */ new Map(),
9347 injectedStyles: /* @__PURE__ */ new WeakMap()
9348 };
9349 if (typeof document !== "undefined") {
9350 registerDocument5(document);
9351 }
9352 return globalScope.__wpStyleRuntime;
9353 }
9354 function documentContainsStyleHash5(targetDocument, hash) {
9355 if (!targetDocument.head) {
9356 return false;
9357 }
9358 for (const style of targetDocument.head.querySelectorAll(
9359 `style[${STYLE_HASH_ATTRIBUTE5}]`
9360 )) {
9361 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9362 return true;
9363 }
9364 }
9365 return false;
9366 }
9367 function injectStyle5(targetDocument, hash, css) {
9368 if (!targetDocument.head) {
9369 return;
9370 }
9371 const runtime = getRuntime5();
9372 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9373 if (!injectedStyles) {
9374 injectedStyles = /* @__PURE__ */ new Set();
9375 runtime.injectedStyles.set(targetDocument, injectedStyles);
9376 }
9377 if (injectedStyles.has(hash)) {
9378 return;
9379 }
9380 if (documentContainsStyleHash5(targetDocument, hash)) {
9381 injectedStyles.add(hash);
9382 return;
9383 }
9384 const style = targetDocument.createElement("style");
9385 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9386 style.appendChild(targetDocument.createTextNode(css));
9387 targetDocument.head.appendChild(style);
9388 injectedStyles.add(hash);
9389 }
9390 function registerDocument5(targetDocument) {
9391 const runtime = getRuntime5();
9392 runtime.documents.set(
9393 targetDocument,
9394 (runtime.documents.get(targetDocument) ?? 0) + 1
9395 );
9396 for (const [hash, css] of runtime.styles) {
9397 injectStyle5(targetDocument, hash, css);
9398 }
9399 return () => {
9400 const count = runtime.documents.get(targetDocument);
9401 if (count === void 0) {
9402 return;
9403 }
9404 if (count <= 1) {
9405 runtime.documents.delete(targetDocument);
9406 return;
9407 }
9408 runtime.documents.set(targetDocument, count - 1);
9409 };
9410 }
9411 function registerStyle5(hash, css) {
9412 const runtime = getRuntime5();
9413 runtime.styles.set(hash, css);
9414 for (const targetDocument of runtime.documents.keys()) {
9415 injectStyle5(targetDocument, hash, css);
9416 }
9417 }
9418 if (typeof process === "undefined" || true) {
9419 registerStyle5("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9420 }
9421 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9422 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
9423 var Popup = (0, import_element14.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9424 const popupContent = (
9425 /* This should ideally use whatever dark color makes sense,
9426 * and not be hardcoded to #1e1e1e. The solutions would be to:
9427 * - review the design of the tooltip, in case we want to stop
9428 * hardcoding it to a dark background
9429 * - create new semantic tokens as needed (aliasing either the
9430 * "inverted bg" or "perma-dark bg" private tokens) and have
9431 * Tooltip.Popup use them;
9432 * - remove the hardcoded `bg` setting from the `ThemeProvider`
9433 * below
9434 */
9435 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
9436 index_parts_exports.Popup,
9437 {
9438 ref,
9439 className: clsx_default(style_default4.popup, className),
9440 ...props,
9441 children
9442 }
9443 ) })
9444 );
9445 const positionedPopup = renderSlotWithChildren(
9446 positioner,
9447 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Positioner, {}),
9448 popupContent
9449 );
9450 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Portal, {}), positionedPopup);
9451 });
9452
9453 // packages/ui/build-module/tooltip/trigger.mjs
9454 var import_element15 = __toESM(require_element(), 1);
9455 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9456 var Trigger = (0, import_element15.forwardRef)(
9457 function TooltipTrigger3(props, ref) {
9458 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Trigger, { ref, ...props });
9459 }
9460 );
9461
9462 // packages/ui/build-module/tooltip/root.mjs
9463 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9464 function Root(props) {
9465 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Root, { ...props });
9466 }
9467
9468 // packages/ui/build-module/tooltip/provider.mjs
9469 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9470 function Provider({ ...props }) {
9471 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(index_parts_exports.Provider, { ...props });
9472 }
9473
9474 // packages/ui/build-module/empty-state/index.mjs
9475 var empty_state_exports = {};
9476 __export(empty_state_exports, {
9477 Actions: () => Actions,
9478 Description: () => Description,
9479 Icon: () => Icon3,
9480 Root: () => Root2,
9481 Title: () => Title,
9482 Visual: () => Visual
9483 });
9484
9485 // packages/ui/build-module/empty-state/root.mjs
9486 var import_element16 = __toESM(require_element(), 1);
9487 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9488 function getRuntime6() {
9489 const globalScope = globalThis;
9490 if (globalScope.__wpStyleRuntime) {
9491 return globalScope.__wpStyleRuntime;
9492 }
9493 globalScope.__wpStyleRuntime = {
9494 documents: /* @__PURE__ */ new Map(),
9495 styles: /* @__PURE__ */ new Map(),
9496 injectedStyles: /* @__PURE__ */ new WeakMap()
9497 };
9498 if (typeof document !== "undefined") {
9499 registerDocument6(document);
9500 }
9501 return globalScope.__wpStyleRuntime;
9502 }
9503 function documentContainsStyleHash6(targetDocument, hash) {
9504 if (!targetDocument.head) {
9505 return false;
9506 }
9507 for (const style of targetDocument.head.querySelectorAll(
9508 `style[${STYLE_HASH_ATTRIBUTE6}]`
9509 )) {
9510 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9511 return true;
9512 }
9513 }
9514 return false;
9515 }
9516 function injectStyle6(targetDocument, hash, css) {
9517 if (!targetDocument.head) {
9518 return;
9519 }
9520 const runtime = getRuntime6();
9521 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9522 if (!injectedStyles) {
9523 injectedStyles = /* @__PURE__ */ new Set();
9524 runtime.injectedStyles.set(targetDocument, injectedStyles);
9525 }
9526 if (injectedStyles.has(hash)) {
9527 return;
9528 }
9529 if (documentContainsStyleHash6(targetDocument, hash)) {
9530 injectedStyles.add(hash);
9531 return;
9532 }
9533 const style = targetDocument.createElement("style");
9534 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9535 style.appendChild(targetDocument.createTextNode(css));
9536 targetDocument.head.appendChild(style);
9537 injectedStyles.add(hash);
9538 }
9539 function registerDocument6(targetDocument) {
9540 const runtime = getRuntime6();
9541 runtime.documents.set(
9542 targetDocument,
9543 (runtime.documents.get(targetDocument) ?? 0) + 1
9544 );
9545 for (const [hash, css] of runtime.styles) {
9546 injectStyle6(targetDocument, hash, css);
9547 }
9548 return () => {
9549 const count = runtime.documents.get(targetDocument);
9550 if (count === void 0) {
9551 return;
9552 }
9553 if (count <= 1) {
9554 runtime.documents.delete(targetDocument);
9555 return;
9556 }
9557 runtime.documents.set(targetDocument, count - 1);
9558 };
9559 }
9560 function registerStyle6(hash, css) {
9561 const runtime = getRuntime6();
9562 runtime.styles.set(hash, css);
9563 for (const targetDocument of runtime.documents.keys()) {
9564 injectStyle6(targetDocument, hash, css);
9565 }
9566 }
9567 if (typeof process === "undefined" || true) {
9568 registerStyle6("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9569 }
9570 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9571 var Root2 = (0, import_element16.forwardRef)(
9572 function EmptyStateRoot({ render: render4, ...props }, ref) {
9573 const className = clsx_default(style_default5.root);
9574 const element = useRender({
9575 defaultTagName: "div",
9576 render: render4,
9577 ref,
9578 props: mergeProps({ className }, props)
9579 });
9580 return element;
9581 }
9582 );
9583
9584 // packages/ui/build-module/empty-state/visual.mjs
9585 var import_element17 = __toESM(require_element(), 1);
9586 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9587 function getRuntime7() {
9588 const globalScope = globalThis;
9589 if (globalScope.__wpStyleRuntime) {
9590 return globalScope.__wpStyleRuntime;
9591 }
9592 globalScope.__wpStyleRuntime = {
9593 documents: /* @__PURE__ */ new Map(),
9594 styles: /* @__PURE__ */ new Map(),
9595 injectedStyles: /* @__PURE__ */ new WeakMap()
9596 };
9597 if (typeof document !== "undefined") {
9598 registerDocument7(document);
9599 }
9600 return globalScope.__wpStyleRuntime;
9601 }
9602 function documentContainsStyleHash7(targetDocument, hash) {
9603 if (!targetDocument.head) {
9604 return false;
9605 }
9606 for (const style of targetDocument.head.querySelectorAll(
9607 `style[${STYLE_HASH_ATTRIBUTE7}]`
9608 )) {
9609 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9610 return true;
9611 }
9612 }
9613 return false;
9614 }
9615 function injectStyle7(targetDocument, hash, css) {
9616 if (!targetDocument.head) {
9617 return;
9618 }
9619 const runtime = getRuntime7();
9620 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9621 if (!injectedStyles) {
9622 injectedStyles = /* @__PURE__ */ new Set();
9623 runtime.injectedStyles.set(targetDocument, injectedStyles);
9624 }
9625 if (injectedStyles.has(hash)) {
9626 return;
9627 }
9628 if (documentContainsStyleHash7(targetDocument, hash)) {
9629 injectedStyles.add(hash);
9630 return;
9631 }
9632 const style = targetDocument.createElement("style");
9633 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9634 style.appendChild(targetDocument.createTextNode(css));
9635 targetDocument.head.appendChild(style);
9636 injectedStyles.add(hash);
9637 }
9638 function registerDocument7(targetDocument) {
9639 const runtime = getRuntime7();
9640 runtime.documents.set(
9641 targetDocument,
9642 (runtime.documents.get(targetDocument) ?? 0) + 1
9643 );
9644 for (const [hash, css] of runtime.styles) {
9645 injectStyle7(targetDocument, hash, css);
9646 }
9647 return () => {
9648 const count = runtime.documents.get(targetDocument);
9649 if (count === void 0) {
9650 return;
9651 }
9652 if (count <= 1) {
9653 runtime.documents.delete(targetDocument);
9654 return;
9655 }
9656 runtime.documents.set(targetDocument, count - 1);
9657 };
9658 }
9659 function registerStyle7(hash, css) {
9660 const runtime = getRuntime7();
9661 runtime.styles.set(hash, css);
9662 for (const targetDocument of runtime.documents.keys()) {
9663 injectStyle7(targetDocument, hash, css);
9664 }
9665 }
9666 if (typeof process === "undefined" || true) {
9667 registerStyle7("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9668 }
9669 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9670 var Visual = (0, import_element17.forwardRef)(
9671 function EmptyStateVisual({ render: render4, ...props }, ref) {
9672 const className = clsx_default(style_default6.visual);
9673 const element = useRender({
9674 defaultTagName: "div",
9675 render: render4,
9676 ref,
9677 props: mergeProps({ className }, props)
9678 });
9679 return element;
9680 }
9681 );
9682
9683 // packages/ui/build-module/empty-state/icon.mjs
9684 var import_element18 = __toESM(require_element(), 1);
9685 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9686 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9687 function getRuntime8() {
9688 const globalScope = globalThis;
9689 if (globalScope.__wpStyleRuntime) {
9690 return globalScope.__wpStyleRuntime;
9691 }
9692 globalScope.__wpStyleRuntime = {
9693 documents: /* @__PURE__ */ new Map(),
9694 styles: /* @__PURE__ */ new Map(),
9695 injectedStyles: /* @__PURE__ */ new WeakMap()
9696 };
9697 if (typeof document !== "undefined") {
9698 registerDocument8(document);
9699 }
9700 return globalScope.__wpStyleRuntime;
9701 }
9702 function documentContainsStyleHash8(targetDocument, hash) {
9703 if (!targetDocument.head) {
9704 return false;
9705 }
9706 for (const style of targetDocument.head.querySelectorAll(
9707 `style[${STYLE_HASH_ATTRIBUTE8}]`
9708 )) {
9709 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9710 return true;
9711 }
9712 }
9713 return false;
9714 }
9715 function injectStyle8(targetDocument, hash, css) {
9716 if (!targetDocument.head) {
9717 return;
9718 }
9719 const runtime = getRuntime8();
9720 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9721 if (!injectedStyles) {
9722 injectedStyles = /* @__PURE__ */ new Set();
9723 runtime.injectedStyles.set(targetDocument, injectedStyles);
9724 }
9725 if (injectedStyles.has(hash)) {
9726 return;
9727 }
9728 if (documentContainsStyleHash8(targetDocument, hash)) {
9729 injectedStyles.add(hash);
9730 return;
9731 }
9732 const style = targetDocument.createElement("style");
9733 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9734 style.appendChild(targetDocument.createTextNode(css));
9735 targetDocument.head.appendChild(style);
9736 injectedStyles.add(hash);
9737 }
9738 function registerDocument8(targetDocument) {
9739 const runtime = getRuntime8();
9740 runtime.documents.set(
9741 targetDocument,
9742 (runtime.documents.get(targetDocument) ?? 0) + 1
9743 );
9744 for (const [hash, css] of runtime.styles) {
9745 injectStyle8(targetDocument, hash, css);
9746 }
9747 return () => {
9748 const count = runtime.documents.get(targetDocument);
9749 if (count === void 0) {
9750 return;
9751 }
9752 if (count <= 1) {
9753 runtime.documents.delete(targetDocument);
9754 return;
9755 }
9756 runtime.documents.set(targetDocument, count - 1);
9757 };
9758 }
9759 function registerStyle8(hash, css) {
9760 const runtime = getRuntime8();
9761 runtime.styles.set(hash, css);
9762 for (const targetDocument of runtime.documents.keys()) {
9763 injectStyle8(targetDocument, hash, css);
9764 }
9765 }
9766 if (typeof process === "undefined" || true) {
9767 registerStyle8("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9768 }
9769 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9770 var Icon3 = (0, import_element18.forwardRef)(
9771 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9772 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9773 Visual,
9774 {
9775 ref,
9776 className: clsx_default(style_default7.icon, className),
9777 ...restProps,
9778 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { icon })
9779 }
9780 );
9781 }
9782 );
9783
9784 // packages/ui/build-module/empty-state/title.mjs
9785 var import_element19 = __toESM(require_element(), 1);
9786 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
9787 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9788 function getRuntime9() {
9789 const globalScope = globalThis;
9790 if (globalScope.__wpStyleRuntime) {
9791 return globalScope.__wpStyleRuntime;
9792 }
9793 globalScope.__wpStyleRuntime = {
9794 documents: /* @__PURE__ */ new Map(),
9795 styles: /* @__PURE__ */ new Map(),
9796 injectedStyles: /* @__PURE__ */ new WeakMap()
9797 };
9798 if (typeof document !== "undefined") {
9799 registerDocument9(document);
9800 }
9801 return globalScope.__wpStyleRuntime;
9802 }
9803 function documentContainsStyleHash9(targetDocument, hash) {
9804 if (!targetDocument.head) {
9805 return false;
9806 }
9807 for (const style of targetDocument.head.querySelectorAll(
9808 `style[${STYLE_HASH_ATTRIBUTE9}]`
9809 )) {
9810 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
9811 return true;
9812 }
9813 }
9814 return false;
9815 }
9816 function injectStyle9(targetDocument, hash, css) {
9817 if (!targetDocument.head) {
9818 return;
9819 }
9820 const runtime = getRuntime9();
9821 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9822 if (!injectedStyles) {
9823 injectedStyles = /* @__PURE__ */ new Set();
9824 runtime.injectedStyles.set(targetDocument, injectedStyles);
9825 }
9826 if (injectedStyles.has(hash)) {
9827 return;
9828 }
9829 if (documentContainsStyleHash9(targetDocument, hash)) {
9830 injectedStyles.add(hash);
9831 return;
9832 }
9833 const style = targetDocument.createElement("style");
9834 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
9835 style.appendChild(targetDocument.createTextNode(css));
9836 targetDocument.head.appendChild(style);
9837 injectedStyles.add(hash);
9838 }
9839 function registerDocument9(targetDocument) {
9840 const runtime = getRuntime9();
9841 runtime.documents.set(
9842 targetDocument,
9843 (runtime.documents.get(targetDocument) ?? 0) + 1
9844 );
9845 for (const [hash, css] of runtime.styles) {
9846 injectStyle9(targetDocument, hash, css);
9847 }
9848 return () => {
9849 const count = runtime.documents.get(targetDocument);
9850 if (count === void 0) {
9851 return;
9852 }
9853 if (count <= 1) {
9854 runtime.documents.delete(targetDocument);
9855 return;
9856 }
9857 runtime.documents.set(targetDocument, count - 1);
9858 };
9859 }
9860 function registerStyle9(hash, css) {
9861 const runtime = getRuntime9();
9862 runtime.styles.set(hash, css);
9863 for (const targetDocument of runtime.documents.keys()) {
9864 injectStyle9(targetDocument, hash, css);
9865 }
9866 }
9867 if (typeof process === "undefined" || true) {
9868 registerStyle9("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9869 }
9870 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9871 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", {});
9872 var Title = (0, import_element19.forwardRef)(
9873 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
9874 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
9875 Text,
9876 {
9877 ref,
9878 variant: "heading-lg",
9879 render: render4,
9880 className: clsx_default(style_default8.title, className),
9881 ...props,
9882 children
9883 }
9884 );
9885 }
9886 );
9887
9888 // packages/ui/build-module/empty-state/description.mjs
9889 var import_element20 = __toESM(require_element(), 1);
9890 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
9891 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
9892 function getRuntime10() {
9893 const globalScope = globalThis;
9894 if (globalScope.__wpStyleRuntime) {
9895 return globalScope.__wpStyleRuntime;
9896 }
9897 globalScope.__wpStyleRuntime = {
9898 documents: /* @__PURE__ */ new Map(),
9899 styles: /* @__PURE__ */ new Map(),
9900 injectedStyles: /* @__PURE__ */ new WeakMap()
9901 };
9902 if (typeof document !== "undefined") {
9903 registerDocument10(document);
9904 }
9905 return globalScope.__wpStyleRuntime;
9906 }
9907 function documentContainsStyleHash10(targetDocument, hash) {
9908 if (!targetDocument.head) {
9909 return false;
9910 }
9911 for (const style of targetDocument.head.querySelectorAll(
9912 `style[${STYLE_HASH_ATTRIBUTE10}]`
9913 )) {
9914 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
9915 return true;
9916 }
9917 }
9918 return false;
9919 }
9920 function injectStyle10(targetDocument, hash, css) {
9921 if (!targetDocument.head) {
9922 return;
9923 }
9924 const runtime = getRuntime10();
9925 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9926 if (!injectedStyles) {
9927 injectedStyles = /* @__PURE__ */ new Set();
9928 runtime.injectedStyles.set(targetDocument, injectedStyles);
9929 }
9930 if (injectedStyles.has(hash)) {
9931 return;
9932 }
9933 if (documentContainsStyleHash10(targetDocument, hash)) {
9934 injectedStyles.add(hash);
9935 return;
9936 }
9937 const style = targetDocument.createElement("style");
9938 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
9939 style.appendChild(targetDocument.createTextNode(css));
9940 targetDocument.head.appendChild(style);
9941 injectedStyles.add(hash);
9942 }
9943 function registerDocument10(targetDocument) {
9944 const runtime = getRuntime10();
9945 runtime.documents.set(
9946 targetDocument,
9947 (runtime.documents.get(targetDocument) ?? 0) + 1
9948 );
9949 for (const [hash, css] of runtime.styles) {
9950 injectStyle10(targetDocument, hash, css);
9951 }
9952 return () => {
9953 const count = runtime.documents.get(targetDocument);
9954 if (count === void 0) {
9955 return;
9956 }
9957 if (count <= 1) {
9958 runtime.documents.delete(targetDocument);
9959 return;
9960 }
9961 runtime.documents.set(targetDocument, count - 1);
9962 };
9963 }
9964 function registerStyle10(hash, css) {
9965 const runtime = getRuntime10();
9966 runtime.styles.set(hash, css);
9967 for (const targetDocument of runtime.documents.keys()) {
9968 injectStyle10(targetDocument, hash, css);
9969 }
9970 }
9971 if (typeof process === "undefined" || true) {
9972 registerStyle10("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
9973 }
9974 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9975 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", {});
9976 var Description = (0, import_element20.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
9977 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
9978 Text,
9979 {
9980 ref,
9981 variant: "body-md",
9982 render: render4,
9983 className: clsx_default(style_default9.description, className),
9984 ...props,
9985 children
9986 }
9987 );
9988 });
9989
9990 // packages/ui/build-module/empty-state/actions.mjs
9991 var import_element21 = __toESM(require_element(), 1);
9992 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
9993 function getRuntime11() {
9994 const globalScope = globalThis;
9995 if (globalScope.__wpStyleRuntime) {
9996 return globalScope.__wpStyleRuntime;
9997 }
9998 globalScope.__wpStyleRuntime = {
9999 documents: /* @__PURE__ */ new Map(),
10000 styles: /* @__PURE__ */ new Map(),
10001 injectedStyles: /* @__PURE__ */ new WeakMap()
10002 };
10003 if (typeof document !== "undefined") {
10004 registerDocument11(document);
10005 }
10006 return globalScope.__wpStyleRuntime;
10007 }
10008 function documentContainsStyleHash11(targetDocument, hash) {
10009 if (!targetDocument.head) {
10010 return false;
10011 }
10012 for (const style of targetDocument.head.querySelectorAll(
10013 `style[${STYLE_HASH_ATTRIBUTE11}]`
10014 )) {
10015 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10016 return true;
10017 }
10018 }
10019 return false;
10020 }
10021 function injectStyle11(targetDocument, hash, css) {
10022 if (!targetDocument.head) {
10023 return;
10024 }
10025 const runtime = getRuntime11();
10026 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10027 if (!injectedStyles) {
10028 injectedStyles = /* @__PURE__ */ new Set();
10029 runtime.injectedStyles.set(targetDocument, injectedStyles);
10030 }
10031 if (injectedStyles.has(hash)) {
10032 return;
10033 }
10034 if (documentContainsStyleHash11(targetDocument, hash)) {
10035 injectedStyles.add(hash);
10036 return;
10037 }
10038 const style = targetDocument.createElement("style");
10039 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10040 style.appendChild(targetDocument.createTextNode(css));
10041 targetDocument.head.appendChild(style);
10042 injectedStyles.add(hash);
10043 }
10044 function registerDocument11(targetDocument) {
10045 const runtime = getRuntime11();
10046 runtime.documents.set(
10047 targetDocument,
10048 (runtime.documents.get(targetDocument) ?? 0) + 1
10049 );
10050 for (const [hash, css] of runtime.styles) {
10051 injectStyle11(targetDocument, hash, css);
10052 }
10053 return () => {
10054 const count = runtime.documents.get(targetDocument);
10055 if (count === void 0) {
10056 return;
10057 }
10058 if (count <= 1) {
10059 runtime.documents.delete(targetDocument);
10060 return;
10061 }
10062 runtime.documents.set(targetDocument, count - 1);
10063 };
10064 }
10065 function registerStyle11(hash, css) {
10066 const runtime = getRuntime11();
10067 runtime.styles.set(hash, css);
10068 for (const targetDocument of runtime.documents.keys()) {
10069 injectStyle11(targetDocument, hash, css);
10070 }
10071 }
10072 if (typeof process === "undefined" || true) {
10073 registerStyle11("6d6361d221", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.a23e08e65c8e62e5__root{text-wrap:balance;align-items:center;color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);gap:var(--wpds-dimension-gap-xs,4px);max-width:var(--wpds-dimension-surface-width-sm,320px);text-align:center}._01303b3680eaa216__visual{align-items:center;color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;justify-content:center;line-height:1;margin-block-end:var(--wpds-dimension-gap-xs,4px)}._58c8e351db225608__icon{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:50%;padding:var(--wpds-dimension-padding-xs,4px)}.b8b96f70820333a1__title{margin:0}._70f1dd22bad55b18__description{color:var(--wpds-color-fg-content-neutral-weak,#707070);margin:0}._89ac025fd8e2bc52__actions{align-items:center;display:flex;flex-direction:column;gap:var(--wpds-dimension-gap-xs,4px);margin-block-start:var(--wpds-dimension-gap-md,12px);@media (min-width:480px){flex-direction:row;justify-content:center}}}');
10074 }
10075 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10076 var Actions = (0, import_element21.forwardRef)(
10077 function EmptyStateActions({ render: render4, ...props }, ref) {
10078 const className = clsx_default(style_default10.actions);
10079 const element = useRender({
10080 defaultTagName: "div",
10081 render: render4,
10082 ref,
10083 props: mergeProps({ className }, props)
10084 });
10085 return element;
10086 }
10087 );
10088
10089 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10090 var import_element22 = __toESM(require_element(), 1);
10091 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10092 function getRuntime12() {
10093 const globalScope = globalThis;
10094 if (globalScope.__wpStyleRuntime) {
10095 return globalScope.__wpStyleRuntime;
10096 }
10097 globalScope.__wpStyleRuntime = {
10098 documents: /* @__PURE__ */ new Map(),
10099 styles: /* @__PURE__ */ new Map(),
10100 injectedStyles: /* @__PURE__ */ new WeakMap()
10101 };
10102 if (typeof document !== "undefined") {
10103 registerDocument12(document);
10104 }
10105 return globalScope.__wpStyleRuntime;
10106 }
10107 function documentContainsStyleHash12(targetDocument, hash) {
10108 if (!targetDocument.head) {
10109 return false;
10110 }
10111 for (const style of targetDocument.head.querySelectorAll(
10112 `style[${STYLE_HASH_ATTRIBUTE12}]`
10113 )) {
10114 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10115 return true;
10116 }
10117 }
10118 return false;
10119 }
10120 function injectStyle12(targetDocument, hash, css) {
10121 if (!targetDocument.head) {
10122 return;
10123 }
10124 const runtime = getRuntime12();
10125 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10126 if (!injectedStyles) {
10127 injectedStyles = /* @__PURE__ */ new Set();
10128 runtime.injectedStyles.set(targetDocument, injectedStyles);
10129 }
10130 if (injectedStyles.has(hash)) {
10131 return;
10132 }
10133 if (documentContainsStyleHash12(targetDocument, hash)) {
10134 injectedStyles.add(hash);
10135 return;
10136 }
10137 const style = targetDocument.createElement("style");
10138 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10139 style.appendChild(targetDocument.createTextNode(css));
10140 targetDocument.head.appendChild(style);
10141 injectedStyles.add(hash);
10142 }
10143 function registerDocument12(targetDocument) {
10144 const runtime = getRuntime12();
10145 runtime.documents.set(
10146 targetDocument,
10147 (runtime.documents.get(targetDocument) ?? 0) + 1
10148 );
10149 for (const [hash, css] of runtime.styles) {
10150 injectStyle12(targetDocument, hash, css);
10151 }
10152 return () => {
10153 const count = runtime.documents.get(targetDocument);
10154 if (count === void 0) {
10155 return;
10156 }
10157 if (count <= 1) {
10158 runtime.documents.delete(targetDocument);
10159 return;
10160 }
10161 runtime.documents.set(targetDocument, count - 1);
10162 };
10163 }
10164 function registerStyle12(hash, css) {
10165 const runtime = getRuntime12();
10166 runtime.styles.set(hash, css);
10167 for (const targetDocument of runtime.documents.keys()) {
10168 injectStyle12(targetDocument, hash, css);
10169 }
10170 }
10171 if (typeof process === "undefined" || true) {
10172 registerStyle12("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}}");
10173 }
10174 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10175 var VisuallyHidden = (0, import_element22.forwardRef)(
10176 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10177 const element = useRender({
10178 render: render4,
10179 ref,
10180 props: mergeProps(
10181 { className: style_default11["visually-hidden"] },
10182 restProps,
10183 {
10184 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10185 "data-visually-hidden": ""
10186 }
10187 )
10188 });
10189 return element;
10190 }
10191 );
10192
10193 // packages/ui/build-module/link/link.mjs
10194 var import_element23 = __toESM(require_element(), 1);
10195 var import_i18n = __toESM(require_i18n(), 1);
10196 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10197 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10198 function getRuntime13() {
10199 const globalScope = globalThis;
10200 if (globalScope.__wpStyleRuntime) {
10201 return globalScope.__wpStyleRuntime;
10202 }
10203 globalScope.__wpStyleRuntime = {
10204 documents: /* @__PURE__ */ new Map(),
10205 styles: /* @__PURE__ */ new Map(),
10206 injectedStyles: /* @__PURE__ */ new WeakMap()
10207 };
10208 if (typeof document !== "undefined") {
10209 registerDocument13(document);
10210 }
10211 return globalScope.__wpStyleRuntime;
10212 }
10213 function documentContainsStyleHash13(targetDocument, hash) {
10214 if (!targetDocument.head) {
10215 return false;
10216 }
10217 for (const style of targetDocument.head.querySelectorAll(
10218 `style[${STYLE_HASH_ATTRIBUTE13}]`
10219 )) {
10220 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10221 return true;
10222 }
10223 }
10224 return false;
10225 }
10226 function injectStyle13(targetDocument, hash, css) {
10227 if (!targetDocument.head) {
10228 return;
10229 }
10230 const runtime = getRuntime13();
10231 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10232 if (!injectedStyles) {
10233 injectedStyles = /* @__PURE__ */ new Set();
10234 runtime.injectedStyles.set(targetDocument, injectedStyles);
10235 }
10236 if (injectedStyles.has(hash)) {
10237 return;
10238 }
10239 if (documentContainsStyleHash13(targetDocument, hash)) {
10240 injectedStyles.add(hash);
10241 return;
10242 }
10243 const style = targetDocument.createElement("style");
10244 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10245 style.appendChild(targetDocument.createTextNode(css));
10246 targetDocument.head.appendChild(style);
10247 injectedStyles.add(hash);
10248 }
10249 function registerDocument13(targetDocument) {
10250 const runtime = getRuntime13();
10251 runtime.documents.set(
10252 targetDocument,
10253 (runtime.documents.get(targetDocument) ?? 0) + 1
10254 );
10255 for (const [hash, css] of runtime.styles) {
10256 injectStyle13(targetDocument, hash, css);
10257 }
10258 return () => {
10259 const count = runtime.documents.get(targetDocument);
10260 if (count === void 0) {
10261 return;
10262 }
10263 if (count <= 1) {
10264 runtime.documents.delete(targetDocument);
10265 return;
10266 }
10267 runtime.documents.set(targetDocument, count - 1);
10268 };
10269 }
10270 function registerStyle13(hash, css) {
10271 const runtime = getRuntime13();
10272 runtime.styles.set(hash, css);
10273 for (const targetDocument of runtime.documents.keys()) {
10274 injectStyle13(targetDocument, hash, css);
10275 }
10276 }
10277 if (typeof process === "undefined" || true) {
10278 registerStyle13("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}}}");
10279 }
10280 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10281 if (typeof process === "undefined" || true) {
10282 registerStyle13("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))}}");
10283 }
10284 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" };
10285 if (typeof process === "undefined" || true) {
10286 registerStyle13("90a23568f8", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.d4250949359b05ce__link{text-decoration-thickness:from-font;text-underline-offset:.2em}.c6055659b8e2cd2c__is-brand,.c6055659b8e2cd2c__is-brand:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand,var(--wp-admin-theme-color,#3858e9))}.c6055659b8e2cd2c__is-brand:active,.c6055659b8e2cd2c__is-brand:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9));color:var(--wpds-color-fg-interactive-brand-active,var(--wp-admin-theme-color,#3858e9))}._92e0dfcaeee15b88__is-neutral,._92e0dfcaeee15b88__is-neutral:visited{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral,#1e1e1e);text-decoration-color:var(--wpds-color-stroke-interactive-neutral,#8d8d8d)}._92e0dfcaeee15b88__is-neutral:active,._92e0dfcaeee15b88__is-neutral:hover{--_gcd-a-color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e);color:var(--wpds-color-fg-interactive-neutral-active,#1e1e1e)}.cf122a9bf1035d42__is-unstyled{--_gcd-a-color:inherit;color:inherit;text-decoration:none}._0cb411afac4c86c7__link-icon{display:inline-block;font-weight:var(--wpds-typography-font-weight-regular,400);line-height:1;margin-inline-start:var(--wpds-dimension-padding-xs,4px);text-decoration:none}._0cb411afac4c86c7__link-icon:after{content:"\\2197"}._0cb411afac4c86c7__link-icon:dir(rtl):after{content:"\\2196"}}');
10287 }
10288 var style_default12 = { "link": "d4250949359b05ce__link", "is-brand": "c6055659b8e2cd2c__is-brand", "is-neutral": "_92e0dfcaeee15b88__is-neutral", "is-unstyled": "cf122a9bf1035d42__is-unstyled", "link-icon": "_0cb411afac4c86c7__link-icon" };
10289 if (typeof process === "undefined" || true) {
10290 registerStyle13("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)}");
10291 }
10292 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" };
10293 var Link = (0, import_element23.forwardRef)(function Link2({
10294 children,
10295 variant = "default",
10296 tone = "brand",
10297 openInNewTab = false,
10298 render: render4,
10299 className,
10300 ...props
10301 }, ref) {
10302 const element = useRender({
10303 render: render4,
10304 defaultTagName: "a",
10305 ref,
10306 props: mergeProps(props, {
10307 className: clsx_default(
10308 global_css_defense_default2.a,
10309 resets_default2["box-sizing"],
10310 focus_default["outset-ring--focus"],
10311 variant !== "unstyled" && style_default12.link,
10312 variant !== "unstyled" && style_default12[`is-${tone}`],
10313 variant === "unstyled" && style_default12["is-unstyled"],
10314 className
10315 ),
10316 target: openInNewTab ? "_blank" : void 0,
10317 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10318 children,
10319 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10320 "span",
10321 {
10322 className: style_default12["link-icon"],
10323 role: "img",
10324 "aria-label": (
10325 /* translators: accessibility text appended to link text */
10326 (0, import_i18n.__)("(opens in a new tab)")
10327 )
10328 }
10329 )
10330 ] })
10331 })
10332 });
10333 return element;
10334 });
10335
10336 // packages/dataviews/build-module/dataviews/index.mjs
10337 var import_element79 = __toESM(require_element(), 1);
10338 var import_compose12 = __toESM(require_compose(), 1);
10339
10340 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10341 var import_element24 = __toESM(require_element(), 1);
10342
10343 // packages/dataviews/build-module/constants.mjs
10344 var import_i18n2 = __toESM(require_i18n(), 1);
10345 var OPERATOR_IS_ANY = "isAny";
10346 var OPERATOR_IS_NONE = "isNone";
10347 var OPERATOR_IS_ALL = "isAll";
10348 var OPERATOR_IS_NOT_ALL = "isNotAll";
10349 var OPERATOR_BETWEEN = "between";
10350 var OPERATOR_IN_THE_PAST = "inThePast";
10351 var OPERATOR_OVER = "over";
10352 var OPERATOR_IS = "is";
10353 var OPERATOR_IS_NOT = "isNot";
10354 var OPERATOR_LESS_THAN = "lessThan";
10355 var OPERATOR_GREATER_THAN = "greaterThan";
10356 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10357 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10358 var OPERATOR_BEFORE = "before";
10359 var OPERATOR_AFTER = "after";
10360 var OPERATOR_BEFORE_INC = "beforeInc";
10361 var OPERATOR_AFTER_INC = "afterInc";
10362 var OPERATOR_CONTAINS = "contains";
10363 var OPERATOR_NOT_CONTAINS = "notContains";
10364 var OPERATOR_STARTS_WITH = "startsWith";
10365 var OPERATOR_ON = "on";
10366 var OPERATOR_NOT_ON = "notOn";
10367 var SORTING_DIRECTIONS = ["asc", "desc"];
10368 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10369 var sortValues = { asc: "ascending", desc: "descending" };
10370 var sortLabels = {
10371 asc: (0, import_i18n2.__)("Sort ascending"),
10372 desc: (0, import_i18n2.__)("Sort descending")
10373 };
10374 var sortIcons = {
10375 asc: arrow_up_default,
10376 desc: arrow_down_default
10377 };
10378 var LAYOUT_TABLE = "table";
10379 var LAYOUT_GRID = "grid";
10380 var LAYOUT_LIST = "list";
10381 var LAYOUT_ACTIVITY = "activity";
10382 var LAYOUT_PICKER_GRID = "pickerGrid";
10383 var LAYOUT_PICKER_TABLE = "pickerTable";
10384
10385 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10386 var DataViewsContext = (0, import_element24.createContext)({
10387 view: { type: LAYOUT_TABLE },
10388 onChangeView: () => {
10389 },
10390 fields: [],
10391 data: [],
10392 paginationInfo: {
10393 totalItems: 0,
10394 totalPages: 0
10395 },
10396 selection: [],
10397 onChangeSelection: () => {
10398 },
10399 setOpenedFilter: () => {
10400 },
10401 openedFilter: null,
10402 getItemId: (item) => item.id,
10403 isItemClickable: () => true,
10404 renderItemLink: void 0,
10405 containerWidth: 0,
10406 containerRef: (0, import_element24.createRef)(),
10407 resizeObserverRef: () => {
10408 },
10409 defaultLayouts: { list: {}, grid: {}, table: {} },
10410 filters: [],
10411 isShowingFilter: false,
10412 setIsShowingFilter: () => {
10413 },
10414 hasInitiallyLoaded: false,
10415 config: {
10416 perPageSizes: []
10417 },
10418 intersectionObserver: null
10419 });
10420 DataViewsContext.displayName = "DataViewsContext";
10421 var dataviews_context_default = DataViewsContext;
10422
10423 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10424 var import_i18n22 = __toESM(require_i18n(), 1);
10425
10426 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10427 var import_i18n10 = __toESM(require_i18n(), 1);
10428 var import_components6 = __toESM(require_components(), 1);
10429 var import_element32 = __toESM(require_element(), 1);
10430 var import_keycodes = __toESM(require_keycodes(), 1);
10431
10432 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10433 var import_components = __toESM(require_components(), 1);
10434 var import_i18n3 = __toESM(require_i18n(), 1);
10435 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10436 function DataViewsSelectionCheckbox({
10437 selection,
10438 onChangeSelection,
10439 item,
10440 getItemId,
10441 titleField,
10442 disabled: disabled2,
10443 ...extraProps
10444 }) {
10445 const id = getItemId(item);
10446 const isInSelectionArray = selection.includes(id);
10447 const checked = !disabled2 && isInSelectionArray;
10448 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10449 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10450 import_components.CheckboxControl,
10451 {
10452 className: "dataviews-selection-checkbox",
10453 "aria-label": selectionLabel,
10454 "aria-disabled": disabled2,
10455 checked,
10456 onChange: () => {
10457 if (disabled2) {
10458 return;
10459 }
10460 onChangeSelection(
10461 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10462 );
10463 },
10464 ...extraProps
10465 }
10466 );
10467 }
10468
10469 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10470 var import_components2 = __toESM(require_components(), 1);
10471 var import_i18n4 = __toESM(require_i18n(), 1);
10472 var import_element25 = __toESM(require_element(), 1);
10473 var import_data = __toESM(require_data(), 1);
10474 var import_compose = __toESM(require_compose(), 1);
10475
10476 // packages/dataviews/build-module/lock-unlock.mjs
10477 var import_private_apis2 = __toESM(require_private_apis(), 1);
10478 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10479 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10480 "@wordpress/dataviews"
10481 );
10482
10483 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10484 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10485 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10486 function ButtonTrigger({
10487 action,
10488 onClick,
10489 items,
10490 variant
10491 }) {
10492 const label = typeof action.label === "string" ? action.label : action.label(items);
10493 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10494 import_components2.Button,
10495 {
10496 disabled: !!action.disabled,
10497 accessibleWhenDisabled: true,
10498 size: "compact",
10499 variant,
10500 onClick,
10501 children: label
10502 }
10503 );
10504 }
10505 function MenuItemTrigger({
10506 action,
10507 onClick,
10508 items
10509 }) {
10510 const label = typeof action.label === "string" ? action.label : action.label(items);
10511 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10512 }
10513 function ActionModal({
10514 action,
10515 items,
10516 closeModal
10517 }) {
10518 const label = typeof action.label === "string" ? action.label : action.label(items);
10519 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10520 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10521 import_components2.Modal,
10522 {
10523 title: modalHeader || label,
10524 __experimentalHideHeader: !!action.hideModalHeader,
10525 onRequestClose: closeModal,
10526 focusOnMount: action.modalFocusOnMount ?? true,
10527 size: action.modalSize || "medium",
10528 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10529 action.id
10530 )}`,
10531 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10532 }
10533 );
10534 }
10535 function ActionsMenuGroup({
10536 actions,
10537 item,
10538 registry,
10539 setActiveModalAction
10540 }) {
10541 const { primaryActions, regularActions } = (0, import_element25.useMemo)(() => {
10542 return actions.reduce(
10543 (acc, action) => {
10544 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10545 return acc;
10546 },
10547 {
10548 primaryActions: [],
10549 regularActions: []
10550 }
10551 );
10552 }, [actions]);
10553 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10554 MenuItemTrigger,
10555 {
10556 action,
10557 onClick: () => {
10558 if ("RenderModal" in action) {
10559 setActiveModalAction(action);
10560 return;
10561 }
10562 action.callback([item], { registry });
10563 },
10564 items: [item]
10565 },
10566 action.id
10567 ));
10568 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10569 renderActionGroup(primaryActions),
10570 renderActionGroup(regularActions)
10571 ] });
10572 }
10573 function ItemActions({
10574 item,
10575 actions,
10576 isCompact
10577 }) {
10578 const registry = (0, import_data.useRegistry)();
10579 const { primaryActions, eligibleActions } = (0, import_element25.useMemo)(() => {
10580 const _eligibleActions = actions.filter(
10581 (action) => !action.isEligible || action.isEligible(item)
10582 );
10583 const _primaryActions = _eligibleActions.filter(
10584 (action) => action.isPrimary
10585 );
10586 return {
10587 primaryActions: _primaryActions,
10588 eligibleActions: _eligibleActions
10589 };
10590 }, [actions, item]);
10591 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10592 if (isCompact) {
10593 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10594 CompactItemActions,
10595 {
10596 item,
10597 actions: eligibleActions,
10598 isSmall: true,
10599 registry
10600 }
10601 );
10602 }
10603 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10604 Stack,
10605 {
10606 direction: "row",
10607 justify: "flex-end",
10608 className: "dataviews-item-actions",
10609 style: {
10610 flexShrink: 0,
10611 width: "auto"
10612 },
10613 children: [
10614 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10615 PrimaryActions,
10616 {
10617 item,
10618 actions: primaryActions,
10619 registry
10620 }
10621 ),
10622 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10623 // there if there are any actions at all.
10624 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10625 CompactItemActions,
10626 {
10627 item,
10628 actions: eligibleActions,
10629 registry
10630 }
10631 )
10632 ]
10633 }
10634 );
10635 }
10636 function CompactItemActions({
10637 item,
10638 actions,
10639 isSmall,
10640 registry
10641 }) {
10642 const [activeModalAction, setActiveModalAction] = (0, import_element25.useState)(
10643 null
10644 );
10645 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10646 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
10647 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10648 Menu.TriggerButton,
10649 {
10650 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10651 import_components2.Button,
10652 {
10653 size: isSmall ? "small" : "compact",
10654 icon: more_vertical_default,
10655 label: (0, import_i18n4.__)("Actions"),
10656 accessibleWhenDisabled: true,
10657 disabled: !actions.length,
10658 className: "dataviews-all-actions-button"
10659 }
10660 )
10661 }
10662 ),
10663 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10664 ActionsMenuGroup,
10665 {
10666 actions,
10667 item,
10668 registry,
10669 setActiveModalAction
10670 }
10671 ) })
10672 ] }),
10673 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10674 ActionModal,
10675 {
10676 action: activeModalAction,
10677 items: [item],
10678 closeModal: () => setActiveModalAction(null)
10679 }
10680 )
10681 ] });
10682 }
10683 function PrimaryActions({
10684 item,
10685 actions,
10686 registry,
10687 buttonVariant
10688 }) {
10689 const [activeModalAction, setActiveModalAction] = (0, import_element25.useState)(null);
10690 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10691 if (isMobileViewport) {
10692 return null;
10693 }
10694 if (!Array.isArray(actions) || actions.length === 0) {
10695 return null;
10696 }
10697 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10698 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10699 ButtonTrigger,
10700 {
10701 action,
10702 onClick: () => {
10703 if ("RenderModal" in action) {
10704 setActiveModalAction(action);
10705 return;
10706 }
10707 action.callback([item], { registry });
10708 },
10709 items: [item],
10710 variant: buttonVariant
10711 },
10712 action.id
10713 )),
10714 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10715 ActionModal,
10716 {
10717 action: activeModalAction,
10718 items: [item],
10719 closeModal: () => setActiveModalAction(null)
10720 }
10721 )
10722 ] });
10723 }
10724
10725 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10726 var import_components3 = __toESM(require_components(), 1);
10727 var import_i18n6 = __toESM(require_i18n(), 1);
10728 var import_element26 = __toESM(require_element(), 1);
10729 var import_data2 = __toESM(require_data(), 1);
10730 var import_compose2 = __toESM(require_compose(), 1);
10731
10732 // packages/dataviews/build-module/utils/get-footer-message.mjs
10733 var import_i18n5 = __toESM(require_i18n(), 1);
10734 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10735 if (selectionCount > 0) {
10736 return (0, import_i18n5.sprintf)(
10737 /* translators: %d: number of items. */
10738 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10739 selectionCount
10740 );
10741 }
10742 if (onlyTotalCount || totalItems <= itemsCount) {
10743 return (0, import_i18n5.sprintf)(
10744 /* translators: %d: number of items. */
10745 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10746 totalItems
10747 );
10748 }
10749 return (0, import_i18n5.sprintf)(
10750 /* translators: %1$d: number of items. %2$d: total number of items. */
10751 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10752 itemsCount,
10753 totalItems
10754 );
10755 }
10756
10757 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10758 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
10759 function ActionWithModal({
10760 action,
10761 items,
10762 ActionTriggerComponent
10763 }) {
10764 const [isModalOpen, setIsModalOpen] = (0, import_element26.useState)(false);
10765 const actionTriggerProps = {
10766 action,
10767 onClick: () => {
10768 setIsModalOpen(true);
10769 },
10770 items
10771 };
10772 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
10773 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10774 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10775 ActionModal,
10776 {
10777 action,
10778 items,
10779 closeModal: () => setIsModalOpen(false)
10780 }
10781 )
10782 ] });
10783 }
10784 function useHasAPossibleBulkAction(actions, item) {
10785 return (0, import_element26.useMemo)(() => {
10786 return actions.some((action) => {
10787 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10788 });
10789 }, [actions, item]);
10790 }
10791 function useSomeItemHasAPossibleBulkAction(actions, data) {
10792 return (0, import_element26.useMemo)(() => {
10793 return data.some((item) => {
10794 return actions.some((action) => {
10795 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10796 });
10797 });
10798 }, [actions, data]);
10799 }
10800 function BulkSelectionCheckbox({
10801 selection,
10802 onChangeSelection,
10803 data,
10804 actions,
10805 getItemId,
10806 disableSelectAll = false
10807 }) {
10808 const selectableItems = (0, import_element26.useMemo)(() => {
10809 return data.filter((item) => {
10810 return actions.some(
10811 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10812 );
10813 });
10814 }, [data, actions]);
10815 const selectedItems = data.filter(
10816 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10817 );
10818 const hasSelection = selection.length > 0;
10819 const areAllSelected = selectedItems.length === selectableItems.length;
10820 if (disableSelectAll) {
10821 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10822 import_components3.CheckboxControl,
10823 {
10824 className: "dataviews-view-table-selection-checkbox",
10825 checked: hasSelection,
10826 disabled: !hasSelection,
10827 onChange: () => {
10828 onChangeSelection([]);
10829 },
10830 "aria-label": (0, import_i18n6.__)("Deselect all")
10831 }
10832 );
10833 }
10834 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10835 import_components3.CheckboxControl,
10836 {
10837 className: "dataviews-view-table-selection-checkbox",
10838 checked: areAllSelected,
10839 indeterminate: !areAllSelected && !!selectedItems.length,
10840 onChange: () => {
10841 if (areAllSelected) {
10842 onChangeSelection([]);
10843 } else {
10844 onChangeSelection(
10845 selectableItems.map((item) => getItemId(item))
10846 );
10847 }
10848 },
10849 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
10850 }
10851 );
10852 }
10853 function ActionTrigger({
10854 action,
10855 onClick,
10856 isBusy,
10857 items
10858 }) {
10859 const label = typeof action.label === "string" ? action.label : action.label(items);
10860 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10861 if (isMobile) {
10862 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10863 import_components3.Button,
10864 {
10865 disabled: isBusy,
10866 accessibleWhenDisabled: true,
10867 label,
10868 icon: action.icon,
10869 size: "compact",
10870 onClick,
10871 isBusy
10872 }
10873 );
10874 }
10875 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10876 import_components3.Button,
10877 {
10878 disabled: isBusy,
10879 accessibleWhenDisabled: true,
10880 size: "compact",
10881 onClick,
10882 isBusy,
10883 children: label
10884 }
10885 );
10886 }
10887 var EMPTY_ARRAY2 = [];
10888 function ActionButton({
10889 action,
10890 selectedItems,
10891 actionInProgress,
10892 setActionInProgress
10893 }) {
10894 const registry = (0, import_data2.useRegistry)();
10895 const selectedEligibleItems = (0, import_element26.useMemo)(() => {
10896 return selectedItems.filter((item) => {
10897 return !action.isEligible || action.isEligible(item);
10898 });
10899 }, [action, selectedItems]);
10900 if ("RenderModal" in action) {
10901 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10902 ActionWithModal,
10903 {
10904 action,
10905 items: selectedEligibleItems,
10906 ActionTriggerComponent: ActionTrigger
10907 },
10908 action.id
10909 );
10910 }
10911 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10912 ActionTrigger,
10913 {
10914 action,
10915 onClick: async () => {
10916 setActionInProgress(action.id);
10917 await action.callback(selectedItems, {
10918 registry
10919 });
10920 setActionInProgress(null);
10921 },
10922 items: selectedEligibleItems,
10923 isBusy: actionInProgress === action.id
10924 },
10925 action.id
10926 );
10927 }
10928 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10929 const message2 = getFooterMessage(
10930 selection.length,
10931 data.length,
10932 paginationInfo.totalItems,
10933 isInfiniteScroll
10934 );
10935 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
10936 Stack,
10937 {
10938 direction: "row",
10939 className: "dataviews-bulk-actions-footer__container",
10940 gap: "md",
10941 align: "center",
10942 children: [
10943 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10944 BulkSelectionCheckbox,
10945 {
10946 selection,
10947 onChangeSelection,
10948 data,
10949 actions,
10950 getItemId,
10951 disableSelectAll: isInfiniteScroll
10952 }
10953 ),
10954 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10955 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
10956 Stack,
10957 {
10958 direction: "row",
10959 className: "dataviews-bulk-actions-footer__action-buttons",
10960 gap: "xs",
10961 children: [
10962 actionsToShow.map((action) => {
10963 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10964 ActionButton,
10965 {
10966 action,
10967 selectedItems,
10968 actionInProgress,
10969 setActionInProgress
10970 },
10971 action.id
10972 );
10973 }),
10974 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10975 import_components3.Button,
10976 {
10977 icon: close_small_default,
10978 showTooltip: true,
10979 tooltipPosition: "top",
10980 size: "compact",
10981 label: (0, import_i18n6.__)("Cancel"),
10982 disabled: !!actionInProgress,
10983 accessibleWhenDisabled: false,
10984 onClick: () => {
10985 onChangeSelection(EMPTY_ARRAY2);
10986 }
10987 }
10988 )
10989 ]
10990 }
10991 )
10992 ]
10993 }
10994 );
10995 }
10996 function FooterContent({
10997 selection,
10998 actions,
10999 onChangeSelection,
11000 data,
11001 getItemId,
11002 isInfiniteScroll,
11003 paginationInfo
11004 }) {
11005 const [actionInProgress, setActionInProgress] = (0, import_element26.useState)(
11006 null
11007 );
11008 const footerContentRef = (0, import_element26.useRef)(void 0);
11009 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11010 const bulkActions = (0, import_element26.useMemo)(
11011 () => actions.filter((action) => action.supportsBulk),
11012 [actions]
11013 );
11014 const selectableItems = (0, import_element26.useMemo)(() => {
11015 return data.filter((item) => {
11016 return bulkActions.some(
11017 (action) => !action.isEligible || action.isEligible(item)
11018 );
11019 });
11020 }, [data, bulkActions]);
11021 const selectedItems = (0, import_element26.useMemo)(() => {
11022 return data.filter(
11023 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11024 );
11025 }, [selection, data, getItemId, selectableItems]);
11026 const actionsToShow = (0, import_element26.useMemo)(
11027 () => actions.filter((action) => {
11028 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11029 (item) => !action.isEligible || action.isEligible(item)
11030 );
11031 }),
11032 [actions, selectedItems, isMobile]
11033 );
11034 if (!actionInProgress) {
11035 if (footerContentRef.current) {
11036 footerContentRef.current = void 0;
11037 }
11038 return renderFooterContent(
11039 data,
11040 actions,
11041 getItemId,
11042 isInfiniteScroll,
11043 selection,
11044 actionsToShow,
11045 selectedItems,
11046 actionInProgress,
11047 setActionInProgress,
11048 onChangeSelection,
11049 paginationInfo
11050 );
11051 } else if (!footerContentRef.current) {
11052 footerContentRef.current = renderFooterContent(
11053 data,
11054 actions,
11055 getItemId,
11056 isInfiniteScroll,
11057 selection,
11058 actionsToShow,
11059 selectedItems,
11060 actionInProgress,
11061 setActionInProgress,
11062 onChangeSelection,
11063 paginationInfo
11064 );
11065 }
11066 return footerContentRef.current;
11067 }
11068 function BulkActionsFooter() {
11069 const {
11070 data,
11071 selection,
11072 actions = EMPTY_ARRAY2,
11073 onChangeSelection,
11074 getItemId,
11075 paginationInfo,
11076 view
11077 } = (0, import_element26.useContext)(dataviews_context_default);
11078 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11079 FooterContent,
11080 {
11081 selection,
11082 onChangeSelection,
11083 data,
11084 actions,
11085 getItemId,
11086 isInfiniteScroll: !!view.infiniteScrollEnabled,
11087 paginationInfo
11088 }
11089 );
11090 }
11091
11092 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11093 var import_i18n7 = __toESM(require_i18n(), 1);
11094 var import_components4 = __toESM(require_components(), 1);
11095 var import_element27 = __toESM(require_element(), 1);
11096
11097 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11098 function getHideableFields(view, fields) {
11099 const togglableFields = [
11100 view?.titleField,
11101 view?.mediaField,
11102 view?.descriptionField
11103 ].filter(Boolean);
11104 return fields.filter(
11105 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11106 );
11107 }
11108
11109 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11110 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11111 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11112 function WithMenuSeparators({ children }) {
11113 return import_element27.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element27.Fragment, { children: [
11114 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11115 child
11116 ] }, i2));
11117 }
11118 var _HeaderMenu = (0, import_element27.forwardRef)(function HeaderMenu({
11119 fieldId,
11120 view,
11121 fields,
11122 onChangeView,
11123 onHide,
11124 setOpenedFilter,
11125 canMove = true,
11126 canInsertLeft = true,
11127 canInsertRight = true
11128 }, ref) {
11129 const visibleFieldIds = view.fields ?? [];
11130 const index2 = visibleFieldIds?.indexOf(fieldId);
11131 const isSorted = view.sort?.field === fieldId;
11132 let isHidable = false;
11133 let isSortable = false;
11134 let canAddFilter = false;
11135 let operators = [];
11136 const field = fields.find((f2) => f2.id === fieldId);
11137 const { setIsShowingFilter } = (0, import_element27.useContext)(dataviews_context_default);
11138 if (!field) {
11139 return null;
11140 }
11141 isHidable = field.enableHiding !== false;
11142 isSortable = field.enableSorting !== false;
11143 const header = field.header;
11144 operators = !!field.filterBy && field.filterBy?.operators || [];
11145 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11146 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11147 return header;
11148 }
11149 const hiddenFields = getHideableFields(view, fields).filter(
11150 (f2) => !visibleFieldIds.includes(f2.id)
11151 );
11152 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11153 const isRtl = (0, import_i18n7.isRTL)();
11154 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11155 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11156 Menu2.TriggerButton,
11157 {
11158 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11159 import_components4.Button,
11160 {
11161 size: "compact",
11162 className: "dataviews-view-table-header-button",
11163 ref,
11164 variant: "tertiary"
11165 }
11166 ),
11167 children: [
11168 header,
11169 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11170 ]
11171 }
11172 ),
11173 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11174 isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11175 (direction) => {
11176 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11177 const value = `${fieldId}-${direction}`;
11178 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11179 Menu2.RadioItem,
11180 {
11181 name: "view-table-sorting",
11182 value,
11183 checked: isChecked,
11184 onChange: () => {
11185 onChangeView({
11186 ...view,
11187 sort: {
11188 field: fieldId,
11189 direction
11190 },
11191 showLevels: false
11192 });
11193 },
11194 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11195 },
11196 value
11197 );
11198 }
11199 ) }),
11200 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11201 Menu2.Item,
11202 {
11203 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11204 onClick: () => {
11205 setOpenedFilter(fieldId);
11206 setIsShowingFilter(true);
11207 onChangeView({
11208 ...view,
11209 page: 1,
11210 filters: [
11211 ...view.filters || [],
11212 {
11213 field: fieldId,
11214 value: void 0,
11215 operator: operators[0]
11216 }
11217 ]
11218 });
11219 },
11220 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11221 }
11222 ) }),
11223 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11224 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11225 Menu2.Item,
11226 {
11227 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11228 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11229 onClick: () => {
11230 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11231 const newFields = [
11232 ...visibleFieldIds
11233 ];
11234 newFields.splice(index2, 1);
11235 newFields.splice(
11236 targetIndex,
11237 0,
11238 fieldId
11239 );
11240 onChangeView({
11241 ...view,
11242 fields: newFields
11243 });
11244 },
11245 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11246 }
11247 ),
11248 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11249 Menu2.Item,
11250 {
11251 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11252 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11253 onClick: () => {
11254 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11255 const newFields = [
11256 ...visibleFieldIds
11257 ];
11258 newFields.splice(index2, 1);
11259 newFields.splice(
11260 targetIndex,
11261 0,
11262 fieldId
11263 );
11264 onChangeView({
11265 ...view,
11266 fields: newFields
11267 });
11268 },
11269 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11270 }
11271 ),
11272 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11273 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11274 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11275 const insertIndex = isRtl ? index2 + 1 : index2;
11276 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11277 Menu2.Item,
11278 {
11279 onClick: () => {
11280 onChangeView({
11281 ...view,
11282 fields: [
11283 ...visibleFieldIds.slice(
11284 0,
11285 insertIndex
11286 ),
11287 hiddenField.id,
11288 ...visibleFieldIds.slice(
11289 insertIndex
11290 )
11291 ]
11292 });
11293 },
11294 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11295 },
11296 hiddenField.id
11297 );
11298 }) })
11299 ] }),
11300 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11301 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11302 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11303 const insertIndex = isRtl ? index2 : index2 + 1;
11304 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11305 Menu2.Item,
11306 {
11307 onClick: () => {
11308 onChangeView({
11309 ...view,
11310 fields: [
11311 ...visibleFieldIds.slice(
11312 0,
11313 insertIndex
11314 ),
11315 hiddenField.id,
11316 ...visibleFieldIds.slice(
11317 insertIndex
11318 )
11319 ]
11320 });
11321 },
11322 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11323 },
11324 hiddenField.id
11325 );
11326 }) })
11327 ] }),
11328 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11329 Menu2.Item,
11330 {
11331 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11332 onClick: () => {
11333 onHide(field);
11334 onChangeView({
11335 ...view,
11336 fields: visibleFieldIds.filter(
11337 (id) => id !== fieldId
11338 )
11339 });
11340 },
11341 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11342 }
11343 )
11344 ] })
11345 ] }) })
11346 ] });
11347 });
11348 var ColumnHeaderMenu = _HeaderMenu;
11349 var column_header_menu_default = ColumnHeaderMenu;
11350
11351 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11352 var import_element28 = __toESM(require_element(), 1);
11353 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11354 function getClickableItemProps({
11355 item,
11356 isItemClickable,
11357 onClickItem,
11358 className
11359 }) {
11360 if (!isItemClickable(item) || !onClickItem) {
11361 return { className };
11362 }
11363 return {
11364 className: className ? `${className} ${className}--clickable` : void 0,
11365 role: "button",
11366 tabIndex: 0,
11367 onClick: (event) => {
11368 event.stopPropagation();
11369 onClickItem(item);
11370 },
11371 onKeyDown: (event) => {
11372 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11373 event.stopPropagation();
11374 onClickItem(item);
11375 }
11376 }
11377 };
11378 }
11379 function ItemClickWrapper({
11380 item,
11381 isItemClickable,
11382 onClickItem,
11383 renderItemLink,
11384 className,
11385 children,
11386 ...extraProps
11387 }) {
11388 if (!isItemClickable(item)) {
11389 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11390 }
11391 if (renderItemLink) {
11392 const renderedElement = renderItemLink({
11393 item,
11394 className: `${className} ${className}--clickable`,
11395 ...extraProps,
11396 children
11397 });
11398 return (0, import_element28.cloneElement)(renderedElement, {
11399 onClick: (event) => {
11400 event.stopPropagation();
11401 if (renderedElement.props.onClick) {
11402 renderedElement.props.onClick(event);
11403 }
11404 },
11405 onKeyDown: (event) => {
11406 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11407 event.stopPropagation();
11408 if (renderedElement.props.onKeyDown) {
11409 renderedElement.props.onKeyDown(event);
11410 }
11411 }
11412 }
11413 });
11414 }
11415 const clickProps = getClickableItemProps({
11416 item,
11417 isItemClickable,
11418 onClickItem,
11419 className
11420 });
11421 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11422 }
11423
11424 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11425 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11426 function ColumnPrimary({
11427 item,
11428 level,
11429 titleField,
11430 mediaField,
11431 descriptionField,
11432 onClickItem,
11433 renderItemLink,
11434 isItemClickable
11435 }) {
11436 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11437 mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11438 ItemClickWrapper,
11439 {
11440 item,
11441 isItemClickable,
11442 onClickItem,
11443 renderItemLink,
11444 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11445 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11446 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11447 mediaField.render,
11448 {
11449 item,
11450 field: mediaField,
11451 config: { sizes: "32px" }
11452 }
11453 )
11454 }
11455 ),
11456 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11457 Stack,
11458 {
11459 direction: "column",
11460 align: "flex-start",
11461 className: "dataviews-view-table__primary-column-content",
11462 children: [
11463 titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11464 ItemClickWrapper,
11465 {
11466 item,
11467 isItemClickable,
11468 onClickItem,
11469 renderItemLink,
11470 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11471 children: [
11472 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11473 Array(level).fill("\u2014").join(" "),
11474 "\xA0"
11475 ] }),
11476 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11477 ]
11478 }
11479 ),
11480 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11481 descriptionField.render,
11482 {
11483 item,
11484 field: descriptionField
11485 }
11486 )
11487 ]
11488 }
11489 )
11490 ] });
11491 }
11492 var column_primary_default = ColumnPrimary;
11493
11494 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11495 var import_element29 = __toESM(require_element(), 1);
11496 var import_i18n8 = __toESM(require_i18n(), 1);
11497 var isScrolledToEnd = (element) => {
11498 if ((0, import_i18n8.isRTL)()) {
11499 const scrollLeft = Math.abs(element.scrollLeft);
11500 return scrollLeft <= 1;
11501 }
11502 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11503 };
11504 function useScrollState({
11505 scrollContainerRef,
11506 enabledHorizontal = false
11507 }) {
11508 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element29.useState)(false);
11509 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element29.useState)(false);
11510 const handleScroll = (0, import_element29.useCallback)(() => {
11511 const scrollContainer = scrollContainerRef.current;
11512 if (!scrollContainer) {
11513 return;
11514 }
11515 if (enabledHorizontal) {
11516 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11517 }
11518 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11519 }, [scrollContainerRef, enabledHorizontal]);
11520 (0, import_element29.useEffect)(() => {
11521 if (typeof window === "undefined" || !scrollContainerRef.current) {
11522 return () => {
11523 };
11524 }
11525 const scrollContainer = scrollContainerRef.current;
11526 handleScroll();
11527 scrollContainer.addEventListener("scroll", handleScroll);
11528 window.addEventListener("resize", handleScroll);
11529 return () => {
11530 scrollContainer.removeEventListener("scroll", handleScroll);
11531 window.removeEventListener("resize", handleScroll);
11532 };
11533 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11534 return { isHorizontalScrollEnd, isVerticallyScrolled };
11535 }
11536
11537 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11538 function getDataByGroup(data, groupByField) {
11539 return data.reduce((groups, item) => {
11540 const groupName = groupByField.getValue({ item });
11541 if (!groups.has(groupName)) {
11542 groups.set(groupName, []);
11543 }
11544 groups.get(groupName)?.push(item);
11545 return groups;
11546 }, /* @__PURE__ */ new Map());
11547 }
11548
11549 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11550 var import_components5 = __toESM(require_components(), 1);
11551 var import_i18n9 = __toESM(require_i18n(), 1);
11552 var import_element30 = __toESM(require_element(), 1);
11553 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11554 function FieldItem({
11555 field,
11556 isVisible: isVisible2,
11557 onToggleVisibility
11558 }) {
11559 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11560 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.Icon, { icon: check_default }) }),
11561 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11562 ] }) });
11563 }
11564 function isDefined(item) {
11565 return !!item;
11566 }
11567 function PropertiesSection({
11568 showLabel = true
11569 }) {
11570 const { view, fields, onChangeView } = (0, import_element30.useContext)(dataviews_context_default);
11571 const regularFields = getHideableFields(view, fields);
11572 if (!regularFields?.length) {
11573 return null;
11574 }
11575 const titleField = fields.find((f2) => f2.id === view.titleField);
11576 const previewField = fields.find((f2) => f2.id === view.mediaField);
11577 const descriptionField = fields.find(
11578 (f2) => f2.id === view.descriptionField
11579 );
11580 const lockedFields = [
11581 {
11582 field: titleField,
11583 isVisibleFlag: "showTitle"
11584 },
11585 {
11586 field: previewField,
11587 isVisibleFlag: "showMedia"
11588 },
11589 {
11590 field: descriptionField,
11591 isVisibleFlag: "showDescription"
11592 }
11593 ].filter(({ field }) => isDefined(field));
11594 const visibleFieldIds = view.fields ?? [];
11595 const visibleRegularFieldsCount = regularFields.filter(
11596 (f2) => visibleFieldIds.includes(f2.id)
11597 ).length;
11598 const visibleLockedFields = lockedFields.filter(
11599 ({ isVisibleFlag }) => (
11600 // @ts-expect-error
11601 view[isVisibleFlag] ?? true
11602 )
11603 );
11604 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11605 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11606 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11607 showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11608 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11609 Stack,
11610 {
11611 direction: "column",
11612 className: "dataviews-view-config__properties",
11613 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11614 lockedFields.map(({ field, isVisibleFlag }) => {
11615 const isVisible2 = view[isVisibleFlag] ?? true;
11616 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11617 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11618 FieldItem,
11619 {
11620 field: fieldToRender,
11621 isVisible: isVisible2,
11622 onToggleVisibility: () => {
11623 onChangeView({
11624 ...view,
11625 [isVisibleFlag]: !isVisible2
11626 });
11627 }
11628 },
11629 field.id
11630 );
11631 }),
11632 regularFields.map((field) => {
11633 const isVisible2 = visibleFieldIds.includes(field.id);
11634 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11635 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11636 FieldItem,
11637 {
11638 field: fieldToRender,
11639 isVisible: isVisible2,
11640 onToggleVisibility: () => {
11641 onChangeView({
11642 ...view,
11643 fields: isVisible2 ? visibleFieldIds.filter(
11644 (fieldId) => fieldId !== field.id
11645 ) : [...visibleFieldIds, field.id]
11646 });
11647 }
11648 },
11649 field.id
11650 );
11651 })
11652 ] })
11653 }
11654 )
11655 ] });
11656 }
11657
11658 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11659 var import_element31 = __toESM(require_element(), 1);
11660 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11661 const [showLoader, setShowLoader] = (0, import_element31.useState)(false);
11662 (0, import_element31.useEffect)(() => {
11663 if (!isLoading) {
11664 return;
11665 }
11666 const timeout = setTimeout(() => {
11667 setShowLoader(true);
11668 }, options.delay);
11669 return () => {
11670 clearTimeout(timeout);
11671 setShowLoader(false);
11672 };
11673 }, [isLoading, options.delay]);
11674 return showLoader;
11675 }
11676
11677 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11678 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11679 function getEffectiveAlign(explicitAlign, fieldType) {
11680 if (explicitAlign) {
11681 return explicitAlign;
11682 }
11683 if (fieldType === "integer" || fieldType === "number") {
11684 return "end";
11685 }
11686 return void 0;
11687 }
11688 function TableColumnField({
11689 item,
11690 fields,
11691 column,
11692 align
11693 }) {
11694 const field = fields.find((f2) => f2.id === column);
11695 if (!field) {
11696 return null;
11697 }
11698 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11699 "dataviews-view-table__cell-align-end": align === "end",
11700 "dataviews-view-table__cell-align-center": align === "center"
11701 });
11702 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
11703 }
11704 function TableRow({
11705 hasBulkActions,
11706 item,
11707 level,
11708 actions,
11709 fields,
11710 id,
11711 view,
11712 titleField,
11713 mediaField,
11714 descriptionField,
11715 selection,
11716 getItemId,
11717 isItemClickable,
11718 onClickItem,
11719 renderItemLink,
11720 onChangeSelection,
11721 isActionsColumnSticky,
11722 posinset
11723 }) {
11724 const { paginationInfo } = (0, import_element32.useContext)(dataviews_context_default);
11725 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11726 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11727 const {
11728 showTitle = true,
11729 showMedia = true,
11730 showDescription = true,
11731 infiniteScrollEnabled
11732 } = view;
11733 const isTouchDeviceRef = (0, import_element32.useRef)(false);
11734 const columns = view.fields ?? [];
11735 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11736 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11737 "tr",
11738 {
11739 className: clsx_default("dataviews-view-table__row", {
11740 "is-selected": hasPossibleBulkAction && isSelected2,
11741 "has-bulk-actions": hasPossibleBulkAction
11742 }),
11743 onTouchStart: () => {
11744 isTouchDeviceRef.current = true;
11745 },
11746 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11747 "aria-posinset": posinset,
11748 role: infiniteScrollEnabled ? "article" : void 0,
11749 onMouseDown: (event) => {
11750 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11751 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11752 event?.preventDefault();
11753 }
11754 },
11755 onClick: (event) => {
11756 if (!hasPossibleBulkAction) {
11757 return;
11758 }
11759 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11760 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11761 onChangeSelection(
11762 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11763 );
11764 }
11765 },
11766 children: [
11767 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11768 DataViewsSelectionCheckbox,
11769 {
11770 item,
11771 selection,
11772 onChangeSelection,
11773 getItemId,
11774 titleField,
11775 disabled: !hasPossibleBulkAction
11776 }
11777 ) }) }),
11778 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11779 column_primary_default,
11780 {
11781 item,
11782 level,
11783 titleField: showTitle ? titleField : void 0,
11784 mediaField: showMedia ? mediaField : void 0,
11785 descriptionField: showDescription ? descriptionField : void 0,
11786 isItemClickable,
11787 onClickItem,
11788 renderItemLink
11789 }
11790 ) }),
11791 columns.map((column) => {
11792 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11793 const field = fields.find((f2) => f2.id === column);
11794 const effectiveAlign = getEffectiveAlign(align, field?.type);
11795 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11796 "td",
11797 {
11798 style: {
11799 width,
11800 maxWidth,
11801 minWidth
11802 },
11803 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11804 TableColumnField,
11805 {
11806 fields,
11807 item,
11808 column,
11809 align: effectiveAlign
11810 }
11811 )
11812 },
11813 column
11814 );
11815 }),
11816 !!actions?.length && // Disable reason: we are not making the element interactive,
11817 // but preventing any click events from bubbling up to the
11818 // table row. This allows us to add a click handler to the row
11819 // itself (to toggle row selection) without erroneously
11820 // intercepting click events from ItemActions.
11821 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11822 "td",
11823 {
11824 className: clsx_default("dataviews-view-table__actions-column", {
11825 "dataviews-view-table__actions-column--sticky": true,
11826 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11827 }),
11828 onClick: (e2) => e2.stopPropagation(),
11829 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
11830 }
11831 )
11832 ]
11833 }
11834 );
11835 }
11836 function ViewTable({
11837 actions,
11838 data,
11839 fields,
11840 getItemId,
11841 getItemLevel,
11842 isLoading = false,
11843 onChangeView,
11844 onChangeSelection,
11845 selection,
11846 setOpenedFilter,
11847 onClickItem,
11848 isItemClickable,
11849 renderItemLink,
11850 view,
11851 className,
11852 empty
11853 }) {
11854 const { containerRef } = (0, import_element32.useContext)(dataviews_context_default);
11855 const isDelayedLoading = useDelayedLoading(isLoading);
11856 const headerMenuRefs = (0, import_element32.useRef)(/* @__PURE__ */ new Map());
11857 const headerMenuToFocusRef = (0, import_element32.useRef)(void 0);
11858 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element32.useState)();
11859 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element32.useState)(null);
11860 (0, import_element32.useEffect)(() => {
11861 if (headerMenuToFocusRef.current) {
11862 headerMenuToFocusRef.current.focus();
11863 headerMenuToFocusRef.current = void 0;
11864 }
11865 });
11866 const tableNoticeId = (0, import_element32.useId)();
11867 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11868 scrollContainerRef: containerRef,
11869 enabledHorizontal: !!actions?.length
11870 });
11871 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11872 if (nextHeaderMenuToFocus) {
11873 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11874 setNextHeaderMenuToFocus(void 0);
11875 return;
11876 }
11877 const onHide = (field) => {
11878 const hidden = headerMenuRefs.current.get(field.id);
11879 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11880 setNextHeaderMenuToFocus(fallback?.node);
11881 };
11882 const handleHeaderContextMenu = (event) => {
11883 event.preventDefault();
11884 event.stopPropagation();
11885 const virtualAnchor = {
11886 getBoundingClientRect: () => ({
11887 x: event.clientX,
11888 y: event.clientY,
11889 top: event.clientY,
11890 left: event.clientX,
11891 right: event.clientX,
11892 bottom: event.clientY,
11893 width: 0,
11894 height: 0,
11895 toJSON: () => ({})
11896 })
11897 };
11898 window.requestAnimationFrame(() => {
11899 setContextMenuAnchor(virtualAnchor);
11900 });
11901 };
11902 const hasData = !!data?.length;
11903 const titleField = fields.find((field) => field.id === view.titleField);
11904 const mediaField = fields.find((field) => field.id === view.mediaField);
11905 const descriptionField = fields.find(
11906 (field) => field.id === view.descriptionField
11907 );
11908 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11909 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11910 const { showTitle = true, showMedia = true, showDescription = true } = view;
11911 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11912 const columns = view.fields ?? [];
11913 const headerMenuRef = (column, index2) => (node) => {
11914 if (node) {
11915 headerMenuRefs.current.set(column, {
11916 node,
11917 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11918 });
11919 } else {
11920 headerMenuRefs.current.delete(column);
11921 }
11922 };
11923 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11924 const isRtl = (0, import_i18n10.isRTL)();
11925 if (!hasData) {
11926 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11927 "div",
11928 {
11929 className: clsx_default("dataviews-no-results", {
11930 "is-refreshing": isDelayedLoading
11931 }),
11932 id: tableNoticeId,
11933 children: empty
11934 }
11935 );
11936 }
11937 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
11938 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11939 "table",
11940 {
11941 className: clsx_default("dataviews-view-table", className, {
11942 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11943 view.layout.density
11944 ),
11945 "has-bulk-actions": hasBulkActions,
11946 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11947 }),
11948 "aria-busy": isLoading,
11949 "aria-describedby": tableNoticeId,
11950 role: isInfiniteScroll ? "feed" : void 0,
11951 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11952 children: [
11953 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
11954 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11955 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11956 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11957 "col",
11958 {
11959 className: clsx_default(
11960 `dataviews-view-table__col-${column}`,
11961 {
11962 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11963 }
11964 )
11965 },
11966 `col-${column}`
11967 )),
11968 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
11969 ] }),
11970 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11971 import_components6.Popover,
11972 {
11973 anchor: contextMenuAnchor,
11974 onClose: () => setContextMenuAnchor(null),
11975 placement: "bottom-start",
11976 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
11977 }
11978 ),
11979 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11980 "thead",
11981 {
11982 className: clsx_default({
11983 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11984 }),
11985 onContextMenu: handleHeaderContextMenu,
11986 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11987 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11988 "th",
11989 {
11990 className: "dataviews-view-table__checkbox-column",
11991 scope: "col",
11992 onContextMenu: handleHeaderContextMenu,
11993 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11994 BulkSelectionCheckbox,
11995 {
11996 selection,
11997 onChangeSelection,
11998 data,
11999 actions,
12000 getItemId
12001 }
12002 )
12003 }
12004 ),
12005 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12006 column_header_menu_default,
12007 {
12008 ref: headerMenuRef(
12009 titleField.id,
12010 0
12011 ),
12012 fieldId: titleField.id,
12013 view,
12014 fields,
12015 onChangeView,
12016 onHide,
12017 setOpenedFilter,
12018 canMove: false,
12019 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12020 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12021 }
12022 ) }),
12023 columns.map((column, index2) => {
12024 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12025 const field = fields.find(
12026 (f2) => f2.id === column
12027 );
12028 const effectiveAlign = getEffectiveAlign(
12029 align,
12030 field?.type
12031 );
12032 const canInsertOrMove = view.layout?.enableMoving ?? true;
12033 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12034 "th",
12035 {
12036 style: {
12037 width,
12038 maxWidth,
12039 minWidth,
12040 textAlign: effectiveAlign
12041 },
12042 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12043 scope: "col",
12044 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12045 column_header_menu_default,
12046 {
12047 ref: headerMenuRef(column, index2),
12048 fieldId: column,
12049 view,
12050 fields,
12051 onChangeView,
12052 onHide,
12053 setOpenedFilter,
12054 canMove: canInsertOrMove,
12055 canInsertLeft: canInsertOrMove,
12056 canInsertRight: canInsertOrMove
12057 }
12058 )
12059 },
12060 column
12061 );
12062 }),
12063 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12064 "th",
12065 {
12066 className: clsx_default(
12067 "dataviews-view-table__actions-column",
12068 {
12069 "dataviews-view-table__actions-column--sticky": true,
12070 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12071 }
12072 ),
12073 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12074 }
12075 )
12076 ] })
12077 }
12078 ),
12079 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12080 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12081 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12082 "td",
12083 {
12084 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12085 className: "dataviews-view-table__group-header-cell",
12086 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12087 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12088 (0, import_i18n10.__)("%1$s: %2$s"),
12089 groupField.label,
12090 groupName
12091 )
12092 }
12093 ) }),
12094 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12095 TableRow,
12096 {
12097 item,
12098 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12099 hasBulkActions,
12100 actions,
12101 fields,
12102 id: getItemId(item) || index2.toString(),
12103 view,
12104 titleField,
12105 mediaField,
12106 descriptionField,
12107 selection,
12108 getItemId,
12109 onChangeSelection,
12110 onClickItem,
12111 renderItemLink,
12112 isItemClickable,
12113 isActionsColumnSticky: !isHorizontalScrollEnd
12114 },
12115 getItemId(item)
12116 ))
12117 ] }, `group-${groupName}`)
12118 ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12119 TableRow,
12120 {
12121 item,
12122 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12123 hasBulkActions,
12124 actions,
12125 fields,
12126 id: getItemId(item) || index2.toString(),
12127 view,
12128 titleField,
12129 mediaField,
12130 descriptionField,
12131 selection,
12132 getItemId,
12133 onChangeSelection,
12134 onClickItem,
12135 renderItemLink,
12136 isItemClickable,
12137 isActionsColumnSticky: !isHorizontalScrollEnd,
12138 posinset: isInfiniteScroll ? index2 + 1 : void 0
12139 },
12140 getItemId(item)
12141 )) })
12142 ]
12143 }
12144 ),
12145 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components6.Spinner, {}) }) })
12146 ] });
12147 }
12148 var table_default = ViewTable;
12149
12150 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12151 var import_components9 = __toESM(require_components(), 1);
12152 var import_i18n13 = __toESM(require_i18n(), 1);
12153
12154 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12155 var import_components8 = __toESM(require_components(), 1);
12156 var import_i18n12 = __toESM(require_i18n(), 1);
12157 var import_compose3 = __toESM(require_compose(), 1);
12158 var import_keycodes2 = __toESM(require_keycodes(), 1);
12159 var import_element36 = __toESM(require_element(), 1);
12160
12161 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12162 var import_components7 = __toESM(require_components(), 1);
12163 var import_i18n11 = __toESM(require_i18n(), 1);
12164 var import_element33 = __toESM(require_element(), 1);
12165 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12166 var imageSizes = [
12167 {
12168 value: 120,
12169 breakpoint: 1
12170 },
12171 {
12172 value: 170,
12173 breakpoint: 1
12174 },
12175 {
12176 value: 230,
12177 breakpoint: 1
12178 },
12179 {
12180 value: 290,
12181 breakpoint: 1112
12182 // at minimum image width, 4 images display at this container size
12183 },
12184 {
12185 value: 350,
12186 breakpoint: 1636
12187 // at minimum image width, 6 images display at this container size
12188 },
12189 {
12190 value: 430,
12191 breakpoint: 588
12192 // at minimum image width, 2 images display at this container size
12193 }
12194 ];
12195 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12196 function useGridColumns() {
12197 const context = (0, import_element33.useContext)(dataviews_context_default);
12198 const view = context.view;
12199 return (0, import_element33.useMemo)(() => {
12200 const containerWidth = context.containerWidth;
12201 const gap = 32;
12202 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12203 const columns = Math.floor(
12204 (containerWidth + gap) / (previewSize + gap)
12205 );
12206 return Math.max(1, columns);
12207 }, [context.containerWidth, view.layout?.previewSize]);
12208 }
12209
12210 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12211 var import_element34 = __toESM(require_element(), 1);
12212 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12213 var GridItems = (0, import_element34.forwardRef)(({ className, previewSize, ...props }, ref) => {
12214 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12215 "div",
12216 {
12217 ref,
12218 className: clsx_default("dataviews-view-grid-items", className),
12219 style: {
12220 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12221 },
12222 ...props
12223 }
12224 );
12225 });
12226
12227 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12228 var import_element35 = __toESM(require_element(), 1);
12229 function useIntersectionObserver(elementRef, posinset) {
12230 const { intersectionObserver } = (0, import_element35.useContext)(dataviews_context_default);
12231 (0, import_element35.useEffect)(() => {
12232 const element = elementRef.current;
12233 if (!element || posinset === void 0 || !intersectionObserver) {
12234 return;
12235 }
12236 intersectionObserver.observe(element);
12237 return () => {
12238 intersectionObserver.unobserve(element);
12239 };
12240 }, [elementRef, intersectionObserver, posinset]);
12241 }
12242 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12243 const hasData = !!data?.length;
12244 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12245 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12246 }
12247
12248 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12249 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12250 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12251 function chunk(array, size4) {
12252 const chunks = [];
12253 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12254 chunks.push(array.slice(i2, i2 + size4));
12255 }
12256 return chunks;
12257 }
12258 var GridItem = (0, import_element36.forwardRef)(
12259 function GridItem2({
12260 view,
12261 selection,
12262 onChangeSelection,
12263 onClickItem,
12264 isItemClickable,
12265 renderItemLink,
12266 getItemId,
12267 item,
12268 actions,
12269 mediaField,
12270 titleField,
12271 descriptionField,
12272 regularFields,
12273 badgeFields,
12274 hasBulkActions,
12275 config,
12276 posinset,
12277 setsize,
12278 ...props
12279 }, forwardedRef) {
12280 const {
12281 showTitle = true,
12282 showMedia = true,
12283 showDescription = true
12284 } = view;
12285 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12286 const id = getItemId(item);
12287 const elementRef = (0, import_element36.useRef)(null);
12288 const setRefs = (0, import_element36.useCallback)(
12289 (node) => {
12290 elementRef.current = node;
12291 if (typeof forwardedRef === "function") {
12292 forwardedRef(node);
12293 } else if (forwardedRef) {
12294 forwardedRef.current = node;
12295 }
12296 },
12297 [forwardedRef]
12298 );
12299 useIntersectionObserver(elementRef, posinset);
12300 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12301 const isSelected2 = selection.includes(id);
12302 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12303 const rendersMediaField = showMedia && mediaField?.render;
12304 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12305 mediaField.render,
12306 {
12307 item,
12308 field: mediaField,
12309 config
12310 }
12311 ) : mediaPlaceholder;
12312 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12313 let mediaA11yProps;
12314 let titleA11yProps;
12315 if (isItemClickable(item) && onClickItem) {
12316 if (renderedTitleField) {
12317 mediaA11yProps = {
12318 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12319 };
12320 titleA11yProps = {
12321 id: `dataviews-view-grid__title-field-${instanceId}`
12322 };
12323 } else {
12324 mediaA11yProps = {
12325 "aria-label": (0, import_i18n12.__)("Navigate to item")
12326 };
12327 }
12328 }
12329 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12330 Stack,
12331 {
12332 direction: "column",
12333 ...props,
12334 ref: setRefs,
12335 "aria-setsize": setsize,
12336 "aria-posinset": posinset,
12337 className: clsx_default(
12338 props.className,
12339 "dataviews-view-grid__row__gridcell",
12340 "dataviews-view-grid__card",
12341 {
12342 "is-selected": hasBulkAction && isSelected2
12343 }
12344 ),
12345 onClickCapture: (event) => {
12346 props.onClickCapture?.(event);
12347 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12348 event.stopPropagation();
12349 event.preventDefault();
12350 if (!hasBulkAction) {
12351 return;
12352 }
12353 onChangeSelection(
12354 isSelected2 ? selection.filter(
12355 (itemId) => id !== itemId
12356 ) : [...selection, id]
12357 );
12358 }
12359 },
12360 children: [
12361 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12362 ItemClickWrapper,
12363 {
12364 item,
12365 isItemClickable,
12366 onClickItem,
12367 renderItemLink,
12368 className: clsx_default("dataviews-view-grid__media", {
12369 "dataviews-view-grid__media--placeholder": !rendersMediaField
12370 }),
12371 ...mediaA11yProps,
12372 children: renderedMediaField
12373 }
12374 ),
12375 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12376 DataViewsSelectionCheckbox,
12377 {
12378 item,
12379 selection,
12380 onChangeSelection,
12381 getItemId,
12382 titleField,
12383 disabled: !hasBulkAction
12384 }
12385 ),
12386 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12387 ItemActions,
12388 {
12389 item,
12390 actions,
12391 isCompact: true
12392 }
12393 ) }),
12394 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12395 ItemClickWrapper,
12396 {
12397 item,
12398 isItemClickable,
12399 onClickItem,
12400 renderItemLink,
12401 className: "dataviews-view-grid__title-field dataviews-title-field",
12402 ...titleA11yProps,
12403 title: titleField?.getValueFormatted({
12404 item,
12405 field: titleField
12406 }) || void 0,
12407 children: renderedTitleField
12408 }
12409 ) }),
12410 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12411 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12412 descriptionField.render,
12413 {
12414 item,
12415 field: descriptionField
12416 }
12417 ),
12418 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12419 Stack,
12420 {
12421 direction: "row",
12422 className: "dataviews-view-grid__badge-fields",
12423 gap: "sm",
12424 wrap: "wrap",
12425 align: "top",
12426 justify: "flex-start",
12427 children: badgeFields.map((field) => {
12428 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12429 WCBadge,
12430 {
12431 className: "dataviews-view-grid__field-value",
12432 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12433 field.render,
12434 {
12435 item,
12436 field
12437 }
12438 )
12439 },
12440 field.id
12441 );
12442 })
12443 }
12444 ),
12445 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12446 Stack,
12447 {
12448 direction: "column",
12449 className: "dataviews-view-grid__fields",
12450 gap: "xs",
12451 children: regularFields.map((field) => {
12452 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12453 import_components8.Flex,
12454 {
12455 className: "dataviews-view-grid__field",
12456 gap: 1,
12457 justify: "flex-start",
12458 expanded: true,
12459 style: { height: "auto" },
12460 direction: "row",
12461 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12462 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12463 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12464 tooltip_exports.Trigger,
12465 {
12466 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12467 }
12468 ),
12469 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12470 ] }),
12471 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12472 import_components8.FlexItem,
12473 {
12474 className: "dataviews-view-grid__field-value",
12475 style: { maxHeight: "none" },
12476 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12477 field.render,
12478 {
12479 item,
12480 field
12481 }
12482 )
12483 }
12484 )
12485 ] })
12486 },
12487 field.id
12488 );
12489 })
12490 }
12491 )
12492 ] })
12493 ]
12494 }
12495 );
12496 }
12497 );
12498 function CompositeGrid({
12499 data,
12500 isInfiniteScroll,
12501 className,
12502 inert,
12503 isLoading,
12504 view,
12505 fields,
12506 selection,
12507 onChangeSelection,
12508 onClickItem,
12509 isItemClickable,
12510 renderItemLink,
12511 getItemId,
12512 actions
12513 }) {
12514 const { paginationInfo, resizeObserverRef } = (0, import_element36.useContext)(dataviews_context_default);
12515 const gridColumns = useGridColumns();
12516 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12517 const titleField = fields.find(
12518 (field) => field.id === view?.titleField
12519 );
12520 const mediaField = fields.find(
12521 (field) => field.id === view?.mediaField
12522 );
12523 const descriptionField = fields.find(
12524 (field) => field.id === view?.descriptionField
12525 );
12526 const otherFields = view.fields ?? [];
12527 const { regularFields, badgeFields } = otherFields.reduce(
12528 (accumulator, fieldId) => {
12529 const field = fields.find((f2) => f2.id === fieldId);
12530 if (!field) {
12531 return accumulator;
12532 }
12533 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12534 accumulator[key].push(field);
12535 return accumulator;
12536 },
12537 { regularFields: [], badgeFields: [] }
12538 );
12539 const size4 = "900px";
12540 const totalRows = Math.ceil(data.length / gridColumns);
12541 const placeholdersNeeded = usePlaceholdersNeeded(
12542 data,
12543 isInfiniteScroll,
12544 gridColumns
12545 );
12546 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12547 // Render infinite scroll layout (no rows, feed semantics)
12548 children: [
12549 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12550 import_components8.Composite,
12551 {
12552 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12553 GridItems,
12554 {
12555 className: clsx_default(
12556 "dataviews-view-grid-infinite-scroll",
12557 className,
12558 {
12559 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12560 "compact",
12561 "comfortable"
12562 ].includes(view.layout.density)
12563 }
12564 ),
12565 previewSize: view.layout?.previewSize,
12566 "aria-busy": isLoading,
12567 ref: resizeObserverRef
12568 }
12569 ),
12570 role: "feed",
12571 focusWrap: true,
12572 inert,
12573 children: [
12574 Array.from({ length: placeholdersNeeded }).map(
12575 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12576 import_components8.Composite.Item,
12577 {
12578 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12579 Stack,
12580 {
12581 ...props,
12582 direction: "column",
12583 role: "article",
12584 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12585 }
12586 ),
12587 "aria-hidden": true,
12588 tabIndex: -1
12589 },
12590 `placeholder-${index2}`
12591 )
12592 ),
12593 data.map((item) => {
12594 const itemId = getItemId(item);
12595 const stablePosition = item.position;
12596 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12597 import_components8.Composite.Item,
12598 {
12599 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12600 GridItem,
12601 {
12602 ...props,
12603 id: itemId,
12604 role: "article",
12605 view,
12606 selection,
12607 onChangeSelection,
12608 onClickItem,
12609 isItemClickable,
12610 renderItemLink,
12611 getItemId,
12612 item,
12613 actions,
12614 mediaField,
12615 titleField,
12616 descriptionField,
12617 regularFields,
12618 badgeFields,
12619 hasBulkActions,
12620 posinset: stablePosition,
12621 setsize: paginationInfo.totalItems,
12622 config: {
12623 sizes: size4
12624 }
12625 }
12626 )
12627 },
12628 itemId
12629 );
12630 })
12631 ]
12632 }
12633 ),
12634 // Render standard grid layout (with rows, grid semantics)
12635 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12636 import_components8.Composite,
12637 {
12638 role: "grid",
12639 className: clsx_default("dataviews-view-grid", className, {
12640 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12641 view.layout.density
12642 )
12643 }),
12644 focusWrap: true,
12645 "aria-busy": isLoading,
12646 "aria-rowcount": totalRows,
12647 ref: resizeObserverRef,
12648 inert,
12649 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12650 import_components8.Composite.Row,
12651 {
12652 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12653 "div",
12654 {
12655 role: "row",
12656 "aria-rowindex": i2 + 1,
12657 "aria-label": (0, import_i18n12.sprintf)(
12658 /* translators: %d: The row number in the grid */
12659 (0, import_i18n12.__)("Row %d"),
12660 i2 + 1
12661 ),
12662 className: "dataviews-view-grid__row",
12663 style: {
12664 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12665 }
12666 }
12667 ),
12668 children: row.map((item) => {
12669 const itemId = getItemId(item);
12670 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12671 import_components8.Composite.Item,
12672 {
12673 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12674 GridItem,
12675 {
12676 ...props,
12677 id: itemId,
12678 role: "gridcell",
12679 view,
12680 selection,
12681 onChangeSelection,
12682 onClickItem,
12683 isItemClickable,
12684 renderItemLink,
12685 getItemId,
12686 item,
12687 actions,
12688 mediaField,
12689 titleField,
12690 descriptionField,
12691 regularFields,
12692 badgeFields,
12693 hasBulkActions,
12694 config: {
12695 sizes: size4
12696 }
12697 }
12698 )
12699 },
12700 itemId
12701 );
12702 })
12703 },
12704 i2
12705 ))
12706 }
12707 )
12708 ]
12709 });
12710 }
12711
12712 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12713 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12714 function ViewGrid({
12715 actions,
12716 data,
12717 fields,
12718 getItemId,
12719 isLoading,
12720 onChangeSelection,
12721 onClickItem,
12722 isItemClickable,
12723 renderItemLink,
12724 selection,
12725 view,
12726 className,
12727 empty
12728 }) {
12729 const isDelayedLoading = useDelayedLoading(!!isLoading);
12730 const hasData = !!data?.length;
12731 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12732 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12733 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12734 if (!hasData) {
12735 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12736 "div",
12737 {
12738 className: clsx_default("dataviews-no-results", {
12739 "is-refreshing": isDelayedLoading
12740 }),
12741 children: empty
12742 }
12743 );
12744 }
12745 const gridProps = {
12746 className: clsx_default(className, {
12747 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12748 }),
12749 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12750 isLoading,
12751 view,
12752 fields,
12753 selection,
12754 onChangeSelection,
12755 onClickItem,
12756 isItemClickable,
12757 renderItemLink,
12758 getItemId,
12759 actions
12760 };
12761 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
12762 // Render multiple groups.
12763 children: [
12764 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12765 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12766 Stack,
12767 {
12768 direction: "column",
12769 gap: "sm",
12770 children: [
12771 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12772 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12773 (0, import_i18n13.__)("%1$s: %2$s"),
12774 groupField.label,
12775 groupName
12776 ) }),
12777 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12778 CompositeGrid,
12779 {
12780 ...gridProps,
12781 data: groupItems,
12782 isInfiniteScroll: false
12783 }
12784 )
12785 ]
12786 },
12787 groupName
12788 )
12789 ) }),
12790 // Render a single grid with all data.
12791 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12792 CompositeGrid,
12793 {
12794 ...gridProps,
12795 data,
12796 isInfiniteScroll: !!isInfiniteScroll
12797 }
12798 ),
12799 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
12800 ]
12801 });
12802 }
12803 var grid_default = ViewGrid;
12804
12805 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12806 var import_compose4 = __toESM(require_compose(), 1);
12807 var import_components10 = __toESM(require_components(), 1);
12808 var import_element37 = __toESM(require_element(), 1);
12809 var import_i18n14 = __toESM(require_i18n(), 1);
12810 var import_data3 = __toESM(require_data(), 1);
12811 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
12812 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12813 function generateItemWrapperCompositeId(idPrefix) {
12814 return `${idPrefix}-item-wrapper`;
12815 }
12816 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12817 return `${idPrefix}-primary-action-${primaryActionId}`;
12818 }
12819 function generateDropdownTriggerCompositeId(idPrefix) {
12820 return `${idPrefix}-dropdown`;
12821 }
12822 function PrimaryActionGridCell({
12823 idPrefix,
12824 primaryAction,
12825 item
12826 }) {
12827 const registry = (0, import_data3.useRegistry)();
12828 const [isModalOpen, setIsModalOpen] = (0, import_element37.useState)(false);
12829 const compositeItemId = generatePrimaryActionCompositeId(
12830 idPrefix,
12831 primaryAction.id
12832 );
12833 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12834 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12835 import_components10.Composite.Item,
12836 {
12837 id: compositeItemId,
12838 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12839 import_components10.Button,
12840 {
12841 disabled: !!primaryAction.disabled,
12842 accessibleWhenDisabled: true,
12843 text: label,
12844 size: "small",
12845 onClick: () => setIsModalOpen(true)
12846 }
12847 ),
12848 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12849 ActionModal,
12850 {
12851 action: primaryAction,
12852 items: [item],
12853 closeModal: () => setIsModalOpen(false)
12854 }
12855 )
12856 }
12857 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12858 import_components10.Composite.Item,
12859 {
12860 id: compositeItemId,
12861 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12862 import_components10.Button,
12863 {
12864 disabled: !!primaryAction.disabled,
12865 accessibleWhenDisabled: true,
12866 size: "small",
12867 onClick: () => {
12868 primaryAction.callback([item], { registry });
12869 },
12870 children: label
12871 }
12872 )
12873 }
12874 ) }, primaryAction.id);
12875 }
12876 function ListItem({
12877 view,
12878 actions,
12879 idPrefix,
12880 isSelected: isSelected2,
12881 item,
12882 titleField,
12883 mediaField,
12884 descriptionField,
12885 onSelect,
12886 otherFields,
12887 onDropdownTriggerKeyDown,
12888 posinset
12889 }) {
12890 const {
12891 showTitle = true,
12892 showMedia = true,
12893 showDescription = true,
12894 infiniteScrollEnabled
12895 } = view;
12896 const itemRef = (0, import_element37.useRef)(null);
12897 const labelId = `${idPrefix}-label`;
12898 const descriptionId = `${idPrefix}-description`;
12899 const registry = (0, import_data3.useRegistry)();
12900 const [isHovered, setIsHovered] = (0, import_element37.useState)(false);
12901 const [activeModalAction, setActiveModalAction] = (0, import_element37.useState)(
12902 null
12903 );
12904 const handleHover = ({ type }) => {
12905 const isHover = type === "mouseenter";
12906 setIsHovered(isHover);
12907 };
12908 const { paginationInfo } = (0, import_element37.useContext)(dataviews_context_default);
12909 (0, import_element37.useEffect)(() => {
12910 if (isSelected2) {
12911 itemRef.current?.scrollIntoView({
12912 behavior: "auto",
12913 block: "nearest",
12914 inline: "nearest"
12915 });
12916 }
12917 }, [isSelected2]);
12918 const { primaryAction, eligibleActions } = (0, import_element37.useMemo)(() => {
12919 const _eligibleActions = actions.filter(
12920 (action) => !action.isEligible || action.isEligible(item)
12921 );
12922 const _primaryActions = _eligibleActions.filter(
12923 (action) => action.isPrimary
12924 );
12925 return {
12926 primaryAction: _primaryActions[0],
12927 eligibleActions: _eligibleActions
12928 };
12929 }, [actions, item]);
12930 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12931 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12932 mediaField.render,
12933 {
12934 item,
12935 field: mediaField,
12936 config: { sizes: "52px" }
12937 }
12938 ) }) : null;
12939 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
12940 const renderDescription = showDescription && descriptionField?.render;
12941 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12942 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
12943 Stack,
12944 {
12945 direction: "row",
12946 gap: "md",
12947 className: "dataviews-view-list__item-actions",
12948 children: [
12949 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12950 PrimaryActionGridCell,
12951 {
12952 idPrefix,
12953 primaryAction,
12954 item
12955 }
12956 ),
12957 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
12958 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
12959 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12960 Menu3.TriggerButton,
12961 {
12962 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12963 import_components10.Composite.Item,
12964 {
12965 id: generateDropdownTriggerCompositeId(
12966 idPrefix
12967 ),
12968 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12969 import_components10.Button,
12970 {
12971 size: "small",
12972 icon: more_vertical_default,
12973 label: (0, import_i18n14.__)("Actions"),
12974 accessibleWhenDisabled: true,
12975 disabled: !actions.length,
12976 onKeyDown: onDropdownTriggerKeyDown
12977 }
12978 )
12979 }
12980 )
12981 }
12982 ),
12983 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12984 ActionsMenuGroup,
12985 {
12986 actions: eligibleActions,
12987 item,
12988 registry,
12989 setActiveModalAction
12990 }
12991 ) })
12992 ] }),
12993 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12994 ActionModal,
12995 {
12996 action: activeModalAction,
12997 items: [item],
12998 closeModal: () => setActiveModalAction(null)
12999 }
13000 )
13001 ] })
13002 ]
13003 }
13004 );
13005 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13006 import_components10.Composite.Row,
13007 {
13008 ref: itemRef,
13009 render: (
13010 /* aria-posinset breaks Composite.Row if passed to it directly. */
13011 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13012 "div",
13013 {
13014 "aria-posinset": posinset,
13015 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13016 }
13017 )
13018 ),
13019 role: infiniteScrollEnabled ? "article" : "row",
13020 className: clsx_default({
13021 "is-selected": isSelected2,
13022 "is-hovered": isHovered
13023 }),
13024 onMouseEnter: handleHover,
13025 onMouseLeave: handleHover,
13026 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13027 Stack,
13028 {
13029 direction: "row",
13030 className: "dataviews-view-list__item-wrapper",
13031 children: [
13032 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13033 import_components10.Composite.Item,
13034 {
13035 id: generateItemWrapperCompositeId(idPrefix),
13036 "aria-pressed": isSelected2,
13037 "aria-labelledby": labelId,
13038 "aria-describedby": descriptionId,
13039 className: "dataviews-view-list__item",
13040 onClick: () => onSelect(item)
13041 }
13042 ) }),
13043 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13044 Stack,
13045 {
13046 direction: "row",
13047 gap: "md",
13048 justify: "start",
13049 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13050 style: { flex: 1, minWidth: 0 },
13051 children: [
13052 renderedMediaField,
13053 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13054 Stack,
13055 {
13056 direction: "column",
13057 gap: "xs",
13058 className: "dataviews-view-list__field-wrapper",
13059 children: [
13060 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13061 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13062 "div",
13063 {
13064 className: "dataviews-title-field dataviews-view-list__title-field",
13065 id: labelId,
13066 children: renderedTitleField
13067 }
13068 ),
13069 usedActions
13070 ] }),
13071 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13072 descriptionField.render,
13073 {
13074 item,
13075 field: descriptionField
13076 }
13077 ) }),
13078 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13079 "div",
13080 {
13081 className: "dataviews-view-list__fields",
13082 id: descriptionId,
13083 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13084 "div",
13085 {
13086 className: "dataviews-view-list__field",
13087 children: [
13088 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13089 VisuallyHidden,
13090 {
13091 className: "dataviews-view-list__field-label",
13092 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13093 children: field.label
13094 }
13095 ),
13096 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13097 field.render,
13098 {
13099 item,
13100 field
13101 }
13102 ) })
13103 ]
13104 },
13105 field.id
13106 ))
13107 }
13108 )
13109 ]
13110 }
13111 )
13112 ]
13113 }
13114 )
13115 ]
13116 }
13117 )
13118 }
13119 );
13120 }
13121 function isDefined2(item) {
13122 return !!item;
13123 }
13124 function ViewList(props) {
13125 const {
13126 actions,
13127 data,
13128 fields,
13129 getItemId,
13130 isLoading,
13131 onChangeSelection,
13132 selection,
13133 view,
13134 className,
13135 empty
13136 } = props;
13137 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13138 const isDelayedLoading = useDelayedLoading(!!isLoading);
13139 const selectedItem = data?.findLast(
13140 (item) => selection.includes(getItemId(item))
13141 );
13142 const titleField = fields.find((field) => field.id === view.titleField);
13143 const mediaField = fields.find((field) => field.id === view.mediaField);
13144 const descriptionField = fields.find(
13145 (field) => field.id === view.descriptionField
13146 );
13147 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13148 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13149 const generateCompositeItemIdPrefix = (0, import_element37.useCallback)(
13150 (item) => `${baseId}-${getItemId(item)}`,
13151 [baseId, getItemId]
13152 );
13153 const isActiveCompositeItem = (0, import_element37.useCallback)(
13154 (item, idToCheck) => {
13155 return idToCheck.startsWith(
13156 generateCompositeItemIdPrefix(item)
13157 );
13158 },
13159 [generateCompositeItemIdPrefix]
13160 );
13161 const [activeCompositeId, setActiveCompositeId] = (0, import_element37.useState)(void 0);
13162 const compositeRef = (0, import_element37.useRef)(null);
13163 (0, import_element37.useEffect)(() => {
13164 if (selectedItem) {
13165 setActiveCompositeId(
13166 generateItemWrapperCompositeId(
13167 generateCompositeItemIdPrefix(selectedItem)
13168 )
13169 );
13170 }
13171 }, [selectedItem, generateCompositeItemIdPrefix]);
13172 const activeItemIndex = data.findIndex(
13173 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13174 );
13175 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13176 const isActiveIdInList = activeItemIndex !== -1;
13177 const selectCompositeItem = (0, import_element37.useCallback)(
13178 (targetIndex, generateCompositeId) => {
13179 const clampedIndex = Math.min(
13180 data.length - 1,
13181 Math.max(0, targetIndex)
13182 );
13183 if (!data[clampedIndex]) {
13184 return;
13185 }
13186 const itemIdPrefix = generateCompositeItemIdPrefix(
13187 data[clampedIndex]
13188 );
13189 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13190 setActiveCompositeId(targetCompositeItemId);
13191 if (compositeRef.current?.contains(
13192 compositeRef.current.ownerDocument.activeElement
13193 )) {
13194 document.getElementById(targetCompositeItemId)?.focus();
13195 }
13196 },
13197 [data, generateCompositeItemIdPrefix]
13198 );
13199 (0, import_element37.useEffect)(() => {
13200 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13201 if (!isActiveIdInList && wasActiveIdInList) {
13202 selectCompositeItem(
13203 previousActiveItemIndex,
13204 generateItemWrapperCompositeId
13205 );
13206 }
13207 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13208 const onDropdownTriggerKeyDown = (0, import_element37.useCallback)(
13209 (event) => {
13210 if (event.key === "ArrowDown") {
13211 event.preventDefault();
13212 selectCompositeItem(
13213 activeItemIndex + 1,
13214 generateDropdownTriggerCompositeId
13215 );
13216 }
13217 if (event.key === "ArrowUp") {
13218 event.preventDefault();
13219 selectCompositeItem(
13220 activeItemIndex - 1,
13221 generateDropdownTriggerCompositeId
13222 );
13223 }
13224 },
13225 [selectCompositeItem, activeItemIndex]
13226 );
13227 const hasData = !!data?.length;
13228 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13229 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13230 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13231 if (!hasData) {
13232 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13233 "div",
13234 {
13235 className: clsx_default("dataviews-no-results", {
13236 "is-refreshing": isDelayedLoading
13237 }),
13238 children: empty
13239 }
13240 );
13241 }
13242 if (hasData && groupField && dataByGroup) {
13243 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13244 import_components10.Composite,
13245 {
13246 ref: compositeRef,
13247 id: `${baseId}`,
13248 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13249 className: "dataviews-view-list__group",
13250 role: "grid",
13251 activeId: activeCompositeId,
13252 setActiveId: setActiveCompositeId,
13253 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13254 Stack,
13255 {
13256 direction: "column",
13257 gap: "lg",
13258 className: clsx_default("dataviews-view-list", className),
13259 children: Array.from(dataByGroup.entries()).map(
13260 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13261 Stack,
13262 {
13263 direction: "column",
13264 gap: "sm",
13265 children: [
13266 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13267 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13268 (0, import_i18n14.__)("%1$s: %2$s"),
13269 groupField.label,
13270 groupName
13271 ) }),
13272 groupItems.map((item) => {
13273 const id = generateCompositeItemIdPrefix(item);
13274 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13275 ListItem,
13276 {
13277 view,
13278 idPrefix: id,
13279 actions,
13280 item,
13281 isSelected: item === selectedItem,
13282 onSelect,
13283 mediaField,
13284 titleField,
13285 descriptionField,
13286 otherFields,
13287 onDropdownTriggerKeyDown
13288 },
13289 id
13290 );
13291 })
13292 ]
13293 },
13294 groupName
13295 )
13296 )
13297 }
13298 )
13299 }
13300 );
13301 }
13302 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13303 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13304 import_components10.Composite,
13305 {
13306 ref: compositeRef,
13307 id: baseId,
13308 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13309 className: clsx_default("dataviews-view-list", className, {
13310 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13311 view.layout.density
13312 ),
13313 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13314 }),
13315 role: view.infiniteScrollEnabled ? "feed" : "grid",
13316 activeId: activeCompositeId,
13317 setActiveId: setActiveCompositeId,
13318 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13319 children: data.map((item, index2) => {
13320 const id = generateCompositeItemIdPrefix(item);
13321 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13322 ListItem,
13323 {
13324 view,
13325 idPrefix: id,
13326 actions,
13327 item,
13328 isSelected: item === selectedItem,
13329 onSelect,
13330 mediaField,
13331 titleField,
13332 descriptionField,
13333 otherFields,
13334 onDropdownTriggerKeyDown,
13335 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13336 },
13337 id
13338 );
13339 })
13340 }
13341 ),
13342 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {}) })
13343 ] });
13344 }
13345
13346 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13347 var import_components11 = __toESM(require_components(), 1);
13348
13349 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13350 var import_i18n15 = __toESM(require_i18n(), 1);
13351 var import_element38 = __toESM(require_element(), 1);
13352 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13353 function ActivityGroup({
13354 groupName,
13355 groupData,
13356 groupField,
13357 showLabel = true,
13358 children
13359 }) {
13360 const groupHeader = showLabel ? (0, import_element38.createInterpolateElement)(
13361 // translators: %s: The label of the field e.g. "Status".
13362 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13363 {
13364 groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13365 groupField.render,
13366 {
13367 item: groupData[0],
13368 field: groupField
13369 }
13370 )
13371 }
13372 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13373 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13374 Stack,
13375 {
13376 direction: "column",
13377 className: "dataviews-view-activity__group",
13378 children: [
13379 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13380 children
13381 ]
13382 },
13383 groupName
13384 );
13385 }
13386
13387 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13388 var import_element39 = __toESM(require_element(), 1);
13389 var import_data4 = __toESM(require_data(), 1);
13390 var import_compose5 = __toESM(require_compose(), 1);
13391 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13392 function ActivityItem(props) {
13393 const {
13394 view,
13395 actions,
13396 item,
13397 titleField,
13398 mediaField,
13399 descriptionField,
13400 otherFields,
13401 posinset,
13402 onClickItem,
13403 renderItemLink,
13404 isItemClickable
13405 } = props;
13406 const {
13407 showTitle = true,
13408 showMedia = true,
13409 showDescription = true,
13410 infiniteScrollEnabled
13411 } = view;
13412 const itemRef = (0, import_element39.useRef)(null);
13413 const registry = (0, import_data4.useRegistry)();
13414 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
13415 const { primaryActions, eligibleActions } = (0, import_element39.useMemo)(() => {
13416 const _eligibleActions = actions.filter(
13417 (action) => !action.isEligible || action.isEligible(item)
13418 );
13419 const _primaryActions = _eligibleActions.filter(
13420 (action) => action.isPrimary
13421 );
13422 return {
13423 primaryActions: _primaryActions,
13424 eligibleActions: _eligibleActions
13425 };
13426 }, [actions, item]);
13427 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13428 const density = view.layout?.density ?? "balanced";
13429 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13430 mediaField.render,
13431 {
13432 item,
13433 field: mediaField,
13434 config: {
13435 sizes: density === "comfortable" ? "32px" : "24px"
13436 }
13437 }
13438 ) : null;
13439 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13440 "span",
13441 {
13442 className: "dataviews-view-activity__item-bullet",
13443 "aria-hidden": "true"
13444 }
13445 ) });
13446 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13447 const verticalGap = (0, import_element39.useMemo)(() => {
13448 switch (density) {
13449 case "comfortable":
13450 return "md";
13451 default:
13452 return "sm";
13453 }
13454 }, [density]);
13455 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13456 "div",
13457 {
13458 ref: itemRef,
13459 role: infiniteScrollEnabled ? "article" : void 0,
13460 "aria-posinset": posinset,
13461 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13462 className: clsx_default(
13463 "dataviews-view-activity__item",
13464 density === "compact" && "is-compact",
13465 density === "balanced" && "is-balanced",
13466 density === "comfortable" && "is-comfortable"
13467 ),
13468 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13469 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13470 Stack,
13471 {
13472 direction: "column",
13473 gap: "xs",
13474 align: "center",
13475 className: "dataviews-view-activity__item-type",
13476 children: renderedMediaField
13477 }
13478 ),
13479 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13480 Stack,
13481 {
13482 direction: "column",
13483 gap: verticalGap,
13484 align: "flex-start",
13485 className: "dataviews-view-activity__item-content",
13486 children: [
13487 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13488 ItemClickWrapper,
13489 {
13490 item,
13491 isItemClickable,
13492 onClickItem,
13493 renderItemLink,
13494 className: "dataviews-view-activity__item-title",
13495 children: renderedTitleField
13496 }
13497 ),
13498 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13499 descriptionField.render,
13500 {
13501 item,
13502 field: descriptionField
13503 }
13504 ) }),
13505 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13506 "div",
13507 {
13508 className: "dataviews-view-activity__item-field",
13509 children: [
13510 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13511 VisuallyHidden,
13512 {
13513 className: "dataviews-view-activity__item-field-label",
13514 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13515 children: field.label
13516 }
13517 ),
13518 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13519 field.render,
13520 {
13521 item,
13522 field
13523 }
13524 ) })
13525 ]
13526 },
13527 field.id
13528 )) }),
13529 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13530 PrimaryActions,
13531 {
13532 item,
13533 actions: primaryActions,
13534 registry,
13535 buttonVariant: "secondary"
13536 }
13537 )
13538 ]
13539 }
13540 ),
13541 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13542 // there if there are any actions at all.
13543 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13544 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13545 ItemActions,
13546 {
13547 item,
13548 actions: eligibleActions,
13549 isCompact: true
13550 }
13551 ) })
13552 ] })
13553 }
13554 );
13555 }
13556 var activity_item_default = ActivityItem;
13557
13558 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13559 var import_react10 = __toESM(require_react(), 1);
13560 function isDefined3(item) {
13561 return !!item;
13562 }
13563 function ActivityItems(props) {
13564 const { data, fields, getItemId, view } = props;
13565 const titleField = fields.find((field) => field.id === view.titleField);
13566 const mediaField = fields.find((field) => field.id === view.mediaField);
13567 const descriptionField = fields.find(
13568 (field) => field.id === view.descriptionField
13569 );
13570 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13571 return data.map((item, index2) => {
13572 return /* @__PURE__ */ (0, import_react10.createElement)(
13573 activity_item_default,
13574 {
13575 ...props,
13576 key: getItemId(item),
13577 item,
13578 mediaField,
13579 titleField,
13580 descriptionField,
13581 otherFields,
13582 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13583 }
13584 );
13585 });
13586 }
13587
13588 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13589 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13590 function ViewActivity(props) {
13591 const { empty, data, fields, isLoading, view, className } = props;
13592 const isDelayedLoading = useDelayedLoading(!!isLoading);
13593 const hasData = !!data?.length;
13594 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13595 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13596 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13597 if (!hasData) {
13598 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13599 "div",
13600 {
13601 className: clsx_default("dataviews-no-results", {
13602 "is-refreshing": isDelayedLoading
13603 }),
13604 children: empty
13605 }
13606 );
13607 }
13608 const isInert = !isInfiniteScroll && !!isLoading;
13609 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13610 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13611 });
13612 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13613 if (hasData && groupField && dataByGroup) {
13614 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13615 Stack,
13616 {
13617 direction: "column",
13618 gap: "sm",
13619 className: wrapperClassName,
13620 inert: isInert ? "true" : void 0,
13621 children: groupedEntries.map(
13622 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13623 ActivityGroup,
13624 {
13625 groupName,
13626 groupData,
13627 groupField,
13628 showLabel: view.groupBy?.showLabel !== false,
13629 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13630 ActivityItems,
13631 {
13632 ...props,
13633 data: groupData
13634 }
13635 )
13636 },
13637 groupName
13638 )
13639 )
13640 }
13641 );
13642 }
13643 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
13644 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13645 "div",
13646 {
13647 className: wrapperClassName,
13648 role: view.infiniteScrollEnabled ? "feed" : void 0,
13649 inert: isInert ? "true" : void 0,
13650 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
13651 }
13652 ),
13653 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
13654 ] });
13655 }
13656
13657 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13658 var import_components14 = __toESM(require_components(), 1);
13659 var import_i18n18 = __toESM(require_i18n(), 1);
13660 var import_compose6 = __toESM(require_compose(), 1);
13661 var import_element42 = __toESM(require_element(), 1);
13662
13663 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13664 var import_components13 = __toESM(require_components(), 1);
13665 var import_data5 = __toESM(require_data(), 1);
13666 var import_element41 = __toESM(require_element(), 1);
13667 var import_i18n17 = __toESM(require_i18n(), 1);
13668
13669 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13670 var import_components12 = __toESM(require_components(), 1);
13671 var import_element40 = __toESM(require_element(), 1);
13672 var import_i18n16 = __toESM(require_i18n(), 1);
13673 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13674 function DataViewsPagination() {
13675 const {
13676 view,
13677 onChangeView,
13678 paginationInfo: { totalItems = 0, totalPages }
13679 } = (0, import_element40.useContext)(dataviews_context_default);
13680 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13681 return null;
13682 }
13683 const currentPage = view.page ?? 1;
13684 const pageSelectOptions = Array.from(Array(totalPages)).map(
13685 (_, i2) => {
13686 const page = i2 + 1;
13687 return {
13688 value: page.toString(),
13689 label: page.toString(),
13690 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13691 // translators: 1: current page number. 2: total number of pages.
13692 (0, import_i18n16.__)("Page %1$d of %2$d"),
13693 currentPage,
13694 totalPages
13695 ) : page.toString()
13696 };
13697 }
13698 );
13699 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13700 Stack,
13701 {
13702 direction: "row",
13703 className: "dataviews-pagination",
13704 justify: "end",
13705 align: "center",
13706 gap: "xl",
13707 children: [
13708 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13709 Stack,
13710 {
13711 direction: "row",
13712 justify: "flex-start",
13713 align: "center",
13714 gap: "xs",
13715 className: "dataviews-pagination__page-select",
13716 children: (0, import_element40.createInterpolateElement)(
13717 (0, import_i18n16.sprintf)(
13718 // translators: 1: Current page number, 2: Total number of pages.
13719 (0, import_i18n16._x)(
13720 "<div>Page</div>%1$s<div>of %2$d</div>",
13721 "paging"
13722 ),
13723 "<CurrentPage />",
13724 totalPages
13725 ),
13726 {
13727 div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
13728 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13729 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13730 import_components12.SelectControl,
13731 {
13732 "aria-label": (0, import_i18n16.__)("Current page"),
13733 value: currentPage.toString(),
13734 options: pageSelectOptions,
13735 onChange: (newValue) => {
13736 onChangeView({
13737 ...view,
13738 page: +newValue
13739 });
13740 },
13741 size: "small",
13742 variant: "minimal"
13743 }
13744 )
13745 }
13746 )
13747 }
13748 ),
13749 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13750 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13751 import_components12.Button,
13752 {
13753 onClick: () => onChangeView({
13754 ...view,
13755 page: currentPage - 1
13756 }),
13757 disabled: currentPage === 1,
13758 accessibleWhenDisabled: true,
13759 label: (0, import_i18n16.__)("Previous page"),
13760 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13761 showTooltip: true,
13762 size: "compact",
13763 tooltipPosition: "top"
13764 }
13765 ),
13766 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13767 import_components12.Button,
13768 {
13769 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13770 disabled: currentPage >= totalPages,
13771 accessibleWhenDisabled: true,
13772 label: (0, import_i18n16.__)("Next page"),
13773 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13774 showTooltip: true,
13775 size: "compact",
13776 tooltipPosition: "top"
13777 }
13778 )
13779 ] })
13780 ]
13781 }
13782 );
13783 }
13784 var dataviews_pagination_default = (0, import_element40.memo)(DataViewsPagination);
13785
13786 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13787 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13788 function useIsMultiselectPicker(actions) {
13789 return (0, import_element41.useMemo)(() => {
13790 return actions?.every((action) => action.supportsBulk);
13791 }, [actions]);
13792 }
13793
13794 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13795 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13796 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13797 function GridItem3({
13798 view,
13799 multiselect,
13800 selection,
13801 onChangeSelection,
13802 getItemId,
13803 item,
13804 mediaField,
13805 titleField,
13806 descriptionField,
13807 regularFields,
13808 badgeFields,
13809 config,
13810 posinset,
13811 setsize
13812 }) {
13813 const { showTitle = true, showMedia = true, showDescription = true } = view;
13814 const id = getItemId(item);
13815 const elementRef = (0, import_element42.useRef)(null);
13816 const isSelected2 = selection.includes(id);
13817 useIntersectionObserver(elementRef, posinset);
13818 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13819 mediaField.render,
13820 {
13821 item,
13822 field: mediaField,
13823 config
13824 }
13825 ) : null;
13826 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
13827 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13828 import_components14.Composite.Item,
13829 {
13830 ref: elementRef,
13831 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
13832 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
13833 role: "option",
13834 "aria-posinset": posinset,
13835 "aria-setsize": setsize,
13836 className: clsx_default("dataviews-view-picker-grid__card", {
13837 "is-selected": isSelected2
13838 }),
13839 "aria-selected": isSelected2,
13840 onClick: () => {
13841 if (isSelected2) {
13842 onChangeSelection(
13843 selection.filter((itemId) => id !== itemId)
13844 );
13845 } else {
13846 const newSelection = multiselect ? [...selection, id] : [id];
13847 onChangeSelection(newSelection);
13848 }
13849 },
13850 children: [
13851 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13852 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13853 DataViewsSelectionCheckbox,
13854 {
13855 item,
13856 selection,
13857 onChangeSelection,
13858 getItemId,
13859 titleField,
13860 disabled: false,
13861 "aria-hidden": true,
13862 tabIndex: -1
13863 }
13864 ),
13865 showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13866 Stack,
13867 {
13868 direction: "row",
13869 justify: "space-between",
13870 className: "dataviews-view-picker-grid__title-actions",
13871 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13872 }
13873 ),
13874 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13875 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13876 descriptionField.render,
13877 {
13878 item,
13879 field: descriptionField
13880 }
13881 ),
13882 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13883 Stack,
13884 {
13885 direction: "row",
13886 className: "dataviews-view-picker-grid__badge-fields",
13887 gap: "sm",
13888 wrap: "wrap",
13889 align: "top",
13890 justify: "flex-start",
13891 children: badgeFields.map((field) => {
13892 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13893 WCBadge2,
13894 {
13895 className: "dataviews-view-picker-grid__field-value",
13896 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13897 field.render,
13898 {
13899 item,
13900 field
13901 }
13902 )
13903 },
13904 field.id
13905 );
13906 })
13907 }
13908 ),
13909 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13910 Stack,
13911 {
13912 direction: "column",
13913 className: "dataviews-view-picker-grid__fields",
13914 gap: "xs",
13915 children: regularFields.map((field) => {
13916 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13917 import_components14.Flex,
13918 {
13919 className: "dataviews-view-picker-grid__field",
13920 gap: 1,
13921 justify: "flex-start",
13922 expanded: true,
13923 style: { height: "auto" },
13924 direction: "row",
13925 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
13926 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13927 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13928 import_components14.FlexItem,
13929 {
13930 className: "dataviews-view-picker-grid__field-value",
13931 style: { maxHeight: "none" },
13932 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13933 field.render,
13934 {
13935 item,
13936 field
13937 }
13938 )
13939 }
13940 )
13941 ] })
13942 },
13943 field.id
13944 );
13945 })
13946 }
13947 )
13948 ] })
13949 ]
13950 },
13951 id
13952 );
13953 }
13954 function GridGroup({
13955 groupName,
13956 groupField,
13957 showLabel = true,
13958 children
13959 }) {
13960 const headerId = (0, import_compose6.useInstanceId)(
13961 GridGroup,
13962 "dataviews-view-picker-grid-group__header"
13963 );
13964 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13965 Stack,
13966 {
13967 direction: "column",
13968 gap: "sm",
13969 role: "group",
13970 "aria-labelledby": headerId,
13971 children: [
13972 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13973 "h3",
13974 {
13975 className: "dataviews-view-picker-grid-group__header",
13976 id: headerId,
13977 children: showLabel ? (0, import_i18n18.sprintf)(
13978 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13979 (0, import_i18n18.__)("%1$s: %2$s"),
13980 groupField.label,
13981 groupName
13982 ) : groupName
13983 }
13984 ),
13985 children
13986 ]
13987 },
13988 groupName
13989 );
13990 }
13991 function ViewPickerGrid({
13992 actions,
13993 data,
13994 fields,
13995 getItemId,
13996 isLoading,
13997 onChangeSelection,
13998 selection,
13999 view,
14000 className,
14001 empty
14002 }) {
14003 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element42.useContext)(dataviews_context_default);
14004 const titleField = fields.find(
14005 (field) => field.id === view?.titleField
14006 );
14007 const mediaField = fields.find(
14008 (field) => field.id === view?.mediaField
14009 );
14010 const descriptionField = fields.find(
14011 (field) => field.id === view?.descriptionField
14012 );
14013 const otherFields = view.fields ?? [];
14014 const { regularFields, badgeFields } = otherFields.reduce(
14015 (accumulator, fieldId) => {
14016 const field = fields.find((f2) => f2.id === fieldId);
14017 if (!field) {
14018 return accumulator;
14019 }
14020 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14021 accumulator[key].push(field);
14022 return accumulator;
14023 },
14024 { regularFields: [], badgeFields: [] }
14025 );
14026 const hasData = !!data?.length;
14027 const usedPreviewSize = view.layout?.previewSize;
14028 const isMultiselect = useIsMultiselectPicker(actions);
14029 const size4 = "900px";
14030 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14031 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14032 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14033 const currentPage = view?.page ?? 1;
14034 const perPage = view?.perPage ?? 0;
14035 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14036 const gridColumns = useGridColumns();
14037 const placeholdersNeeded = usePlaceholdersNeeded(
14038 data,
14039 isInfiniteScroll,
14040 gridColumns
14041 );
14042 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14043 // Render multiple groups.
14044 children: [
14045 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14046 import_components14.Composite,
14047 {
14048 virtualFocus: true,
14049 orientation: "horizontal",
14050 role: "listbox",
14051 "aria-multiselectable": isMultiselect,
14052 className: clsx_default(
14053 "dataviews-view-picker-grid",
14054 className,
14055 {
14056 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14057 view.layout.density
14058 )
14059 }
14060 ),
14061 "aria-label": itemListLabel,
14062 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14063 Stack,
14064 {
14065 direction: "column",
14066 gap: "lg",
14067 children,
14068 ...props
14069 }
14070 ),
14071 children: Array.from(dataByGroup.entries()).map(
14072 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14073 GridGroup,
14074 {
14075 groupName,
14076 groupField,
14077 showLabel: view.groupBy?.showLabel !== false,
14078 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14079 GridItems,
14080 {
14081 previewSize: usedPreviewSize,
14082 style: {
14083 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14084 },
14085 "aria-busy": isLoading,
14086 ref: resizeObserverRef,
14087 children: groupItems.map((item) => {
14088 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14089 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14090 GridItem3,
14091 {
14092 view,
14093 multiselect: isMultiselect,
14094 selection,
14095 onChangeSelection,
14096 getItemId,
14097 item,
14098 mediaField,
14099 titleField,
14100 descriptionField,
14101 regularFields,
14102 badgeFields,
14103 config: {
14104 sizes: size4
14105 },
14106 posinset: posInSet,
14107 setsize: setSize
14108 },
14109 getItemId(item)
14110 );
14111 })
14112 }
14113 )
14114 },
14115 groupName
14116 )
14117 )
14118 }
14119 ),
14120 // Render a single grid with all data.
14121 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14122 import_components14.Composite,
14123 {
14124 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14125 GridItems,
14126 {
14127 className: clsx_default(
14128 "dataviews-view-picker-grid",
14129 className,
14130 {
14131 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14132 "compact",
14133 "comfortable"
14134 ].includes(view.layout.density)
14135 }
14136 ),
14137 previewSize: usedPreviewSize,
14138 "aria-busy": isLoading,
14139 ref: resizeObserverRef
14140 }
14141 ),
14142 virtualFocus: true,
14143 orientation: "horizontal",
14144 role: "listbox",
14145 "aria-multiselectable": isMultiselect,
14146 "aria-label": itemListLabel,
14147 children: [
14148 Array.from({ length: placeholdersNeeded }).map(
14149 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14150 import_components14.Composite.Item,
14151 {
14152 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14153 Stack,
14154 {
14155 direction: "column",
14156 children,
14157 ...props
14158 }
14159 ),
14160 role: "option",
14161 "aria-hidden": true,
14162 tabIndex: -1,
14163 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14164 },
14165 `placeholder-${index2}`
14166 )
14167 ),
14168 data.map((item) => {
14169 const posinset = item.position;
14170 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14171 GridItem3,
14172 {
14173 view,
14174 multiselect: isMultiselect,
14175 selection,
14176 onChangeSelection,
14177 getItemId,
14178 item,
14179 mediaField,
14180 titleField,
14181 descriptionField,
14182 regularFields,
14183 badgeFields,
14184 config: {
14185 sizes: size4
14186 },
14187 posinset,
14188 setsize: setSize
14189 },
14190 getItemId(item)
14191 );
14192 })
14193 ]
14194 }
14195 ),
14196 // Render empty state.
14197 !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14198 "div",
14199 {
14200 className: clsx_default({
14201 "dataviews-loading": isLoading,
14202 "dataviews-no-results": !isLoading
14203 }),
14204 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14205 }
14206 ),
14207 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14208 ]
14209 });
14210 }
14211 var picker_grid_default = ViewPickerGrid;
14212
14213 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14214 var import_i18n19 = __toESM(require_i18n(), 1);
14215 var import_components15 = __toESM(require_components(), 1);
14216 var import_element43 = __toESM(require_element(), 1);
14217 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14218 function TableColumnField2({
14219 item,
14220 fields,
14221 column,
14222 align
14223 }) {
14224 const field = fields.find((f2) => f2.id === column);
14225 if (!field) {
14226 return null;
14227 }
14228 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14229 "dataviews-view-table__cell-align-end": align === "end",
14230 "dataviews-view-table__cell-align-center": align === "center"
14231 });
14232 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14233 }
14234 function TableRow2({
14235 item,
14236 fields,
14237 id,
14238 view,
14239 titleField,
14240 mediaField,
14241 descriptionField,
14242 selection,
14243 getItemId,
14244 onChangeSelection,
14245 multiselect,
14246 posinset
14247 }) {
14248 const { paginationInfo } = (0, import_element43.useContext)(dataviews_context_default);
14249 const isSelected2 = selection.includes(id);
14250 const [isHovered, setIsHovered] = (0, import_element43.useState)(false);
14251 const elementRef = (0, import_element43.useRef)(null);
14252 useIntersectionObserver(elementRef, posinset);
14253 const {
14254 showTitle = true,
14255 showMedia = true,
14256 showDescription = true,
14257 infiniteScrollEnabled
14258 } = view;
14259 const handleMouseEnter = () => {
14260 setIsHovered(true);
14261 };
14262 const handleMouseLeave = () => {
14263 setIsHovered(false);
14264 };
14265 const columns = view.fields ?? [];
14266 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14267 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14268 import_components15.Composite.Item,
14269 {
14270 ref: elementRef,
14271 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14272 "tr",
14273 {
14274 className: clsx_default("dataviews-view-table__row", {
14275 "is-selected": isSelected2,
14276 "is-hovered": isHovered
14277 }),
14278 onMouseEnter: handleMouseEnter,
14279 onMouseLeave: handleMouseLeave,
14280 children,
14281 ...props
14282 }
14283 ),
14284 "aria-selected": isSelected2,
14285 "aria-setsize": paginationInfo.totalItems || void 0,
14286 "aria-posinset": posinset,
14287 role: infiniteScrollEnabled ? "article" : "option",
14288 onMouseDown: (event) => {
14289 if (event.button !== 0) {
14290 return;
14291 }
14292 event.currentTarget.parentElement?.focus({
14293 preventScroll: true
14294 });
14295 },
14296 onClick: () => {
14297 if (isSelected2) {
14298 onChangeSelection(
14299 selection.filter((itemId) => id !== itemId)
14300 );
14301 } else {
14302 const newSelection = multiselect ? [...selection, id] : [id];
14303 onChangeSelection(newSelection);
14304 }
14305 },
14306 children: [
14307 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14308 "td",
14309 {
14310 className: "dataviews-view-table__checkbox-column",
14311 role: "presentation",
14312 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14313 DataViewsSelectionCheckbox,
14314 {
14315 item,
14316 selection,
14317 onChangeSelection,
14318 getItemId,
14319 titleField,
14320 disabled: false,
14321 "aria-hidden": true,
14322 tabIndex: -1
14323 }
14324 ) })
14325 }
14326 ),
14327 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14328 "td",
14329 {
14330 role: "presentation",
14331 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14332 column_primary_default,
14333 {
14334 item,
14335 titleField: showTitle ? titleField : void 0,
14336 mediaField: showMedia ? mediaField : void 0,
14337 descriptionField: showDescription ? descriptionField : void 0,
14338 isItemClickable: () => false
14339 }
14340 )
14341 }
14342 ),
14343 columns.map((column) => {
14344 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14345 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14346 "td",
14347 {
14348 style: {
14349 width,
14350 maxWidth,
14351 minWidth
14352 },
14353 role: "presentation",
14354 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14355 TableColumnField2,
14356 {
14357 fields,
14358 item,
14359 column,
14360 align
14361 }
14362 )
14363 },
14364 column
14365 );
14366 })
14367 ]
14368 },
14369 id
14370 );
14371 }
14372 function ViewPickerTable({
14373 actions,
14374 data,
14375 fields,
14376 getItemId,
14377 isLoading = false,
14378 onChangeView,
14379 onChangeSelection,
14380 selection,
14381 setOpenedFilter,
14382 view,
14383 className,
14384 empty
14385 }) {
14386 const headerMenuRefs = (0, import_element43.useRef)(/* @__PURE__ */ new Map());
14387 const headerMenuToFocusRef = (0, import_element43.useRef)(void 0);
14388 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element43.useState)();
14389 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14390 (0, import_element43.useEffect)(() => {
14391 if (headerMenuToFocusRef.current) {
14392 headerMenuToFocusRef.current.focus();
14393 headerMenuToFocusRef.current = void 0;
14394 }
14395 });
14396 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14397 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14398 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14399 const tableNoticeId = (0, import_element43.useId)();
14400 if (nextHeaderMenuToFocus) {
14401 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14402 setNextHeaderMenuToFocus(void 0);
14403 return;
14404 }
14405 const onHide = (field) => {
14406 const hidden = headerMenuRefs.current.get(field.id);
14407 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14408 setNextHeaderMenuToFocus(fallback?.node);
14409 };
14410 const hasData = !!data?.length;
14411 const titleField = fields.find((field) => field.id === view.titleField);
14412 const mediaField = fields.find((field) => field.id === view.mediaField);
14413 const descriptionField = fields.find(
14414 (field) => field.id === view.descriptionField
14415 );
14416 const { showTitle = true, showMedia = true, showDescription = true } = view;
14417 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14418 const columns = view.fields ?? [];
14419 const headerMenuRef = (column, index2) => (node) => {
14420 if (node) {
14421 headerMenuRefs.current.set(column, {
14422 node,
14423 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14424 });
14425 } else {
14426 headerMenuRefs.current.delete(column);
14427 }
14428 };
14429 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14430 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14431 "table",
14432 {
14433 className: clsx_default(
14434 "dataviews-view-table",
14435 "dataviews-view-picker-table",
14436 className,
14437 {
14438 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14439 view.layout.density
14440 )
14441 }
14442 ),
14443 "aria-busy": isLoading,
14444 "aria-describedby": tableNoticeId,
14445 role: isInfiniteScroll ? "feed" : "listbox",
14446 children: [
14447 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14448 "tr",
14449 {
14450 className: "dataviews-view-table__row",
14451 role: "presentation",
14452 children: [
14453 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14454 BulkSelectionCheckbox,
14455 {
14456 selection,
14457 onChangeSelection,
14458 data,
14459 actions,
14460 getItemId,
14461 disableSelectAll: isInfiniteScroll
14462 }
14463 ) }),
14464 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14465 column_header_menu_default,
14466 {
14467 ref: headerMenuRef(
14468 titleField.id,
14469 0
14470 ),
14471 fieldId: titleField.id,
14472 view,
14473 fields,
14474 onChangeView,
14475 onHide,
14476 setOpenedFilter,
14477 canMove: false
14478 }
14479 ) }),
14480 columns.map((column, index2) => {
14481 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14482 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14483 "th",
14484 {
14485 style: {
14486 width,
14487 maxWidth,
14488 minWidth,
14489 textAlign: align
14490 },
14491 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14492 scope: "col",
14493 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14494 column_header_menu_default,
14495 {
14496 ref: headerMenuRef(column, index2),
14497 fieldId: column,
14498 view,
14499 fields,
14500 onChangeView,
14501 onHide,
14502 setOpenedFilter,
14503 canMove: view.layout?.enableMoving ?? true
14504 }
14505 )
14506 },
14507 column
14508 );
14509 })
14510 ]
14511 }
14512 ) }),
14513 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14514 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14515 import_components15.Composite,
14516 {
14517 virtualFocus: true,
14518 orientation: "vertical",
14519 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
14520 children: [
14521 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14522 "tr",
14523 {
14524 className: "dataviews-view-table__group-header-row",
14525 role: "presentation",
14526 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14527 "td",
14528 {
14529 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14530 className: "dataviews-view-table__group-header-cell",
14531 role: "presentation",
14532 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14533 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14534 (0, import_i18n19.__)("%1$s: %2$s"),
14535 groupField.label,
14536 groupName
14537 )
14538 }
14539 )
14540 }
14541 ),
14542 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14543 TableRow2,
14544 {
14545 item,
14546 fields,
14547 id: getItemId(item) || index2.toString(),
14548 view,
14549 titleField,
14550 mediaField,
14551 descriptionField,
14552 selection,
14553 getItemId,
14554 onChangeSelection,
14555 multiselect: isMultiselect
14556 },
14557 getItemId(item)
14558 ))
14559 ]
14560 },
14561 `group-${groupName}`
14562 )
14563 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14564 import_components15.Composite,
14565 {
14566 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
14567 virtualFocus: true,
14568 orientation: "vertical",
14569 children: hasData && data.map((item, index2) => {
14570 const itemId = getItemId(item);
14571 const posinset = item.position;
14572 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14573 TableRow2,
14574 {
14575 item,
14576 fields,
14577 id: itemId || index2.toString(),
14578 view,
14579 titleField,
14580 mediaField,
14581 descriptionField,
14582 selection,
14583 getItemId,
14584 onChangeSelection,
14585 multiselect: isMultiselect,
14586 posinset
14587 },
14588 itemId
14589 );
14590 })
14591 }
14592 )
14593 ]
14594 }
14595 ),
14596 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14597 "div",
14598 {
14599 className: clsx_default({
14600 "dataviews-loading": isLoading,
14601 "dataviews-no-results": !hasData && !isLoading
14602 }),
14603 id: tableNoticeId,
14604 children: [
14605 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
14606 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
14607 ]
14608 }
14609 )
14610 ] });
14611 }
14612 var picker_table_default = ViewPickerTable;
14613
14614 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14615 var import_components16 = __toESM(require_components(), 1);
14616 var import_i18n20 = __toESM(require_i18n(), 1);
14617 var import_element44 = __toESM(require_element(), 1);
14618 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14619 function DensityPicker() {
14620 const context = (0, import_element44.useContext)(dataviews_context_default);
14621 const view = context.view;
14622 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14623 import_components16.__experimentalToggleGroupControl,
14624 {
14625 size: "__unstable-large",
14626 label: (0, import_i18n20.__)("Density"),
14627 value: view.layout?.density || "balanced",
14628 onChange: (value) => {
14629 context.onChangeView({
14630 ...view,
14631 layout: {
14632 ...view.layout,
14633 density: value
14634 }
14635 });
14636 },
14637 isBlock: true,
14638 children: [
14639 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14640 import_components16.__experimentalToggleGroupControlOption,
14641 {
14642 value: "comfortable",
14643 label: (0, import_i18n20._x)(
14644 "Comfortable",
14645 "Density option for DataView layout"
14646 )
14647 },
14648 "comfortable"
14649 ),
14650 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14651 import_components16.__experimentalToggleGroupControlOption,
14652 {
14653 value: "balanced",
14654 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14655 },
14656 "balanced"
14657 ),
14658 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14659 import_components16.__experimentalToggleGroupControlOption,
14660 {
14661 value: "compact",
14662 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14663 },
14664 "compact"
14665 )
14666 ]
14667 }
14668 );
14669 }
14670
14671 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14672 var import_components17 = __toESM(require_components(), 1);
14673 var import_i18n21 = __toESM(require_i18n(), 1);
14674 var import_element45 = __toESM(require_element(), 1);
14675 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
14676 var imageSizes2 = [
14677 {
14678 value: 120,
14679 breakpoint: 1
14680 },
14681 {
14682 value: 170,
14683 breakpoint: 1
14684 },
14685 {
14686 value: 230,
14687 breakpoint: 1
14688 },
14689 {
14690 value: 290,
14691 breakpoint: 1112
14692 // at minimum image width, 4 images display at this container size
14693 },
14694 {
14695 value: 350,
14696 breakpoint: 1636
14697 // at minimum image width, 6 images display at this container size
14698 },
14699 {
14700 value: 430,
14701 breakpoint: 588
14702 // at minimum image width, 2 images display at this container size
14703 }
14704 ];
14705 function PreviewSizePicker() {
14706 const context = (0, import_element45.useContext)(dataviews_context_default);
14707 const view = context.view;
14708 const breakValues = imageSizes2.filter((size4) => {
14709 return context.containerWidth >= size4.breakpoint;
14710 });
14711 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14712 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14713 const marks = breakValues.map((size4, index2) => {
14714 return {
14715 value: index2
14716 };
14717 });
14718 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14719 import_components17.RangeControl,
14720 {
14721 __next40pxDefaultSize: true,
14722 showTooltip: false,
14723 label: (0, import_i18n21.__)("Preview size"),
14724 value: previewSizeToUse,
14725 min: 0,
14726 max: breakValues.length - 1,
14727 withInputField: false,
14728 onChange: (value = 0) => {
14729 context.onChangeView({
14730 ...view,
14731 layout: {
14732 ...view.layout,
14733 previewSize: breakValues[value].value
14734 }
14735 });
14736 },
14737 step: 1,
14738 marks
14739 }
14740 );
14741 }
14742
14743 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14744 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14745 function GridConfigOptions() {
14746 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
14747 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(DensityPicker, {}),
14748 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(PreviewSizePicker, {})
14749 ] });
14750 }
14751
14752 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14753 var VIEW_LAYOUTS = [
14754 {
14755 type: LAYOUT_TABLE,
14756 label: (0, import_i18n22.__)("Table"),
14757 component: table_default,
14758 icon: block_table_default,
14759 viewConfigOptions: DensityPicker
14760 },
14761 {
14762 type: LAYOUT_GRID,
14763 label: (0, import_i18n22.__)("Grid"),
14764 component: grid_default,
14765 icon: category_default,
14766 viewConfigOptions: GridConfigOptions
14767 },
14768 {
14769 type: LAYOUT_LIST,
14770 label: (0, import_i18n22.__)("List"),
14771 component: ViewList,
14772 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14773 viewConfigOptions: DensityPicker
14774 },
14775 {
14776 type: LAYOUT_ACTIVITY,
14777 label: (0, import_i18n22.__)("Activity"),
14778 component: ViewActivity,
14779 icon: scheduled_default,
14780 viewConfigOptions: DensityPicker
14781 },
14782 {
14783 type: LAYOUT_PICKER_GRID,
14784 label: (0, import_i18n22.__)("Grid"),
14785 component: picker_grid_default,
14786 icon: category_default,
14787 viewConfigOptions: GridConfigOptions,
14788 isPicker: true
14789 },
14790 {
14791 type: LAYOUT_PICKER_TABLE,
14792 label: (0, import_i18n22.__)("Table"),
14793 component: picker_table_default,
14794 icon: block_table_default,
14795 viewConfigOptions: DensityPicker,
14796 isPicker: true
14797 }
14798 ];
14799
14800 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14801 var import_element53 = __toESM(require_element(), 1);
14802
14803 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14804 var import_components20 = __toESM(require_components(), 1);
14805 var import_i18n25 = __toESM(require_i18n(), 1);
14806 var import_element50 = __toESM(require_element(), 1);
14807
14808 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14809 function noop4(..._) {
14810 }
14811 function applyState(argument, currentValue) {
14812 if (isUpdater(argument)) {
14813 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14814 return argument(value);
14815 }
14816 return argument;
14817 }
14818 function isUpdater(argument) {
14819 return typeof argument === "function";
14820 }
14821 function isLazyValue(value) {
14822 return typeof value === "function";
14823 }
14824 function hasOwnProperty(object, prop) {
14825 if (typeof Object.hasOwn === "function") {
14826 return Object.hasOwn(object, prop);
14827 }
14828 return Object.prototype.hasOwnProperty.call(object, prop);
14829 }
14830 function chain(...fns) {
14831 return (...args) => {
14832 for (const fn of fns) {
14833 if (typeof fn === "function") {
14834 fn(...args);
14835 }
14836 }
14837 };
14838 }
14839 function normalizeString(str) {
14840 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14841 }
14842 function omit(object, keys) {
14843 const result = { ...object };
14844 for (const key of keys) {
14845 if (hasOwnProperty(result, key)) {
14846 delete result[key];
14847 }
14848 }
14849 return result;
14850 }
14851 function pick(object, paths) {
14852 const result = {};
14853 for (const key of paths) {
14854 if (hasOwnProperty(object, key)) {
14855 result[key] = object[key];
14856 }
14857 }
14858 return result;
14859 }
14860 function identity(value) {
14861 return value;
14862 }
14863 function invariant(condition, message2) {
14864 if (condition) return;
14865 if (typeof message2 !== "string") throw new Error("Invariant failed");
14866 throw new Error(message2);
14867 }
14868 function getKeys(obj) {
14869 return Object.keys(obj);
14870 }
14871 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14872 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14873 if (result == null) return false;
14874 return !result;
14875 }
14876 function disabledFromProps(props) {
14877 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14878 }
14879 function removeUndefinedValues(obj) {
14880 const result = {};
14881 for (const key in obj) {
14882 if (obj[key] !== void 0) {
14883 result[key] = obj[key];
14884 }
14885 }
14886 return result;
14887 }
14888 function defaultValue(...values) {
14889 for (const value of values) {
14890 if (value !== void 0) return value;
14891 }
14892 return void 0;
14893 }
14894
14895 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14896 var import_react11 = __toESM(require_react(), 1);
14897 function setRef(ref, value) {
14898 if (typeof ref === "function") {
14899 ref(value);
14900 } else if (ref) {
14901 ref.current = value;
14902 }
14903 }
14904 function isValidElementWithRef(element) {
14905 if (!element) return false;
14906 if (!(0, import_react11.isValidElement)(element)) return false;
14907 if ("ref" in element.props) return true;
14908 if ("ref" in element) return true;
14909 return false;
14910 }
14911 function getRefProperty(element) {
14912 if (!isValidElementWithRef(element)) return null;
14913 const props = { ...element.props };
14914 return props.ref || element.ref;
14915 }
14916 function mergeProps3(base, overrides) {
14917 const props = { ...base };
14918 for (const key in overrides) {
14919 if (!hasOwnProperty(overrides, key)) continue;
14920 if (key === "className") {
14921 const prop = "className";
14922 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14923 continue;
14924 }
14925 if (key === "style") {
14926 const prop = "style";
14927 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14928 continue;
14929 }
14930 const overrideValue = overrides[key];
14931 if (typeof overrideValue === "function" && key.startsWith("on")) {
14932 const baseValue = base[key];
14933 if (typeof baseValue === "function") {
14934 props[key] = (...args) => {
14935 overrideValue(...args);
14936 baseValue(...args);
14937 };
14938 continue;
14939 }
14940 }
14941 props[key] = overrideValue;
14942 }
14943 return props;
14944 }
14945
14946 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14947 var canUseDOM = checkIsBrowser();
14948 function checkIsBrowser() {
14949 var _a;
14950 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14951 }
14952 function getDocument(node) {
14953 if (!node) return document;
14954 if ("self" in node) return node.document;
14955 return node.ownerDocument || document;
14956 }
14957 function getActiveElement(node, activeDescendant = false) {
14958 var _a;
14959 const { activeElement: activeElement2 } = getDocument(node);
14960 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14961 return null;
14962 }
14963 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14964 return getActiveElement(
14965 activeElement2.contentDocument.body,
14966 activeDescendant
14967 );
14968 }
14969 if (activeDescendant) {
14970 const id = activeElement2.getAttribute("aria-activedescendant");
14971 if (id) {
14972 const element = getDocument(activeElement2).getElementById(id);
14973 if (element) {
14974 return element;
14975 }
14976 }
14977 }
14978 return activeElement2;
14979 }
14980 function contains2(parent, child) {
14981 return parent === child || parent.contains(child);
14982 }
14983 function isFrame(element) {
14984 return element.tagName === "IFRAME";
14985 }
14986 function isButton(element) {
14987 const tagName = element.tagName.toLowerCase();
14988 if (tagName === "button") return true;
14989 if (tagName === "input" && element.type) {
14990 return buttonInputTypes.indexOf(element.type) !== -1;
14991 }
14992 return false;
14993 }
14994 var buttonInputTypes = [
14995 "button",
14996 "color",
14997 "file",
14998 "image",
14999 "reset",
15000 "submit"
15001 ];
15002 function isVisible(element) {
15003 if (typeof element.checkVisibility === "function") {
15004 return element.checkVisibility();
15005 }
15006 const htmlElement = element;
15007 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15008 }
15009 function isTextField(element) {
15010 try {
15011 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15012 const isTextArea = element.tagName === "TEXTAREA";
15013 return isTextInput || isTextArea || false;
15014 } catch (_error) {
15015 return false;
15016 }
15017 }
15018 function isTextbox(element) {
15019 return element.isContentEditable || isTextField(element);
15020 }
15021 function getTextboxValue(element) {
15022 if (isTextField(element)) {
15023 return element.value;
15024 }
15025 if (element.isContentEditable) {
15026 const range = getDocument(element).createRange();
15027 range.selectNodeContents(element);
15028 return range.toString();
15029 }
15030 return "";
15031 }
15032 function getTextboxSelection(element) {
15033 let start = 0;
15034 let end = 0;
15035 if (isTextField(element)) {
15036 start = element.selectionStart || 0;
15037 end = element.selectionEnd || 0;
15038 } else if (element.isContentEditable) {
15039 const selection = getDocument(element).getSelection();
15040 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15041 const range = selection.getRangeAt(0);
15042 const nextRange = range.cloneRange();
15043 nextRange.selectNodeContents(element);
15044 nextRange.setEnd(range.startContainer, range.startOffset);
15045 start = nextRange.toString().length;
15046 nextRange.setEnd(range.endContainer, range.endOffset);
15047 end = nextRange.toString().length;
15048 }
15049 }
15050 return { start, end };
15051 }
15052 function getPopupRole(element, fallback) {
15053 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
15054 const role = element == null ? void 0 : element.getAttribute("role");
15055 if (role && allowedPopupRoles.indexOf(role) !== -1) {
15056 return role;
15057 }
15058 return fallback;
15059 }
15060 function getScrollingElement(element) {
15061 if (!element) return null;
15062 const isScrollableOverflow = (overflow) => {
15063 if (overflow === "auto") return true;
15064 if (overflow === "scroll") return true;
15065 return false;
15066 };
15067 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15068 const { overflowY } = getComputedStyle(element);
15069 if (isScrollableOverflow(overflowY)) return element;
15070 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15071 const { overflowX } = getComputedStyle(element);
15072 if (isScrollableOverflow(overflowX)) return element;
15073 }
15074 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15075 }
15076 function setSelectionRange(element, ...args) {
15077 if (/text|search|password|tel|url/i.test(element.type)) {
15078 element.setSelectionRange(...args);
15079 }
15080 }
15081 function sortBasedOnDOMPosition(items, getElement) {
15082 const pairs = items.map((item, index2) => [index2, item]);
15083 let isOrderDifferent = false;
15084 pairs.sort(([indexA, a2], [indexB, b2]) => {
15085 const elementA = getElement(a2);
15086 const elementB = getElement(b2);
15087 if (elementA === elementB) return 0;
15088 if (!elementA || !elementB) return 0;
15089 if (isElementPreceding(elementA, elementB)) {
15090 if (indexA > indexB) {
15091 isOrderDifferent = true;
15092 }
15093 return -1;
15094 }
15095 if (indexA < indexB) {
15096 isOrderDifferent = true;
15097 }
15098 return 1;
15099 });
15100 if (isOrderDifferent) {
15101 return pairs.map(([_, item]) => item);
15102 }
15103 return items;
15104 }
15105 function isElementPreceding(a2, b2) {
15106 return Boolean(
15107 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
15108 );
15109 }
15110
15111 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
15112 function isTouchDevice() {
15113 return canUseDOM && !!navigator.maxTouchPoints;
15114 }
15115 function isApple() {
15116 if (!canUseDOM) return false;
15117 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15118 }
15119 function isSafari2() {
15120 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15121 }
15122 function isFirefox2() {
15123 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15124 }
15125
15126 // node_modules/@ariakit/core/esm/utils/events.js
15127 function isPortalEvent(event) {
15128 return Boolean(
15129 event.currentTarget && !contains2(event.currentTarget, event.target)
15130 );
15131 }
15132 function isSelfTarget(event) {
15133 return event.target === event.currentTarget;
15134 }
15135 function isOpeningInNewTab(event) {
15136 const element = event.currentTarget;
15137 if (!element) return false;
15138 const isAppleDevice = isApple();
15139 if (isAppleDevice && !event.metaKey) return false;
15140 if (!isAppleDevice && !event.ctrlKey) return false;
15141 const tagName = element.tagName.toLowerCase();
15142 if (tagName === "a") return true;
15143 if (tagName === "button" && element.type === "submit") return true;
15144 if (tagName === "input" && element.type === "submit") return true;
15145 return false;
15146 }
15147 function isDownloading(event) {
15148 const element = event.currentTarget;
15149 if (!element) return false;
15150 const tagName = element.tagName.toLowerCase();
15151 if (!event.altKey) return false;
15152 if (tagName === "a") return true;
15153 if (tagName === "button" && element.type === "submit") return true;
15154 if (tagName === "input" && element.type === "submit") return true;
15155 return false;
15156 }
15157 function fireBlurEvent(element, eventInit) {
15158 const event = new FocusEvent("blur", eventInit);
15159 const defaultAllowed = element.dispatchEvent(event);
15160 const bubbleInit = { ...eventInit, bubbles: true };
15161 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15162 return defaultAllowed;
15163 }
15164 function fireKeyboardEvent(element, type, eventInit) {
15165 const event = new KeyboardEvent(type, eventInit);
15166 return element.dispatchEvent(event);
15167 }
15168 function fireClickEvent(element, eventInit) {
15169 const event = new MouseEvent("click", eventInit);
15170 return element.dispatchEvent(event);
15171 }
15172 function isFocusEventOutside(event, container) {
15173 const containerElement = container || event.currentTarget;
15174 const relatedTarget = event.relatedTarget;
15175 return !relatedTarget || !contains2(containerElement, relatedTarget);
15176 }
15177 function queueBeforeEvent(element, type, callback, timeout) {
15178 const createTimer = (callback2) => {
15179 if (timeout) {
15180 const timerId2 = setTimeout(callback2, timeout);
15181 return () => clearTimeout(timerId2);
15182 }
15183 const timerId = requestAnimationFrame(callback2);
15184 return () => cancelAnimationFrame(timerId);
15185 };
15186 const cancelTimer = createTimer(() => {
15187 element.removeEventListener(type, callSync, true);
15188 callback();
15189 });
15190 const callSync = () => {
15191 cancelTimer();
15192 callback();
15193 };
15194 element.addEventListener(type, callSync, { once: true, capture: true });
15195 return cancelTimer;
15196 }
15197 function addGlobalEventListener(type, listener, options, scope = window) {
15198 const children = [];
15199 try {
15200 scope.document.addEventListener(type, listener, options);
15201 for (const frame of Array.from(scope.frames)) {
15202 children.push(addGlobalEventListener(type, listener, options, frame));
15203 }
15204 } catch (e2) {
15205 }
15206 const removeEventListener = () => {
15207 try {
15208 scope.document.removeEventListener(type, listener, options);
15209 } catch (e2) {
15210 }
15211 for (const remove of children) {
15212 remove();
15213 }
15214 };
15215 return removeEventListener;
15216 }
15217
15218 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15219 var React48 = __toESM(require_react(), 1);
15220 var import_react12 = __toESM(require_react(), 1);
15221 var _React = { ...React48 };
15222 var useReactId = _React.useId;
15223 var useReactDeferredValue = _React.useDeferredValue;
15224 var useReactInsertionEffect = _React.useInsertionEffect;
15225 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15226 function useInitialValue(value) {
15227 const [initialValue] = (0, import_react12.useState)(value);
15228 return initialValue;
15229 }
15230 function useLiveRef(value) {
15231 const ref = (0, import_react12.useRef)(value);
15232 useSafeLayoutEffect(() => {
15233 ref.current = value;
15234 });
15235 return ref;
15236 }
15237 function useEvent(callback) {
15238 const ref = (0, import_react12.useRef)(() => {
15239 throw new Error("Cannot call an event handler while rendering.");
15240 });
15241 if (useReactInsertionEffect) {
15242 useReactInsertionEffect(() => {
15243 ref.current = callback;
15244 });
15245 } else {
15246 ref.current = callback;
15247 }
15248 return (0, import_react12.useCallback)((...args) => {
15249 var _a;
15250 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15251 }, []);
15252 }
15253 function useTransactionState(callback) {
15254 const [state, setState] = (0, import_react12.useState)(null);
15255 useSafeLayoutEffect(() => {
15256 if (state == null) return;
15257 if (!callback) return;
15258 let prevState = null;
15259 callback((prev) => {
15260 prevState = prev;
15261 return state;
15262 });
15263 return () => {
15264 callback(prevState);
15265 };
15266 }, [state, callback]);
15267 return [state, setState];
15268 }
15269 function useMergeRefs(...refs) {
15270 return (0, import_react12.useMemo)(() => {
15271 if (!refs.some(Boolean)) return;
15272 return (value) => {
15273 for (const ref of refs) {
15274 setRef(ref, value);
15275 }
15276 };
15277 }, refs);
15278 }
15279 function useId4(defaultId) {
15280 if (useReactId) {
15281 const reactId = useReactId();
15282 if (defaultId) return defaultId;
15283 return reactId;
15284 }
15285 const [id, setId] = (0, import_react12.useState)(defaultId);
15286 useSafeLayoutEffect(() => {
15287 if (defaultId || id) return;
15288 const random = Math.random().toString(36).slice(2, 8);
15289 setId(`id-${random}`);
15290 }, [defaultId, id]);
15291 return defaultId || id;
15292 }
15293 function useTagName(refOrElement, type) {
15294 const stringOrUndefined = (type2) => {
15295 if (typeof type2 !== "string") return;
15296 return type2;
15297 };
15298 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15299 useSafeLayoutEffect(() => {
15300 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15301 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15302 }, [refOrElement, type]);
15303 return tagName;
15304 }
15305 function useAttribute(refOrElement, attributeName, defaultValue2) {
15306 const initialValue = useInitialValue(defaultValue2);
15307 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15308 (0, import_react12.useEffect)(() => {
15309 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15310 if (!element) return;
15311 const callback = () => {
15312 const value = element.getAttribute(attributeName);
15313 setAttribute(value == null ? initialValue : value);
15314 };
15315 const observer = new MutationObserver(callback);
15316 observer.observe(element, { attributeFilter: [attributeName] });
15317 callback();
15318 return () => observer.disconnect();
15319 }, [refOrElement, attributeName, initialValue]);
15320 return attribute;
15321 }
15322 function useUpdateEffect(effect, deps) {
15323 const mounted = (0, import_react12.useRef)(false);
15324 (0, import_react12.useEffect)(() => {
15325 if (mounted.current) {
15326 return effect();
15327 }
15328 mounted.current = true;
15329 }, deps);
15330 (0, import_react12.useEffect)(
15331 () => () => {
15332 mounted.current = false;
15333 },
15334 []
15335 );
15336 }
15337 function useUpdateLayoutEffect(effect, deps) {
15338 const mounted = (0, import_react12.useRef)(false);
15339 useSafeLayoutEffect(() => {
15340 if (mounted.current) {
15341 return effect();
15342 }
15343 mounted.current = true;
15344 }, deps);
15345 useSafeLayoutEffect(
15346 () => () => {
15347 mounted.current = false;
15348 },
15349 []
15350 );
15351 }
15352 function useForceUpdate() {
15353 return (0, import_react12.useReducer)(() => [], []);
15354 }
15355 function useBooleanEvent(booleanOrCallback) {
15356 return useEvent(
15357 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15358 );
15359 }
15360 function useWrapElement(props, callback, deps = []) {
15361 const wrapElement = (0, import_react12.useCallback)(
15362 (element) => {
15363 if (props.wrapElement) {
15364 element = props.wrapElement(element);
15365 }
15366 return callback(element);
15367 },
15368 [...deps, props.wrapElement]
15369 );
15370 return { ...props, wrapElement };
15371 }
15372 function useMetadataProps(props, key, value) {
15373 const parent = props.onLoadedMetadataCapture;
15374 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15375 return Object.assign(() => {
15376 }, { ...parent, [key]: value });
15377 }, [parent, key, value]);
15378 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15379 }
15380 var hasInstalledGlobalEventListeners = false;
15381 function useIsMouseMoving() {
15382 (0, import_react12.useEffect)(() => {
15383 if (hasInstalledGlobalEventListeners) return;
15384 addGlobalEventListener("mousemove", setMouseMoving, true);
15385 addGlobalEventListener("mousedown", resetMouseMoving, true);
15386 addGlobalEventListener("mouseup", resetMouseMoving, true);
15387 addGlobalEventListener("keydown", resetMouseMoving, true);
15388 addGlobalEventListener("scroll", resetMouseMoving, true);
15389 hasInstalledGlobalEventListeners = true;
15390 }, []);
15391 const isMouseMoving = useEvent(() => mouseMoving);
15392 return isMouseMoving;
15393 }
15394 var mouseMoving = false;
15395 var previousScreenX = 0;
15396 var previousScreenY = 0;
15397 function hasMouseMovement(event) {
15398 const movementX = event.movementX || event.screenX - previousScreenX;
15399 const movementY = event.movementY || event.screenY - previousScreenY;
15400 previousScreenX = event.screenX;
15401 previousScreenY = event.screenY;
15402 return movementX || movementY || false;
15403 }
15404 function setMouseMoving(event) {
15405 if (!hasMouseMovement(event)) return;
15406 mouseMoving = true;
15407 }
15408 function resetMouseMoving() {
15409 mouseMoving = false;
15410 }
15411
15412 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15413 var React49 = __toESM(require_react(), 1);
15414 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15415 function forwardRef29(render4) {
15416 const Role = React49.forwardRef(
15417 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15418 (props, ref) => render4({ ...props, ref })
15419 );
15420 Role.displayName = render4.displayName || render4.name;
15421 return Role;
15422 }
15423 function memo22(Component, propsAreEqual) {
15424 return React49.memo(Component, propsAreEqual);
15425 }
15426 function createElement3(Type, props) {
15427 const { wrapElement, render: render4, ...rest } = props;
15428 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15429 let element;
15430 if (React49.isValidElement(render4)) {
15431 const renderProps = {
15432 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15433 ...render4.props,
15434 ref: mergedRef
15435 };
15436 element = React49.cloneElement(render4, mergeProps3(rest, renderProps));
15437 } else if (render4) {
15438 element = render4(rest);
15439 } else {
15440 element = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Type, { ...rest });
15441 }
15442 if (wrapElement) {
15443 return wrapElement(element);
15444 }
15445 return element;
15446 }
15447 function createHook(useProps) {
15448 const useRole = (props = {}) => {
15449 return useProps(props);
15450 };
15451 useRole.displayName = useProps.name;
15452 return useRole;
15453 }
15454 function createStoreContext(providers = [], scopedProviders = []) {
15455 const context = React49.createContext(void 0);
15456 const scopedContext = React49.createContext(void 0);
15457 const useContext210 = () => React49.useContext(context);
15458 const useScopedContext = (onlyScoped = false) => {
15459 const scoped = React49.useContext(scopedContext);
15460 const store = useContext210();
15461 if (onlyScoped) return scoped;
15462 return scoped || store;
15463 };
15464 const useProviderContext = () => {
15465 const scoped = React49.useContext(scopedContext);
15466 const store = useContext210();
15467 if (scoped && scoped === store) return;
15468 return store;
15469 };
15470 const ContextProvider = (props) => {
15471 return providers.reduceRight(
15472 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }),
15473 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(context.Provider, { ...props })
15474 );
15475 };
15476 const ScopedContextProvider = (props) => {
15477 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15478 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }),
15479 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(scopedContext.Provider, { ...props })
15480 ) });
15481 };
15482 return {
15483 context,
15484 scopedContext,
15485 useContext: useContext210,
15486 useScopedContext,
15487 useProviderContext,
15488 ContextProvider,
15489 ScopedContextProvider
15490 };
15491 }
15492
15493 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15494 var ctx = createStoreContext();
15495 var useCollectionContext = ctx.useContext;
15496 var useCollectionScopedContext = ctx.useScopedContext;
15497 var useCollectionProviderContext = ctx.useProviderContext;
15498 var CollectionContextProvider = ctx.ContextProvider;
15499 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15500
15501 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15502 var import_react13 = __toESM(require_react(), 1);
15503 var ctx2 = createStoreContext(
15504 [CollectionContextProvider],
15505 [CollectionScopedContextProvider]
15506 );
15507 var useCompositeContext = ctx2.useContext;
15508 var useCompositeScopedContext = ctx2.useScopedContext;
15509 var useCompositeProviderContext = ctx2.useProviderContext;
15510 var CompositeContextProvider = ctx2.ContextProvider;
15511 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15512 var CompositeItemContext = (0, import_react13.createContext)(
15513 void 0
15514 );
15515 var CompositeRowContext = (0, import_react13.createContext)(
15516 void 0
15517 );
15518
15519 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15520 function findFirstEnabledItem(items, excludeId) {
15521 return items.find((item) => {
15522 if (excludeId) {
15523 return !item.disabled && item.id !== excludeId;
15524 }
15525 return !item.disabled;
15526 });
15527 }
15528 function getEnabledItem(store, id) {
15529 if (!id) return null;
15530 return store.item(id) || null;
15531 }
15532 function groupItemsByRows(items) {
15533 const rows = [];
15534 for (const item of items) {
15535 const row = rows.find((currentRow) => {
15536 var _a;
15537 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15538 });
15539 if (row) {
15540 row.push(item);
15541 } else {
15542 rows.push([item]);
15543 }
15544 }
15545 return rows;
15546 }
15547 function selectTextField(element, collapseToEnd = false) {
15548 if (isTextField(element)) {
15549 element.setSelectionRange(
15550 collapseToEnd ? element.value.length : 0,
15551 element.value.length
15552 );
15553 } else if (element.isContentEditable) {
15554 const selection = getDocument(element).getSelection();
15555 selection == null ? void 0 : selection.selectAllChildren(element);
15556 if (collapseToEnd) {
15557 selection == null ? void 0 : selection.collapseToEnd();
15558 }
15559 }
15560 }
15561 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15562 function focusSilently(element) {
15563 element[FOCUS_SILENTLY] = true;
15564 element.focus({ preventScroll: true });
15565 }
15566 function silentlyFocused(element) {
15567 const isSilentlyFocused = element[FOCUS_SILENTLY];
15568 delete element[FOCUS_SILENTLY];
15569 return isSilentlyFocused;
15570 }
15571 function isItem(store, element, exclude) {
15572 if (!element) return false;
15573 if (element === exclude) return false;
15574 const item = store.item(element.id);
15575 if (!item) return false;
15576 if (exclude && item.element === exclude) return false;
15577 return true;
15578 }
15579
15580 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15581 var import_react14 = __toESM(require_react(), 1);
15582 var TagName = "div";
15583 var useCollectionItem = createHook(
15584 function useCollectionItem2({
15585 store,
15586 shouldRegisterItem = true,
15587 getItem = identity,
15588 // @ts-expect-error This prop may come from a collection renderer.
15589 element,
15590 ...props
15591 }) {
15592 const context = useCollectionContext();
15593 store = store || context;
15594 const id = useId4(props.id);
15595 const ref = (0, import_react14.useRef)(element);
15596 (0, import_react14.useEffect)(() => {
15597 const element2 = ref.current;
15598 if (!id) return;
15599 if (!element2) return;
15600 if (!shouldRegisterItem) return;
15601 const item = getItem({ id, element: element2 });
15602 return store == null ? void 0 : store.renderItem(item);
15603 }, [id, shouldRegisterItem, getItem, store]);
15604 props = {
15605 ...props,
15606 ref: useMergeRefs(ref, props.ref)
15607 };
15608 return removeUndefinedValues(props);
15609 }
15610 );
15611 var CollectionItem = forwardRef29(function CollectionItem2(props) {
15612 const htmlProps = useCollectionItem(props);
15613 return createElement3(TagName, htmlProps);
15614 });
15615
15616 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15617 var import_react15 = __toESM(require_react(), 1);
15618 var FocusableContext = (0, import_react15.createContext)(true);
15619
15620 // node_modules/@ariakit/core/esm/utils/focus.js
15621 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'])";
15622 function isFocusable(element) {
15623 if (!element.matches(selector)) return false;
15624 if (!isVisible(element)) return false;
15625 if (element.closest("[inert]")) return false;
15626 return true;
15627 }
15628 function getClosestFocusable(element) {
15629 while (element && !isFocusable(element)) {
15630 element = element.closest(selector);
15631 }
15632 return element || null;
15633 }
15634 function hasFocus(element) {
15635 const activeElement2 = getActiveElement(element);
15636 if (!activeElement2) return false;
15637 if (activeElement2 === element) return true;
15638 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15639 if (!activeDescendant) return false;
15640 return activeDescendant === element.id;
15641 }
15642 function hasFocusWithin(element) {
15643 const activeElement2 = getActiveElement(element);
15644 if (!activeElement2) return false;
15645 if (contains2(element, activeElement2)) return true;
15646 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15647 if (!activeDescendant) return false;
15648 if (!("id" in element)) return false;
15649 if (activeDescendant === element.id) return true;
15650 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15651 }
15652 function focusIfNeeded(element) {
15653 if (!hasFocusWithin(element) && isFocusable(element)) {
15654 element.focus();
15655 }
15656 }
15657 function focusIntoView(element, options) {
15658 if (!("scrollIntoView" in element)) {
15659 element.focus();
15660 } else {
15661 element.focus({ preventScroll: true });
15662 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15663 }
15664 }
15665
15666 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15667 var import_react16 = __toESM(require_react(), 1);
15668 var TagName2 = "div";
15669 var isSafariBrowser = isSafari2();
15670 var alwaysFocusVisibleInputTypes = [
15671 "text",
15672 "search",
15673 "url",
15674 "tel",
15675 "email",
15676 "password",
15677 "number",
15678 "date",
15679 "month",
15680 "week",
15681 "time",
15682 "datetime",
15683 "datetime-local"
15684 ];
15685 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15686 function markSafariFocusAncestor(element, value) {
15687 if (!element) return;
15688 element[safariFocusAncestorSymbol] = value;
15689 }
15690 function isAlwaysFocusVisible(element) {
15691 const { tagName, readOnly, type } = element;
15692 if (tagName === "TEXTAREA" && !readOnly) return true;
15693 if (tagName === "SELECT" && !readOnly) return true;
15694 if (tagName === "INPUT" && !readOnly) {
15695 return alwaysFocusVisibleInputTypes.includes(type);
15696 }
15697 if (element.isContentEditable) return true;
15698 const role = element.getAttribute("role");
15699 if (role === "combobox" && element.dataset.name) {
15700 return true;
15701 }
15702 return false;
15703 }
15704 function getLabels(element) {
15705 if ("labels" in element) {
15706 return element.labels;
15707 }
15708 return null;
15709 }
15710 function isNativeCheckboxOrRadio(element) {
15711 const tagName = element.tagName.toLowerCase();
15712 if (tagName === "input" && element.type) {
15713 return element.type === "radio" || element.type === "checkbox";
15714 }
15715 return false;
15716 }
15717 function isNativeTabbable(tagName) {
15718 if (!tagName) return true;
15719 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15720 }
15721 function supportsDisabledAttribute(tagName) {
15722 if (!tagName) return true;
15723 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15724 }
15725 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15726 if (!focusable2) {
15727 return tabIndexProp;
15728 }
15729 if (trulyDisabled) {
15730 if (nativeTabbable && !supportsDisabled) {
15731 return -1;
15732 }
15733 return;
15734 }
15735 if (nativeTabbable) {
15736 return tabIndexProp;
15737 }
15738 return tabIndexProp || 0;
15739 }
15740 function useDisableEvent(onEvent, disabled2) {
15741 return useEvent((event) => {
15742 onEvent == null ? void 0 : onEvent(event);
15743 if (event.defaultPrevented) return;
15744 if (disabled2) {
15745 event.stopPropagation();
15746 event.preventDefault();
15747 }
15748 });
15749 }
15750 var hasInstalledGlobalEventListeners2 = false;
15751 var isKeyboardModality = true;
15752 function onGlobalMouseDown(event) {
15753 const target = event.target;
15754 if (target && "hasAttribute" in target) {
15755 if (!target.hasAttribute("data-focus-visible")) {
15756 isKeyboardModality = false;
15757 }
15758 }
15759 }
15760 function onGlobalKeyDown(event) {
15761 if (event.metaKey) return;
15762 if (event.ctrlKey) return;
15763 if (event.altKey) return;
15764 isKeyboardModality = true;
15765 }
15766 var useFocusable = createHook(
15767 function useFocusable2({
15768 focusable: focusable2 = true,
15769 accessibleWhenDisabled,
15770 autoFocus,
15771 onFocusVisible,
15772 ...props
15773 }) {
15774 const ref = (0, import_react16.useRef)(null);
15775 (0, import_react16.useEffect)(() => {
15776 if (!focusable2) return;
15777 if (hasInstalledGlobalEventListeners2) return;
15778 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15779 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15780 hasInstalledGlobalEventListeners2 = true;
15781 }, [focusable2]);
15782 if (isSafariBrowser) {
15783 (0, import_react16.useEffect)(() => {
15784 if (!focusable2) return;
15785 const element = ref.current;
15786 if (!element) return;
15787 if (!isNativeCheckboxOrRadio(element)) return;
15788 const labels = getLabels(element);
15789 if (!labels) return;
15790 const onMouseUp = () => queueMicrotask(() => element.focus());
15791 for (const label of labels) {
15792 label.addEventListener("mouseup", onMouseUp);
15793 }
15794 return () => {
15795 for (const label of labels) {
15796 label.removeEventListener("mouseup", onMouseUp);
15797 }
15798 };
15799 }, [focusable2]);
15800 }
15801 const disabled2 = focusable2 && disabledFromProps(props);
15802 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15803 const [focusVisible, setFocusVisible] = (0, import_react16.useState)(false);
15804 (0, import_react16.useEffect)(() => {
15805 if (!focusable2) return;
15806 if (trulyDisabled && focusVisible) {
15807 setFocusVisible(false);
15808 }
15809 }, [focusable2, trulyDisabled, focusVisible]);
15810 (0, import_react16.useEffect)(() => {
15811 if (!focusable2) return;
15812 if (!focusVisible) return;
15813 const element = ref.current;
15814 if (!element) return;
15815 if (typeof IntersectionObserver === "undefined") return;
15816 const observer = new IntersectionObserver(() => {
15817 if (!isFocusable(element)) {
15818 setFocusVisible(false);
15819 }
15820 });
15821 observer.observe(element);
15822 return () => observer.disconnect();
15823 }, [focusable2, focusVisible]);
15824 const onKeyPressCapture = useDisableEvent(
15825 props.onKeyPressCapture,
15826 disabled2
15827 );
15828 const onMouseDownCapture = useDisableEvent(
15829 props.onMouseDownCapture,
15830 disabled2
15831 );
15832 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15833 const onMouseDownProp = props.onMouseDown;
15834 const onMouseDown = useEvent((event) => {
15835 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15836 if (event.defaultPrevented) return;
15837 if (!focusable2) return;
15838 const element = event.currentTarget;
15839 if (!isSafariBrowser) return;
15840 if (isPortalEvent(event)) return;
15841 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15842 let receivedFocus = false;
15843 const onFocus = () => {
15844 receivedFocus = true;
15845 };
15846 const options = { capture: true, once: true };
15847 element.addEventListener("focusin", onFocus, options);
15848 const focusableContainer = getClosestFocusable(element.parentElement);
15849 markSafariFocusAncestor(focusableContainer, true);
15850 queueBeforeEvent(element, "mouseup", () => {
15851 element.removeEventListener("focusin", onFocus, true);
15852 markSafariFocusAncestor(focusableContainer, false);
15853 if (receivedFocus) return;
15854 focusIfNeeded(element);
15855 });
15856 });
15857 const handleFocusVisible = (event, currentTarget) => {
15858 if (currentTarget) {
15859 event.currentTarget = currentTarget;
15860 }
15861 if (!focusable2) return;
15862 const element = event.currentTarget;
15863 if (!element) return;
15864 if (!hasFocus(element)) return;
15865 onFocusVisible == null ? void 0 : onFocusVisible(event);
15866 if (event.defaultPrevented) return;
15867 element.dataset.focusVisible = "true";
15868 setFocusVisible(true);
15869 };
15870 const onKeyDownCaptureProp = props.onKeyDownCapture;
15871 const onKeyDownCapture = useEvent((event) => {
15872 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15873 if (event.defaultPrevented) return;
15874 if (!focusable2) return;
15875 if (focusVisible) return;
15876 if (event.metaKey) return;
15877 if (event.altKey) return;
15878 if (event.ctrlKey) return;
15879 if (!isSelfTarget(event)) return;
15880 const element = event.currentTarget;
15881 const applyFocusVisible = () => handleFocusVisible(event, element);
15882 queueBeforeEvent(element, "focusout", applyFocusVisible);
15883 });
15884 const onFocusCaptureProp = props.onFocusCapture;
15885 const onFocusCapture = useEvent((event) => {
15886 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15887 if (event.defaultPrevented) return;
15888 if (!focusable2) return;
15889 if (!isSelfTarget(event)) {
15890 setFocusVisible(false);
15891 return;
15892 }
15893 const element = event.currentTarget;
15894 const applyFocusVisible = () => handleFocusVisible(event, element);
15895 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15896 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15897 } else {
15898 setFocusVisible(false);
15899 }
15900 });
15901 const onBlurProp = props.onBlur;
15902 const onBlur = useEvent((event) => {
15903 onBlurProp == null ? void 0 : onBlurProp(event);
15904 if (!focusable2) return;
15905 if (!isFocusEventOutside(event)) return;
15906 event.currentTarget.removeAttribute("data-focus-visible");
15907 setFocusVisible(false);
15908 });
15909 const autoFocusOnShow = (0, import_react16.useContext)(FocusableContext);
15910 const autoFocusRef = useEvent((element) => {
15911 if (!focusable2) return;
15912 if (!autoFocus) return;
15913 if (!element) return;
15914 if (!autoFocusOnShow) return;
15915 queueMicrotask(() => {
15916 if (hasFocus(element)) return;
15917 if (!isFocusable(element)) return;
15918 element.focus();
15919 });
15920 });
15921 const tagName = useTagName(ref);
15922 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15923 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15924 const styleProp = props.style;
15925 const style = (0, import_react16.useMemo)(() => {
15926 if (trulyDisabled) {
15927 return { pointerEvents: "none", ...styleProp };
15928 }
15929 return styleProp;
15930 }, [trulyDisabled, styleProp]);
15931 props = {
15932 "data-focus-visible": focusable2 && focusVisible || void 0,
15933 "data-autofocus": autoFocus || void 0,
15934 "aria-disabled": disabled2 || void 0,
15935 ...props,
15936 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15937 style,
15938 tabIndex: getTabIndex2(
15939 focusable2,
15940 trulyDisabled,
15941 nativeTabbable,
15942 supportsDisabled,
15943 props.tabIndex
15944 ),
15945 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15946 // TODO: Test Focusable contentEditable.
15947 contentEditable: disabled2 ? void 0 : props.contentEditable,
15948 onKeyPressCapture,
15949 onClickCapture,
15950 onMouseDownCapture,
15951 onMouseDown,
15952 onKeyDownCapture,
15953 onFocusCapture,
15954 onBlur
15955 };
15956 return removeUndefinedValues(props);
15957 }
15958 );
15959 var Focusable = forwardRef29(function Focusable2(props) {
15960 const htmlProps = useFocusable(props);
15961 return createElement3(TagName2, htmlProps);
15962 });
15963
15964 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15965 var import_react17 = __toESM(require_react(), 1);
15966 var TagName3 = "button";
15967 function isNativeClick(event) {
15968 if (!event.isTrusted) return false;
15969 const element = event.currentTarget;
15970 if (event.key === "Enter") {
15971 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15972 }
15973 if (event.key === " ") {
15974 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
15975 }
15976 return false;
15977 }
15978 var symbol = /* @__PURE__ */ Symbol("command");
15979 var useCommand = createHook(
15980 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
15981 const ref = (0, import_react17.useRef)(null);
15982 const [isNativeButton, setIsNativeButton] = (0, import_react17.useState)(false);
15983 (0, import_react17.useEffect)(() => {
15984 if (!ref.current) return;
15985 setIsNativeButton(isButton(ref.current));
15986 }, []);
15987 const [active, setActive] = (0, import_react17.useState)(false);
15988 const activeRef = (0, import_react17.useRef)(false);
15989 const disabled2 = disabledFromProps(props);
15990 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
15991 const onKeyDownProp = props.onKeyDown;
15992 const onKeyDown = useEvent((event) => {
15993 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
15994 const element = event.currentTarget;
15995 if (event.defaultPrevented) return;
15996 if (isDuplicate) return;
15997 if (disabled2) return;
15998 if (!isSelfTarget(event)) return;
15999 if (isTextField(element)) return;
16000 if (element.isContentEditable) return;
16001 const isEnter = clickOnEnter && event.key === "Enter";
16002 const isSpace = clickOnSpace && event.key === " ";
16003 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16004 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16005 if (shouldPreventEnter || shouldPreventSpace) {
16006 event.preventDefault();
16007 return;
16008 }
16009 if (isEnter || isSpace) {
16010 const nativeClick = isNativeClick(event);
16011 if (isEnter) {
16012 if (!nativeClick) {
16013 event.preventDefault();
16014 const { view, ...eventInit } = event;
16015 const click = () => fireClickEvent(element, eventInit);
16016 if (isFirefox2()) {
16017 queueBeforeEvent(element, "keyup", click);
16018 } else {
16019 queueMicrotask(click);
16020 }
16021 }
16022 } else if (isSpace) {
16023 activeRef.current = true;
16024 if (!nativeClick) {
16025 event.preventDefault();
16026 setActive(true);
16027 }
16028 }
16029 }
16030 });
16031 const onKeyUpProp = props.onKeyUp;
16032 const onKeyUp = useEvent((event) => {
16033 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
16034 if (event.defaultPrevented) return;
16035 if (isDuplicate) return;
16036 if (disabled2) return;
16037 if (event.metaKey) return;
16038 const isSpace = clickOnSpace && event.key === " ";
16039 if (activeRef.current && isSpace) {
16040 activeRef.current = false;
16041 if (!isNativeClick(event)) {
16042 event.preventDefault();
16043 setActive(false);
16044 const element = event.currentTarget;
16045 const { view, ...eventInit } = event;
16046 queueMicrotask(() => fireClickEvent(element, eventInit));
16047 }
16048 }
16049 });
16050 props = {
16051 "data-active": active || void 0,
16052 type: isNativeButton ? "button" : void 0,
16053 ...metadataProps,
16054 ...props,
16055 ref: useMergeRefs(ref, props.ref),
16056 onKeyDown,
16057 onKeyUp
16058 };
16059 props = useFocusable(props);
16060 return props;
16061 }
16062 );
16063 var Command = forwardRef29(function Command2(props) {
16064 const htmlProps = useCommand(props);
16065 return createElement3(TagName3, htmlProps);
16066 });
16067
16068 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
16069 function getInternal(store, key) {
16070 const internals = store.__unstableInternals;
16071 invariant(internals, "Invalid store");
16072 return internals[key];
16073 }
16074 function createStore(initialState, ...stores) {
16075 let state = initialState;
16076 let prevStateBatch = state;
16077 let lastUpdate = /* @__PURE__ */ Symbol();
16078 let destroy = noop4;
16079 const instances = /* @__PURE__ */ new Set();
16080 const updatedKeys = /* @__PURE__ */ new Set();
16081 const setups = /* @__PURE__ */ new Set();
16082 const listeners = /* @__PURE__ */ new Set();
16083 const batchListeners = /* @__PURE__ */ new Set();
16084 const disposables = /* @__PURE__ */ new WeakMap();
16085 const listenerKeys = /* @__PURE__ */ new WeakMap();
16086 const storeSetup = (callback) => {
16087 setups.add(callback);
16088 return () => setups.delete(callback);
16089 };
16090 const storeInit = () => {
16091 const initialized = instances.size;
16092 const instance = /* @__PURE__ */ Symbol();
16093 instances.add(instance);
16094 const maybeDestroy = () => {
16095 instances.delete(instance);
16096 if (instances.size) return;
16097 destroy();
16098 };
16099 if (initialized) return maybeDestroy;
16100 const desyncs = getKeys(state).map(
16101 (key) => chain(
16102 ...stores.map((store) => {
16103 var _a;
16104 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
16105 if (!storeState) return;
16106 if (!hasOwnProperty(storeState, key)) return;
16107 return sync(store, [key], (state2) => {
16108 setState(
16109 key,
16110 state2[key],
16111 // @ts-expect-error - Not public API. This is just to prevent
16112 // infinite loops.
16113 true
16114 );
16115 });
16116 })
16117 )
16118 );
16119 const teardowns = [];
16120 for (const setup2 of setups) {
16121 teardowns.push(setup2());
16122 }
16123 const cleanups = stores.map(init);
16124 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16125 return maybeDestroy;
16126 };
16127 const sub = (keys, listener, set2 = listeners) => {
16128 set2.add(listener);
16129 listenerKeys.set(listener, keys);
16130 return () => {
16131 var _a;
16132 (_a = disposables.get(listener)) == null ? void 0 : _a();
16133 disposables.delete(listener);
16134 listenerKeys.delete(listener);
16135 set2.delete(listener);
16136 };
16137 };
16138 const storeSubscribe = (keys, listener) => sub(keys, listener);
16139 const storeSync = (keys, listener) => {
16140 disposables.set(listener, listener(state, state));
16141 return sub(keys, listener);
16142 };
16143 const storeBatch = (keys, listener) => {
16144 disposables.set(listener, listener(state, prevStateBatch));
16145 return sub(keys, listener, batchListeners);
16146 };
16147 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16148 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16149 const getState = () => state;
16150 const setState = (key, value, fromStores = false) => {
16151 var _a;
16152 if (!hasOwnProperty(state, key)) return;
16153 const nextValue = applyState(value, state[key]);
16154 if (nextValue === state[key]) return;
16155 if (!fromStores) {
16156 for (const store of stores) {
16157 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
16158 }
16159 }
16160 const prevState = state;
16161 state = { ...state, [key]: nextValue };
16162 const thisUpdate = /* @__PURE__ */ Symbol();
16163 lastUpdate = thisUpdate;
16164 updatedKeys.add(key);
16165 const run = (listener, prev, uKeys) => {
16166 var _a2;
16167 const keys = listenerKeys.get(listener);
16168 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
16169 if (!keys || keys.some(updated)) {
16170 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
16171 disposables.set(listener, listener(state, prev));
16172 }
16173 };
16174 for (const listener of listeners) {
16175 run(listener, prevState);
16176 }
16177 queueMicrotask(() => {
16178 if (lastUpdate !== thisUpdate) return;
16179 const snapshot = state;
16180 for (const listener of batchListeners) {
16181 run(listener, prevStateBatch, updatedKeys);
16182 }
16183 prevStateBatch = snapshot;
16184 updatedKeys.clear();
16185 });
16186 };
16187 const finalStore = {
16188 getState,
16189 setState,
16190 __unstableInternals: {
16191 setup: storeSetup,
16192 init: storeInit,
16193 subscribe: storeSubscribe,
16194 sync: storeSync,
16195 batch: storeBatch,
16196 pick: storePick,
16197 omit: storeOmit
16198 }
16199 };
16200 return finalStore;
16201 }
16202 function setup(store, ...args) {
16203 if (!store) return;
16204 return getInternal(store, "setup")(...args);
16205 }
16206 function init(store, ...args) {
16207 if (!store) return;
16208 return getInternal(store, "init")(...args);
16209 }
16210 function subscribe(store, ...args) {
16211 if (!store) return;
16212 return getInternal(store, "subscribe")(...args);
16213 }
16214 function sync(store, ...args) {
16215 if (!store) return;
16216 return getInternal(store, "sync")(...args);
16217 }
16218 function batch(store, ...args) {
16219 if (!store) return;
16220 return getInternal(store, "batch")(...args);
16221 }
16222 function omit2(store, ...args) {
16223 if (!store) return;
16224 return getInternal(store, "omit")(...args);
16225 }
16226 function pick2(store, ...args) {
16227 if (!store) return;
16228 return getInternal(store, "pick")(...args);
16229 }
16230 function mergeStore(...stores) {
16231 var _a;
16232 const initialState = {};
16233 for (const store2 of stores) {
16234 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16235 if (nextState) {
16236 Object.assign(initialState, nextState);
16237 }
16238 }
16239 const store = createStore(initialState, ...stores);
16240 return Object.assign({}, ...stores, store);
16241 }
16242 function throwOnConflictingProps(props, store) {
16243 if (false) return;
16244 if (!store) return;
16245 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16246 var _a;
16247 const stateKey = key.replace("default", "");
16248 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16249 });
16250 if (!defaultKeys.length) return;
16251 const storeState = store.getState();
16252 const conflictingProps = defaultKeys.filter(
16253 (key) => hasOwnProperty(storeState, key)
16254 );
16255 if (!conflictingProps.length) return;
16256 throw new Error(
16257 `Passing a store prop in conjunction with a default state is not supported.
16258
16259 const store = useSelectStore();
16260 <SelectProvider store={store} defaultValue="Apple" />
16261 ^ ^
16262
16263 Instead, pass the default state to the topmost store:
16264
16265 const store = useSelectStore({ defaultValue: "Apple" });
16266 <SelectProvider store={store} />
16267
16268 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16269
16270 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16271 `
16272 );
16273 }
16274
16275 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16276 var React50 = __toESM(require_react(), 1);
16277 var import_shim2 = __toESM(require_shim(), 1);
16278 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16279 var noopSubscribe = () => () => {
16280 };
16281 function useStoreState(store, keyOrSelector = identity) {
16282 const storeSubscribe = React50.useCallback(
16283 (callback) => {
16284 if (!store) return noopSubscribe();
16285 return subscribe(store, null, callback);
16286 },
16287 [store]
16288 );
16289 const getSnapshot = () => {
16290 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16291 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16292 const state = store == null ? void 0 : store.getState();
16293 if (selector2) return selector2(state);
16294 if (!state) return;
16295 if (!key) return;
16296 if (!hasOwnProperty(state, key)) return;
16297 return state[key];
16298 };
16299 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16300 }
16301 function useStoreStateObject(store, object) {
16302 const objRef = React50.useRef(
16303 {}
16304 );
16305 const storeSubscribe = React50.useCallback(
16306 (callback) => {
16307 if (!store) return noopSubscribe();
16308 return subscribe(store, null, callback);
16309 },
16310 [store]
16311 );
16312 const getSnapshot = () => {
16313 const state = store == null ? void 0 : store.getState();
16314 let updated = false;
16315 const obj = objRef.current;
16316 for (const prop in object) {
16317 const keyOrSelector = object[prop];
16318 if (typeof keyOrSelector === "function") {
16319 const value = keyOrSelector(state);
16320 if (value !== obj[prop]) {
16321 obj[prop] = value;
16322 updated = true;
16323 }
16324 }
16325 if (typeof keyOrSelector === "string") {
16326 if (!state) continue;
16327 if (!hasOwnProperty(state, keyOrSelector)) continue;
16328 const value = state[keyOrSelector];
16329 if (value !== obj[prop]) {
16330 obj[prop] = value;
16331 updated = true;
16332 }
16333 }
16334 }
16335 if (updated) {
16336 objRef.current = { ...obj };
16337 }
16338 return objRef.current;
16339 };
16340 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16341 }
16342 function useStoreProps(store, props, key, setKey) {
16343 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16344 const setValue = setKey ? props[setKey] : void 0;
16345 const propsRef = useLiveRef({ value, setValue });
16346 useSafeLayoutEffect(() => {
16347 return sync(store, [key], (state, prev) => {
16348 const { value: value2, setValue: setValue2 } = propsRef.current;
16349 if (!setValue2) return;
16350 if (state[key] === prev[key]) return;
16351 if (state[key] === value2) return;
16352 setValue2(state[key]);
16353 });
16354 }, [store, key]);
16355 useSafeLayoutEffect(() => {
16356 if (value === void 0) return;
16357 store.setState(key, value);
16358 return batch(store, [key], () => {
16359 if (value === void 0) return;
16360 store.setState(key, value);
16361 });
16362 });
16363 }
16364 function useStore2(createStore2, props) {
16365 const [store, setStore] = React50.useState(() => createStore2(props));
16366 useSafeLayoutEffect(() => init(store), [store]);
16367 const useState210 = React50.useCallback(
16368 (keyOrSelector) => useStoreState(store, keyOrSelector),
16369 [store]
16370 );
16371 const memoizedStore = React50.useMemo(
16372 () => ({ ...store, useState: useState210 }),
16373 [store, useState210]
16374 );
16375 const updateStore = useEvent(() => {
16376 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16377 });
16378 return [memoizedStore, updateStore];
16379 }
16380
16381 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16382 var import_react18 = __toESM(require_react(), 1);
16383 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16384 var TagName4 = "button";
16385 function isEditableElement(element) {
16386 if (isTextbox(element)) return true;
16387 return element.tagName === "INPUT" && !isButton(element);
16388 }
16389 function getNextPageOffset(scrollingElement, pageUp = false) {
16390 const height = scrollingElement.clientHeight;
16391 const { top } = scrollingElement.getBoundingClientRect();
16392 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16393 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16394 if (scrollingElement.tagName === "HTML") {
16395 return pageOffset + scrollingElement.scrollTop;
16396 }
16397 return pageOffset;
16398 }
16399 function getItemOffset(itemElement, pageUp = false) {
16400 const { top } = itemElement.getBoundingClientRect();
16401 if (pageUp) {
16402 return top + itemElement.clientHeight;
16403 }
16404 return top;
16405 }
16406 function findNextPageItemId(element, store, next, pageUp = false) {
16407 var _a;
16408 if (!store) return;
16409 if (!next) return;
16410 const { renderedItems } = store.getState();
16411 const scrollingElement = getScrollingElement(element);
16412 if (!scrollingElement) return;
16413 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16414 let id;
16415 let prevDifference;
16416 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16417 const previousId = id;
16418 id = next(i2);
16419 if (!id) break;
16420 if (id === previousId) continue;
16421 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16422 if (!itemElement) continue;
16423 const itemOffset = getItemOffset(itemElement, pageUp);
16424 const difference = itemOffset - nextPageOffset;
16425 const absDifference = Math.abs(difference);
16426 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16427 if (prevDifference !== void 0 && prevDifference < absDifference) {
16428 id = previousId;
16429 }
16430 break;
16431 }
16432 prevDifference = absDifference;
16433 }
16434 return id;
16435 }
16436 function targetIsAnotherItem(event, store) {
16437 if (isSelfTarget(event)) return false;
16438 return isItem(store, event.target);
16439 }
16440 var useCompositeItem = createHook(
16441 function useCompositeItem2({
16442 store,
16443 rowId: rowIdProp,
16444 preventScrollOnKeyDown = false,
16445 moveOnKeyPress = true,
16446 tabbable: tabbable2 = false,
16447 getItem: getItemProp,
16448 "aria-setsize": ariaSetSizeProp,
16449 "aria-posinset": ariaPosInSetProp,
16450 ...props
16451 }) {
16452 const context = useCompositeContext();
16453 store = store || context;
16454 const id = useId4(props.id);
16455 const ref = (0, import_react18.useRef)(null);
16456 const row = (0, import_react18.useContext)(CompositeRowContext);
16457 const disabled2 = disabledFromProps(props);
16458 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16459 const {
16460 rowId,
16461 baseElement,
16462 isActiveItem,
16463 ariaSetSize,
16464 ariaPosInSet,
16465 isTabbable
16466 } = useStoreStateObject(store, {
16467 rowId(state) {
16468 if (rowIdProp) return rowIdProp;
16469 if (!state) return;
16470 if (!(row == null ? void 0 : row.baseElement)) return;
16471 if (row.baseElement !== state.baseElement) return;
16472 return row.id;
16473 },
16474 baseElement(state) {
16475 return (state == null ? void 0 : state.baseElement) || void 0;
16476 },
16477 isActiveItem(state) {
16478 return !!state && state.activeId === id;
16479 },
16480 ariaSetSize(state) {
16481 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16482 if (!state) return;
16483 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16484 if (row.baseElement !== state.baseElement) return;
16485 return row.ariaSetSize;
16486 },
16487 ariaPosInSet(state) {
16488 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16489 if (!state) return;
16490 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16491 if (row.baseElement !== state.baseElement) return;
16492 const itemsInRow = state.renderedItems.filter(
16493 (item) => item.rowId === rowId
16494 );
16495 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16496 },
16497 isTabbable(state) {
16498 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16499 if (state.virtualFocus) return false;
16500 if (tabbable2) return true;
16501 if (state.activeId === null) return false;
16502 const item = store == null ? void 0 : store.item(state.activeId);
16503 if (item == null ? void 0 : item.disabled) return true;
16504 if (!(item == null ? void 0 : item.element)) return true;
16505 return state.activeId === id;
16506 }
16507 });
16508 const getItem = (0, import_react18.useCallback)(
16509 (item) => {
16510 var _a;
16511 const nextItem = {
16512 ...item,
16513 id: id || item.id,
16514 rowId,
16515 disabled: !!trulyDisabled,
16516 children: (_a = item.element) == null ? void 0 : _a.textContent
16517 };
16518 if (getItemProp) {
16519 return getItemProp(nextItem);
16520 }
16521 return nextItem;
16522 },
16523 [id, rowId, trulyDisabled, getItemProp]
16524 );
16525 const onFocusProp = props.onFocus;
16526 const hasFocusedComposite = (0, import_react18.useRef)(false);
16527 const onFocus = useEvent((event) => {
16528 onFocusProp == null ? void 0 : onFocusProp(event);
16529 if (event.defaultPrevented) return;
16530 if (isPortalEvent(event)) return;
16531 if (!id) return;
16532 if (!store) return;
16533 if (targetIsAnotherItem(event, store)) return;
16534 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16535 store.setActiveId(id);
16536 if (isTextbox(event.currentTarget)) {
16537 selectTextField(event.currentTarget);
16538 }
16539 if (!virtualFocus) return;
16540 if (!isSelfTarget(event)) return;
16541 if (isEditableElement(event.currentTarget)) return;
16542 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16543 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16544 event.currentTarget.scrollIntoView({
16545 block: "nearest",
16546 inline: "nearest"
16547 });
16548 }
16549 hasFocusedComposite.current = true;
16550 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16551 if (fromComposite) {
16552 focusSilently(baseElement2);
16553 } else {
16554 baseElement2.focus();
16555 }
16556 });
16557 const onBlurCaptureProp = props.onBlurCapture;
16558 const onBlurCapture = useEvent((event) => {
16559 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16560 if (event.defaultPrevented) return;
16561 const state = store == null ? void 0 : store.getState();
16562 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16563 hasFocusedComposite.current = false;
16564 event.preventDefault();
16565 event.stopPropagation();
16566 }
16567 });
16568 const onKeyDownProp = props.onKeyDown;
16569 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16570 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16571 const onKeyDown = useEvent((event) => {
16572 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16573 if (event.defaultPrevented) return;
16574 if (!isSelfTarget(event)) return;
16575 if (!store) return;
16576 const { currentTarget } = event;
16577 const state = store.getState();
16578 const item = store.item(id);
16579 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16580 const isVertical = state.orientation !== "horizontal";
16581 const isHorizontal = state.orientation !== "vertical";
16582 const canHomeEnd = () => {
16583 if (isGrid2) return true;
16584 if (isHorizontal) return true;
16585 if (!state.baseElement) return true;
16586 if (!isTextField(state.baseElement)) return true;
16587 return false;
16588 };
16589 const keyMap = {
16590 ArrowUp: (isGrid2 || isVertical) && store.up,
16591 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16592 ArrowDown: (isGrid2 || isVertical) && store.down,
16593 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16594 Home: () => {
16595 if (!canHomeEnd()) return;
16596 if (!isGrid2 || event.ctrlKey) {
16597 return store == null ? void 0 : store.first();
16598 }
16599 return store == null ? void 0 : store.previous(-1);
16600 },
16601 End: () => {
16602 if (!canHomeEnd()) return;
16603 if (!isGrid2 || event.ctrlKey) {
16604 return store == null ? void 0 : store.last();
16605 }
16606 return store == null ? void 0 : store.next(-1);
16607 },
16608 PageUp: () => {
16609 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16610 },
16611 PageDown: () => {
16612 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16613 }
16614 };
16615 const action = keyMap[event.key];
16616 if (action) {
16617 if (isTextbox(currentTarget)) {
16618 const selection = getTextboxSelection(currentTarget);
16619 const isLeft = isHorizontal && event.key === "ArrowLeft";
16620 const isRight = isHorizontal && event.key === "ArrowRight";
16621 const isUp = isVertical && event.key === "ArrowUp";
16622 const isDown = isVertical && event.key === "ArrowDown";
16623 if (isRight || isDown) {
16624 const { length: valueLength } = getTextboxValue(currentTarget);
16625 if (selection.end !== valueLength) return;
16626 } else if ((isLeft || isUp) && selection.start !== 0) return;
16627 }
16628 const nextId = action();
16629 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16630 if (!moveOnKeyPressProp(event)) return;
16631 event.preventDefault();
16632 store.move(nextId);
16633 }
16634 }
16635 });
16636 const providerValue = (0, import_react18.useMemo)(
16637 () => ({ id, baseElement }),
16638 [id, baseElement]
16639 );
16640 props = useWrapElement(
16641 props,
16642 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16643 [providerValue]
16644 );
16645 props = {
16646 id,
16647 "data-active-item": isActiveItem || void 0,
16648 ...props,
16649 ref: useMergeRefs(ref, props.ref),
16650 tabIndex: isTabbable ? props.tabIndex : -1,
16651 onFocus,
16652 onBlurCapture,
16653 onKeyDown
16654 };
16655 props = useCommand(props);
16656 props = useCollectionItem({
16657 store,
16658 ...props,
16659 getItem,
16660 shouldRegisterItem: id ? props.shouldRegisterItem : false
16661 });
16662 return removeUndefinedValues({
16663 ...props,
16664 "aria-setsize": ariaSetSize,
16665 "aria-posinset": ariaPosInSet
16666 });
16667 }
16668 );
16669 var CompositeItem = memo22(
16670 forwardRef29(function CompositeItem2(props) {
16671 const htmlProps = useCompositeItem(props);
16672 return createElement3(TagName4, htmlProps);
16673 })
16674 );
16675
16676 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16677 function toArray(arg) {
16678 if (Array.isArray(arg)) {
16679 return arg;
16680 }
16681 return typeof arg !== "undefined" ? [arg] : [];
16682 }
16683 function flatten2DArray(array) {
16684 const flattened = [];
16685 for (const row of array) {
16686 flattened.push(...row);
16687 }
16688 return flattened;
16689 }
16690 function reverseArray(array) {
16691 return array.slice().reverse();
16692 }
16693
16694 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16695 var import_react19 = __toESM(require_react(), 1);
16696 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
16697 var TagName5 = "div";
16698 function isGrid(items) {
16699 return items.some((item) => !!item.rowId);
16700 }
16701 function isPrintableKey(event) {
16702 const target = event.target;
16703 if (target && !isTextField(target)) return false;
16704 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16705 }
16706 function isModifierKey(event) {
16707 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16708 }
16709 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16710 return useEvent((event) => {
16711 var _a;
16712 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16713 if (event.defaultPrevented) return;
16714 if (event.isPropagationStopped()) return;
16715 if (!isSelfTarget(event)) return;
16716 if (isModifierKey(event)) return;
16717 if (isPrintableKey(event)) return;
16718 const state = store.getState();
16719 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16720 if (!activeElement2) return;
16721 const { view, ...eventInit } = event;
16722 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16723 if (activeElement2 !== previousElement) {
16724 activeElement2.focus();
16725 }
16726 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16727 event.preventDefault();
16728 }
16729 if (event.currentTarget.contains(activeElement2)) {
16730 event.stopPropagation();
16731 }
16732 });
16733 }
16734 function findFirstEnabledItemInTheLastRow(items) {
16735 return findFirstEnabledItem(
16736 flatten2DArray(reverseArray(groupItemsByRows(items)))
16737 );
16738 }
16739 function useScheduleFocus(store) {
16740 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
16741 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
16742 const activeItem = store.useState(
16743 (state) => getEnabledItem(store, state.activeId)
16744 );
16745 (0, import_react19.useEffect)(() => {
16746 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16747 if (!scheduled) return;
16748 if (!activeElement2) return;
16749 setScheduled(false);
16750 activeElement2.focus({ preventScroll: true });
16751 }, [activeItem, scheduled]);
16752 return schedule;
16753 }
16754 var useComposite = createHook(
16755 function useComposite2({
16756 store,
16757 composite = true,
16758 focusOnMove = composite,
16759 moveOnKeyPress = true,
16760 ...props
16761 }) {
16762 const context = useCompositeProviderContext();
16763 store = store || context;
16764 invariant(
16765 store,
16766 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16767 );
16768 const ref = (0, import_react19.useRef)(null);
16769 const previousElementRef = (0, import_react19.useRef)(null);
16770 const scheduleFocus = useScheduleFocus(store);
16771 const moves = store.useState("moves");
16772 const [, setBaseElement] = useTransactionState(
16773 composite ? store.setBaseElement : null
16774 );
16775 (0, import_react19.useEffect)(() => {
16776 var _a;
16777 if (!store) return;
16778 if (!moves) return;
16779 if (!composite) return;
16780 if (!focusOnMove) return;
16781 const { activeId: activeId2 } = store.getState();
16782 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16783 if (!itemElement) return;
16784 focusIntoView(itemElement);
16785 }, [store, moves, composite, focusOnMove]);
16786 useSafeLayoutEffect(() => {
16787 if (!store) return;
16788 if (!moves) return;
16789 if (!composite) return;
16790 const { baseElement, activeId: activeId2 } = store.getState();
16791 const isSelfAcive = activeId2 === null;
16792 if (!isSelfAcive) return;
16793 if (!baseElement) return;
16794 const previousElement = previousElementRef.current;
16795 previousElementRef.current = null;
16796 if (previousElement) {
16797 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16798 }
16799 if (!hasFocus(baseElement)) {
16800 baseElement.focus();
16801 }
16802 }, [store, moves, composite]);
16803 const activeId = store.useState("activeId");
16804 const virtualFocus = store.useState("virtualFocus");
16805 useSafeLayoutEffect(() => {
16806 var _a;
16807 if (!store) return;
16808 if (!composite) return;
16809 if (!virtualFocus) return;
16810 const previousElement = previousElementRef.current;
16811 previousElementRef.current = null;
16812 if (!previousElement) return;
16813 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16814 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16815 if (relatedTarget === previousElement) return;
16816 fireBlurEvent(previousElement, { relatedTarget });
16817 }, [store, activeId, virtualFocus, composite]);
16818 const onKeyDownCapture = useKeyboardEventProxy(
16819 store,
16820 props.onKeyDownCapture,
16821 previousElementRef
16822 );
16823 const onKeyUpCapture = useKeyboardEventProxy(
16824 store,
16825 props.onKeyUpCapture,
16826 previousElementRef
16827 );
16828 const onFocusCaptureProp = props.onFocusCapture;
16829 const onFocusCapture = useEvent((event) => {
16830 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16831 if (event.defaultPrevented) return;
16832 if (!store) return;
16833 const { virtualFocus: virtualFocus2 } = store.getState();
16834 if (!virtualFocus2) return;
16835 const previousActiveElement = event.relatedTarget;
16836 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16837 if (isSelfTarget(event) && isSilentlyFocused) {
16838 event.stopPropagation();
16839 previousElementRef.current = previousActiveElement;
16840 }
16841 });
16842 const onFocusProp = props.onFocus;
16843 const onFocus = useEvent((event) => {
16844 onFocusProp == null ? void 0 : onFocusProp(event);
16845 if (event.defaultPrevented) return;
16846 if (!composite) return;
16847 if (!store) return;
16848 const { relatedTarget } = event;
16849 const { virtualFocus: virtualFocus2 } = store.getState();
16850 if (virtualFocus2) {
16851 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16852 queueMicrotask(scheduleFocus);
16853 }
16854 } else if (isSelfTarget(event)) {
16855 store.setActiveId(null);
16856 }
16857 });
16858 const onBlurCaptureProp = props.onBlurCapture;
16859 const onBlurCapture = useEvent((event) => {
16860 var _a;
16861 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16862 if (event.defaultPrevented) return;
16863 if (!store) return;
16864 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16865 if (!virtualFocus2) return;
16866 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16867 const nextActiveElement = event.relatedTarget;
16868 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16869 const previousElement = previousElementRef.current;
16870 previousElementRef.current = null;
16871 if (isSelfTarget(event) && nextActiveElementIsItem) {
16872 if (nextActiveElement === activeElement2) {
16873 if (previousElement && previousElement !== nextActiveElement) {
16874 fireBlurEvent(previousElement, event);
16875 }
16876 } else if (activeElement2) {
16877 fireBlurEvent(activeElement2, event);
16878 } else if (previousElement) {
16879 fireBlurEvent(previousElement, event);
16880 }
16881 event.stopPropagation();
16882 } else {
16883 const targetIsItem = isItem(store, event.target);
16884 if (!targetIsItem && activeElement2) {
16885 fireBlurEvent(activeElement2, event);
16886 }
16887 }
16888 });
16889 const onKeyDownProp = props.onKeyDown;
16890 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16891 const onKeyDown = useEvent((event) => {
16892 var _a;
16893 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16894 if (event.nativeEvent.isComposing) return;
16895 if (event.defaultPrevented) return;
16896 if (!store) return;
16897 if (!isSelfTarget(event)) return;
16898 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16899 const activeItem = getEnabledItem(store, activeId2);
16900 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16901 const isVertical = orientation !== "horizontal";
16902 const isHorizontal = orientation !== "vertical";
16903 const grid = isGrid(renderedItems);
16904 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16905 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16906 const up = () => {
16907 if (grid) {
16908 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16909 return item == null ? void 0 : item.id;
16910 }
16911 return store == null ? void 0 : store.last();
16912 };
16913 const keyMap = {
16914 ArrowUp: (grid || isVertical) && up,
16915 ArrowRight: (grid || isHorizontal) && store.first,
16916 ArrowDown: (grid || isVertical) && store.first,
16917 ArrowLeft: (grid || isHorizontal) && store.last,
16918 Home: store.first,
16919 End: store.last,
16920 PageUp: store.first,
16921 PageDown: store.last
16922 };
16923 const action = keyMap[event.key];
16924 if (action) {
16925 const id = action();
16926 if (id !== void 0) {
16927 if (!moveOnKeyPressProp(event)) return;
16928 event.preventDefault();
16929 store.move(id);
16930 }
16931 }
16932 });
16933 props = useWrapElement(
16934 props,
16935 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeContextProvider, { value: store, children: element }),
16936 [store]
16937 );
16938 const activeDescendant = store.useState((state) => {
16939 var _a;
16940 if (!store) return;
16941 if (!composite) return;
16942 if (!state.virtualFocus) return;
16943 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16944 });
16945 props = {
16946 "aria-activedescendant": activeDescendant,
16947 ...props,
16948 ref: useMergeRefs(ref, setBaseElement, props.ref),
16949 onKeyDownCapture,
16950 onKeyUpCapture,
16951 onFocusCapture,
16952 onFocus,
16953 onBlurCapture,
16954 onKeyDown
16955 };
16956 const focusable2 = store.useState(
16957 (state) => composite && (state.virtualFocus || state.activeId === null)
16958 );
16959 props = useFocusable({ focusable: focusable2, ...props });
16960 return props;
16961 }
16962 );
16963 var Composite5 = forwardRef29(function Composite22(props) {
16964 const htmlProps = useComposite(props);
16965 return createElement3(TagName5, htmlProps);
16966 });
16967
16968 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
16969 var ctx3 = createStoreContext();
16970 var useDisclosureContext = ctx3.useContext;
16971 var useDisclosureScopedContext = ctx3.useScopedContext;
16972 var useDisclosureProviderContext = ctx3.useProviderContext;
16973 var DisclosureContextProvider = ctx3.ContextProvider;
16974 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
16975
16976 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
16977 var import_react20 = __toESM(require_react(), 1);
16978 var ctx4 = createStoreContext(
16979 [DisclosureContextProvider],
16980 [DisclosureScopedContextProvider]
16981 );
16982 var useDialogContext = ctx4.useContext;
16983 var useDialogScopedContext = ctx4.useScopedContext;
16984 var useDialogProviderContext = ctx4.useProviderContext;
16985 var DialogContextProvider = ctx4.ContextProvider;
16986 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
16987 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
16988 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
16989
16990 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
16991 var import_react21 = __toESM(require_react(), 1);
16992 var import_react_dom4 = __toESM(require_react_dom(), 1);
16993 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
16994 var TagName6 = "div";
16995 function afterTimeout(timeoutMs, cb) {
16996 const timeoutId = setTimeout(cb, timeoutMs);
16997 return () => clearTimeout(timeoutId);
16998 }
16999 function afterPaint2(cb) {
17000 let raf = requestAnimationFrame(() => {
17001 raf = requestAnimationFrame(cb);
17002 });
17003 return () => cancelAnimationFrame(raf);
17004 }
17005 function parseCSSTime(...times) {
17006 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17007 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17008 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17009 if (currentTime > longestTime) return currentTime;
17010 return longestTime;
17011 }, 0);
17012 }
17013 function isHidden(mounted, hidden, alwaysVisible) {
17014 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17015 }
17016 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17017 const context = useDisclosureProviderContext();
17018 store = store || context;
17019 invariant(
17020 store,
17021 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
17022 );
17023 const ref = (0, import_react21.useRef)(null);
17024 const id = useId4(props.id);
17025 const [transition, setTransition] = (0, import_react21.useState)(null);
17026 const open = store.useState("open");
17027 const mounted = store.useState("mounted");
17028 const animated = store.useState("animated");
17029 const contentElement = store.useState("contentElement");
17030 const otherElement = useStoreState(store.disclosure, "contentElement");
17031 useSafeLayoutEffect(() => {
17032 if (!ref.current) return;
17033 store == null ? void 0 : store.setContentElement(ref.current);
17034 }, [store]);
17035 useSafeLayoutEffect(() => {
17036 let previousAnimated;
17037 store == null ? void 0 : store.setState("animated", (animated2) => {
17038 previousAnimated = animated2;
17039 return true;
17040 });
17041 return () => {
17042 if (previousAnimated === void 0) return;
17043 store == null ? void 0 : store.setState("animated", previousAnimated);
17044 };
17045 }, [store]);
17046 useSafeLayoutEffect(() => {
17047 if (!animated) return;
17048 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
17049 setTransition(null);
17050 return;
17051 }
17052 return afterPaint2(() => {
17053 setTransition(open ? "enter" : mounted ? "leave" : null);
17054 });
17055 }, [animated, contentElement, open, mounted]);
17056 useSafeLayoutEffect(() => {
17057 if (!store) return;
17058 if (!animated) return;
17059 if (!transition) return;
17060 if (!contentElement) return;
17061 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
17062 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17063 if (transition === "leave" && open) return;
17064 if (transition === "enter" && !open) return;
17065 if (typeof animated === "number") {
17066 const timeout2 = animated;
17067 return afterTimeout(timeout2, stopAnimationSync);
17068 }
17069 const {
17070 transitionDuration,
17071 animationDuration,
17072 transitionDelay,
17073 animationDelay
17074 } = getComputedStyle(contentElement);
17075 const {
17076 transitionDuration: transitionDuration2 = "0",
17077 animationDuration: animationDuration2 = "0",
17078 transitionDelay: transitionDelay2 = "0",
17079 animationDelay: animationDelay2 = "0"
17080 } = otherElement ? getComputedStyle(otherElement) : {};
17081 const delay = parseCSSTime(
17082 transitionDelay,
17083 animationDelay,
17084 transitionDelay2,
17085 animationDelay2
17086 );
17087 const duration = parseCSSTime(
17088 transitionDuration,
17089 animationDuration,
17090 transitionDuration2,
17091 animationDuration2
17092 );
17093 const timeout = delay + duration;
17094 if (!timeout) {
17095 if (transition === "enter") {
17096 store.setState("animated", false);
17097 }
17098 stopAnimation();
17099 return;
17100 }
17101 const frameRate = 1e3 / 60;
17102 const maxTimeout = Math.max(timeout - frameRate, 0);
17103 return afterTimeout(maxTimeout, stopAnimationSync);
17104 }, [store, animated, contentElement, otherElement, open, transition]);
17105 props = useWrapElement(
17106 props,
17107 (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DialogScopedContextProvider, { value: store, children: element }),
17108 [store]
17109 );
17110 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17111 const styleProp = props.style;
17112 const style = (0, import_react21.useMemo)(() => {
17113 if (hidden) {
17114 return { ...styleProp, display: "none" };
17115 }
17116 return styleProp;
17117 }, [hidden, styleProp]);
17118 props = {
17119 id,
17120 "data-open": open || void 0,
17121 "data-enter": transition === "enter" || void 0,
17122 "data-leave": transition === "leave" || void 0,
17123 hidden,
17124 ...props,
17125 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17126 style
17127 };
17128 return removeUndefinedValues(props);
17129 });
17130 var DisclosureContentImpl = forwardRef29(function DisclosureContentImpl2(props) {
17131 const htmlProps = useDisclosureContent(props);
17132 return createElement3(TagName6, htmlProps);
17133 });
17134 var DisclosureContent = forwardRef29(function DisclosureContent2({
17135 unmountOnHide,
17136 ...props
17137 }) {
17138 const context = useDisclosureProviderContext();
17139 const store = props.store || context;
17140 const mounted = useStoreState(
17141 store,
17142 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
17143 );
17144 if (mounted === false) return null;
17145 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DisclosureContentImpl, { ...props });
17146 });
17147
17148 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
17149 function createDisclosureStore(props = {}) {
17150 const store = mergeStore(
17151 props.store,
17152 omit2(props.disclosure, ["contentElement", "disclosureElement"])
17153 );
17154 throwOnConflictingProps(props, store);
17155 const syncState = store == null ? void 0 : store.getState();
17156 const open = defaultValue(
17157 props.open,
17158 syncState == null ? void 0 : syncState.open,
17159 props.defaultOpen,
17160 false
17161 );
17162 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
17163 const initialState = {
17164 open,
17165 animated,
17166 animating: !!animated && open,
17167 mounted: open,
17168 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
17169 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
17170 };
17171 const disclosure = createStore(initialState, store);
17172 setup(
17173 disclosure,
17174 () => sync(disclosure, ["animated", "animating"], (state) => {
17175 if (state.animated) return;
17176 disclosure.setState("animating", false);
17177 })
17178 );
17179 setup(
17180 disclosure,
17181 () => subscribe(disclosure, ["open"], () => {
17182 if (!disclosure.getState().animated) return;
17183 disclosure.setState("animating", true);
17184 })
17185 );
17186 setup(
17187 disclosure,
17188 () => sync(disclosure, ["open", "animating"], (state) => {
17189 disclosure.setState("mounted", state.open || state.animating);
17190 })
17191 );
17192 return {
17193 ...disclosure,
17194 disclosure: props.disclosure,
17195 setOpen: (value) => disclosure.setState("open", value),
17196 show: () => disclosure.setState("open", true),
17197 hide: () => disclosure.setState("open", false),
17198 toggle: () => disclosure.setState("open", (open2) => !open2),
17199 stopAnimation: () => disclosure.setState("animating", false),
17200 setContentElement: (value) => disclosure.setState("contentElement", value),
17201 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17202 };
17203 }
17204
17205 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17206 function useDisclosureStoreProps(store, update2, props) {
17207 useUpdateEffect(update2, [props.store, props.disclosure]);
17208 useStoreProps(store, props, "open", "setOpen");
17209 useStoreProps(store, props, "mounted", "setMounted");
17210 useStoreProps(store, props, "animated");
17211 return Object.assign(store, { disclosure: props.disclosure });
17212 }
17213
17214 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17215 var ctx5 = createStoreContext(
17216 [DialogContextProvider],
17217 [DialogScopedContextProvider]
17218 );
17219 var usePopoverContext = ctx5.useContext;
17220 var usePopoverScopedContext = ctx5.useScopedContext;
17221 var usePopoverProviderContext = ctx5.useProviderContext;
17222 var PopoverContextProvider = ctx5.ContextProvider;
17223 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17224
17225 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17226 function getCommonParent(items) {
17227 var _a;
17228 const firstItem = items.find((item) => !!item.element);
17229 const lastItem = [...items].reverse().find((item) => !!item.element);
17230 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17231 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17232 const parent = parentElement;
17233 if (lastItem && parent.contains(lastItem.element)) {
17234 return parentElement;
17235 }
17236 parentElement = parentElement.parentElement;
17237 }
17238 return getDocument(parentElement).body;
17239 }
17240 function getPrivateStore(store) {
17241 return store == null ? void 0 : store.__unstablePrivateStore;
17242 }
17243 function createCollectionStore(props = {}) {
17244 var _a;
17245 throwOnConflictingProps(props, props.store);
17246 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17247 const items = defaultValue(
17248 props.items,
17249 syncState == null ? void 0 : syncState.items,
17250 props.defaultItems,
17251 []
17252 );
17253 const itemsMap = new Map(items.map((item) => [item.id, item]));
17254 const initialState = {
17255 items,
17256 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17257 };
17258 const syncPrivateStore = getPrivateStore(props.store);
17259 const privateStore = createStore(
17260 { items, renderedItems: initialState.renderedItems },
17261 syncPrivateStore
17262 );
17263 const collection = createStore(initialState, props.store);
17264 const sortItems = (renderedItems) => {
17265 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17266 privateStore.setState("renderedItems", sortedItems);
17267 collection.setState("renderedItems", sortedItems);
17268 };
17269 setup(collection, () => init(privateStore));
17270 setup(privateStore, () => {
17271 return batch(privateStore, ["items"], (state) => {
17272 collection.setState("items", state.items);
17273 });
17274 });
17275 setup(privateStore, () => {
17276 return batch(privateStore, ["renderedItems"], (state) => {
17277 let firstRun = true;
17278 let raf = requestAnimationFrame(() => {
17279 const { renderedItems } = collection.getState();
17280 if (state.renderedItems === renderedItems) return;
17281 sortItems(state.renderedItems);
17282 });
17283 if (typeof IntersectionObserver !== "function") {
17284 return () => cancelAnimationFrame(raf);
17285 }
17286 const ioCallback = () => {
17287 if (firstRun) {
17288 firstRun = false;
17289 return;
17290 }
17291 cancelAnimationFrame(raf);
17292 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17293 };
17294 const root = getCommonParent(state.renderedItems);
17295 const observer = new IntersectionObserver(ioCallback, { root });
17296 for (const item of state.renderedItems) {
17297 if (!item.element) continue;
17298 observer.observe(item.element);
17299 }
17300 return () => {
17301 cancelAnimationFrame(raf);
17302 observer.disconnect();
17303 };
17304 });
17305 });
17306 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17307 let prevItem;
17308 setItems((items2) => {
17309 const index2 = items2.findIndex(({ id }) => id === item.id);
17310 const nextItems = items2.slice();
17311 if (index2 !== -1) {
17312 prevItem = items2[index2];
17313 const nextItem = { ...prevItem, ...item };
17314 nextItems[index2] = nextItem;
17315 itemsMap.set(item.id, nextItem);
17316 } else {
17317 nextItems.push(item);
17318 itemsMap.set(item.id, item);
17319 }
17320 return nextItems;
17321 });
17322 const unmergeItem = () => {
17323 setItems((items2) => {
17324 if (!prevItem) {
17325 if (canDeleteFromMap) {
17326 itemsMap.delete(item.id);
17327 }
17328 return items2.filter(({ id }) => id !== item.id);
17329 }
17330 const index2 = items2.findIndex(({ id }) => id === item.id);
17331 if (index2 === -1) return items2;
17332 const nextItems = items2.slice();
17333 nextItems[index2] = prevItem;
17334 itemsMap.set(item.id, prevItem);
17335 return nextItems;
17336 });
17337 };
17338 return unmergeItem;
17339 };
17340 const registerItem = (item) => mergeItem(
17341 item,
17342 (getItems) => privateStore.setState("items", getItems),
17343 true
17344 );
17345 return {
17346 ...collection,
17347 registerItem,
17348 renderItem: (item) => chain(
17349 registerItem(item),
17350 mergeItem(
17351 item,
17352 (getItems) => privateStore.setState("renderedItems", getItems)
17353 )
17354 ),
17355 item: (id) => {
17356 if (!id) return null;
17357 let item = itemsMap.get(id);
17358 if (!item) {
17359 const { items: items2 } = privateStore.getState();
17360 item = items2.find((item2) => item2.id === id);
17361 if (item) {
17362 itemsMap.set(id, item);
17363 }
17364 }
17365 return item || null;
17366 },
17367 // @ts-expect-error Internal
17368 __unstablePrivateStore: privateStore
17369 };
17370 }
17371
17372 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17373 function useCollectionStoreProps(store, update2, props) {
17374 useUpdateEffect(update2, [props.store]);
17375 useStoreProps(store, props, "items", "setItems");
17376 return store;
17377 }
17378
17379 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17380 var NULL_ITEM = { id: null };
17381 function findFirstEnabledItem2(items, excludeId) {
17382 return items.find((item) => {
17383 if (excludeId) {
17384 return !item.disabled && item.id !== excludeId;
17385 }
17386 return !item.disabled;
17387 });
17388 }
17389 function getEnabledItems(items, excludeId) {
17390 return items.filter((item) => {
17391 if (excludeId) {
17392 return !item.disabled && item.id !== excludeId;
17393 }
17394 return !item.disabled;
17395 });
17396 }
17397 function getItemsInRow(items, rowId) {
17398 return items.filter((item) => item.rowId === rowId);
17399 }
17400 function flipItems(items, activeId, shouldInsertNullItem = false) {
17401 const index2 = items.findIndex((item) => item.id === activeId);
17402 return [
17403 ...items.slice(index2 + 1),
17404 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17405 ...items.slice(0, index2)
17406 ];
17407 }
17408 function groupItemsByRows2(items) {
17409 const rows = [];
17410 for (const item of items) {
17411 const row = rows.find((currentRow) => {
17412 var _a;
17413 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17414 });
17415 if (row) {
17416 row.push(item);
17417 } else {
17418 rows.push([item]);
17419 }
17420 }
17421 return rows;
17422 }
17423 function getMaxRowLength(array) {
17424 let maxLength = 0;
17425 for (const { length } of array) {
17426 if (length > maxLength) {
17427 maxLength = length;
17428 }
17429 }
17430 return maxLength;
17431 }
17432 function createEmptyItem(rowId) {
17433 return {
17434 id: "__EMPTY_ITEM__",
17435 disabled: true,
17436 rowId
17437 };
17438 }
17439 function normalizeRows(rows, activeId, focusShift) {
17440 const maxLength = getMaxRowLength(rows);
17441 for (const row of rows) {
17442 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17443 const item = row[i2];
17444 if (!item || focusShift && item.disabled) {
17445 const isFirst = i2 === 0;
17446 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17447 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17448 }
17449 }
17450 }
17451 return rows;
17452 }
17453 function verticalizeItems(items) {
17454 const rows = groupItemsByRows2(items);
17455 const maxLength = getMaxRowLength(rows);
17456 const verticalized = [];
17457 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17458 for (const row of rows) {
17459 const item = row[i2];
17460 if (item) {
17461 verticalized.push({
17462 ...item,
17463 // If there's no rowId, it means that it's not a grid composite, but
17464 // a single row instead. So, instead of verticalizing it, that is,
17465 // assigning a different rowId based on the column index, we keep it
17466 // undefined so they will be part of the same row. This is useful
17467 // when using up/down on one-dimensional composites.
17468 rowId: item.rowId ? `${i2}` : void 0
17469 });
17470 }
17471 }
17472 }
17473 return verticalized;
17474 }
17475 function createCompositeStore(props = {}) {
17476 var _a;
17477 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17478 const collection = createCollectionStore(props);
17479 const activeId = defaultValue(
17480 props.activeId,
17481 syncState == null ? void 0 : syncState.activeId,
17482 props.defaultActiveId
17483 );
17484 const initialState = {
17485 ...collection.getState(),
17486 id: defaultValue(
17487 props.id,
17488 syncState == null ? void 0 : syncState.id,
17489 `id-${Math.random().toString(36).slice(2, 8)}`
17490 ),
17491 activeId,
17492 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17493 includesBaseElement: defaultValue(
17494 props.includesBaseElement,
17495 syncState == null ? void 0 : syncState.includesBaseElement,
17496 activeId === null
17497 ),
17498 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17499 orientation: defaultValue(
17500 props.orientation,
17501 syncState == null ? void 0 : syncState.orientation,
17502 "both"
17503 ),
17504 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17505 virtualFocus: defaultValue(
17506 props.virtualFocus,
17507 syncState == null ? void 0 : syncState.virtualFocus,
17508 false
17509 ),
17510 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17511 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17512 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17513 };
17514 const composite = createStore(initialState, collection, props.store);
17515 setup(
17516 composite,
17517 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17518 composite.setState("activeId", (activeId2) => {
17519 var _a2;
17520 if (activeId2 !== void 0) return activeId2;
17521 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17522 });
17523 })
17524 );
17525 const getNextId = (direction = "next", options = {}) => {
17526 var _a2, _b;
17527 const defaultState = composite.getState();
17528 const {
17529 skip = 0,
17530 activeId: activeId2 = defaultState.activeId,
17531 focusShift = defaultState.focusShift,
17532 focusLoop = defaultState.focusLoop,
17533 focusWrap = defaultState.focusWrap,
17534 includesBaseElement = defaultState.includesBaseElement,
17535 renderedItems = defaultState.renderedItems,
17536 rtl = defaultState.rtl
17537 } = options;
17538 const isVerticalDirection = direction === "up" || direction === "down";
17539 const isNextDirection = direction === "next" || direction === "down";
17540 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17541 const canShift = focusShift && !skip;
17542 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17543 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17544 );
17545 items = canReverse ? reverseArray(items) : items;
17546 items = isVerticalDirection ? verticalizeItems(items) : items;
17547 if (activeId2 == null) {
17548 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17549 }
17550 const activeItem = items.find((item) => item.id === activeId2);
17551 if (!activeItem) {
17552 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17553 }
17554 const isGrid2 = items.some((item) => item.rowId);
17555 const activeIndex = items.indexOf(activeItem);
17556 const nextItems = items.slice(activeIndex + 1);
17557 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17558 if (skip) {
17559 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17560 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17561 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17562 return nextItem2 == null ? void 0 : nextItem2.id;
17563 }
17564 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17565 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17566 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17567 if (canLoop) {
17568 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17569 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17570 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17571 return nextItem2 == null ? void 0 : nextItem2.id;
17572 }
17573 if (canWrap) {
17574 const nextItem2 = findFirstEnabledItem2(
17575 // We can use nextItems, which contains all the next items, including
17576 // items from other rows, to wrap between rows. However, if there is a
17577 // null item (the composite container), we'll only use the next items in
17578 // the row. So moving next from the last item will focus on the
17579 // composite container. On grid composites, horizontal navigation never
17580 // focuses on the composite container, only vertical.
17581 hasNullItem ? nextItemsInRow : nextItems,
17582 activeId2
17583 );
17584 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17585 return nextId;
17586 }
17587 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17588 if (!nextItem && hasNullItem) {
17589 return null;
17590 }
17591 return nextItem == null ? void 0 : nextItem.id;
17592 };
17593 return {
17594 ...collection,
17595 ...composite,
17596 setBaseElement: (element) => composite.setState("baseElement", element),
17597 setActiveId: (id) => composite.setState("activeId", id),
17598 move: (id) => {
17599 if (id === void 0) return;
17600 composite.setState("activeId", id);
17601 composite.setState("moves", (moves) => moves + 1);
17602 },
17603 first: () => {
17604 var _a2;
17605 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17606 },
17607 last: () => {
17608 var _a2;
17609 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17610 },
17611 next: (options) => {
17612 if (options !== void 0 && typeof options === "number") {
17613 options = { skip: options };
17614 }
17615 return getNextId("next", options);
17616 },
17617 previous: (options) => {
17618 if (options !== void 0 && typeof options === "number") {
17619 options = { skip: options };
17620 }
17621 return getNextId("previous", options);
17622 },
17623 down: (options) => {
17624 if (options !== void 0 && typeof options === "number") {
17625 options = { skip: options };
17626 }
17627 return getNextId("down", options);
17628 },
17629 up: (options) => {
17630 if (options !== void 0 && typeof options === "number") {
17631 options = { skip: options };
17632 }
17633 return getNextId("up", options);
17634 }
17635 };
17636 }
17637
17638 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17639 function useCompositeStoreOptions(props) {
17640 const id = useId4(props.id);
17641 return { id, ...props };
17642 }
17643 function useCompositeStoreProps(store, update2, props) {
17644 store = useCollectionStoreProps(store, update2, props);
17645 useStoreProps(store, props, "activeId", "setActiveId");
17646 useStoreProps(store, props, "includesBaseElement");
17647 useStoreProps(store, props, "virtualFocus");
17648 useStoreProps(store, props, "orientation");
17649 useStoreProps(store, props, "rtl");
17650 useStoreProps(store, props, "focusLoop");
17651 useStoreProps(store, props, "focusWrap");
17652 useStoreProps(store, props, "focusShift");
17653 return store;
17654 }
17655
17656 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17657 var import_react22 = __toESM(require_react(), 1);
17658 var ComboboxListRoleContext = (0, import_react22.createContext)(
17659 void 0
17660 );
17661 var ctx6 = createStoreContext(
17662 [PopoverContextProvider, CompositeContextProvider],
17663 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17664 );
17665 var useComboboxContext = ctx6.useContext;
17666 var useComboboxScopedContext = ctx6.useScopedContext;
17667 var useComboboxProviderContext = ctx6.useProviderContext;
17668 var ComboboxContextProvider = ctx6.ContextProvider;
17669 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17670 var ComboboxItemValueContext = (0, import_react22.createContext)(
17671 void 0
17672 );
17673 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
17674
17675 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17676 function createDialogStore(props = {}) {
17677 return createDisclosureStore(props);
17678 }
17679
17680 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17681 function useDialogStoreProps(store, update2, props) {
17682 return useDisclosureStoreProps(store, update2, props);
17683 }
17684
17685 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17686 function createPopoverStore({
17687 popover: otherPopover,
17688 ...props
17689 } = {}) {
17690 const store = mergeStore(
17691 props.store,
17692 omit2(otherPopover, [
17693 "arrowElement",
17694 "anchorElement",
17695 "contentElement",
17696 "popoverElement",
17697 "disclosureElement"
17698 ])
17699 );
17700 throwOnConflictingProps(props, store);
17701 const syncState = store == null ? void 0 : store.getState();
17702 const dialog = createDialogStore({ ...props, store });
17703 const placement = defaultValue(
17704 props.placement,
17705 syncState == null ? void 0 : syncState.placement,
17706 "bottom"
17707 );
17708 const initialState = {
17709 ...dialog.getState(),
17710 placement,
17711 currentPlacement: placement,
17712 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17713 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17714 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17715 rendered: /* @__PURE__ */ Symbol("rendered")
17716 };
17717 const popover = createStore(initialState, dialog, store);
17718 return {
17719 ...dialog,
17720 ...popover,
17721 setAnchorElement: (element) => popover.setState("anchorElement", element),
17722 setPopoverElement: (element) => popover.setState("popoverElement", element),
17723 setArrowElement: (element) => popover.setState("arrowElement", element),
17724 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17725 };
17726 }
17727
17728 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17729 function usePopoverStoreProps(store, update2, props) {
17730 useUpdateEffect(update2, [props.popover]);
17731 useStoreProps(store, props, "placement");
17732 return useDialogStoreProps(store, update2, props);
17733 }
17734
17735 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17736 var TagName7 = "div";
17737 var usePopoverAnchor = createHook(
17738 function usePopoverAnchor2({ store, ...props }) {
17739 const context = usePopoverProviderContext();
17740 store = store || context;
17741 props = {
17742 ...props,
17743 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17744 };
17745 return props;
17746 }
17747 );
17748 var PopoverAnchor = forwardRef29(function PopoverAnchor2(props) {
17749 const htmlProps = usePopoverAnchor(props);
17750 return createElement3(TagName7, htmlProps);
17751 });
17752
17753 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17754 var import_react23 = __toESM(require_react(), 1);
17755 var TagName8 = "div";
17756 function getMouseDestination(event) {
17757 const relatedTarget = event.relatedTarget;
17758 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17759 return relatedTarget;
17760 }
17761 return null;
17762 }
17763 function hoveringInside(event) {
17764 const nextElement = getMouseDestination(event);
17765 if (!nextElement) return false;
17766 return contains2(event.currentTarget, nextElement);
17767 }
17768 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17769 function movingToAnotherItem(event) {
17770 let dest = getMouseDestination(event);
17771 if (!dest) return false;
17772 do {
17773 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17774 dest = dest.parentElement;
17775 } while (dest);
17776 return false;
17777 }
17778 var useCompositeHover = createHook(
17779 function useCompositeHover2({
17780 store,
17781 focusOnHover = true,
17782 blurOnHoverEnd = !!focusOnHover,
17783 ...props
17784 }) {
17785 const context = useCompositeContext();
17786 store = store || context;
17787 invariant(
17788 store,
17789 "CompositeHover must be wrapped in a Composite component."
17790 );
17791 const isMouseMoving = useIsMouseMoving();
17792 const onMouseMoveProp = props.onMouseMove;
17793 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17794 const onMouseMove = useEvent((event) => {
17795 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17796 if (event.defaultPrevented) return;
17797 if (!isMouseMoving()) return;
17798 if (!focusOnHoverProp(event)) return;
17799 if (!hasFocusWithin(event.currentTarget)) {
17800 const baseElement = store == null ? void 0 : store.getState().baseElement;
17801 if (baseElement && !hasFocus(baseElement)) {
17802 baseElement.focus();
17803 }
17804 }
17805 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17806 });
17807 const onMouseLeaveProp = props.onMouseLeave;
17808 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17809 const onMouseLeave = useEvent((event) => {
17810 var _a;
17811 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17812 if (event.defaultPrevented) return;
17813 if (!isMouseMoving()) return;
17814 if (hoveringInside(event)) return;
17815 if (movingToAnotherItem(event)) return;
17816 if (!focusOnHoverProp(event)) return;
17817 if (!blurOnHoverEndProp(event)) return;
17818 store == null ? void 0 : store.setActiveId(null);
17819 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17820 });
17821 const ref = (0, import_react23.useCallback)((element) => {
17822 if (!element) return;
17823 element[symbol2] = true;
17824 }, []);
17825 props = {
17826 ...props,
17827 ref: useMergeRefs(ref, props.ref),
17828 onMouseMove,
17829 onMouseLeave
17830 };
17831 return removeUndefinedValues(props);
17832 }
17833 );
17834 var CompositeHover = memo22(
17835 forwardRef29(function CompositeHover2(props) {
17836 const htmlProps = useCompositeHover(props);
17837 return createElement3(TagName8, htmlProps);
17838 })
17839 );
17840
17841 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17842 var import_react24 = __toESM(require_react(), 1);
17843 var TagName9 = "input";
17844 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17845 if (!autoSelect) return false;
17846 const firstItem = items.find((item) => !item.disabled && item.value);
17847 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17848 }
17849 function hasCompletionString(value, activeValue) {
17850 if (!activeValue) return false;
17851 if (value == null) return false;
17852 value = normalizeString(value);
17853 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17854 }
17855 function isInputEvent(event) {
17856 return event.type === "input";
17857 }
17858 function isAriaAutoCompleteValue(value) {
17859 return value === "inline" || value === "list" || value === "both" || value === "none";
17860 }
17861 function getDefaultAutoSelectId(items) {
17862 const item = items.find((item2) => {
17863 var _a;
17864 if (item2.disabled) return false;
17865 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17866 });
17867 return item == null ? void 0 : item.id;
17868 }
17869 var useCombobox = createHook(
17870 function useCombobox2({
17871 store,
17872 focusable: focusable2 = true,
17873 autoSelect: autoSelectProp = false,
17874 getAutoSelectId,
17875 setValueOnChange,
17876 showMinLength = 0,
17877 showOnChange,
17878 showOnMouseDown,
17879 showOnClick = showOnMouseDown,
17880 showOnKeyDown,
17881 showOnKeyPress = showOnKeyDown,
17882 blurActiveItemOnClick,
17883 setValueOnClick = true,
17884 moveOnKeyPress = true,
17885 autoComplete = "list",
17886 ...props
17887 }) {
17888 const context = useComboboxProviderContext();
17889 store = store || context;
17890 invariant(
17891 store,
17892 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17893 );
17894 const ref = (0, import_react24.useRef)(null);
17895 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17896 const canAutoSelectRef = (0, import_react24.useRef)(false);
17897 const composingRef = (0, import_react24.useRef)(false);
17898 const autoSelect = store.useState(
17899 (state) => state.virtualFocus && autoSelectProp
17900 );
17901 const inline4 = autoComplete === "inline" || autoComplete === "both";
17902 const [canInline, setCanInline] = (0, import_react24.useState)(inline4);
17903 useUpdateLayoutEffect(() => {
17904 if (!inline4) return;
17905 setCanInline(true);
17906 }, [inline4]);
17907 const storeValue = store.useState("value");
17908 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
17909 (0, import_react24.useEffect)(() => {
17910 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17911 prevSelectedValueRef.current = prev.selectedValue;
17912 });
17913 }, []);
17914 const inlineActiveValue = store.useState((state) => {
17915 var _a;
17916 if (!inline4) return;
17917 if (!canInline) return;
17918 if (state.activeValue && Array.isArray(state.selectedValue)) {
17919 if (state.selectedValue.includes(state.activeValue)) return;
17920 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17921 }
17922 return state.activeValue;
17923 });
17924 const items = store.useState("renderedItems");
17925 const open = store.useState("open");
17926 const contentElement = store.useState("contentElement");
17927 const value = (0, import_react24.useMemo)(() => {
17928 if (!inline4) return storeValue;
17929 if (!canInline) return storeValue;
17930 const firstItemAutoSelected = isFirstItemAutoSelected(
17931 items,
17932 inlineActiveValue,
17933 autoSelect
17934 );
17935 if (firstItemAutoSelected) {
17936 if (hasCompletionString(storeValue, inlineActiveValue)) {
17937 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17938 return storeValue + slice;
17939 }
17940 return storeValue;
17941 }
17942 return inlineActiveValue || storeValue;
17943 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17944 (0, import_react24.useEffect)(() => {
17945 const element = ref.current;
17946 if (!element) return;
17947 const onCompositeItemMove = () => setCanInline(true);
17948 element.addEventListener("combobox-item-move", onCompositeItemMove);
17949 return () => {
17950 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17951 };
17952 }, []);
17953 (0, import_react24.useEffect)(() => {
17954 if (!inline4) return;
17955 if (!canInline) return;
17956 if (!inlineActiveValue) return;
17957 const firstItemAutoSelected = isFirstItemAutoSelected(
17958 items,
17959 inlineActiveValue,
17960 autoSelect
17961 );
17962 if (!firstItemAutoSelected) return;
17963 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17964 let cleanup = noop4;
17965 queueMicrotask(() => {
17966 const element = ref.current;
17967 if (!element) return;
17968 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17969 const nextStart = storeValue.length;
17970 const nextEnd = inlineActiveValue.length;
17971 setSelectionRange(element, nextStart, nextEnd);
17972 cleanup = () => {
17973 if (!hasFocus(element)) return;
17974 const { start, end } = getTextboxSelection(element);
17975 if (start !== nextStart) return;
17976 if (end !== nextEnd) return;
17977 setSelectionRange(element, prevStart, prevEnd);
17978 };
17979 });
17980 return () => cleanup();
17981 }, [
17982 valueUpdated,
17983 inline4,
17984 canInline,
17985 inlineActiveValue,
17986 items,
17987 autoSelect,
17988 storeValue
17989 ]);
17990 const scrollingElementRef = (0, import_react24.useRef)(null);
17991 const getAutoSelectIdProp = useEvent(getAutoSelectId);
17992 const autoSelectIdRef = (0, import_react24.useRef)(null);
17993 (0, import_react24.useEffect)(() => {
17994 if (!open) return;
17995 if (!contentElement) return;
17996 const scrollingElement = getScrollingElement(contentElement);
17997 if (!scrollingElement) return;
17998 scrollingElementRef.current = scrollingElement;
17999 const onUserScroll = () => {
18000 canAutoSelectRef.current = false;
18001 };
18002 const onScroll = () => {
18003 if (!store) return;
18004 if (!canAutoSelectRef.current) return;
18005 const { activeId } = store.getState();
18006 if (activeId === null) return;
18007 if (activeId === autoSelectIdRef.current) return;
18008 canAutoSelectRef.current = false;
18009 };
18010 const options = { passive: true, capture: true };
18011 scrollingElement.addEventListener("wheel", onUserScroll, options);
18012 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18013 scrollingElement.addEventListener("scroll", onScroll, options);
18014 return () => {
18015 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18016 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18017 scrollingElement.removeEventListener("scroll", onScroll, true);
18018 };
18019 }, [open, contentElement, store]);
18020 useSafeLayoutEffect(() => {
18021 if (!storeValue) return;
18022 if (composingRef.current) return;
18023 canAutoSelectRef.current = true;
18024 }, [storeValue]);
18025 useSafeLayoutEffect(() => {
18026 if (autoSelect !== "always" && open) return;
18027 canAutoSelectRef.current = open;
18028 }, [autoSelect, open]);
18029 const resetValueOnSelect = store.useState("resetValueOnSelect");
18030 useUpdateEffect(() => {
18031 var _a, _b;
18032 const canAutoSelect = canAutoSelectRef.current;
18033 if (!store) return;
18034 if (!open) return;
18035 if (!canAutoSelect && !resetValueOnSelect) return;
18036 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18037 if (baseElement && !hasFocus(baseElement)) return;
18038 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
18039 const observer = new MutationObserver(forceValueUpdate);
18040 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18041 return () => observer.disconnect();
18042 }
18043 if (autoSelect && canAutoSelect) {
18044 const userAutoSelectId = getAutoSelectIdProp(items);
18045 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
18046 autoSelectIdRef.current = autoSelectId;
18047 store.move(autoSelectId != null ? autoSelectId : null);
18048 } else {
18049 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
18050 if (element && "scrollIntoView" in element) {
18051 element.scrollIntoView({ block: "nearest", inline: "nearest" });
18052 }
18053 }
18054 return;
18055 }, [
18056 store,
18057 open,
18058 valueUpdated,
18059 storeValue,
18060 autoSelect,
18061 resetValueOnSelect,
18062 getAutoSelectIdProp,
18063 items
18064 ]);
18065 (0, import_react24.useEffect)(() => {
18066 if (!inline4) return;
18067 const combobox = ref.current;
18068 if (!combobox) return;
18069 const elements = [combobox, contentElement].filter(
18070 (value2) => !!value2
18071 );
18072 const onBlur2 = (event) => {
18073 if (elements.every((el) => isFocusEventOutside(event, el))) {
18074 store == null ? void 0 : store.setValue(value);
18075 }
18076 };
18077 for (const element of elements) {
18078 element.addEventListener("focusout", onBlur2);
18079 }
18080 return () => {
18081 for (const element of elements) {
18082 element.removeEventListener("focusout", onBlur2);
18083 }
18084 };
18085 }, [inline4, contentElement, store, value]);
18086 const canShow = (event) => {
18087 const currentTarget = event.currentTarget;
18088 return currentTarget.value.length >= showMinLength;
18089 };
18090 const onChangeProp = props.onChange;
18091 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
18092 const setValueOnChangeProp = useBooleanEvent(
18093 // If the combobox is combined with tags, the value will be set by the tag
18094 // input component.
18095 setValueOnChange != null ? setValueOnChange : !store.tag
18096 );
18097 const onChange = useEvent((event) => {
18098 onChangeProp == null ? void 0 : onChangeProp(event);
18099 if (event.defaultPrevented) return;
18100 if (!store) return;
18101 const currentTarget = event.currentTarget;
18102 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18103 const nativeEvent = event.nativeEvent;
18104 canAutoSelectRef.current = true;
18105 if (isInputEvent(nativeEvent)) {
18106 if (nativeEvent.isComposing) {
18107 canAutoSelectRef.current = false;
18108 composingRef.current = true;
18109 }
18110 if (inline4) {
18111 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18112 const caretAtEnd = selectionStart === value2.length;
18113 setCanInline(textInserted && caretAtEnd);
18114 }
18115 }
18116 if (setValueOnChangeProp(event)) {
18117 const isSameValue = value2 === store.getState().value;
18118 store.setValue(value2);
18119 queueMicrotask(() => {
18120 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18121 });
18122 if (inline4 && autoSelect && isSameValue) {
18123 forceValueUpdate();
18124 }
18125 }
18126 if (showOnChangeProp(event)) {
18127 store.show();
18128 }
18129 if (!autoSelect || !canAutoSelectRef.current) {
18130 store.setActiveId(null);
18131 }
18132 });
18133 const onCompositionEndProp = props.onCompositionEnd;
18134 const onCompositionEnd = useEvent((event) => {
18135 canAutoSelectRef.current = true;
18136 composingRef.current = false;
18137 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
18138 if (event.defaultPrevented) return;
18139 if (!autoSelect) return;
18140 forceValueUpdate();
18141 });
18142 const onMouseDownProp = props.onMouseDown;
18143 const blurActiveItemOnClickProp = useBooleanEvent(
18144 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
18145 );
18146 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18147 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
18148 const onMouseDown = useEvent((event) => {
18149 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18150 if (event.defaultPrevented) return;
18151 if (event.button) return;
18152 if (event.ctrlKey) return;
18153 if (!store) return;
18154 if (blurActiveItemOnClickProp(event)) {
18155 store.setActiveId(null);
18156 }
18157 if (setValueOnClickProp(event)) {
18158 store.setValue(value);
18159 }
18160 if (showOnClickProp(event)) {
18161 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18162 }
18163 });
18164 const onKeyDownProp = props.onKeyDown;
18165 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
18166 const onKeyDown = useEvent((event) => {
18167 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18168 if (!event.repeat) {
18169 canAutoSelectRef.current = false;
18170 }
18171 if (event.defaultPrevented) return;
18172 if (event.ctrlKey) return;
18173 if (event.altKey) return;
18174 if (event.shiftKey) return;
18175 if (event.metaKey) return;
18176 if (!store) return;
18177 const { open: open2 } = store.getState();
18178 if (open2) return;
18179 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18180 if (showOnKeyPressProp(event)) {
18181 event.preventDefault();
18182 store.show();
18183 }
18184 }
18185 });
18186 const onBlurProp = props.onBlur;
18187 const onBlur = useEvent((event) => {
18188 canAutoSelectRef.current = false;
18189 onBlurProp == null ? void 0 : onBlurProp(event);
18190 if (event.defaultPrevented) return;
18191 });
18192 const id = useId4(props.id);
18193 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18194 const isActiveItem = store.useState((state) => state.activeId === null);
18195 props = {
18196 id,
18197 role: "combobox",
18198 "aria-autocomplete": ariaAutoComplete,
18199 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18200 "aria-expanded": open,
18201 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18202 "data-active-item": isActiveItem || void 0,
18203 value,
18204 ...props,
18205 ref: useMergeRefs(ref, props.ref),
18206 onChange,
18207 onCompositionEnd,
18208 onMouseDown,
18209 onKeyDown,
18210 onBlur
18211 };
18212 props = useComposite({
18213 store,
18214 focusable: focusable2,
18215 ...props,
18216 // Enable inline autocomplete when the user moves from the combobox input
18217 // to an item.
18218 moveOnKeyPress: (event) => {
18219 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18220 if (inline4) setCanInline(true);
18221 return true;
18222 }
18223 });
18224 props = usePopoverAnchor({ store, ...props });
18225 return { autoComplete: "off", ...props };
18226 }
18227 );
18228 var Combobox = forwardRef29(function Combobox2(props) {
18229 const htmlProps = useCombobox(props);
18230 return createElement3(TagName9, htmlProps);
18231 });
18232
18233 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18234 var import_react25 = __toESM(require_react(), 1);
18235 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18236 var TagName10 = "div";
18237 function isSelected(storeValue, itemValue) {
18238 if (itemValue == null) return;
18239 if (storeValue == null) return false;
18240 if (Array.isArray(storeValue)) {
18241 return storeValue.includes(itemValue);
18242 }
18243 return storeValue === itemValue;
18244 }
18245 function getItemRole(popupRole) {
18246 var _a;
18247 const itemRoleByPopupRole = {
18248 menu: "menuitem",
18249 listbox: "option",
18250 tree: "treeitem"
18251 };
18252 const key = popupRole;
18253 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18254 }
18255 var useComboboxItem = createHook(
18256 function useComboboxItem2({
18257 store,
18258 value,
18259 hideOnClick,
18260 setValueOnClick,
18261 selectValueOnClick = true,
18262 resetValueOnSelect,
18263 focusOnHover = false,
18264 moveOnKeyPress = true,
18265 getItem: getItemProp,
18266 ...props
18267 }) {
18268 var _a;
18269 const context = useComboboxScopedContext();
18270 store = store || context;
18271 invariant(
18272 store,
18273 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18274 );
18275 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18276 resetValueOnSelectState: "resetValueOnSelect",
18277 multiSelectable(state) {
18278 return Array.isArray(state.selectedValue);
18279 },
18280 selected(state) {
18281 return isSelected(state.selectedValue, value);
18282 }
18283 });
18284 const getItem = (0, import_react25.useCallback)(
18285 (item) => {
18286 const nextItem = { ...item, value };
18287 if (getItemProp) {
18288 return getItemProp(nextItem);
18289 }
18290 return nextItem;
18291 },
18292 [value, getItemProp]
18293 );
18294 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18295 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18296 const onClickProp = props.onClick;
18297 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18298 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18299 const resetValueOnSelectProp = useBooleanEvent(
18300 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18301 );
18302 const hideOnClickProp = useBooleanEvent(hideOnClick);
18303 const onClick = useEvent((event) => {
18304 onClickProp == null ? void 0 : onClickProp(event);
18305 if (event.defaultPrevented) return;
18306 if (isDownloading(event)) return;
18307 if (isOpeningInNewTab(event)) return;
18308 if (value != null) {
18309 if (selectValueOnClickProp(event)) {
18310 if (resetValueOnSelectProp(event)) {
18311 store == null ? void 0 : store.resetValue();
18312 }
18313 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18314 if (!Array.isArray(prevValue)) return value;
18315 if (prevValue.includes(value)) {
18316 return prevValue.filter((v2) => v2 !== value);
18317 }
18318 return [...prevValue, value];
18319 });
18320 }
18321 if (setValueOnClickProp(event)) {
18322 store == null ? void 0 : store.setValue(value);
18323 }
18324 }
18325 if (hideOnClickProp(event)) {
18326 store == null ? void 0 : store.hide();
18327 }
18328 });
18329 const onKeyDownProp = props.onKeyDown;
18330 const onKeyDown = useEvent((event) => {
18331 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18332 if (event.defaultPrevented) return;
18333 const baseElement = store == null ? void 0 : store.getState().baseElement;
18334 if (!baseElement) return;
18335 if (hasFocus(baseElement)) return;
18336 const printable = event.key.length === 1;
18337 if (printable || event.key === "Backspace" || event.key === "Delete") {
18338 queueMicrotask(() => baseElement.focus());
18339 if (isTextField(baseElement)) {
18340 store == null ? void 0 : store.setValue(baseElement.value);
18341 }
18342 }
18343 });
18344 if (multiSelectable && selected != null) {
18345 props = {
18346 "aria-selected": selected,
18347 ...props
18348 };
18349 }
18350 props = useWrapElement(
18351 props,
18352 (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
18353 [value, selected]
18354 );
18355 const popupRole = (0, import_react25.useContext)(ComboboxListRoleContext);
18356 props = {
18357 role: getItemRole(popupRole),
18358 children: value,
18359 ...props,
18360 onClick,
18361 onKeyDown
18362 };
18363 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18364 props = useCompositeItem({
18365 store,
18366 ...props,
18367 getItem,
18368 // Dispatch a custom event on the combobox input when moving to an item
18369 // with the keyboard so the Combobox component can enable inline
18370 // autocompletion.
18371 moveOnKeyPress: (event) => {
18372 if (!moveOnKeyPressProp(event)) return false;
18373 const moveEvent = new Event("combobox-item-move");
18374 const baseElement = store == null ? void 0 : store.getState().baseElement;
18375 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18376 return true;
18377 }
18378 });
18379 props = useCompositeHover({ store, focusOnHover, ...props });
18380 return props;
18381 }
18382 );
18383 var ComboboxItem = memo22(
18384 forwardRef29(function ComboboxItem2(props) {
18385 const htmlProps = useComboboxItem(props);
18386 return createElement3(TagName10, htmlProps);
18387 })
18388 );
18389
18390 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18391 var import_react26 = __toESM(require_react(), 1);
18392 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18393 var TagName11 = "span";
18394 function normalizeValue(value) {
18395 return normalizeString(value).toLowerCase();
18396 }
18397 function getOffsets(string, values) {
18398 const offsets = [];
18399 for (const value of values) {
18400 let pos = 0;
18401 const length = value.length;
18402 while (string.indexOf(value, pos) !== -1) {
18403 const index2 = string.indexOf(value, pos);
18404 if (index2 !== -1) {
18405 offsets.push([index2, length]);
18406 }
18407 pos = index2 + 1;
18408 }
18409 }
18410 return offsets;
18411 }
18412 function filterOverlappingOffsets(offsets) {
18413 return offsets.filter(([offset4, length], i2, arr) => {
18414 return !arr.some(
18415 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18416 );
18417 });
18418 }
18419 function sortOffsets(offsets) {
18420 return offsets.sort(([a2], [b2]) => a2 - b2);
18421 }
18422 function splitValue(itemValue, userValue) {
18423 if (!itemValue) return itemValue;
18424 if (!userValue) return itemValue;
18425 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18426 const parts = [];
18427 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
18428 "span",
18429 {
18430 "data-autocomplete-value": autocomplete ? "" : void 0,
18431 "data-user-value": autocomplete ? void 0 : "",
18432 children: value
18433 },
18434 parts.length
18435 );
18436 const offsets = sortOffsets(
18437 filterOverlappingOffsets(
18438 // Convert userValues into a set to avoid duplicates
18439 getOffsets(normalizeValue(itemValue), new Set(userValues))
18440 )
18441 );
18442 if (!offsets.length) {
18443 parts.push(span(itemValue, true));
18444 return parts;
18445 }
18446 const [firstOffset] = offsets[0];
18447 const values = [
18448 itemValue.slice(0, firstOffset),
18449 ...offsets.flatMap(([offset4, length], i2) => {
18450 var _a;
18451 const value = itemValue.slice(offset4, offset4 + length);
18452 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18453 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18454 return [value, nextValue];
18455 })
18456 ];
18457 values.forEach((value, i2) => {
18458 if (!value) return;
18459 parts.push(span(value, i2 % 2 === 0));
18460 });
18461 return parts;
18462 }
18463 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18464 const context = useComboboxScopedContext();
18465 store = store || context;
18466 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
18467 const itemValue = value != null ? value : itemContext;
18468 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18469 const children = (0, import_react26.useMemo)(() => {
18470 if (!itemValue) return;
18471 if (!inputValue) return itemValue;
18472 return splitValue(itemValue, inputValue);
18473 }, [itemValue, inputValue]);
18474 props = {
18475 children,
18476 ...props
18477 };
18478 return removeUndefinedValues(props);
18479 });
18480 var ComboboxItemValue = forwardRef29(function ComboboxItemValue2(props) {
18481 const htmlProps = useComboboxItemValue(props);
18482 return createElement3(TagName11, htmlProps);
18483 });
18484
18485 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18486 var TagName12 = "label";
18487 var useComboboxLabel = createHook(
18488 function useComboboxLabel2({ store, ...props }) {
18489 const context = useComboboxProviderContext();
18490 store = store || context;
18491 invariant(
18492 store,
18493 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18494 );
18495 const comboboxId = store.useState((state) => {
18496 var _a;
18497 return (_a = state.baseElement) == null ? void 0 : _a.id;
18498 });
18499 props = {
18500 htmlFor: comboboxId,
18501 ...props
18502 };
18503 return removeUndefinedValues(props);
18504 }
18505 );
18506 var ComboboxLabel = memo22(
18507 forwardRef29(function ComboboxLabel2(props) {
18508 const htmlProps = useComboboxLabel(props);
18509 return createElement3(TagName12, htmlProps);
18510 })
18511 );
18512
18513 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18514 var import_react27 = __toESM(require_react(), 1);
18515 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18516 var TagName13 = "div";
18517 var useComboboxList = createHook(
18518 function useComboboxList2({ store, alwaysVisible, ...props }) {
18519 const scopedContext = useComboboxScopedContext(true);
18520 const context = useComboboxContext();
18521 store = store || context;
18522 const scopedContextSameStore = !!store && store === scopedContext;
18523 invariant(
18524 store,
18525 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18526 );
18527 const ref = (0, import_react27.useRef)(null);
18528 const id = useId4(props.id);
18529 const mounted = store.useState("mounted");
18530 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18531 const style = hidden ? { ...props.style, display: "none" } : props.style;
18532 const multiSelectable = store.useState(
18533 (state) => Array.isArray(state.selectedValue)
18534 );
18535 const role = useAttribute(ref, "role", props.role);
18536 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18537 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18538 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
18539 const contentElement = store.useState("contentElement");
18540 useSafeLayoutEffect(() => {
18541 if (!mounted) return;
18542 const element = ref.current;
18543 if (!element) return;
18544 if (contentElement !== element) return;
18545 const callback = () => {
18546 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18547 };
18548 const observer = new MutationObserver(callback);
18549 observer.observe(element, {
18550 subtree: true,
18551 childList: true,
18552 attributeFilter: ["role"]
18553 });
18554 callback();
18555 return () => observer.disconnect();
18556 }, [mounted, contentElement]);
18557 if (!hasListboxInside) {
18558 props = {
18559 role: "listbox",
18560 "aria-multiselectable": ariaMultiSelectable,
18561 ...props
18562 };
18563 }
18564 props = useWrapElement(
18565 props,
18566 (element) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18567 [store, role]
18568 );
18569 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18570 props = {
18571 id,
18572 hidden,
18573 ...props,
18574 ref: useMergeRefs(setContentElement, ref, props.ref),
18575 style
18576 };
18577 return removeUndefinedValues(props);
18578 }
18579 );
18580 var ComboboxList = forwardRef29(function ComboboxList2(props) {
18581 const htmlProps = useComboboxList(props);
18582 return createElement3(TagName13, htmlProps);
18583 });
18584
18585 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18586 var import_react28 = __toESM(require_react(), 1);
18587 var TagValueContext = (0, import_react28.createContext)(null);
18588 var TagRemoveIdContext = (0, import_react28.createContext)(
18589 null
18590 );
18591 var ctx7 = createStoreContext(
18592 [CompositeContextProvider],
18593 [CompositeScopedContextProvider]
18594 );
18595 var useTagContext = ctx7.useContext;
18596 var useTagScopedContext = ctx7.useScopedContext;
18597 var useTagProviderContext = ctx7.useProviderContext;
18598 var TagContextProvider = ctx7.ContextProvider;
18599 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18600
18601 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18602 var isTouchSafari = isSafari2() && isTouchDevice();
18603 function createComboboxStore({
18604 tag,
18605 ...props
18606 } = {}) {
18607 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18608 throwOnConflictingProps(props, store);
18609 const tagState = tag == null ? void 0 : tag.getState();
18610 const syncState = store == null ? void 0 : store.getState();
18611 const activeId = defaultValue(
18612 props.activeId,
18613 syncState == null ? void 0 : syncState.activeId,
18614 props.defaultActiveId,
18615 null
18616 );
18617 const composite = createCompositeStore({
18618 ...props,
18619 activeId,
18620 includesBaseElement: defaultValue(
18621 props.includesBaseElement,
18622 syncState == null ? void 0 : syncState.includesBaseElement,
18623 true
18624 ),
18625 orientation: defaultValue(
18626 props.orientation,
18627 syncState == null ? void 0 : syncState.orientation,
18628 "vertical"
18629 ),
18630 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18631 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18632 virtualFocus: defaultValue(
18633 props.virtualFocus,
18634 syncState == null ? void 0 : syncState.virtualFocus,
18635 true
18636 )
18637 });
18638 const popover = createPopoverStore({
18639 ...props,
18640 placement: defaultValue(
18641 props.placement,
18642 syncState == null ? void 0 : syncState.placement,
18643 "bottom-start"
18644 )
18645 });
18646 const value = defaultValue(
18647 props.value,
18648 syncState == null ? void 0 : syncState.value,
18649 props.defaultValue,
18650 ""
18651 );
18652 const selectedValue = defaultValue(
18653 props.selectedValue,
18654 syncState == null ? void 0 : syncState.selectedValue,
18655 tagState == null ? void 0 : tagState.values,
18656 props.defaultSelectedValue,
18657 ""
18658 );
18659 const multiSelectable = Array.isArray(selectedValue);
18660 const initialState = {
18661 ...composite.getState(),
18662 ...popover.getState(),
18663 value,
18664 selectedValue,
18665 resetValueOnSelect: defaultValue(
18666 props.resetValueOnSelect,
18667 syncState == null ? void 0 : syncState.resetValueOnSelect,
18668 multiSelectable
18669 ),
18670 resetValueOnHide: defaultValue(
18671 props.resetValueOnHide,
18672 syncState == null ? void 0 : syncState.resetValueOnHide,
18673 multiSelectable && !tag
18674 ),
18675 activeValue: syncState == null ? void 0 : syncState.activeValue
18676 };
18677 const combobox = createStore(initialState, composite, popover, store);
18678 if (isTouchSafari) {
18679 setup(
18680 combobox,
18681 () => sync(combobox, ["virtualFocus"], () => {
18682 combobox.setState("virtualFocus", false);
18683 })
18684 );
18685 }
18686 setup(combobox, () => {
18687 if (!tag) return;
18688 return chain(
18689 sync(combobox, ["selectedValue"], (state) => {
18690 if (!Array.isArray(state.selectedValue)) return;
18691 tag.setValues(state.selectedValue);
18692 }),
18693 sync(tag, ["values"], (state) => {
18694 combobox.setState("selectedValue", state.values);
18695 })
18696 );
18697 });
18698 setup(
18699 combobox,
18700 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18701 if (!state.resetValueOnHide) return;
18702 if (state.mounted) return;
18703 combobox.setState("value", value);
18704 })
18705 );
18706 setup(
18707 combobox,
18708 () => sync(combobox, ["open"], (state) => {
18709 if (state.open) return;
18710 combobox.setState("activeId", activeId);
18711 combobox.setState("moves", 0);
18712 })
18713 );
18714 setup(
18715 combobox,
18716 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18717 if (state.moves === prevState.moves) {
18718 combobox.setState("activeValue", void 0);
18719 }
18720 })
18721 );
18722 setup(
18723 combobox,
18724 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18725 if (state.moves === prev.moves) return;
18726 const { activeId: activeId2 } = combobox.getState();
18727 const activeItem = composite.item(activeId2);
18728 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18729 })
18730 );
18731 return {
18732 ...popover,
18733 ...composite,
18734 ...combobox,
18735 tag,
18736 setValue: (value2) => combobox.setState("value", value2),
18737 resetValue: () => combobox.setState("value", initialState.value),
18738 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18739 };
18740 }
18741
18742 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18743 function useComboboxStoreOptions(props) {
18744 const tag = useTagContext();
18745 props = {
18746 ...props,
18747 tag: props.tag !== void 0 ? props.tag : tag
18748 };
18749 return useCompositeStoreOptions(props);
18750 }
18751 function useComboboxStoreProps(store, update2, props) {
18752 useUpdateEffect(update2, [props.tag]);
18753 useStoreProps(store, props, "value", "setValue");
18754 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18755 useStoreProps(store, props, "resetValueOnHide");
18756 useStoreProps(store, props, "resetValueOnSelect");
18757 return Object.assign(
18758 useCompositeStoreProps(
18759 usePopoverStoreProps(store, update2, props),
18760 update2,
18761 props
18762 ),
18763 { tag: props.tag }
18764 );
18765 }
18766 function useComboboxStore(props = {}) {
18767 props = useComboboxStoreOptions(props);
18768 const [store, update2] = useStore2(createComboboxStore, props);
18769 return useComboboxStoreProps(store, update2, props);
18770 }
18771
18772 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18773 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18774 function ComboboxProvider(props = {}) {
18775 const store = useComboboxStore(props);
18776 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18777 }
18778
18779 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18780 var import_remove_accents = __toESM(require_remove_accents(), 1);
18781 var import_compose7 = __toESM(require_compose(), 1);
18782 var import_i18n23 = __toESM(require_i18n(), 1);
18783 var import_element47 = __toESM(require_element(), 1);
18784 var import_components18 = __toESM(require_components(), 1);
18785
18786 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18787 var EMPTY_ARRAY3 = [];
18788 var getCurrentValue = (filterDefinition, currentFilter) => {
18789 if (filterDefinition.singleSelection) {
18790 return currentFilter?.value;
18791 }
18792 if (Array.isArray(currentFilter?.value)) {
18793 return currentFilter.value;
18794 }
18795 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18796 return [currentFilter.value];
18797 }
18798 return EMPTY_ARRAY3;
18799 };
18800
18801 // packages/dataviews/build-module/hooks/use-elements.mjs
18802 var import_element46 = __toESM(require_element(), 1);
18803 var EMPTY_ARRAY4 = [];
18804 function useElements({
18805 elements,
18806 getElements
18807 }) {
18808 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18809 const [records, setRecords] = (0, import_element46.useState)(staticElements);
18810 const [isLoading, setIsLoading] = (0, import_element46.useState)(false);
18811 (0, import_element46.useEffect)(() => {
18812 if (!getElements) {
18813 setRecords(staticElements);
18814 return;
18815 }
18816 let cancelled = false;
18817 setIsLoading(true);
18818 getElements().then((fetchedElements) => {
18819 if (!cancelled) {
18820 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18821 setRecords(dynamicElements);
18822 }
18823 }).catch(() => {
18824 if (!cancelled) {
18825 setRecords(staticElements);
18826 }
18827 }).finally(() => {
18828 if (!cancelled) {
18829 setIsLoading(false);
18830 }
18831 });
18832 return () => {
18833 cancelled = true;
18834 };
18835 }, [getElements, staticElements]);
18836 return {
18837 elements: records,
18838 isLoading
18839 };
18840 }
18841
18842 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18843 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
18844 function normalizeSearchInput(input = "") {
18845 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18846 }
18847 var getNewValue = (filterDefinition, currentFilter, value) => {
18848 if (filterDefinition.singleSelection) {
18849 return value;
18850 }
18851 if (Array.isArray(currentFilter?.value)) {
18852 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18853 }
18854 return [value];
18855 };
18856 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18857 return `${prefix}-${filterElementValue}`;
18858 }
18859 var MultiSelectionOption = ({ selected }) => {
18860 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18861 "span",
18862 {
18863 className: clsx_default(
18864 "dataviews-filters__search-widget-listitem-multi-selection",
18865 { "is-selected": selected }
18866 ),
18867 children: selected && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Icon, { icon: check_default })
18868 }
18869 );
18870 };
18871 var SingleSelectionOption = ({ selected }) => {
18872 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18873 "span",
18874 {
18875 className: clsx_default(
18876 "dataviews-filters__search-widget-listitem-single-selection",
18877 { "is-selected": selected }
18878 )
18879 }
18880 );
18881 };
18882 function ListBox({ view, filter, onChangeView }) {
18883 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
18884 const [activeCompositeId, setActiveCompositeId] = (0, import_element47.useState)(
18885 // When there are one or less operators, the first item is set as active
18886 // (by setting the initial `activeId` to `undefined`).
18887 // With 2 or more operators, the focus is moved on the operators control
18888 // (by setting the initial `activeId` to `null`), meaning that there won't
18889 // be an active item initially. Focus is then managed via the
18890 // `onFocusVisible` callback.
18891 filter.operators?.length === 1 ? void 0 : null
18892 );
18893 const currentFilter = view.filters?.find(
18894 (f2) => f2.field === filter.field
18895 );
18896 const currentValue = getCurrentValue(filter, currentFilter);
18897 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18898 import_components18.Composite,
18899 {
18900 virtualFocus: true,
18901 focusLoop: true,
18902 activeId: activeCompositeId,
18903 setActiveId: setActiveCompositeId,
18904 role: "listbox",
18905 className: "dataviews-filters__search-widget-listbox",
18906 "aria-label": (0, import_i18n23.sprintf)(
18907 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18908 (0, import_i18n23.__)("List of: %1$s"),
18909 filter.name
18910 ),
18911 onFocusVisible: () => {
18912 if (!activeCompositeId && filter.elements.length) {
18913 setActiveCompositeId(
18914 generateFilterElementCompositeItemId(
18915 baseId,
18916 filter.elements[0].value
18917 )
18918 );
18919 }
18920 },
18921 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Composite.Typeahead, {}),
18922 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
18923 import_components18.Composite.Hover,
18924 {
18925 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18926 import_components18.Composite.Item,
18927 {
18928 id: generateFilterElementCompositeItemId(
18929 baseId,
18930 element.value
18931 ),
18932 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18933 "div",
18934 {
18935 "aria-label": element.label,
18936 role: "option",
18937 className: "dataviews-filters__search-widget-listitem"
18938 }
18939 ),
18940 onClick: () => {
18941 const newFilters = currentFilter ? [
18942 ...(view.filters ?? []).map(
18943 (_filter) => {
18944 if (_filter.field === filter.field) {
18945 return {
18946 ..._filter,
18947 operator: currentFilter.operator || filter.operators[0],
18948 value: getNewValue(
18949 filter,
18950 currentFilter,
18951 element.value
18952 )
18953 };
18954 }
18955 return _filter;
18956 }
18957 )
18958 ] : [
18959 ...view.filters ?? [],
18960 {
18961 field: filter.field,
18962 operator: filter.operators[0],
18963 value: getNewValue(
18964 filter,
18965 currentFilter,
18966 element.value
18967 )
18968 }
18969 ];
18970 onChangeView({
18971 ...view,
18972 page: 1,
18973 filters: newFilters
18974 });
18975 }
18976 }
18977 ),
18978 children: [
18979 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18980 SingleSelectionOption,
18981 {
18982 selected: currentValue === element.value
18983 }
18984 ),
18985 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18986 MultiSelectionOption,
18987 {
18988 selected: currentValue.includes(element.value)
18989 }
18990 ),
18991 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
18992 "span",
18993 {
18994 className: "dataviews-filters__search-widget-listitem-value",
18995 title: element.label,
18996 children: element.label
18997 }
18998 )
18999 ]
19000 },
19001 element.value
19002 ))
19003 }
19004 );
19005 }
19006 function ComboboxList22({ view, filter, onChangeView }) {
19007 const [searchValue, setSearchValue] = (0, import_element47.useState)("");
19008 const deferredSearchValue = (0, import_element47.useDeferredValue)(searchValue);
19009 const currentFilter = view.filters?.find(
19010 (_filter) => _filter.field === filter.field
19011 );
19012 const currentValue = getCurrentValue(filter, currentFilter);
19013 const matches = (0, import_element47.useMemo)(() => {
19014 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19015 return filter.elements.filter(
19016 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19017 );
19018 }, [filter.elements, deferredSearchValue]);
19019 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19020 ComboboxProvider,
19021 {
19022 selectedValue: currentValue,
19023 setSelectedValue: (value) => {
19024 const newFilters = currentFilter ? [
19025 ...(view.filters ?? []).map((_filter) => {
19026 if (_filter.field === filter.field) {
19027 return {
19028 ..._filter,
19029 operator: currentFilter.operator || filter.operators[0],
19030 value
19031 };
19032 }
19033 return _filter;
19034 })
19035 ] : [
19036 ...view.filters ?? [],
19037 {
19038 field: filter.field,
19039 operator: filter.operators[0],
19040 value
19041 }
19042 ];
19043 onChangeView({
19044 ...view,
19045 page: 1,
19046 filters: newFilters
19047 });
19048 },
19049 setValue: setSearchValue,
19050 children: [
19051 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19052 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
19053 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19054 Combobox,
19055 {
19056 autoSelect: "always",
19057 placeholder: (0, import_i18n23.__)("Search"),
19058 className: "dataviews-filters__search-widget-filter-combobox__input"
19059 }
19060 ),
19061 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Icon, { icon: search_default }) })
19062 ] }),
19063 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19064 ComboboxList,
19065 {
19066 className: "dataviews-filters__search-widget-filter-combobox-list",
19067 alwaysVisible: true,
19068 children: [
19069 matches.map((element) => {
19070 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19071 ComboboxItem,
19072 {
19073 resetValueOnSelect: false,
19074 value: element.value,
19075 className: "dataviews-filters__search-widget-listitem",
19076 hideOnClick: false,
19077 setValueOnClick: false,
19078 focusOnHover: true,
19079 children: [
19080 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19081 SingleSelectionOption,
19082 {
19083 selected: currentValue === element.value
19084 }
19085 ),
19086 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19087 MultiSelectionOption,
19088 {
19089 selected: currentValue.includes(
19090 element.value
19091 )
19092 }
19093 ),
19094 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19095 "span",
19096 {
19097 className: "dataviews-filters__search-widget-listitem-value",
19098 title: element.label,
19099 children: [
19100 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19101 ComboboxItemValue,
19102 {
19103 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19104 value: element.label
19105 }
19106 ),
19107 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19108 ]
19109 }
19110 )
19111 ]
19112 },
19113 element.value
19114 );
19115 }),
19116 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
19117 ]
19118 }
19119 )
19120 ]
19121 }
19122 );
19123 }
19124 function SearchWidget(props) {
19125 const { elements, isLoading } = useElements({
19126 elements: props.filter.elements,
19127 getElements: props.filter.getElements
19128 });
19129 if (isLoading) {
19130 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components18.Spinner, {}) });
19131 }
19132 if (elements.length === 0) {
19133 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
19134 }
19135 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19136 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19137 }
19138
19139 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19140 var import_es6 = __toESM(require_es6(), 1);
19141 var import_compose8 = __toESM(require_compose(), 1);
19142 var import_element48 = __toESM(require_element(), 1);
19143 var import_components19 = __toESM(require_components(), 1);
19144 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19145 function InputWidget({
19146 filter,
19147 view,
19148 onChangeView,
19149 fields
19150 }) {
19151 const currentFilter = view.filters?.find(
19152 (f2) => f2.field === filter.field
19153 );
19154 const currentValue = getCurrentValue(filter, currentFilter);
19155 const field = (0, import_element48.useMemo)(() => {
19156 const currentField = fields.find((f2) => f2.id === filter.field);
19157 if (currentField) {
19158 return {
19159 ...currentField,
19160 // Deactivate validation for filters.
19161 isValid: {},
19162 // Filter controls are always enabled.
19163 isDisabled: () => false,
19164 // Filter controls are always visible.
19165 isVisible: () => true,
19166 // Configure getValue/setValue as if Item was a plain object.
19167 getValue: ({ item }) => item[currentField.id],
19168 setValue: ({ value }) => ({
19169 [currentField.id]: value
19170 })
19171 };
19172 }
19173 return currentField;
19174 }, [fields, filter.field]);
19175 const data = (0, import_element48.useMemo)(() => {
19176 return (view.filters ?? []).reduce(
19177 (acc, activeFilter) => {
19178 acc[activeFilter.field] = activeFilter.value;
19179 return acc;
19180 },
19181 {}
19182 );
19183 }, [view.filters]);
19184 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
19185 if (!field || !currentFilter) {
19186 return;
19187 }
19188 const nextValue = field.getValue({ item: updatedData });
19189 if ((0, import_es6.default)(nextValue, currentValue)) {
19190 return;
19191 }
19192 onChangeView({
19193 ...view,
19194 filters: (view.filters ?? []).map(
19195 (_filter) => _filter.field === filter.field ? {
19196 ..._filter,
19197 operator: currentFilter.operator || filter.operators[0],
19198 // Consider empty strings as undefined:
19199 //
19200 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19201 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19202 //
19203 // In practice, this means the filter will not be able to find an empty string as the value.
19204 value: nextValue === "" ? void 0 : nextValue
19205 } : _filter
19206 )
19207 });
19208 });
19209 if (!field || !field.Edit || !currentFilter) {
19210 return null;
19211 }
19212 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19213 import_components19.Flex,
19214 {
19215 className: "dataviews-filters__user-input-widget",
19216 gap: 2.5,
19217 direction: "column",
19218 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19219 field.Edit,
19220 {
19221 hideLabelFromVision: true,
19222 data,
19223 field,
19224 operator: currentFilter.operator,
19225 onChange: handleChange
19226 }
19227 )
19228 }
19229 );
19230 }
19231
19232 // node_modules/date-fns/constants.js
19233 var daysInYear = 365.2425;
19234 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19235 var minTime = -maxTime;
19236 var millisecondsInWeek = 6048e5;
19237 var millisecondsInDay = 864e5;
19238 var secondsInHour = 3600;
19239 var secondsInDay = secondsInHour * 24;
19240 var secondsInWeek = secondsInDay * 7;
19241 var secondsInYear = secondsInDay * daysInYear;
19242 var secondsInMonth = secondsInYear / 12;
19243 var secondsInQuarter = secondsInMonth * 3;
19244 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19245
19246 // node_modules/date-fns/constructFrom.js
19247 function constructFrom(date, value) {
19248 if (typeof date === "function") return date(value);
19249 if (date && typeof date === "object" && constructFromSymbol in date)
19250 return date[constructFromSymbol](value);
19251 if (date instanceof Date) return new date.constructor(value);
19252 return new Date(value);
19253 }
19254
19255 // node_modules/date-fns/toDate.js
19256 function toDate(argument, context) {
19257 return constructFrom(context || argument, argument);
19258 }
19259
19260 // node_modules/date-fns/addDays.js
19261 function addDays(date, amount, options) {
19262 const _date = toDate(date, options?.in);
19263 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19264 if (!amount) return _date;
19265 _date.setDate(_date.getDate() + amount);
19266 return _date;
19267 }
19268
19269 // node_modules/date-fns/addMonths.js
19270 function addMonths(date, amount, options) {
19271 const _date = toDate(date, options?.in);
19272 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19273 if (!amount) {
19274 return _date;
19275 }
19276 const dayOfMonth = _date.getDate();
19277 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19278 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19279 const daysInMonth = endOfDesiredMonth.getDate();
19280 if (dayOfMonth >= daysInMonth) {
19281 return endOfDesiredMonth;
19282 } else {
19283 _date.setFullYear(
19284 endOfDesiredMonth.getFullYear(),
19285 endOfDesiredMonth.getMonth(),
19286 dayOfMonth
19287 );
19288 return _date;
19289 }
19290 }
19291
19292 // node_modules/date-fns/_lib/defaultOptions.js
19293 var defaultOptions = {};
19294 function getDefaultOptions() {
19295 return defaultOptions;
19296 }
19297
19298 // node_modules/date-fns/startOfWeek.js
19299 function startOfWeek(date, options) {
19300 const defaultOptions2 = getDefaultOptions();
19301 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19302 const _date = toDate(date, options?.in);
19303 const day = _date.getDay();
19304 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19305 _date.setDate(_date.getDate() - diff);
19306 _date.setHours(0, 0, 0, 0);
19307 return _date;
19308 }
19309
19310 // node_modules/date-fns/startOfISOWeek.js
19311 function startOfISOWeek(date, options) {
19312 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19313 }
19314
19315 // node_modules/date-fns/getISOWeekYear.js
19316 function getISOWeekYear(date, options) {
19317 const _date = toDate(date, options?.in);
19318 const year = _date.getFullYear();
19319 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19320 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19321 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19322 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19323 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19324 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19325 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19326 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19327 if (_date.getTime() >= startOfNextYear.getTime()) {
19328 return year + 1;
19329 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19330 return year;
19331 } else {
19332 return year - 1;
19333 }
19334 }
19335
19336 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19337 function getTimezoneOffsetInMilliseconds(date) {
19338 const _date = toDate(date);
19339 const utcDate = new Date(
19340 Date.UTC(
19341 _date.getFullYear(),
19342 _date.getMonth(),
19343 _date.getDate(),
19344 _date.getHours(),
19345 _date.getMinutes(),
19346 _date.getSeconds(),
19347 _date.getMilliseconds()
19348 )
19349 );
19350 utcDate.setUTCFullYear(_date.getFullYear());
19351 return +date - +utcDate;
19352 }
19353
19354 // node_modules/date-fns/_lib/normalizeDates.js
19355 function normalizeDates(context, ...dates) {
19356 const normalize = constructFrom.bind(
19357 null,
19358 context || dates.find((date) => typeof date === "object")
19359 );
19360 return dates.map(normalize);
19361 }
19362
19363 // node_modules/date-fns/startOfDay.js
19364 function startOfDay(date, options) {
19365 const _date = toDate(date, options?.in);
19366 _date.setHours(0, 0, 0, 0);
19367 return _date;
19368 }
19369
19370 // node_modules/date-fns/differenceInCalendarDays.js
19371 function differenceInCalendarDays(laterDate, earlierDate, options) {
19372 const [laterDate_, earlierDate_] = normalizeDates(
19373 options?.in,
19374 laterDate,
19375 earlierDate
19376 );
19377 const laterStartOfDay = startOfDay(laterDate_);
19378 const earlierStartOfDay = startOfDay(earlierDate_);
19379 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19380 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19381 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19382 }
19383
19384 // node_modules/date-fns/startOfISOWeekYear.js
19385 function startOfISOWeekYear(date, options) {
19386 const year = getISOWeekYear(date, options);
19387 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19388 fourthOfJanuary.setFullYear(year, 0, 4);
19389 fourthOfJanuary.setHours(0, 0, 0, 0);
19390 return startOfISOWeek(fourthOfJanuary);
19391 }
19392
19393 // node_modules/date-fns/addWeeks.js
19394 function addWeeks(date, amount, options) {
19395 return addDays(date, amount * 7, options);
19396 }
19397
19398 // node_modules/date-fns/addYears.js
19399 function addYears(date, amount, options) {
19400 return addMonths(date, amount * 12, options);
19401 }
19402
19403 // node_modules/date-fns/isDate.js
19404 function isDate(value) {
19405 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19406 }
19407
19408 // node_modules/date-fns/isValid.js
19409 function isValid(date) {
19410 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19411 }
19412
19413 // node_modules/date-fns/startOfMonth.js
19414 function startOfMonth(date, options) {
19415 const _date = toDate(date, options?.in);
19416 _date.setDate(1);
19417 _date.setHours(0, 0, 0, 0);
19418 return _date;
19419 }
19420
19421 // node_modules/date-fns/startOfYear.js
19422 function startOfYear(date, options) {
19423 const date_ = toDate(date, options?.in);
19424 date_.setFullYear(date_.getFullYear(), 0, 1);
19425 date_.setHours(0, 0, 0, 0);
19426 return date_;
19427 }
19428
19429 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19430 var formatDistanceLocale = {
19431 lessThanXSeconds: {
19432 one: "less than a second",
19433 other: "less than {{count}} seconds"
19434 },
19435 xSeconds: {
19436 one: "1 second",
19437 other: "{{count}} seconds"
19438 },
19439 halfAMinute: "half a minute",
19440 lessThanXMinutes: {
19441 one: "less than a minute",
19442 other: "less than {{count}} minutes"
19443 },
19444 xMinutes: {
19445 one: "1 minute",
19446 other: "{{count}} minutes"
19447 },
19448 aboutXHours: {
19449 one: "about 1 hour",
19450 other: "about {{count}} hours"
19451 },
19452 xHours: {
19453 one: "1 hour",
19454 other: "{{count}} hours"
19455 },
19456 xDays: {
19457 one: "1 day",
19458 other: "{{count}} days"
19459 },
19460 aboutXWeeks: {
19461 one: "about 1 week",
19462 other: "about {{count}} weeks"
19463 },
19464 xWeeks: {
19465 one: "1 week",
19466 other: "{{count}} weeks"
19467 },
19468 aboutXMonths: {
19469 one: "about 1 month",
19470 other: "about {{count}} months"
19471 },
19472 xMonths: {
19473 one: "1 month",
19474 other: "{{count}} months"
19475 },
19476 aboutXYears: {
19477 one: "about 1 year",
19478 other: "about {{count}} years"
19479 },
19480 xYears: {
19481 one: "1 year",
19482 other: "{{count}} years"
19483 },
19484 overXYears: {
19485 one: "over 1 year",
19486 other: "over {{count}} years"
19487 },
19488 almostXYears: {
19489 one: "almost 1 year",
19490 other: "almost {{count}} years"
19491 }
19492 };
19493 var formatDistance = (token, count, options) => {
19494 let result;
19495 const tokenValue = formatDistanceLocale[token];
19496 if (typeof tokenValue === "string") {
19497 result = tokenValue;
19498 } else if (count === 1) {
19499 result = tokenValue.one;
19500 } else {
19501 result = tokenValue.other.replace("{{count}}", count.toString());
19502 }
19503 if (options?.addSuffix) {
19504 if (options.comparison && options.comparison > 0) {
19505 return "in " + result;
19506 } else {
19507 return result + " ago";
19508 }
19509 }
19510 return result;
19511 };
19512
19513 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19514 function buildFormatLongFn(args) {
19515 return (options = {}) => {
19516 const width = options.width ? String(options.width) : args.defaultWidth;
19517 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19518 return format6;
19519 };
19520 }
19521
19522 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19523 var dateFormats = {
19524 full: "EEEE, MMMM do, y",
19525 long: "MMMM do, y",
19526 medium: "MMM d, y",
19527 short: "MM/dd/yyyy"
19528 };
19529 var timeFormats = {
19530 full: "h:mm:ss a zzzz",
19531 long: "h:mm:ss a z",
19532 medium: "h:mm:ss a",
19533 short: "h:mm a"
19534 };
19535 var dateTimeFormats = {
19536 full: "{{date}} 'at' {{time}}",
19537 long: "{{date}} 'at' {{time}}",
19538 medium: "{{date}}, {{time}}",
19539 short: "{{date}}, {{time}}"
19540 };
19541 var formatLong = {
19542 date: buildFormatLongFn({
19543 formats: dateFormats,
19544 defaultWidth: "full"
19545 }),
19546 time: buildFormatLongFn({
19547 formats: timeFormats,
19548 defaultWidth: "full"
19549 }),
19550 dateTime: buildFormatLongFn({
19551 formats: dateTimeFormats,
19552 defaultWidth: "full"
19553 })
19554 };
19555
19556 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19557 var formatRelativeLocale = {
19558 lastWeek: "'last' eeee 'at' p",
19559 yesterday: "'yesterday at' p",
19560 today: "'today at' p",
19561 tomorrow: "'tomorrow at' p",
19562 nextWeek: "eeee 'at' p",
19563 other: "P"
19564 };
19565 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19566
19567 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19568 function buildLocalizeFn(args) {
19569 return (value, options) => {
19570 const context = options?.context ? String(options.context) : "standalone";
19571 let valuesArray;
19572 if (context === "formatting" && args.formattingValues) {
19573 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19574 const width = options?.width ? String(options.width) : defaultWidth;
19575 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19576 } else {
19577 const defaultWidth = args.defaultWidth;
19578 const width = options?.width ? String(options.width) : args.defaultWidth;
19579 valuesArray = args.values[width] || args.values[defaultWidth];
19580 }
19581 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19582 return valuesArray[index2];
19583 };
19584 }
19585
19586 // node_modules/date-fns/locale/en-US/_lib/localize.js
19587 var eraValues = {
19588 narrow: ["B", "A"],
19589 abbreviated: ["BC", "AD"],
19590 wide: ["Before Christ", "Anno Domini"]
19591 };
19592 var quarterValues = {
19593 narrow: ["1", "2", "3", "4"],
19594 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19595 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19596 };
19597 var monthValues = {
19598 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19599 abbreviated: [
19600 "Jan",
19601 "Feb",
19602 "Mar",
19603 "Apr",
19604 "May",
19605 "Jun",
19606 "Jul",
19607 "Aug",
19608 "Sep",
19609 "Oct",
19610 "Nov",
19611 "Dec"
19612 ],
19613 wide: [
19614 "January",
19615 "February",
19616 "March",
19617 "April",
19618 "May",
19619 "June",
19620 "July",
19621 "August",
19622 "September",
19623 "October",
19624 "November",
19625 "December"
19626 ]
19627 };
19628 var dayValues = {
19629 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19630 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19631 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19632 wide: [
19633 "Sunday",
19634 "Monday",
19635 "Tuesday",
19636 "Wednesday",
19637 "Thursday",
19638 "Friday",
19639 "Saturday"
19640 ]
19641 };
19642 var dayPeriodValues = {
19643 narrow: {
19644 am: "a",
19645 pm: "p",
19646 midnight: "mi",
19647 noon: "n",
19648 morning: "morning",
19649 afternoon: "afternoon",
19650 evening: "evening",
19651 night: "night"
19652 },
19653 abbreviated: {
19654 am: "AM",
19655 pm: "PM",
19656 midnight: "midnight",
19657 noon: "noon",
19658 morning: "morning",
19659 afternoon: "afternoon",
19660 evening: "evening",
19661 night: "night"
19662 },
19663 wide: {
19664 am: "a.m.",
19665 pm: "p.m.",
19666 midnight: "midnight",
19667 noon: "noon",
19668 morning: "morning",
19669 afternoon: "afternoon",
19670 evening: "evening",
19671 night: "night"
19672 }
19673 };
19674 var formattingDayPeriodValues = {
19675 narrow: {
19676 am: "a",
19677 pm: "p",
19678 midnight: "mi",
19679 noon: "n",
19680 morning: "in the morning",
19681 afternoon: "in the afternoon",
19682 evening: "in the evening",
19683 night: "at night"
19684 },
19685 abbreviated: {
19686 am: "AM",
19687 pm: "PM",
19688 midnight: "midnight",
19689 noon: "noon",
19690 morning: "in the morning",
19691 afternoon: "in the afternoon",
19692 evening: "in the evening",
19693 night: "at night"
19694 },
19695 wide: {
19696 am: "a.m.",
19697 pm: "p.m.",
19698 midnight: "midnight",
19699 noon: "noon",
19700 morning: "in the morning",
19701 afternoon: "in the afternoon",
19702 evening: "in the evening",
19703 night: "at night"
19704 }
19705 };
19706 var ordinalNumber = (dirtyNumber, _options) => {
19707 const number = Number(dirtyNumber);
19708 const rem100 = number % 100;
19709 if (rem100 > 20 || rem100 < 10) {
19710 switch (rem100 % 10) {
19711 case 1:
19712 return number + "st";
19713 case 2:
19714 return number + "nd";
19715 case 3:
19716 return number + "rd";
19717 }
19718 }
19719 return number + "th";
19720 };
19721 var localize = {
19722 ordinalNumber,
19723 era: buildLocalizeFn({
19724 values: eraValues,
19725 defaultWidth: "wide"
19726 }),
19727 quarter: buildLocalizeFn({
19728 values: quarterValues,
19729 defaultWidth: "wide",
19730 argumentCallback: (quarter) => quarter - 1
19731 }),
19732 month: buildLocalizeFn({
19733 values: monthValues,
19734 defaultWidth: "wide"
19735 }),
19736 day: buildLocalizeFn({
19737 values: dayValues,
19738 defaultWidth: "wide"
19739 }),
19740 dayPeriod: buildLocalizeFn({
19741 values: dayPeriodValues,
19742 defaultWidth: "wide",
19743 formattingValues: formattingDayPeriodValues,
19744 defaultFormattingWidth: "wide"
19745 })
19746 };
19747
19748 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19749 function buildMatchFn(args) {
19750 return (string, options = {}) => {
19751 const width = options.width;
19752 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19753 const matchResult = string.match(matchPattern);
19754 if (!matchResult) {
19755 return null;
19756 }
19757 const matchedString = matchResult[0];
19758 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19759 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19760 // [TODO] -- I challenge you to fix the type
19761 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19762 );
19763 let value;
19764 value = args.valueCallback ? args.valueCallback(key) : key;
19765 value = options.valueCallback ? (
19766 // [TODO] -- I challenge you to fix the type
19767 options.valueCallback(value)
19768 ) : value;
19769 const rest = string.slice(matchedString.length);
19770 return { value, rest };
19771 };
19772 }
19773 function findKey(object, predicate) {
19774 for (const key in object) {
19775 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19776 return key;
19777 }
19778 }
19779 return void 0;
19780 }
19781 function findIndex(array, predicate) {
19782 for (let key = 0; key < array.length; key++) {
19783 if (predicate(array[key])) {
19784 return key;
19785 }
19786 }
19787 return void 0;
19788 }
19789
19790 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19791 function buildMatchPatternFn(args) {
19792 return (string, options = {}) => {
19793 const matchResult = string.match(args.matchPattern);
19794 if (!matchResult) return null;
19795 const matchedString = matchResult[0];
19796 const parseResult = string.match(args.parsePattern);
19797 if (!parseResult) return null;
19798 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19799 value = options.valueCallback ? options.valueCallback(value) : value;
19800 const rest = string.slice(matchedString.length);
19801 return { value, rest };
19802 };
19803 }
19804
19805 // node_modules/date-fns/locale/en-US/_lib/match.js
19806 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19807 var parseOrdinalNumberPattern = /\d+/i;
19808 var matchEraPatterns = {
19809 narrow: /^(b|a)/i,
19810 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19811 wide: /^(before christ|before common era|anno domini|common era)/i
19812 };
19813 var parseEraPatterns = {
19814 any: [/^b/i, /^(a|c)/i]
19815 };
19816 var matchQuarterPatterns = {
19817 narrow: /^[1234]/i,
19818 abbreviated: /^q[1234]/i,
19819 wide: /^[1234](th|st|nd|rd)? quarter/i
19820 };
19821 var parseQuarterPatterns = {
19822 any: [/1/i, /2/i, /3/i, /4/i]
19823 };
19824 var matchMonthPatterns = {
19825 narrow: /^[jfmasond]/i,
19826 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19827 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19828 };
19829 var parseMonthPatterns = {
19830 narrow: [
19831 /^j/i,
19832 /^f/i,
19833 /^m/i,
19834 /^a/i,
19835 /^m/i,
19836 /^j/i,
19837 /^j/i,
19838 /^a/i,
19839 /^s/i,
19840 /^o/i,
19841 /^n/i,
19842 /^d/i
19843 ],
19844 any: [
19845 /^ja/i,
19846 /^f/i,
19847 /^mar/i,
19848 /^ap/i,
19849 /^may/i,
19850 /^jun/i,
19851 /^jul/i,
19852 /^au/i,
19853 /^s/i,
19854 /^o/i,
19855 /^n/i,
19856 /^d/i
19857 ]
19858 };
19859 var matchDayPatterns = {
19860 narrow: /^[smtwf]/i,
19861 short: /^(su|mo|tu|we|th|fr|sa)/i,
19862 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19863 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19864 };
19865 var parseDayPatterns = {
19866 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19867 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19868 };
19869 var matchDayPeriodPatterns = {
19870 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19871 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19872 };
19873 var parseDayPeriodPatterns = {
19874 any: {
19875 am: /^a/i,
19876 pm: /^p/i,
19877 midnight: /^mi/i,
19878 noon: /^no/i,
19879 morning: /morning/i,
19880 afternoon: /afternoon/i,
19881 evening: /evening/i,
19882 night: /night/i
19883 }
19884 };
19885 var match = {
19886 ordinalNumber: buildMatchPatternFn({
19887 matchPattern: matchOrdinalNumberPattern,
19888 parsePattern: parseOrdinalNumberPattern,
19889 valueCallback: (value) => parseInt(value, 10)
19890 }),
19891 era: buildMatchFn({
19892 matchPatterns: matchEraPatterns,
19893 defaultMatchWidth: "wide",
19894 parsePatterns: parseEraPatterns,
19895 defaultParseWidth: "any"
19896 }),
19897 quarter: buildMatchFn({
19898 matchPatterns: matchQuarterPatterns,
19899 defaultMatchWidth: "wide",
19900 parsePatterns: parseQuarterPatterns,
19901 defaultParseWidth: "any",
19902 valueCallback: (index2) => index2 + 1
19903 }),
19904 month: buildMatchFn({
19905 matchPatterns: matchMonthPatterns,
19906 defaultMatchWidth: "wide",
19907 parsePatterns: parseMonthPatterns,
19908 defaultParseWidth: "any"
19909 }),
19910 day: buildMatchFn({
19911 matchPatterns: matchDayPatterns,
19912 defaultMatchWidth: "wide",
19913 parsePatterns: parseDayPatterns,
19914 defaultParseWidth: "any"
19915 }),
19916 dayPeriod: buildMatchFn({
19917 matchPatterns: matchDayPeriodPatterns,
19918 defaultMatchWidth: "any",
19919 parsePatterns: parseDayPeriodPatterns,
19920 defaultParseWidth: "any"
19921 })
19922 };
19923
19924 // node_modules/date-fns/locale/en-US.js
19925 var enUS = {
19926 code: "en-US",
19927 formatDistance,
19928 formatLong,
19929 formatRelative,
19930 localize,
19931 match,
19932 options: {
19933 weekStartsOn: 0,
19934 firstWeekContainsDate: 1
19935 }
19936 };
19937
19938 // node_modules/date-fns/getDayOfYear.js
19939 function getDayOfYear(date, options) {
19940 const _date = toDate(date, options?.in);
19941 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19942 const dayOfYear = diff + 1;
19943 return dayOfYear;
19944 }
19945
19946 // node_modules/date-fns/getISOWeek.js
19947 function getISOWeek(date, options) {
19948 const _date = toDate(date, options?.in);
19949 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19950 return Math.round(diff / millisecondsInWeek) + 1;
19951 }
19952
19953 // node_modules/date-fns/getWeekYear.js
19954 function getWeekYear(date, options) {
19955 const _date = toDate(date, options?.in);
19956 const year = _date.getFullYear();
19957 const defaultOptions2 = getDefaultOptions();
19958 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19959 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19960 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19961 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19962 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19963 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19964 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19965 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19966 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19967 if (+_date >= +startOfNextYear) {
19968 return year + 1;
19969 } else if (+_date >= +startOfThisYear) {
19970 return year;
19971 } else {
19972 return year - 1;
19973 }
19974 }
19975
19976 // node_modules/date-fns/startOfWeekYear.js
19977 function startOfWeekYear(date, options) {
19978 const defaultOptions2 = getDefaultOptions();
19979 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19980 const year = getWeekYear(date, options);
19981 const firstWeek = constructFrom(options?.in || date, 0);
19982 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19983 firstWeek.setHours(0, 0, 0, 0);
19984 const _date = startOfWeek(firstWeek, options);
19985 return _date;
19986 }
19987
19988 // node_modules/date-fns/getWeek.js
19989 function getWeek(date, options) {
19990 const _date = toDate(date, options?.in);
19991 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19992 return Math.round(diff / millisecondsInWeek) + 1;
19993 }
19994
19995 // node_modules/date-fns/_lib/addLeadingZeros.js
19996 function addLeadingZeros(number, targetLength) {
19997 const sign = number < 0 ? "-" : "";
19998 const output = Math.abs(number).toString().padStart(targetLength, "0");
19999 return sign + output;
20000 }
20001
20002 // node_modules/date-fns/_lib/format/lightFormatters.js
20003 var lightFormatters = {
20004 // Year
20005 y(date, token) {
20006 const signedYear = date.getFullYear();
20007 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20008 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20009 },
20010 // Month
20011 M(date, token) {
20012 const month = date.getMonth();
20013 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20014 },
20015 // Day of the month
20016 d(date, token) {
20017 return addLeadingZeros(date.getDate(), token.length);
20018 },
20019 // AM or PM
20020 a(date, token) {
20021 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20022 switch (token) {
20023 case "a":
20024 case "aa":
20025 return dayPeriodEnumValue.toUpperCase();
20026 case "aaa":
20027 return dayPeriodEnumValue;
20028 case "aaaaa":
20029 return dayPeriodEnumValue[0];
20030 case "aaaa":
20031 default:
20032 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20033 }
20034 },
20035 // Hour [1-12]
20036 h(date, token) {
20037 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20038 },
20039 // Hour [0-23]
20040 H(date, token) {
20041 return addLeadingZeros(date.getHours(), token.length);
20042 },
20043 // Minute
20044 m(date, token) {
20045 return addLeadingZeros(date.getMinutes(), token.length);
20046 },
20047 // Second
20048 s(date, token) {
20049 return addLeadingZeros(date.getSeconds(), token.length);
20050 },
20051 // Fraction of second
20052 S(date, token) {
20053 const numberOfDigits = token.length;
20054 const milliseconds = date.getMilliseconds();
20055 const fractionalSeconds = Math.trunc(
20056 milliseconds * Math.pow(10, numberOfDigits - 3)
20057 );
20058 return addLeadingZeros(fractionalSeconds, token.length);
20059 }
20060 };
20061
20062 // node_modules/date-fns/_lib/format/formatters.js
20063 var dayPeriodEnum = {
20064 am: "am",
20065 pm: "pm",
20066 midnight: "midnight",
20067 noon: "noon",
20068 morning: "morning",
20069 afternoon: "afternoon",
20070 evening: "evening",
20071 night: "night"
20072 };
20073 var formatters = {
20074 // Era
20075 G: function(date, token, localize2) {
20076 const era = date.getFullYear() > 0 ? 1 : 0;
20077 switch (token) {
20078 // AD, BC
20079 case "G":
20080 case "GG":
20081 case "GGG":
20082 return localize2.era(era, { width: "abbreviated" });
20083 // A, B
20084 case "GGGGG":
20085 return localize2.era(era, { width: "narrow" });
20086 // Anno Domini, Before Christ
20087 case "GGGG":
20088 default:
20089 return localize2.era(era, { width: "wide" });
20090 }
20091 },
20092 // Year
20093 y: function(date, token, localize2) {
20094 if (token === "yo") {
20095 const signedYear = date.getFullYear();
20096 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20097 return localize2.ordinalNumber(year, { unit: "year" });
20098 }
20099 return lightFormatters.y(date, token);
20100 },
20101 // Local week-numbering year
20102 Y: function(date, token, localize2, options) {
20103 const signedWeekYear = getWeekYear(date, options);
20104 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20105 if (token === "YY") {
20106 const twoDigitYear = weekYear % 100;
20107 return addLeadingZeros(twoDigitYear, 2);
20108 }
20109 if (token === "Yo") {
20110 return localize2.ordinalNumber(weekYear, { unit: "year" });
20111 }
20112 return addLeadingZeros(weekYear, token.length);
20113 },
20114 // ISO week-numbering year
20115 R: function(date, token) {
20116 const isoWeekYear = getISOWeekYear(date);
20117 return addLeadingZeros(isoWeekYear, token.length);
20118 },
20119 // Extended year. This is a single number designating the year of this calendar system.
20120 // The main difference between `y` and `u` localizers are B.C. years:
20121 // | Year | `y` | `u` |
20122 // |------|-----|-----|
20123 // | AC 1 | 1 | 1 |
20124 // | BC 1 | 1 | 0 |
20125 // | BC 2 | 2 | -1 |
20126 // Also `yy` always returns the last two digits of a year,
20127 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20128 u: function(date, token) {
20129 const year = date.getFullYear();
20130 return addLeadingZeros(year, token.length);
20131 },
20132 // Quarter
20133 Q: function(date, token, localize2) {
20134 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20135 switch (token) {
20136 // 1, 2, 3, 4
20137 case "Q":
20138 return String(quarter);
20139 // 01, 02, 03, 04
20140 case "QQ":
20141 return addLeadingZeros(quarter, 2);
20142 // 1st, 2nd, 3rd, 4th
20143 case "Qo":
20144 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20145 // Q1, Q2, Q3, Q4
20146 case "QQQ":
20147 return localize2.quarter(quarter, {
20148 width: "abbreviated",
20149 context: "formatting"
20150 });
20151 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20152 case "QQQQQ":
20153 return localize2.quarter(quarter, {
20154 width: "narrow",
20155 context: "formatting"
20156 });
20157 // 1st quarter, 2nd quarter, ...
20158 case "QQQQ":
20159 default:
20160 return localize2.quarter(quarter, {
20161 width: "wide",
20162 context: "formatting"
20163 });
20164 }
20165 },
20166 // Stand-alone quarter
20167 q: function(date, token, localize2) {
20168 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20169 switch (token) {
20170 // 1, 2, 3, 4
20171 case "q":
20172 return String(quarter);
20173 // 01, 02, 03, 04
20174 case "qq":
20175 return addLeadingZeros(quarter, 2);
20176 // 1st, 2nd, 3rd, 4th
20177 case "qo":
20178 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20179 // Q1, Q2, Q3, Q4
20180 case "qqq":
20181 return localize2.quarter(quarter, {
20182 width: "abbreviated",
20183 context: "standalone"
20184 });
20185 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20186 case "qqqqq":
20187 return localize2.quarter(quarter, {
20188 width: "narrow",
20189 context: "standalone"
20190 });
20191 // 1st quarter, 2nd quarter, ...
20192 case "qqqq":
20193 default:
20194 return localize2.quarter(quarter, {
20195 width: "wide",
20196 context: "standalone"
20197 });
20198 }
20199 },
20200 // Month
20201 M: function(date, token, localize2) {
20202 const month = date.getMonth();
20203 switch (token) {
20204 case "M":
20205 case "MM":
20206 return lightFormatters.M(date, token);
20207 // 1st, 2nd, ..., 12th
20208 case "Mo":
20209 return localize2.ordinalNumber(month + 1, { unit: "month" });
20210 // Jan, Feb, ..., Dec
20211 case "MMM":
20212 return localize2.month(month, {
20213 width: "abbreviated",
20214 context: "formatting"
20215 });
20216 // J, F, ..., D
20217 case "MMMMM":
20218 return localize2.month(month, {
20219 width: "narrow",
20220 context: "formatting"
20221 });
20222 // January, February, ..., December
20223 case "MMMM":
20224 default:
20225 return localize2.month(month, { width: "wide", context: "formatting" });
20226 }
20227 },
20228 // Stand-alone month
20229 L: function(date, token, localize2) {
20230 const month = date.getMonth();
20231 switch (token) {
20232 // 1, 2, ..., 12
20233 case "L":
20234 return String(month + 1);
20235 // 01, 02, ..., 12
20236 case "LL":
20237 return addLeadingZeros(month + 1, 2);
20238 // 1st, 2nd, ..., 12th
20239 case "Lo":
20240 return localize2.ordinalNumber(month + 1, { unit: "month" });
20241 // Jan, Feb, ..., Dec
20242 case "LLL":
20243 return localize2.month(month, {
20244 width: "abbreviated",
20245 context: "standalone"
20246 });
20247 // J, F, ..., D
20248 case "LLLLL":
20249 return localize2.month(month, {
20250 width: "narrow",
20251 context: "standalone"
20252 });
20253 // January, February, ..., December
20254 case "LLLL":
20255 default:
20256 return localize2.month(month, { width: "wide", context: "standalone" });
20257 }
20258 },
20259 // Local week of year
20260 w: function(date, token, localize2, options) {
20261 const week = getWeek(date, options);
20262 if (token === "wo") {
20263 return localize2.ordinalNumber(week, { unit: "week" });
20264 }
20265 return addLeadingZeros(week, token.length);
20266 },
20267 // ISO week of year
20268 I: function(date, token, localize2) {
20269 const isoWeek = getISOWeek(date);
20270 if (token === "Io") {
20271 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20272 }
20273 return addLeadingZeros(isoWeek, token.length);
20274 },
20275 // Day of the month
20276 d: function(date, token, localize2) {
20277 if (token === "do") {
20278 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20279 }
20280 return lightFormatters.d(date, token);
20281 },
20282 // Day of year
20283 D: function(date, token, localize2) {
20284 const dayOfYear = getDayOfYear(date);
20285 if (token === "Do") {
20286 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20287 }
20288 return addLeadingZeros(dayOfYear, token.length);
20289 },
20290 // Day of week
20291 E: function(date, token, localize2) {
20292 const dayOfWeek = date.getDay();
20293 switch (token) {
20294 // Tue
20295 case "E":
20296 case "EE":
20297 case "EEE":
20298 return localize2.day(dayOfWeek, {
20299 width: "abbreviated",
20300 context: "formatting"
20301 });
20302 // T
20303 case "EEEEE":
20304 return localize2.day(dayOfWeek, {
20305 width: "narrow",
20306 context: "formatting"
20307 });
20308 // Tu
20309 case "EEEEEE":
20310 return localize2.day(dayOfWeek, {
20311 width: "short",
20312 context: "formatting"
20313 });
20314 // Tuesday
20315 case "EEEE":
20316 default:
20317 return localize2.day(dayOfWeek, {
20318 width: "wide",
20319 context: "formatting"
20320 });
20321 }
20322 },
20323 // Local day of week
20324 e: function(date, token, localize2, options) {
20325 const dayOfWeek = date.getDay();
20326 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20327 switch (token) {
20328 // Numerical value (Nth day of week with current locale or weekStartsOn)
20329 case "e":
20330 return String(localDayOfWeek);
20331 // Padded numerical value
20332 case "ee":
20333 return addLeadingZeros(localDayOfWeek, 2);
20334 // 1st, 2nd, ..., 7th
20335 case "eo":
20336 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20337 case "eee":
20338 return localize2.day(dayOfWeek, {
20339 width: "abbreviated",
20340 context: "formatting"
20341 });
20342 // T
20343 case "eeeee":
20344 return localize2.day(dayOfWeek, {
20345 width: "narrow",
20346 context: "formatting"
20347 });
20348 // Tu
20349 case "eeeeee":
20350 return localize2.day(dayOfWeek, {
20351 width: "short",
20352 context: "formatting"
20353 });
20354 // Tuesday
20355 case "eeee":
20356 default:
20357 return localize2.day(dayOfWeek, {
20358 width: "wide",
20359 context: "formatting"
20360 });
20361 }
20362 },
20363 // Stand-alone local day of week
20364 c: function(date, token, localize2, options) {
20365 const dayOfWeek = date.getDay();
20366 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20367 switch (token) {
20368 // Numerical value (same as in `e`)
20369 case "c":
20370 return String(localDayOfWeek);
20371 // Padded numerical value
20372 case "cc":
20373 return addLeadingZeros(localDayOfWeek, token.length);
20374 // 1st, 2nd, ..., 7th
20375 case "co":
20376 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20377 case "ccc":
20378 return localize2.day(dayOfWeek, {
20379 width: "abbreviated",
20380 context: "standalone"
20381 });
20382 // T
20383 case "ccccc":
20384 return localize2.day(dayOfWeek, {
20385 width: "narrow",
20386 context: "standalone"
20387 });
20388 // Tu
20389 case "cccccc":
20390 return localize2.day(dayOfWeek, {
20391 width: "short",
20392 context: "standalone"
20393 });
20394 // Tuesday
20395 case "cccc":
20396 default:
20397 return localize2.day(dayOfWeek, {
20398 width: "wide",
20399 context: "standalone"
20400 });
20401 }
20402 },
20403 // ISO day of week
20404 i: function(date, token, localize2) {
20405 const dayOfWeek = date.getDay();
20406 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20407 switch (token) {
20408 // 2
20409 case "i":
20410 return String(isoDayOfWeek);
20411 // 02
20412 case "ii":
20413 return addLeadingZeros(isoDayOfWeek, token.length);
20414 // 2nd
20415 case "io":
20416 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20417 // Tue
20418 case "iii":
20419 return localize2.day(dayOfWeek, {
20420 width: "abbreviated",
20421 context: "formatting"
20422 });
20423 // T
20424 case "iiiii":
20425 return localize2.day(dayOfWeek, {
20426 width: "narrow",
20427 context: "formatting"
20428 });
20429 // Tu
20430 case "iiiiii":
20431 return localize2.day(dayOfWeek, {
20432 width: "short",
20433 context: "formatting"
20434 });
20435 // Tuesday
20436 case "iiii":
20437 default:
20438 return localize2.day(dayOfWeek, {
20439 width: "wide",
20440 context: "formatting"
20441 });
20442 }
20443 },
20444 // AM or PM
20445 a: function(date, token, localize2) {
20446 const hours = date.getHours();
20447 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20448 switch (token) {
20449 case "a":
20450 case "aa":
20451 return localize2.dayPeriod(dayPeriodEnumValue, {
20452 width: "abbreviated",
20453 context: "formatting"
20454 });
20455 case "aaa":
20456 return localize2.dayPeriod(dayPeriodEnumValue, {
20457 width: "abbreviated",
20458 context: "formatting"
20459 }).toLowerCase();
20460 case "aaaaa":
20461 return localize2.dayPeriod(dayPeriodEnumValue, {
20462 width: "narrow",
20463 context: "formatting"
20464 });
20465 case "aaaa":
20466 default:
20467 return localize2.dayPeriod(dayPeriodEnumValue, {
20468 width: "wide",
20469 context: "formatting"
20470 });
20471 }
20472 },
20473 // AM, PM, midnight, noon
20474 b: function(date, token, localize2) {
20475 const hours = date.getHours();
20476 let dayPeriodEnumValue;
20477 if (hours === 12) {
20478 dayPeriodEnumValue = dayPeriodEnum.noon;
20479 } else if (hours === 0) {
20480 dayPeriodEnumValue = dayPeriodEnum.midnight;
20481 } else {
20482 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20483 }
20484 switch (token) {
20485 case "b":
20486 case "bb":
20487 return localize2.dayPeriod(dayPeriodEnumValue, {
20488 width: "abbreviated",
20489 context: "formatting"
20490 });
20491 case "bbb":
20492 return localize2.dayPeriod(dayPeriodEnumValue, {
20493 width: "abbreviated",
20494 context: "formatting"
20495 }).toLowerCase();
20496 case "bbbbb":
20497 return localize2.dayPeriod(dayPeriodEnumValue, {
20498 width: "narrow",
20499 context: "formatting"
20500 });
20501 case "bbbb":
20502 default:
20503 return localize2.dayPeriod(dayPeriodEnumValue, {
20504 width: "wide",
20505 context: "formatting"
20506 });
20507 }
20508 },
20509 // in the morning, in the afternoon, in the evening, at night
20510 B: function(date, token, localize2) {
20511 const hours = date.getHours();
20512 let dayPeriodEnumValue;
20513 if (hours >= 17) {
20514 dayPeriodEnumValue = dayPeriodEnum.evening;
20515 } else if (hours >= 12) {
20516 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20517 } else if (hours >= 4) {
20518 dayPeriodEnumValue = dayPeriodEnum.morning;
20519 } else {
20520 dayPeriodEnumValue = dayPeriodEnum.night;
20521 }
20522 switch (token) {
20523 case "B":
20524 case "BB":
20525 case "BBB":
20526 return localize2.dayPeriod(dayPeriodEnumValue, {
20527 width: "abbreviated",
20528 context: "formatting"
20529 });
20530 case "BBBBB":
20531 return localize2.dayPeriod(dayPeriodEnumValue, {
20532 width: "narrow",
20533 context: "formatting"
20534 });
20535 case "BBBB":
20536 default:
20537 return localize2.dayPeriod(dayPeriodEnumValue, {
20538 width: "wide",
20539 context: "formatting"
20540 });
20541 }
20542 },
20543 // Hour [1-12]
20544 h: function(date, token, localize2) {
20545 if (token === "ho") {
20546 let hours = date.getHours() % 12;
20547 if (hours === 0) hours = 12;
20548 return localize2.ordinalNumber(hours, { unit: "hour" });
20549 }
20550 return lightFormatters.h(date, token);
20551 },
20552 // Hour [0-23]
20553 H: function(date, token, localize2) {
20554 if (token === "Ho") {
20555 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20556 }
20557 return lightFormatters.H(date, token);
20558 },
20559 // Hour [0-11]
20560 K: function(date, token, localize2) {
20561 const hours = date.getHours() % 12;
20562 if (token === "Ko") {
20563 return localize2.ordinalNumber(hours, { unit: "hour" });
20564 }
20565 return addLeadingZeros(hours, token.length);
20566 },
20567 // Hour [1-24]
20568 k: function(date, token, localize2) {
20569 let hours = date.getHours();
20570 if (hours === 0) hours = 24;
20571 if (token === "ko") {
20572 return localize2.ordinalNumber(hours, { unit: "hour" });
20573 }
20574 return addLeadingZeros(hours, token.length);
20575 },
20576 // Minute
20577 m: function(date, token, localize2) {
20578 if (token === "mo") {
20579 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20580 }
20581 return lightFormatters.m(date, token);
20582 },
20583 // Second
20584 s: function(date, token, localize2) {
20585 if (token === "so") {
20586 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20587 }
20588 return lightFormatters.s(date, token);
20589 },
20590 // Fraction of second
20591 S: function(date, token) {
20592 return lightFormatters.S(date, token);
20593 },
20594 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20595 X: function(date, token, _localize) {
20596 const timezoneOffset = date.getTimezoneOffset();
20597 if (timezoneOffset === 0) {
20598 return "Z";
20599 }
20600 switch (token) {
20601 // Hours and optional minutes
20602 case "X":
20603 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20604 // Hours, minutes and optional seconds without `:` delimiter
20605 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20606 // so this token always has the same output as `XX`
20607 case "XXXX":
20608 case "XX":
20609 return formatTimezone(timezoneOffset);
20610 // Hours, minutes and optional seconds with `:` delimiter
20611 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20612 // so this token always has the same output as `XXX`
20613 case "XXXXX":
20614 case "XXX":
20615 // Hours and minutes with `:` delimiter
20616 default:
20617 return formatTimezone(timezoneOffset, ":");
20618 }
20619 },
20620 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20621 x: function(date, token, _localize) {
20622 const timezoneOffset = date.getTimezoneOffset();
20623 switch (token) {
20624 // Hours and optional minutes
20625 case "x":
20626 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20627 // Hours, minutes and optional seconds without `:` delimiter
20628 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20629 // so this token always has the same output as `xx`
20630 case "xxxx":
20631 case "xx":
20632 return formatTimezone(timezoneOffset);
20633 // Hours, minutes and optional seconds with `:` delimiter
20634 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20635 // so this token always has the same output as `xxx`
20636 case "xxxxx":
20637 case "xxx":
20638 // Hours and minutes with `:` delimiter
20639 default:
20640 return formatTimezone(timezoneOffset, ":");
20641 }
20642 },
20643 // Timezone (GMT)
20644 O: function(date, token, _localize) {
20645 const timezoneOffset = date.getTimezoneOffset();
20646 switch (token) {
20647 // Short
20648 case "O":
20649 case "OO":
20650 case "OOO":
20651 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20652 // Long
20653 case "OOOO":
20654 default:
20655 return "GMT" + formatTimezone(timezoneOffset, ":");
20656 }
20657 },
20658 // Timezone (specific non-location)
20659 z: function(date, token, _localize) {
20660 const timezoneOffset = date.getTimezoneOffset();
20661 switch (token) {
20662 // Short
20663 case "z":
20664 case "zz":
20665 case "zzz":
20666 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20667 // Long
20668 case "zzzz":
20669 default:
20670 return "GMT" + formatTimezone(timezoneOffset, ":");
20671 }
20672 },
20673 // Seconds timestamp
20674 t: function(date, token, _localize) {
20675 const timestamp = Math.trunc(+date / 1e3);
20676 return addLeadingZeros(timestamp, token.length);
20677 },
20678 // Milliseconds timestamp
20679 T: function(date, token, _localize) {
20680 return addLeadingZeros(+date, token.length);
20681 }
20682 };
20683 function formatTimezoneShort(offset4, delimiter = "") {
20684 const sign = offset4 > 0 ? "-" : "+";
20685 const absOffset = Math.abs(offset4);
20686 const hours = Math.trunc(absOffset / 60);
20687 const minutes = absOffset % 60;
20688 if (minutes === 0) {
20689 return sign + String(hours);
20690 }
20691 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20692 }
20693 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20694 if (offset4 % 60 === 0) {
20695 const sign = offset4 > 0 ? "-" : "+";
20696 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20697 }
20698 return formatTimezone(offset4, delimiter);
20699 }
20700 function formatTimezone(offset4, delimiter = "") {
20701 const sign = offset4 > 0 ? "-" : "+";
20702 const absOffset = Math.abs(offset4);
20703 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20704 const minutes = addLeadingZeros(absOffset % 60, 2);
20705 return sign + hours + delimiter + minutes;
20706 }
20707
20708 // node_modules/date-fns/_lib/format/longFormatters.js
20709 var dateLongFormatter = (pattern, formatLong2) => {
20710 switch (pattern) {
20711 case "P":
20712 return formatLong2.date({ width: "short" });
20713 case "PP":
20714 return formatLong2.date({ width: "medium" });
20715 case "PPP":
20716 return formatLong2.date({ width: "long" });
20717 case "PPPP":
20718 default:
20719 return formatLong2.date({ width: "full" });
20720 }
20721 };
20722 var timeLongFormatter = (pattern, formatLong2) => {
20723 switch (pattern) {
20724 case "p":
20725 return formatLong2.time({ width: "short" });
20726 case "pp":
20727 return formatLong2.time({ width: "medium" });
20728 case "ppp":
20729 return formatLong2.time({ width: "long" });
20730 case "pppp":
20731 default:
20732 return formatLong2.time({ width: "full" });
20733 }
20734 };
20735 var dateTimeLongFormatter = (pattern, formatLong2) => {
20736 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20737 const datePattern = matchResult[1];
20738 const timePattern = matchResult[2];
20739 if (!timePattern) {
20740 return dateLongFormatter(pattern, formatLong2);
20741 }
20742 let dateTimeFormat;
20743 switch (datePattern) {
20744 case "P":
20745 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20746 break;
20747 case "PP":
20748 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20749 break;
20750 case "PPP":
20751 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20752 break;
20753 case "PPPP":
20754 default:
20755 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20756 break;
20757 }
20758 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20759 };
20760 var longFormatters = {
20761 p: timeLongFormatter,
20762 P: dateTimeLongFormatter
20763 };
20764
20765 // node_modules/date-fns/_lib/protectedTokens.js
20766 var dayOfYearTokenRE = /^D+$/;
20767 var weekYearTokenRE = /^Y+$/;
20768 var throwTokens = ["D", "DD", "YY", "YYYY"];
20769 function isProtectedDayOfYearToken(token) {
20770 return dayOfYearTokenRE.test(token);
20771 }
20772 function isProtectedWeekYearToken(token) {
20773 return weekYearTokenRE.test(token);
20774 }
20775 function warnOrThrowProtectedError(token, format6, input) {
20776 const _message = message(token, format6, input);
20777 console.warn(_message);
20778 if (throwTokens.includes(token)) throw new RangeError(_message);
20779 }
20780 function message(token, format6, input) {
20781 const subject = token[0] === "Y" ? "years" : "days of the month";
20782 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`;
20783 }
20784
20785 // node_modules/date-fns/format.js
20786 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20787 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20788 var escapedStringRegExp = /^'([^]*?)'?$/;
20789 var doubleQuoteRegExp = /''/g;
20790 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20791 function format(date, formatStr, options) {
20792 const defaultOptions2 = getDefaultOptions();
20793 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20794 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20795 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20796 const originalDate = toDate(date, options?.in);
20797 if (!isValid(originalDate)) {
20798 throw new RangeError("Invalid time value");
20799 }
20800 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20801 const firstCharacter = substring[0];
20802 if (firstCharacter === "p" || firstCharacter === "P") {
20803 const longFormatter = longFormatters[firstCharacter];
20804 return longFormatter(substring, locale.formatLong);
20805 }
20806 return substring;
20807 }).join("").match(formattingTokensRegExp).map((substring) => {
20808 if (substring === "''") {
20809 return { isToken: false, value: "'" };
20810 }
20811 const firstCharacter = substring[0];
20812 if (firstCharacter === "'") {
20813 return { isToken: false, value: cleanEscapedString(substring) };
20814 }
20815 if (formatters[firstCharacter]) {
20816 return { isToken: true, value: substring };
20817 }
20818 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20819 throw new RangeError(
20820 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20821 );
20822 }
20823 return { isToken: false, value: substring };
20824 });
20825 if (locale.localize.preprocessor) {
20826 parts = locale.localize.preprocessor(originalDate, parts);
20827 }
20828 const formatterOptions = {
20829 firstWeekContainsDate,
20830 weekStartsOn,
20831 locale
20832 };
20833 return parts.map((part) => {
20834 if (!part.isToken) return part.value;
20835 const token = part.value;
20836 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20837 warnOrThrowProtectedError(token, formatStr, String(date));
20838 }
20839 const formatter = formatters[token[0]];
20840 return formatter(originalDate, token, locale.localize, formatterOptions);
20841 }).join("");
20842 }
20843 function cleanEscapedString(input) {
20844 const matched = input.match(escapedStringRegExp);
20845 if (!matched) {
20846 return input;
20847 }
20848 return matched[1].replace(doubleQuoteRegExp, "'");
20849 }
20850
20851 // node_modules/date-fns/subDays.js
20852 function subDays(date, amount, options) {
20853 return addDays(date, -amount, options);
20854 }
20855
20856 // node_modules/date-fns/subMonths.js
20857 function subMonths(date, amount, options) {
20858 return addMonths(date, -amount, options);
20859 }
20860
20861 // node_modules/date-fns/subWeeks.js
20862 function subWeeks(date, amount, options) {
20863 return addWeeks(date, -amount, options);
20864 }
20865
20866 // node_modules/date-fns/subYears.js
20867 function subYears(date, amount, options) {
20868 return addYears(date, -amount, options);
20869 }
20870
20871 // packages/dataviews/build-module/utils/operators.mjs
20872 var import_i18n24 = __toESM(require_i18n(), 1);
20873 var import_element49 = __toESM(require_element(), 1);
20874 var import_date = __toESM(require_date(), 1);
20875 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
20876 var filterTextWrappers = {
20877 Name: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20878 Value: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20879 };
20880 function getRelativeDate(value, unit) {
20881 switch (unit) {
20882 case "days":
20883 return subDays(/* @__PURE__ */ new Date(), value);
20884 case "weeks":
20885 return subWeeks(/* @__PURE__ */ new Date(), value);
20886 case "months":
20887 return subMonths(/* @__PURE__ */ new Date(), value);
20888 case "years":
20889 return subYears(/* @__PURE__ */ new Date(), value);
20890 default:
20891 return /* @__PURE__ */ new Date();
20892 }
20893 }
20894 var isNoneOperatorDefinition = {
20895 /* translators: DataViews operator name */
20896 label: (0, import_i18n24.__)("Is none of"),
20897 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20898 (0, import_i18n24.sprintf)(
20899 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20900 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20901 filter.name,
20902 activeElements.map((element) => element.label).join(", ")
20903 ),
20904 filterTextWrappers
20905 ),
20906 filter: ((item, field, filterValue) => {
20907 if (!filterValue?.length) {
20908 return true;
20909 }
20910 const fieldValue = field.getValue({ item });
20911 if (Array.isArray(fieldValue)) {
20912 return !filterValue.some(
20913 (fv) => fieldValue.includes(fv)
20914 );
20915 } else if (typeof fieldValue === "string") {
20916 return !filterValue.includes(fieldValue);
20917 }
20918 return false;
20919 }),
20920 selection: "multi"
20921 };
20922 var OPERATORS = [
20923 {
20924 name: OPERATOR_IS_ANY,
20925 /* translators: DataViews operator name */
20926 label: (0, import_i18n24.__)("Includes"),
20927 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20928 (0, import_i18n24.sprintf)(
20929 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20930 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20931 filter.name,
20932 activeElements.map((element) => element.label).join(", ")
20933 ),
20934 filterTextWrappers
20935 ),
20936 filter(item, field, filterValue) {
20937 if (!filterValue?.length) {
20938 return true;
20939 }
20940 const fieldValue = field.getValue({ item });
20941 if (Array.isArray(fieldValue)) {
20942 return filterValue.some(
20943 (fv) => fieldValue.includes(fv)
20944 );
20945 } else if (typeof fieldValue === "string") {
20946 return filterValue.includes(fieldValue);
20947 }
20948 return false;
20949 },
20950 selection: "multi"
20951 },
20952 {
20953 name: OPERATOR_IS_NONE,
20954 ...isNoneOperatorDefinition
20955 },
20956 {
20957 name: OPERATOR_IS_ALL,
20958 /* translators: DataViews operator name */
20959 label: (0, import_i18n24.__)("Includes all"),
20960 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20961 (0, import_i18n24.sprintf)(
20962 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20963 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20964 filter.name,
20965 activeElements.map((element) => element.label).join(", ")
20966 ),
20967 filterTextWrappers
20968 ),
20969 filter(item, field, filterValue) {
20970 if (!filterValue?.length) {
20971 return true;
20972 }
20973 return filterValue.every((value) => {
20974 return field.getValue({ item })?.includes(value);
20975 });
20976 },
20977 selection: "multi"
20978 },
20979 {
20980 name: OPERATOR_IS_NOT_ALL,
20981 ...isNoneOperatorDefinition
20982 },
20983 {
20984 name: OPERATOR_BETWEEN,
20985 /* translators: DataViews operator name */
20986 label: (0, import_i18n24.__)("Between (inc)"),
20987 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
20988 (0, import_i18n24.sprintf)(
20989 /* 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". */
20990 (0, import_i18n24.__)(
20991 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20992 ),
20993 filter.name,
20994 activeElements[0].label[0],
20995 activeElements[0].label[1]
20996 ),
20997 filterTextWrappers
20998 ),
20999 filter(item, field, filterValue) {
21000 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21001 return true;
21002 }
21003 const fieldValue = field.getValue({ item });
21004 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21005 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21006 }
21007 return false;
21008 },
21009 selection: "custom"
21010 },
21011 {
21012 name: OPERATOR_IN_THE_PAST,
21013 /* translators: DataViews operator name */
21014 label: (0, import_i18n24.__)("In the past"),
21015 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21016 (0, import_i18n24.sprintf)(
21017 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21018 (0, import_i18n24.__)(
21019 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21020 ),
21021 filter.name,
21022 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21023 ),
21024 filterTextWrappers
21025 ),
21026 filter(item, field, filterValue) {
21027 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21028 return true;
21029 }
21030 const targetDate = getRelativeDate(
21031 filterValue.value,
21032 filterValue.unit
21033 );
21034 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21035 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21036 },
21037 selection: "custom"
21038 },
21039 {
21040 name: OPERATOR_OVER,
21041 /* translators: DataViews operator name */
21042 label: (0, import_i18n24.__)("Over"),
21043 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21044 (0, import_i18n24.sprintf)(
21045 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21046 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21047 filter.name,
21048 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21049 ),
21050 filterTextWrappers
21051 ),
21052 filter(item, field, filterValue) {
21053 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21054 return true;
21055 }
21056 const targetDate = getRelativeDate(
21057 filterValue.value,
21058 filterValue.unit
21059 );
21060 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21061 return fieldValue < targetDate;
21062 },
21063 selection: "custom"
21064 },
21065 {
21066 name: OPERATOR_IS,
21067 /* translators: DataViews operator name */
21068 label: (0, import_i18n24.__)("Is"),
21069 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21070 (0, import_i18n24.sprintf)(
21071 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21072 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21073 filter.name,
21074 activeElements[0].label
21075 ),
21076 filterTextWrappers
21077 ),
21078 filter(item, field, filterValue) {
21079 return filterValue === field.getValue({ item }) || filterValue === void 0;
21080 },
21081 selection: "single"
21082 },
21083 {
21084 name: OPERATOR_IS_NOT,
21085 /* translators: DataViews operator name */
21086 label: (0, import_i18n24.__)("Is not"),
21087 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21088 (0, import_i18n24.sprintf)(
21089 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21090 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21091 filter.name,
21092 activeElements[0].label
21093 ),
21094 filterTextWrappers
21095 ),
21096 filter(item, field, filterValue) {
21097 return filterValue !== field.getValue({ item });
21098 },
21099 selection: "single"
21100 },
21101 {
21102 name: OPERATOR_LESS_THAN,
21103 /* translators: DataViews operator name */
21104 label: (0, import_i18n24.__)("Less than"),
21105 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21106 (0, import_i18n24.sprintf)(
21107 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21108 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21109 filter.name,
21110 activeElements[0].label
21111 ),
21112 filterTextWrappers
21113 ),
21114 filter(item, field, filterValue) {
21115 if (filterValue === void 0) {
21116 return true;
21117 }
21118 const fieldValue = field.getValue({ item });
21119 return fieldValue < filterValue;
21120 },
21121 selection: "single"
21122 },
21123 {
21124 name: OPERATOR_GREATER_THAN,
21125 /* translators: DataViews operator name */
21126 label: (0, import_i18n24.__)("Greater than"),
21127 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21128 (0, import_i18n24.sprintf)(
21129 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21130 (0, import_i18n24.__)(
21131 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21132 ),
21133 filter.name,
21134 activeElements[0].label
21135 ),
21136 filterTextWrappers
21137 ),
21138 filter(item, field, filterValue) {
21139 if (filterValue === void 0) {
21140 return true;
21141 }
21142 const fieldValue = field.getValue({ item });
21143 return fieldValue > filterValue;
21144 },
21145 selection: "single"
21146 },
21147 {
21148 name: OPERATOR_LESS_THAN_OR_EQUAL,
21149 /* translators: DataViews operator name */
21150 label: (0, import_i18n24.__)("Less than or equal"),
21151 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21152 (0, import_i18n24.sprintf)(
21153 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21154 (0, import_i18n24.__)(
21155 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21156 ),
21157 filter.name,
21158 activeElements[0].label
21159 ),
21160 filterTextWrappers
21161 ),
21162 filter(item, field, filterValue) {
21163 if (filterValue === void 0) {
21164 return true;
21165 }
21166 const fieldValue = field.getValue({ item });
21167 return fieldValue <= filterValue;
21168 },
21169 selection: "single"
21170 },
21171 {
21172 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21173 /* translators: DataViews operator name */
21174 label: (0, import_i18n24.__)("Greater than or equal"),
21175 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21176 (0, import_i18n24.sprintf)(
21177 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21178 (0, import_i18n24.__)(
21179 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21180 ),
21181 filter.name,
21182 activeElements[0].label
21183 ),
21184 filterTextWrappers
21185 ),
21186 filter(item, field, filterValue) {
21187 if (filterValue === void 0) {
21188 return true;
21189 }
21190 const fieldValue = field.getValue({ item });
21191 return fieldValue >= filterValue;
21192 },
21193 selection: "single"
21194 },
21195 {
21196 name: OPERATOR_BEFORE,
21197 /* translators: DataViews operator name */
21198 label: (0, import_i18n24.__)("Before"),
21199 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21200 (0, import_i18n24.sprintf)(
21201 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21202 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21203 filter.name,
21204 activeElements[0].label
21205 ),
21206 filterTextWrappers
21207 ),
21208 filter(item, field, filterValue) {
21209 if (filterValue === void 0) {
21210 return true;
21211 }
21212 const filterDate = (0, import_date.getDate)(filterValue);
21213 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21214 return fieldDate < filterDate;
21215 },
21216 selection: "single"
21217 },
21218 {
21219 name: OPERATOR_AFTER,
21220 /* translators: DataViews operator name */
21221 label: (0, import_i18n24.__)("After"),
21222 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21223 (0, import_i18n24.sprintf)(
21224 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21225 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21226 filter.name,
21227 activeElements[0].label
21228 ),
21229 filterTextWrappers
21230 ),
21231 filter(item, field, filterValue) {
21232 if (filterValue === void 0) {
21233 return true;
21234 }
21235 const filterDate = (0, import_date.getDate)(filterValue);
21236 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21237 return fieldDate > filterDate;
21238 },
21239 selection: "single"
21240 },
21241 {
21242 name: OPERATOR_BEFORE_INC,
21243 /* translators: DataViews operator name */
21244 label: (0, import_i18n24.__)("Before (inc)"),
21245 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21246 (0, import_i18n24.sprintf)(
21247 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21248 (0, import_i18n24.__)(
21249 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21250 ),
21251 filter.name,
21252 activeElements[0].label
21253 ),
21254 filterTextWrappers
21255 ),
21256 filter(item, field, filterValue) {
21257 if (filterValue === void 0) {
21258 return true;
21259 }
21260 const filterDate = (0, import_date.getDate)(filterValue);
21261 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21262 return fieldDate <= filterDate;
21263 },
21264 selection: "single"
21265 },
21266 {
21267 name: OPERATOR_AFTER_INC,
21268 /* translators: DataViews operator name */
21269 label: (0, import_i18n24.__)("After (inc)"),
21270 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21271 (0, import_i18n24.sprintf)(
21272 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21273 (0, import_i18n24.__)(
21274 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21275 ),
21276 filter.name,
21277 activeElements[0].label
21278 ),
21279 filterTextWrappers
21280 ),
21281 filter(item, field, filterValue) {
21282 if (filterValue === void 0) {
21283 return true;
21284 }
21285 const filterDate = (0, import_date.getDate)(filterValue);
21286 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21287 return fieldDate >= filterDate;
21288 },
21289 selection: "single"
21290 },
21291 {
21292 name: OPERATOR_CONTAINS,
21293 /* translators: DataViews operator name */
21294 label: (0, import_i18n24.__)("Contains"),
21295 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21296 (0, import_i18n24.sprintf)(
21297 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21298 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21299 filter.name,
21300 activeElements[0].label
21301 ),
21302 filterTextWrappers
21303 ),
21304 filter(item, field, filterValue) {
21305 if (filterValue === void 0) {
21306 return true;
21307 }
21308 const fieldValue = field.getValue({ item });
21309 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21310 },
21311 selection: "single"
21312 },
21313 {
21314 name: OPERATOR_NOT_CONTAINS,
21315 /* translators: DataViews operator name */
21316 label: (0, import_i18n24.__)("Doesn't contain"),
21317 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21318 (0, import_i18n24.sprintf)(
21319 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21320 (0, import_i18n24.__)(
21321 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21322 ),
21323 filter.name,
21324 activeElements[0].label
21325 ),
21326 filterTextWrappers
21327 ),
21328 filter(item, field, filterValue) {
21329 if (filterValue === void 0) {
21330 return true;
21331 }
21332 const fieldValue = field.getValue({ item });
21333 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21334 },
21335 selection: "single"
21336 },
21337 {
21338 name: OPERATOR_STARTS_WITH,
21339 /* translators: DataViews operator name */
21340 label: (0, import_i18n24.__)("Starts with"),
21341 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21342 (0, import_i18n24.sprintf)(
21343 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21344 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21345 filter.name,
21346 activeElements[0].label
21347 ),
21348 filterTextWrappers
21349 ),
21350 filter(item, field, filterValue) {
21351 if (filterValue === void 0) {
21352 return true;
21353 }
21354 const fieldValue = field.getValue({ item });
21355 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21356 },
21357 selection: "single"
21358 },
21359 {
21360 name: OPERATOR_ON,
21361 /* translators: DataViews operator name */
21362 label: (0, import_i18n24.__)("On"),
21363 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21364 (0, import_i18n24.sprintf)(
21365 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21366 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21367 filter.name,
21368 activeElements[0].label
21369 ),
21370 filterTextWrappers
21371 ),
21372 filter(item, field, filterValue) {
21373 if (filterValue === void 0) {
21374 return true;
21375 }
21376 const filterDate = (0, import_date.getDate)(filterValue);
21377 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21378 return filterDate.getTime() === fieldDate.getTime();
21379 },
21380 selection: "single"
21381 },
21382 {
21383 name: OPERATOR_NOT_ON,
21384 /* translators: DataViews operator name */
21385 label: (0, import_i18n24.__)("Not on"),
21386 filterText: (filter, activeElements) => (0, import_element49.createInterpolateElement)(
21387 (0, import_i18n24.sprintf)(
21388 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21389 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21390 filter.name,
21391 activeElements[0].label
21392 ),
21393 filterTextWrappers
21394 ),
21395 filter(item, field, filterValue) {
21396 if (filterValue === void 0) {
21397 return true;
21398 }
21399 const filterDate = (0, import_date.getDate)(filterValue);
21400 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21401 return filterDate.getTime() !== fieldDate.getTime();
21402 },
21403 selection: "single"
21404 }
21405 ];
21406 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21407 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21408 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21409 (op) => op.name === name
21410 );
21411 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21412
21413 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21414 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21415 var ENTER = "Enter";
21416 var SPACE = " ";
21417 var FilterText = ({
21418 activeElements,
21419 filterInView,
21420 filter
21421 }) => {
21422 if (activeElements === void 0 || activeElements.length === 0) {
21423 return filter.name;
21424 }
21425 const operator = getOperatorByName(filterInView?.operator);
21426 if (operator !== void 0) {
21427 return operator.filterText(filter, activeElements);
21428 }
21429 return (0, import_i18n25.sprintf)(
21430 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21431 (0, import_i18n25.__)("Unknown status for %1$s"),
21432 filter.name
21433 );
21434 };
21435 function OperatorSelector({
21436 filter,
21437 view,
21438 onChangeView
21439 }) {
21440 const operatorOptions = filter.operators?.map((operator) => ({
21441 value: operator,
21442 label: getOperatorByName(operator)?.label || operator
21443 }));
21444 const currentFilter = view.filters?.find(
21445 (_filter) => _filter.field === filter.field
21446 );
21447 const value = currentFilter?.operator || filter.operators[0];
21448 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
21449 Stack,
21450 {
21451 direction: "row",
21452 gap: "sm",
21453 justify: "flex-start",
21454 className: "dataviews-filters__summary-operators-container",
21455 align: "center",
21456 children: [
21457 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21458 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21459 import_components20.SelectControl,
21460 {
21461 className: "dataviews-filters__summary-operators-filter-select",
21462 label: (0, import_i18n25.__)("Conditions"),
21463 value,
21464 options: operatorOptions,
21465 onChange: (newValue) => {
21466 const newOperator = newValue;
21467 const currentOperator = currentFilter?.operator;
21468 const newFilters = currentFilter ? [
21469 ...(view.filters ?? []).map(
21470 (_filter) => {
21471 if (_filter.field === filter.field) {
21472 const currentOpSelectionModel = getOperatorByName(
21473 currentOperator
21474 )?.selection;
21475 const newOpSelectionModel = getOperatorByName(
21476 newOperator
21477 )?.selection;
21478 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21479 currentOpSelectionModel,
21480 newOpSelectionModel
21481 ].includes("custom");
21482 return {
21483 ..._filter,
21484 value: shouldResetValue ? void 0 : _filter.value,
21485 operator: newOperator
21486 };
21487 }
21488 return _filter;
21489 }
21490 )
21491 ] : [
21492 ...view.filters ?? [],
21493 {
21494 field: filter.field,
21495 operator: newOperator,
21496 value: void 0
21497 }
21498 ];
21499 onChangeView({
21500 ...view,
21501 page: 1,
21502 filters: newFilters
21503 });
21504 },
21505 size: "small",
21506 variant: "minimal",
21507 hideLabelFromVision: true
21508 }
21509 )
21510 ]
21511 }
21512 );
21513 }
21514 function Filter({
21515 addFilterRef,
21516 openedFilter,
21517 fields,
21518 ...commonProps
21519 }) {
21520 const toggleRef = (0, import_element50.useRef)(null);
21521 const { filter, view, onChangeView } = commonProps;
21522 const filterInView = view.filters?.find(
21523 (f2) => f2.field === filter.field
21524 );
21525 let activeElements = [];
21526 const field = (0, import_element50.useMemo)(() => {
21527 const currentField = fields.find((f2) => f2.id === filter.field);
21528 if (currentField) {
21529 return {
21530 ...currentField,
21531 // Configure getValue as if Item was a plain object.
21532 // See related input-widget.tsx
21533 getValue: ({ item }) => item[currentField.id]
21534 };
21535 }
21536 return currentField;
21537 }, [fields, filter.field]);
21538 const { elements } = useElements({
21539 elements: filter.elements,
21540 getElements: filter.getElements
21541 });
21542 if (elements.length > 0) {
21543 activeElements = elements.filter((element) => {
21544 if (filter.singleSelection) {
21545 return element.value === filterInView?.value;
21546 }
21547 return filterInView?.value?.includes(element.value);
21548 });
21549 } else if (Array.isArray(filterInView?.value)) {
21550 const label = filterInView.value.map((v2) => {
21551 const formattedValue = field?.getValueFormatted({
21552 item: { [field.id]: v2 },
21553 field
21554 });
21555 return formattedValue || String(v2);
21556 });
21557 activeElements = [
21558 {
21559 value: filterInView.value,
21560 // @ts-ignore
21561 label
21562 }
21563 ];
21564 } else if (typeof filterInView?.value === "object") {
21565 activeElements = [
21566 { value: filterInView.value, label: filterInView.value }
21567 ];
21568 } else if (filterInView?.value !== void 0) {
21569 const label = field !== void 0 ? field.getValueFormatted({
21570 item: { [field.id]: filterInView.value },
21571 field
21572 }) : String(filterInView.value);
21573 activeElements = [
21574 {
21575 value: filterInView.value,
21576 label
21577 }
21578 ];
21579 }
21580 const isPrimary = filter.isPrimary;
21581 const isLocked = filterInView?.isLocked;
21582 const hasValues = !isLocked && filterInView?.value !== void 0;
21583 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21584 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21585 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21586 import_components20.Dropdown,
21587 {
21588 defaultOpen: openedFilter === filter.field,
21589 contentClassName: "dataviews-filters__summary-popover",
21590 popoverProps: { placement: "bottom-start", role: "dialog" },
21591 onClose: () => {
21592 toggleRef.current?.focus();
21593 },
21594 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21595 /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
21596 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21597 tooltip_exports.Trigger,
21598 {
21599 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21600 "div",
21601 {
21602 className: clsx_default(
21603 "dataviews-filters__summary-chip",
21604 {
21605 "has-reset": canResetOrRemove,
21606 "has-values": hasValues,
21607 "is-not-clickable": isLocked
21608 }
21609 ),
21610 role: "button",
21611 tabIndex: isLocked ? -1 : 0,
21612 onClick: () => {
21613 if (!isLocked) {
21614 onToggle();
21615 }
21616 },
21617 onKeyDown: (event) => {
21618 if (!isLocked && [ENTER, SPACE].includes(
21619 event.key
21620 )) {
21621 onToggle();
21622 event.preventDefault();
21623 }
21624 },
21625 "aria-disabled": isLocked,
21626 "aria-pressed": isOpen,
21627 "aria-expanded": isOpen,
21628 ref: toggleRef,
21629 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21630 FilterText,
21631 {
21632 activeElements,
21633 filterInView,
21634 filter
21635 }
21636 )
21637 }
21638 )
21639 }
21640 ),
21641 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21642 /* translators: 1: Filter name. */
21643 (0, import_i18n25.__)("Filter by: %1$s"),
21644 filter.name.toLowerCase()
21645 ) })
21646 ] }),
21647 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
21648 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21649 tooltip_exports.Trigger,
21650 {
21651 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21652 "button",
21653 {
21654 className: clsx_default(
21655 "dataviews-filters__summary-chip-remove",
21656 { "has-values": hasValues }
21657 ),
21658 "aria-label": resetOrRemoveLabel,
21659 onClick: () => {
21660 onChangeView({
21661 ...view,
21662 page: 1,
21663 filters: view.filters?.filter(
21664 (_filter) => _filter.field !== filter.field
21665 )
21666 });
21667 if (!isPrimary) {
21668 addFilterRef.current?.focus();
21669 } else {
21670 toggleRef.current?.focus();
21671 }
21672 },
21673 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components20.Icon, { icon: close_small_default })
21674 }
21675 )
21676 }
21677 ),
21678 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21679 ] })
21680 ] }),
21681 renderContent: () => {
21682 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21683 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(OperatorSelector, { ...commonProps }),
21684 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21685 SearchWidget,
21686 {
21687 ...commonProps,
21688 filter: {
21689 ...commonProps.filter,
21690 elements
21691 }
21692 }
21693 ) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(InputWidget, { ...commonProps, fields })
21694 ] });
21695 }
21696 }
21697 );
21698 }
21699
21700 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21701 var import_components21 = __toESM(require_components(), 1);
21702 var import_i18n26 = __toESM(require_i18n(), 1);
21703 var import_element51 = __toESM(require_element(), 1);
21704 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21705 var { Menu: Menu4 } = unlock2(import_components21.privateApis);
21706 function AddFilterMenu({
21707 filters,
21708 view,
21709 onChangeView,
21710 setOpenedFilter,
21711 triggerProps
21712 }) {
21713 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21714 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu4, { children: [
21715 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21716 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21717 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21718 Menu4.Item,
21719 {
21720 onClick: () => {
21721 setOpenedFilter(filter.field);
21722 onChangeView({
21723 ...view,
21724 page: 1,
21725 filters: [
21726 ...view.filters || [],
21727 {
21728 field: filter.field,
21729 value: void 0,
21730 operator: filter.operators[0]
21731 }
21732 ]
21733 });
21734 },
21735 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.ItemLabel, { children: filter.name })
21736 },
21737 filter.field
21738 );
21739 }) })
21740 ] });
21741 }
21742 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21743 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21744 return null;
21745 }
21746 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21747 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21748 AddFilterMenu,
21749 {
21750 triggerProps: {
21751 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21752 import_components21.Button,
21753 {
21754 accessibleWhenDisabled: true,
21755 size: "compact",
21756 className: "dataviews-filters-button",
21757 variant: "tertiary",
21758 disabled: !inactiveFilters.length,
21759 ref
21760 }
21761 ),
21762 children: (0, import_i18n26.__)("Add filter")
21763 },
21764 ...{ filters, view, onChangeView, setOpenedFilter }
21765 }
21766 );
21767 }
21768 var add_filter_default = (0, import_element51.forwardRef)(AddFilter);
21769
21770 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21771 var import_components22 = __toESM(require_components(), 1);
21772 var import_i18n27 = __toESM(require_i18n(), 1);
21773 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
21774 function ResetFilter({
21775 filters,
21776 view,
21777 onChangeView
21778 }) {
21779 const isPrimary = (field) => filters.some(
21780 (_filter) => _filter.field === field && _filter.isPrimary
21781 );
21782 const isDisabled = !view.search && !view.filters?.some(
21783 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21784 );
21785 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
21786 import_components22.Button,
21787 {
21788 disabled: isDisabled,
21789 accessibleWhenDisabled: true,
21790 size: "compact",
21791 variant: "tertiary",
21792 className: "dataviews-filters__reset-button",
21793 onClick: () => {
21794 onChangeView({
21795 ...view,
21796 page: 1,
21797 search: "",
21798 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21799 });
21800 },
21801 children: (0, import_i18n27.__)("Reset")
21802 }
21803 );
21804 }
21805
21806 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21807 var import_element52 = __toESM(require_element(), 1);
21808 function useFilters(fields, view) {
21809 return (0, import_element52.useMemo)(() => {
21810 const filters = [];
21811 fields.forEach((field) => {
21812 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21813 return;
21814 }
21815 const operators = field.filterBy.operators;
21816 const isPrimary = !!field.filterBy?.isPrimary;
21817 const isLocked = view.filters?.some(
21818 (f2) => f2.field === field.id && !!f2.isLocked
21819 ) ?? false;
21820 filters.push({
21821 field: field.id,
21822 name: field.label,
21823 elements: field.elements,
21824 getElements: field.getElements,
21825 hasElements: field.hasElements,
21826 singleSelection: operators.some(
21827 (op) => isSingleSelectionOperator(op)
21828 ),
21829 operators,
21830 isVisible: isLocked || isPrimary || !!view.filters?.some(
21831 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21832 ),
21833 isPrimary,
21834 isLocked
21835 });
21836 });
21837 filters.sort((a2, b2) => {
21838 if (a2.isLocked && !b2.isLocked) {
21839 return -1;
21840 }
21841 if (!a2.isLocked && b2.isLocked) {
21842 return 1;
21843 }
21844 if (a2.isPrimary && !b2.isPrimary) {
21845 return -1;
21846 }
21847 if (!a2.isPrimary && b2.isPrimary) {
21848 return 1;
21849 }
21850 return a2.name.localeCompare(b2.name);
21851 });
21852 return filters;
21853 }, [fields, view]);
21854 }
21855 var use_filters_default = useFilters;
21856
21857 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21858 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
21859 function Filters({ className }) {
21860 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element53.useContext)(dataviews_context_default);
21861 const addFilterRef = (0, import_element53.useRef)(null);
21862 const filters = use_filters_default(fields, view);
21863 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21864 add_filter_default,
21865 {
21866 filters,
21867 view,
21868 onChangeView,
21869 ref: addFilterRef,
21870 setOpenedFilter
21871 },
21872 "add-filter"
21873 );
21874 const visibleFilters = filters.filter((filter) => filter.isVisible);
21875 if (visibleFilters.length === 0) {
21876 return null;
21877 }
21878 const filterComponents = [
21879 ...visibleFilters.map((filter) => {
21880 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21881 Filter,
21882 {
21883 filter,
21884 view,
21885 fields,
21886 onChangeView,
21887 addFilterRef,
21888 openedFilter
21889 },
21890 filter.field
21891 );
21892 }),
21893 addFilter
21894 ];
21895 filterComponents.push(
21896 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21897 ResetFilter,
21898 {
21899 filters,
21900 view,
21901 onChangeView
21902 },
21903 "reset-filters"
21904 )
21905 );
21906 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
21907 Stack,
21908 {
21909 direction: "row",
21910 justify: "flex-start",
21911 gap: "sm",
21912 style: { width: "fit-content" },
21913 wrap: "wrap",
21914 className,
21915 children: filterComponents
21916 }
21917 );
21918 }
21919 var filters_default = (0, import_element53.memo)(Filters);
21920
21921 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21922 var import_element54 = __toESM(require_element(), 1);
21923 var import_components23 = __toESM(require_components(), 1);
21924 var import_i18n28 = __toESM(require_i18n(), 1);
21925 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
21926 function FiltersToggle() {
21927 const {
21928 filters,
21929 view,
21930 onChangeView,
21931 setOpenedFilter,
21932 isShowingFilter,
21933 setIsShowingFilter
21934 } = (0, import_element54.useContext)(dataviews_context_default);
21935 const buttonRef = (0, import_element54.useRef)(null);
21936 const onChangeViewWithFilterVisibility = (0, import_element54.useCallback)(
21937 (_view) => {
21938 onChangeView(_view);
21939 setIsShowingFilter(true);
21940 },
21941 [onChangeView, setIsShowingFilter]
21942 );
21943 if (filters.length === 0) {
21944 return null;
21945 }
21946 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21947 const addFilterButtonProps = {
21948 label: (0, import_i18n28.__)("Add filter"),
21949 "aria-expanded": false,
21950 isPressed: false
21951 };
21952 const toggleFiltersButtonProps = {
21953 label: (0, import_i18n28._x)("Filter", "verb"),
21954 "aria-expanded": isShowingFilter,
21955 isPressed: isShowingFilter,
21956 onClick: () => {
21957 if (!isShowingFilter) {
21958 setOpenedFilter(null);
21959 }
21960 setIsShowingFilter(!isShowingFilter);
21961 }
21962 };
21963 const hasPrimaryOrLockedFilters = filters.some(
21964 (filter) => filter.isPrimary || filter.isLocked
21965 );
21966 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21967 import_components23.Button,
21968 {
21969 ref: buttonRef,
21970 className: "dataviews-filters__visibility-toggle",
21971 size: "compact",
21972 icon: funnel_default,
21973 disabled: hasPrimaryOrLockedFilters,
21974 accessibleWhenDisabled: true,
21975 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21976 }
21977 );
21978 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21979 AddFilterMenu,
21980 {
21981 filters,
21982 view,
21983 onChangeView: onChangeViewWithFilterVisibility,
21984 setOpenedFilter,
21985 triggerProps: { render: buttonComponent }
21986 }
21987 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
21988 FilterVisibilityToggle,
21989 {
21990 buttonRef,
21991 filtersCount: view.filters?.length,
21992 children: buttonComponent
21993 }
21994 ) });
21995 }
21996 function FilterVisibilityToggle({
21997 buttonRef,
21998 filtersCount,
21999 children
22000 }) {
22001 (0, import_element54.useEffect)(
22002 () => () => {
22003 buttonRef.current?.focus();
22004 },
22005 [buttonRef]
22006 );
22007 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
22008 children,
22009 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22010 ] });
22011 }
22012 var toggle_default = FiltersToggle;
22013
22014 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22015 var import_element55 = __toESM(require_element(), 1);
22016 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22017 function FiltersToggled(props) {
22018 const { isShowingFilter } = (0, import_element55.useContext)(dataviews_context_default);
22019 if (!isShowingFilter) {
22020 return null;
22021 }
22022 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(filters_default, { ...props });
22023 }
22024 var filters_toggled_default = FiltersToggled;
22025
22026 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22027 var import_element56 = __toESM(require_element(), 1);
22028 var import_components24 = __toESM(require_components(), 1);
22029 var import_i18n29 = __toESM(require_i18n(), 1);
22030 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22031 function DataViewsLayout({ className }) {
22032 const {
22033 actions = [],
22034 data,
22035 fields,
22036 getItemId,
22037 getItemLevel,
22038 hasInitiallyLoaded,
22039 isLoading,
22040 view,
22041 onChangeView,
22042 selection,
22043 onChangeSelection,
22044 setOpenedFilter,
22045 onClickItem,
22046 isItemClickable,
22047 renderItemLink,
22048 defaultLayouts,
22049 containerRef,
22050 empty = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: (0, import_i18n29.__)("No results") })
22051 } = (0, import_element56.useContext)(dataviews_context_default);
22052 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22053 delay: 200
22054 });
22055 if (!hasInitiallyLoaded) {
22056 if (!isDelayedInitialLoading) {
22057 return null;
22058 }
22059 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components24.Spinner, {}) }) });
22060 }
22061 const ViewComponent = VIEW_LAYOUTS.find(
22062 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22063 )?.component;
22064 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22065 ViewComponent,
22066 {
22067 className,
22068 actions,
22069 data,
22070 fields,
22071 getItemId,
22072 getItemLevel,
22073 isLoading,
22074 onChangeView,
22075 onChangeSelection,
22076 selection,
22077 setOpenedFilter,
22078 onClickItem,
22079 renderItemLink,
22080 isItemClickable,
22081 view,
22082 empty
22083 }
22084 ) });
22085 }
22086
22087 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22088 var import_element57 = __toESM(require_element(), 1);
22089 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22090 var EMPTY_ARRAY5 = [];
22091 function DataViewsFooter() {
22092 const {
22093 view,
22094 paginationInfo: { totalItems = 0, totalPages },
22095 data,
22096 actions = EMPTY_ARRAY5,
22097 isLoading,
22098 hasInitiallyLoaded
22099 } = (0, import_element57.useContext)(dataviews_context_default);
22100 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22101 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22102 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22103 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22104 return null;
22105 }
22106 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22107 "div",
22108 {
22109 className: "dataviews-footer",
22110 inert: isRefreshing ? "true" : void 0,
22111 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22112 Stack,
22113 {
22114 direction: "row",
22115 justify: "end",
22116 align: "center",
22117 className: clsx_default("dataviews-footer__content", {
22118 "is-refreshing": isDelayedRefreshing
22119 }),
22120 gap: "sm",
22121 children: [
22122 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(BulkActionsFooter, {}),
22123 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(dataviews_pagination_default, {})
22124 ]
22125 }
22126 )
22127 }
22128 );
22129 }
22130
22131 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22132 var import_i18n30 = __toESM(require_i18n(), 1);
22133 var import_element58 = __toESM(require_element(), 1);
22134 var import_components25 = __toESM(require_components(), 1);
22135 var import_compose9 = __toESM(require_compose(), 1);
22136 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22137 var DataViewsSearch = (0, import_element58.memo)(function Search({ label }) {
22138 const { view, onChangeView } = (0, import_element58.useContext)(dataviews_context_default);
22139 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
22140 view.search
22141 );
22142 (0, import_element58.useEffect)(() => {
22143 if (view.search !== debouncedSearch) {
22144 setSearch(view.search ?? "");
22145 }
22146 }, [view.search, setSearch]);
22147 const onChangeViewRef = (0, import_element58.useRef)(onChangeView);
22148 const viewRef = (0, import_element58.useRef)(view);
22149 (0, import_element58.useEffect)(() => {
22150 onChangeViewRef.current = onChangeView;
22151 viewRef.current = view;
22152 }, [onChangeView, view]);
22153 (0, import_element58.useEffect)(() => {
22154 if (debouncedSearch !== viewRef.current?.search) {
22155 onChangeViewRef.current({
22156 ...viewRef.current,
22157 page: view.page ? 1 : void 0,
22158 startPosition: view.startPosition ? 1 : void 0,
22159 search: debouncedSearch
22160 });
22161 }
22162 }, [debouncedSearch]);
22163 const searchLabel = label || (0, import_i18n30.__)("Search");
22164 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22165 import_components25.SearchControl,
22166 {
22167 className: "dataviews-search",
22168 onChange: setSearch,
22169 value: search,
22170 label: searchLabel,
22171 placeholder: searchLabel,
22172 size: "compact"
22173 }
22174 );
22175 });
22176 var dataviews_search_default = DataViewsSearch;
22177
22178 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22179 var import_components26 = __toESM(require_components(), 1);
22180 var import_i18n31 = __toESM(require_i18n(), 1);
22181 var import_element59 = __toESM(require_element(), 1);
22182 var import_warning = __toESM(require_warning(), 1);
22183 var import_compose10 = __toESM(require_compose(), 1);
22184 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22185 var { Menu: Menu5 } = unlock2(import_components26.privateApis);
22186 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22187 className: "dataviews-config__popover",
22188 placement: "bottom-end",
22189 offset: 9
22190 };
22191 function ViewTypeMenu() {
22192 const { view, onChangeView, defaultLayouts } = (0, import_element59.useContext)(dataviews_context_default);
22193 const availableLayouts = Object.keys(defaultLayouts);
22194 if (availableLayouts.length <= 1) {
22195 return null;
22196 }
22197 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22198 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Menu5, { children: [
22199 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22200 Menu5.TriggerButton,
22201 {
22202 render: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22203 import_components26.Button,
22204 {
22205 size: "compact",
22206 icon: activeView?.icon,
22207 label: (0, import_i18n31.__)("Layout")
22208 }
22209 )
22210 }
22211 ),
22212 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22213 const config = VIEW_LAYOUTS.find(
22214 (v2) => v2.type === layout
22215 );
22216 if (!config) {
22217 return null;
22218 }
22219 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22220 Menu5.RadioItem,
22221 {
22222 value: layout,
22223 name: "view-actions-available-view",
22224 checked: layout === view.type,
22225 hideOnClick: true,
22226 onChange: (e2) => {
22227 switch (e2.target.value) {
22228 case "list":
22229 case "grid":
22230 case "table":
22231 case "pickerGrid":
22232 case "pickerTable":
22233 case "activity":
22234 const viewWithoutLayout = { ...view };
22235 if ("layout" in viewWithoutLayout) {
22236 delete viewWithoutLayout.layout;
22237 }
22238 return onChangeView({
22239 ...viewWithoutLayout,
22240 type: e2.target.value,
22241 ...defaultLayouts[e2.target.value]
22242 });
22243 }
22244 (0, import_warning.default)("Invalid dataview");
22245 },
22246 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.ItemLabel, { children: config.label })
22247 },
22248 layout
22249 );
22250 }) })
22251 ] });
22252 }
22253 function SortFieldControl() {
22254 const { view, fields, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22255 const orderOptions = (0, import_element59.useMemo)(() => {
22256 const sortableFields = fields.filter(
22257 (field) => field.enableSorting !== false
22258 );
22259 return sortableFields.map((field) => {
22260 return {
22261 label: field.label,
22262 value: field.id
22263 };
22264 });
22265 }, [fields]);
22266 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22267 import_components26.SelectControl,
22268 {
22269 __next40pxDefaultSize: true,
22270 label: (0, import_i18n31.__)("Sort by"),
22271 value: view.sort?.field,
22272 options: orderOptions,
22273 onChange: (value) => {
22274 onChangeView({
22275 ...view,
22276 sort: {
22277 direction: view?.sort?.direction || "desc",
22278 field: value
22279 },
22280 showLevels: false
22281 });
22282 }
22283 }
22284 );
22285 }
22286 function SortDirectionControl() {
22287 const { view, fields, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22288 const sortableFields = fields.filter(
22289 (field) => field.enableSorting !== false
22290 );
22291 if (sortableFields.length === 0) {
22292 return null;
22293 }
22294 let value = view.sort?.direction;
22295 if (!value && view.sort?.field) {
22296 value = "desc";
22297 }
22298 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22299 import_components26.__experimentalToggleGroupControl,
22300 {
22301 className: "dataviews-view-config__sort-direction",
22302 __next40pxDefaultSize: true,
22303 isBlock: true,
22304 label: (0, import_i18n31.__)("Order"),
22305 value,
22306 onChange: (newDirection) => {
22307 if (newDirection === "asc" || newDirection === "desc") {
22308 onChangeView({
22309 ...view,
22310 sort: {
22311 direction: newDirection,
22312 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22313 fields.find(
22314 (field) => field.enableSorting !== false
22315 )?.id || ""
22316 },
22317 showLevels: false
22318 });
22319 return;
22320 }
22321 (0, import_warning.default)("Invalid direction");
22322 },
22323 children: SORTING_DIRECTIONS.map((direction) => {
22324 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22325 import_components26.__experimentalToggleGroupControlOptionIcon,
22326 {
22327 value: direction,
22328 icon: sortIcons[direction],
22329 label: sortLabels[direction]
22330 },
22331 direction
22332 );
22333 })
22334 }
22335 );
22336 }
22337 function ItemsPerPageControl() {
22338 const { view, config, onChangeView } = (0, import_element59.useContext)(dataviews_context_default);
22339 const { infiniteScrollEnabled } = view;
22340 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22341 return null;
22342 }
22343 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22344 import_components26.__experimentalToggleGroupControl,
22345 {
22346 __next40pxDefaultSize: true,
22347 isBlock: true,
22348 label: (0, import_i18n31.__)("Items per page"),
22349 value: view.perPage || 10,
22350 disabled: !view?.sort?.field,
22351 onChange: (newItemsPerPage) => {
22352 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22353 onChangeView({
22354 ...view,
22355 perPage: newItemsPerPageNumber,
22356 page: 1
22357 });
22358 },
22359 children: config.perPageSizes.map((value) => {
22360 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22361 import_components26.__experimentalToggleGroupControlOption,
22362 {
22363 value,
22364 label: value.toString()
22365 },
22366 value
22367 );
22368 })
22369 }
22370 );
22371 }
22372 function ResetViewButton() {
22373 const { onReset } = (0, import_element59.useContext)(dataviews_context_default);
22374 if (onReset === void 0) {
22375 return null;
22376 }
22377 const isDisabled = onReset === false;
22378 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22379 import_components26.Button,
22380 {
22381 variant: "tertiary",
22382 size: "compact",
22383 disabled: isDisabled,
22384 accessibleWhenDisabled: true,
22385 className: "dataviews-view-config__reset-button",
22386 onClick: () => {
22387 if (typeof onReset === "function") {
22388 onReset();
22389 }
22390 },
22391 children: (0, import_i18n31.__)("Reset view")
22392 }
22393 );
22394 }
22395 function DataviewsViewConfigDropdown() {
22396 const { view, onReset } = (0, import_element59.useContext)(dataviews_context_default);
22397 const popoverId = (0, import_compose10.useInstanceId)(
22398 _DataViewsViewConfig,
22399 "dataviews-view-config-dropdown"
22400 );
22401 const activeLayout = VIEW_LAYOUTS.find(
22402 (layout) => layout.type === view.type
22403 );
22404 const isModified = typeof onReset === "function";
22405 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22406 import_components26.Dropdown,
22407 {
22408 expandOnMobile: true,
22409 popoverProps: {
22410 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22411 id: popoverId
22412 },
22413 renderToggle: ({ onToggle, isOpen }) => {
22414 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22415 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22416 import_components26.Button,
22417 {
22418 size: "compact",
22419 icon: cog_default,
22420 label: (0, import_i18n31._x)(
22421 "View options",
22422 "View is used as a noun"
22423 ),
22424 onClick: onToggle,
22425 "aria-expanded": isOpen ? "true" : "false",
22426 "aria-controls": popoverId
22427 }
22428 ),
22429 isModified && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22430 ] });
22431 },
22432 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22433 import_components26.__experimentalDropdownContentWrapper,
22434 {
22435 paddingSize: "medium",
22436 className: "dataviews-config__popover-content-wrapper",
22437 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22438 Stack,
22439 {
22440 direction: "column",
22441 className: "dataviews-view-config",
22442 gap: "xl",
22443 children: [
22444 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22445 Stack,
22446 {
22447 direction: "row",
22448 justify: "space-between",
22449 align: "center",
22450 className: "dataviews-view-config__header",
22451 children: [
22452 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22453 import_components26.__experimentalHeading,
22454 {
22455 level: 2,
22456 className: "dataviews-settings-section__title",
22457 children: (0, import_i18n31.__)("Appearance")
22458 }
22459 ),
22460 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ResetViewButton, {})
22461 ]
22462 }
22463 ),
22464 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22465 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22466 Stack,
22467 {
22468 direction: "row",
22469 gap: "sm",
22470 className: "dataviews-view-config__sort-controls",
22471 children: [
22472 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortFieldControl, {}),
22473 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortDirectionControl, {})
22474 ]
22475 }
22476 ),
22477 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(activeLayout.viewConfigOptions, {}),
22478 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ItemsPerPageControl, {}),
22479 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(PropertiesSection, {})
22480 ] })
22481 ]
22482 }
22483 )
22484 }
22485 )
22486 }
22487 );
22488 }
22489 function _DataViewsViewConfig() {
22490 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
22491 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ViewTypeMenu, {}),
22492 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DataviewsViewConfigDropdown, {})
22493 ] });
22494 }
22495 var DataViewsViewConfig = (0, import_element59.memo)(_DataViewsViewConfig);
22496 var dataviews_view_config_default = DataViewsViewConfig;
22497
22498 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22499 var import_components27 = __toESM(require_components(), 1);
22500 var import_element60 = __toESM(require_element(), 1);
22501
22502 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22503 function getCustomValidity(isValid2, validity) {
22504 let customValidity;
22505 if (isValid2?.required && validity?.required) {
22506 customValidity = validity?.required?.message ? validity.required : void 0;
22507 } else if (isValid2?.pattern && validity?.pattern) {
22508 customValidity = validity.pattern;
22509 } else if (isValid2?.min && validity?.min) {
22510 customValidity = validity.min;
22511 } else if (isValid2?.max && validity?.max) {
22512 customValidity = validity.max;
22513 } else if (isValid2?.minLength && validity?.minLength) {
22514 customValidity = validity.minLength;
22515 } else if (isValid2?.maxLength && validity?.maxLength) {
22516 customValidity = validity.maxLength;
22517 } else if (isValid2?.elements && validity?.elements) {
22518 customValidity = validity.elements;
22519 } else if (validity?.custom) {
22520 customValidity = validity.custom;
22521 }
22522 return customValidity;
22523 }
22524
22525 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22526 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22527 var { ValidatedCheckboxControl } = unlock2(import_components27.privateApis);
22528 function Checkbox({
22529 field,
22530 onChange,
22531 data,
22532 hideLabelFromVision,
22533 markWhenOptional,
22534 validity
22535 }) {
22536 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22537 const disabled2 = field.isDisabled({ item: data, field });
22538 const onChangeControl = (0, import_element60.useCallback)(() => {
22539 onChange(
22540 setValue({ item: data, value: !getValue({ item: data }) })
22541 );
22542 }, [data, getValue, onChange, setValue]);
22543 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22544 ValidatedCheckboxControl,
22545 {
22546 required: !!field.isValid?.required,
22547 markWhenOptional,
22548 customValidity: getCustomValidity(isValid2, validity),
22549 hidden: hideLabelFromVision,
22550 label,
22551 help: description,
22552 checked: getValue({ item: data }),
22553 onChange: onChangeControl,
22554 disabled: disabled2
22555 }
22556 );
22557 }
22558
22559 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22560 var import_components28 = __toESM(require_components(), 1);
22561 var import_element61 = __toESM(require_element(), 1);
22562 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22563 var { ValidatedComboboxControl } = unlock2(import_components28.privateApis);
22564 function Combobox3({
22565 data,
22566 field,
22567 onChange,
22568 hideLabelFromVision,
22569 validity
22570 }) {
22571 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22572 const value = getValue({ item: data }) ?? "";
22573 const onChangeControl = (0, import_element61.useCallback)(
22574 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22575 [data, onChange, setValue]
22576 );
22577 const { elements, isLoading } = useElements({
22578 elements: field.elements,
22579 getElements: field.getElements
22580 });
22581 if (isLoading) {
22582 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components28.Spinner, {});
22583 }
22584 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22585 ValidatedComboboxControl,
22586 {
22587 required: !!field.isValid?.required,
22588 customValidity: getCustomValidity(isValid2, validity),
22589 label,
22590 value,
22591 help: description,
22592 placeholder,
22593 options: elements,
22594 onChange: onChangeControl,
22595 hideLabelFromVision,
22596 allowReset: true,
22597 expandOnFocus: true
22598 }
22599 );
22600 }
22601
22602 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22603 var import_components30 = __toESM(require_components(), 1);
22604 var import_element64 = __toESM(require_element(), 1);
22605 var import_i18n33 = __toESM(require_i18n(), 1);
22606 var import_date3 = __toESM(require_date(), 1);
22607
22608 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22609 var import_components29 = __toESM(require_components(), 1);
22610 var import_element62 = __toESM(require_element(), 1);
22611 var import_i18n32 = __toESM(require_i18n(), 1);
22612 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22613 var TIME_UNITS_OPTIONS = {
22614 [OPERATOR_IN_THE_PAST]: [
22615 { value: "days", label: (0, import_i18n32.__)("Days") },
22616 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22617 { value: "months", label: (0, import_i18n32.__)("Months") },
22618 { value: "years", label: (0, import_i18n32.__)("Years") }
22619 ],
22620 [OPERATOR_OVER]: [
22621 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22622 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22623 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22624 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22625 ]
22626 };
22627 function RelativeDateControl({
22628 className,
22629 data,
22630 field,
22631 onChange,
22632 hideLabelFromVision,
22633 operator
22634 }) {
22635 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22636 const { id, label, description, getValue, setValue } = field;
22637 const disabled2 = field.isDisabled({ item: data, field });
22638 const fieldValue = getValue({ item: data });
22639 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22640 const onChangeValue = (0, import_element62.useCallback)(
22641 (newValue) => onChange(
22642 setValue({
22643 item: data,
22644 value: { value: Number(newValue), unit }
22645 })
22646 ),
22647 [onChange, setValue, data, unit]
22648 );
22649 const onChangeUnit = (0, import_element62.useCallback)(
22650 (newUnit) => onChange(
22651 setValue({
22652 item: data,
22653 value: { value: relValue, unit: newUnit }
22654 })
22655 ),
22656 [onChange, setValue, data, relValue]
22657 );
22658 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22659 import_components29.BaseControl,
22660 {
22661 id,
22662 className: clsx_default(className, "dataviews-controls__relative-date"),
22663 label,
22664 hideLabelFromVision,
22665 help: description,
22666 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22667 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22668 import_components29.__experimentalNumberControl,
22669 {
22670 __next40pxDefaultSize: true,
22671 className: "dataviews-controls__relative-date-number",
22672 spinControls: "none",
22673 min: 1,
22674 step: 1,
22675 value: relValue,
22676 onChange: onChangeValue,
22677 disabled: disabled2
22678 }
22679 ),
22680 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
22681 import_components29.SelectControl,
22682 {
22683 className: "dataviews-controls__relative-date-unit",
22684 __next40pxDefaultSize: true,
22685 label: (0, import_i18n32.__)("Unit"),
22686 value: unit,
22687 options,
22688 onChange: onChangeUnit,
22689 hideLabelFromVision: true,
22690 disabled: disabled2
22691 }
22692 )
22693 ] })
22694 }
22695 );
22696 }
22697
22698 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22699 var import_element63 = __toESM(require_element(), 1);
22700 function useDisabledDateMatchers(isValid2, parseDateFn) {
22701 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22702 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22703 const disabledMatchers = (0, import_element63.useMemo)(() => {
22704 const matchers = [];
22705 if (minConstraint) {
22706 const minDate = parseDateFn(minConstraint);
22707 if (minDate) {
22708 matchers.push({ before: minDate });
22709 }
22710 }
22711 if (maxConstraint) {
22712 const maxDate = parseDateFn(maxConstraint);
22713 if (maxDate) {
22714 matchers.push({ after: maxDate });
22715 }
22716 }
22717 return matchers.length > 0 ? matchers : void 0;
22718 }, [minConstraint, maxConstraint, parseDateFn]);
22719 return { minConstraint, maxConstraint, disabledMatchers };
22720 }
22721
22722 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22723 var import_date2 = __toESM(require_date(), 1);
22724 function parseDateTime(dateTimeString) {
22725 if (!dateTimeString) {
22726 return null;
22727 }
22728 const parsed = (0, import_date2.getDate)(dateTimeString);
22729 return parsed && isValid(parsed) ? parsed : null;
22730 }
22731
22732 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22733 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
22734 var { DateCalendar, ValidatedInputControl } = unlock2(import_components30.privateApis);
22735 var formatDateTime = (value) => {
22736 if (!value) {
22737 return "";
22738 }
22739 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22740 };
22741 function CalendarDateTimeControl({
22742 data,
22743 field,
22744 onChange,
22745 hideLabelFromVision,
22746 markWhenOptional,
22747 validity,
22748 config
22749 }) {
22750 const { compact } = config || {};
22751 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22752 const disabled2 = field.isDisabled({ item: data, field });
22753 const fieldValue = getValue({ item: data });
22754 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22755 const [calendarMonth, setCalendarMonth] = (0, import_element64.useState)(() => {
22756 const parsedDate = parseDateTime(value);
22757 return parsedDate || /* @__PURE__ */ new Date();
22758 });
22759 const inputControlRef = (0, import_element64.useRef)(null);
22760 const validationTimeoutRef = (0, import_element64.useRef)(void 0);
22761 const previousFocusRef = (0, import_element64.useRef)(null);
22762 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22763 const onChangeCallback = (0, import_element64.useCallback)(
22764 (newValue) => onChange(setValue({ item: data, value: newValue })),
22765 [data, onChange, setValue]
22766 );
22767 (0, import_element64.useEffect)(() => {
22768 return () => {
22769 if (validationTimeoutRef.current) {
22770 clearTimeout(validationTimeoutRef.current);
22771 }
22772 };
22773 }, []);
22774 const onSelectDate = (0, import_element64.useCallback)(
22775 (newDate) => {
22776 let dateTimeValue;
22777 if (newDate) {
22778 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22779 let wpTime;
22780 if (value) {
22781 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22782 } else {
22783 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22784 }
22785 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22786 dateTimeValue = finalDateTime.toISOString();
22787 onChangeCallback(dateTimeValue);
22788 if (validationTimeoutRef.current) {
22789 clearTimeout(validationTimeoutRef.current);
22790 }
22791 } else {
22792 onChangeCallback(void 0);
22793 }
22794 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22795 validationTimeoutRef.current = setTimeout(() => {
22796 if (inputControlRef.current) {
22797 inputControlRef.current.focus();
22798 inputControlRef.current.blur();
22799 onChangeCallback(dateTimeValue);
22800 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22801 previousFocusRef.current.focus();
22802 }
22803 }
22804 }, 0);
22805 },
22806 [onChangeCallback, value]
22807 );
22808 const handleManualDateTimeChange = (0, import_element64.useCallback)(
22809 (newValue) => {
22810 if (newValue) {
22811 const dateTime = (0, import_date3.getDate)(newValue);
22812 onChangeCallback(dateTime.toISOString());
22813 const parsedDate = parseDateTime(dateTime.toISOString());
22814 if (parsedDate) {
22815 setCalendarMonth(parsedDate);
22816 }
22817 } else {
22818 onChangeCallback(void 0);
22819 }
22820 },
22821 [onChangeCallback]
22822 );
22823 const { format: fieldFormat } = field;
22824 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22825 const {
22826 timezone: { string: timezoneString }
22827 } = (0, import_date3.getSettings)();
22828 let displayLabel = label;
22829 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22830 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22831 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22832 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22833 }
22834 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22835 import_components30.BaseControl,
22836 {
22837 id,
22838 label: displayLabel,
22839 help: description,
22840 hideLabelFromVision,
22841 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22842 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22843 ValidatedInputControl,
22844 {
22845 ref: inputControlRef,
22846 __next40pxDefaultSize: true,
22847 required: !!isValid2?.required,
22848 customValidity: getCustomValidity(isValid2, validity),
22849 type: "datetime-local",
22850 label: (0, import_i18n33.__)("Date time"),
22851 hideLabelFromVision: true,
22852 value: formatDateTime(value),
22853 onChange: handleManualDateTimeChange,
22854 disabled: disabled2,
22855 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22856 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22857 }
22858 ),
22859 !compact && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22860 DateCalendar,
22861 {
22862 style: { width: "100%" },
22863 selected: value ? parseDateTime(value) || void 0 : void 0,
22864 onSelect: onSelectDate,
22865 month: calendarMonth,
22866 onMonthChange: setCalendarMonth,
22867 timeZone: timezoneString || void 0,
22868 weekStartsOn,
22869 disabled: disabled2 || disabledMatchers
22870 }
22871 )
22872 ] })
22873 }
22874 );
22875 }
22876 function DateTime({
22877 data,
22878 field,
22879 onChange,
22880 hideLabelFromVision,
22881 markWhenOptional,
22882 operator,
22883 validity,
22884 config
22885 }) {
22886 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22887 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22888 RelativeDateControl,
22889 {
22890 className: "dataviews-controls__datetime",
22891 data,
22892 field,
22893 onChange,
22894 hideLabelFromVision,
22895 operator
22896 }
22897 );
22898 }
22899 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
22900 CalendarDateTimeControl,
22901 {
22902 data,
22903 field,
22904 onChange,
22905 hideLabelFromVision,
22906 markWhenOptional,
22907 validity,
22908 config
22909 }
22910 );
22911 }
22912
22913 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22914 var import_components31 = __toESM(require_components(), 1);
22915 var import_element65 = __toESM(require_element(), 1);
22916 var import_i18n34 = __toESM(require_i18n(), 1);
22917 var import_date4 = __toESM(require_date(), 1);
22918 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
22919 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components31.privateApis);
22920 var DATE_PRESETS = [
22921 {
22922 id: "today",
22923 label: (0, import_i18n34.__)("Today"),
22924 getValue: () => (0, import_date4.getDate)(null)
22925 },
22926 {
22927 id: "yesterday",
22928 label: (0, import_i18n34.__)("Yesterday"),
22929 getValue: () => {
22930 const today = (0, import_date4.getDate)(null);
22931 return subDays(today, 1);
22932 }
22933 },
22934 {
22935 id: "past-week",
22936 label: (0, import_i18n34.__)("Past week"),
22937 getValue: () => {
22938 const today = (0, import_date4.getDate)(null);
22939 return subDays(today, 7);
22940 }
22941 },
22942 {
22943 id: "past-month",
22944 label: (0, import_i18n34.__)("Past month"),
22945 getValue: () => {
22946 const today = (0, import_date4.getDate)(null);
22947 return subMonths(today, 1);
22948 }
22949 }
22950 ];
22951 var DATE_RANGE_PRESETS = [
22952 {
22953 id: "last-7-days",
22954 label: (0, import_i18n34.__)("Last 7 days"),
22955 getValue: () => {
22956 const today = (0, import_date4.getDate)(null);
22957 return [subDays(today, 7), today];
22958 }
22959 },
22960 {
22961 id: "last-30-days",
22962 label: (0, import_i18n34.__)("Last 30 days"),
22963 getValue: () => {
22964 const today = (0, import_date4.getDate)(null);
22965 return [subDays(today, 30), today];
22966 }
22967 },
22968 {
22969 id: "month-to-date",
22970 label: (0, import_i18n34.__)("Month to date"),
22971 getValue: () => {
22972 const today = (0, import_date4.getDate)(null);
22973 return [startOfMonth(today), today];
22974 }
22975 },
22976 {
22977 id: "last-year",
22978 label: (0, import_i18n34.__)("Last year"),
22979 getValue: () => {
22980 const today = (0, import_date4.getDate)(null);
22981 return [subYears(today, 1), today];
22982 }
22983 },
22984 {
22985 id: "year-to-date",
22986 label: (0, import_i18n34.__)("Year to date"),
22987 getValue: () => {
22988 const today = (0, import_date4.getDate)(null);
22989 return [startOfYear(today), today];
22990 }
22991 }
22992 ];
22993 var parseDate = (dateString) => {
22994 if (!dateString) {
22995 return null;
22996 }
22997 const parsed = (0, import_date4.getDate)(dateString);
22998 return parsed && isValid(parsed) ? parsed : null;
22999 };
23000 var formatDate = (date) => {
23001 if (!date) {
23002 return "";
23003 }
23004 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23005 };
23006 function ValidatedDateControl({
23007 field,
23008 validity,
23009 inputRefs,
23010 isTouched,
23011 setIsTouched,
23012 children
23013 }) {
23014 const { isValid: isValid2 } = field;
23015 const [customValidity, setCustomValidity] = (0, import_element65.useState)(void 0);
23016 const validateRefs = (0, import_element65.useCallback)(() => {
23017 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23018 for (const ref of refs) {
23019 const input = ref.current;
23020 if (input && !input.validity.valid) {
23021 setCustomValidity({
23022 type: "invalid",
23023 message: input.validationMessage
23024 });
23025 return;
23026 }
23027 }
23028 setCustomValidity(void 0);
23029 }, [inputRefs]);
23030 (0, import_element65.useEffect)(() => {
23031 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23032 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23033 for (const ref of refs) {
23034 const input = ref.current;
23035 if (input) {
23036 input.setCustomValidity(
23037 result?.type === "invalid" && result.message ? result.message : ""
23038 );
23039 }
23040 }
23041 }, [inputRefs, isValid2, validity]);
23042 (0, import_element65.useEffect)(() => {
23043 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23044 const handleInvalid = (event) => {
23045 event.preventDefault();
23046 setIsTouched(true);
23047 };
23048 for (const ref of refs) {
23049 ref.current?.addEventListener("invalid", handleInvalid);
23050 }
23051 return () => {
23052 for (const ref of refs) {
23053 ref.current?.removeEventListener("invalid", handleInvalid);
23054 }
23055 };
23056 }, [inputRefs, setIsTouched]);
23057 (0, import_element65.useEffect)(() => {
23058 if (!isTouched) {
23059 return;
23060 }
23061 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23062 if (result) {
23063 setCustomValidity(result);
23064 } else {
23065 validateRefs();
23066 }
23067 }, [isTouched, isValid2, validity, validateRefs]);
23068 const onBlur = (event) => {
23069 if (isTouched) {
23070 return;
23071 }
23072 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23073 setIsTouched(true);
23074 }
23075 };
23076 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { onBlur, children: [
23077 children,
23078 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23079 "p",
23080 {
23081 className: clsx_default(
23082 "components-validated-control__indicator",
23083 customValidity.type === "invalid" ? "is-invalid" : void 0
23084 ),
23085 children: [
23086 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23087 import_components31.Icon,
23088 {
23089 className: "components-validated-control__indicator-icon",
23090 icon: error_default,
23091 size: 16,
23092 fill: "currentColor"
23093 }
23094 ),
23095 customValidity.message
23096 ]
23097 }
23098 ) })
23099 ] });
23100 }
23101 function CalendarDateControl({
23102 data,
23103 field,
23104 onChange,
23105 hideLabelFromVision,
23106 markWhenOptional,
23107 validity
23108 }) {
23109 const {
23110 id,
23111 label,
23112 description,
23113 setValue,
23114 getValue,
23115 isValid: isValid2,
23116 format: fieldFormat
23117 } = field;
23118 const disabled2 = field.isDisabled({ item: data, field });
23119 const [selectedPresetId, setSelectedPresetId] = (0, import_element65.useState)(
23120 null
23121 );
23122 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23123 const fieldValue = getValue({ item: data });
23124 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23125 const [calendarMonth, setCalendarMonth] = (0, import_element65.useState)(() => {
23126 const parsedDate = parseDate(value);
23127 return parsedDate || /* @__PURE__ */ new Date();
23128 });
23129 const [isTouched, setIsTouched] = (0, import_element65.useState)(false);
23130 const validityTargetRef = (0, import_element65.useRef)(null);
23131 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23132 const onChangeCallback = (0, import_element65.useCallback)(
23133 (newValue) => onChange(setValue({ item: data, value: newValue })),
23134 [data, onChange, setValue]
23135 );
23136 const onSelectDate = (0, import_element65.useCallback)(
23137 (newDate) => {
23138 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23139 onChangeCallback(dateValue);
23140 setSelectedPresetId(null);
23141 setIsTouched(true);
23142 },
23143 [onChangeCallback]
23144 );
23145 const handlePresetClick = (0, import_element65.useCallback)(
23146 (preset) => {
23147 const presetDate = preset.getValue();
23148 const dateValue = formatDate(presetDate);
23149 setCalendarMonth(presetDate);
23150 onChangeCallback(dateValue);
23151 setSelectedPresetId(preset.id);
23152 setIsTouched(true);
23153 },
23154 [onChangeCallback]
23155 );
23156 const handleManualDateChange = (0, import_element65.useCallback)(
23157 (newValue) => {
23158 onChangeCallback(newValue);
23159 if (newValue) {
23160 const parsedDate = parseDate(newValue);
23161 if (parsedDate) {
23162 setCalendarMonth(parsedDate);
23163 }
23164 }
23165 setSelectedPresetId(null);
23166 setIsTouched(true);
23167 },
23168 [onChangeCallback]
23169 );
23170 const {
23171 timezone: { string: timezoneString }
23172 } = (0, import_date4.getSettings)();
23173 let displayLabel = label;
23174 if (isValid2?.required && !markWhenOptional) {
23175 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23176 } else if (!isValid2?.required && markWhenOptional) {
23177 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23178 }
23179 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23180 ValidatedDateControl,
23181 {
23182 field,
23183 validity,
23184 inputRefs: validityTargetRef,
23185 isTouched,
23186 setIsTouched,
23187 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23188 import_components31.BaseControl,
23189 {
23190 id,
23191 className: "dataviews-controls__date",
23192 label: displayLabel,
23193 help: description,
23194 hideLabelFromVision,
23195 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23196 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23197 Stack,
23198 {
23199 direction: "row",
23200 gap: "sm",
23201 wrap: "wrap",
23202 justify: "flex-start",
23203 children: [
23204 DATE_PRESETS.map((preset) => {
23205 const isSelected2 = selectedPresetId === preset.id;
23206 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23207 import_components31.Button,
23208 {
23209 className: "dataviews-controls__date-preset",
23210 variant: "tertiary",
23211 isPressed: isSelected2,
23212 size: "small",
23213 disabled: disabled2,
23214 accessibleWhenDisabled: true,
23215 onClick: () => handlePresetClick(preset),
23216 children: preset.label
23217 },
23218 preset.id
23219 );
23220 }),
23221 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23222 import_components31.Button,
23223 {
23224 className: "dataviews-controls__date-preset",
23225 variant: "tertiary",
23226 isPressed: !selectedPresetId,
23227 size: "small",
23228 disabled: !!selectedPresetId || disabled2,
23229 accessibleWhenDisabled: true,
23230 children: (0, import_i18n34.__)("Custom")
23231 }
23232 )
23233 ]
23234 }
23235 ),
23236 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23237 import_components31.__experimentalInputControl,
23238 {
23239 __next40pxDefaultSize: true,
23240 ref: validityTargetRef,
23241 type: "date",
23242 label: (0, import_i18n34.__)("Date"),
23243 hideLabelFromVision: true,
23244 value,
23245 onChange: handleManualDateChange,
23246 required: !!field.isValid?.required,
23247 disabled: disabled2,
23248 min: minConstraint,
23249 max: maxConstraint
23250 }
23251 ),
23252 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23253 DateCalendar2,
23254 {
23255 style: { width: "100%" },
23256 selected: value ? parseDate(value) || void 0 : void 0,
23257 onSelect: onSelectDate,
23258 month: calendarMonth,
23259 onMonthChange: setCalendarMonth,
23260 timeZone: timezoneString || void 0,
23261 weekStartsOn,
23262 disabled: disabled2 || disabledMatchers,
23263 disableNavigation: disabled2
23264 }
23265 )
23266 ] })
23267 }
23268 )
23269 }
23270 );
23271 }
23272 function CalendarDateRangeControl({
23273 data,
23274 field,
23275 onChange,
23276 hideLabelFromVision,
23277 markWhenOptional,
23278 validity
23279 }) {
23280 const {
23281 id,
23282 label,
23283 description,
23284 getValue,
23285 setValue,
23286 isValid: isValid2,
23287 format: fieldFormat
23288 } = field;
23289 const disabled2 = field.isDisabled({ item: data, field });
23290 let value;
23291 const fieldValue = getValue({ item: data });
23292 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23293 value = fieldValue;
23294 }
23295 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23296 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23297 const onChangeCallback = (0, import_element65.useCallback)(
23298 (newValue) => {
23299 onChange(
23300 setValue({
23301 item: data,
23302 value: newValue
23303 })
23304 );
23305 },
23306 [data, onChange, setValue]
23307 );
23308 const [selectedPresetId, setSelectedPresetId] = (0, import_element65.useState)(
23309 null
23310 );
23311 const selectedRange = (0, import_element65.useMemo)(() => {
23312 if (!value) {
23313 return { from: void 0, to: void 0 };
23314 }
23315 const [from, to] = value;
23316 return {
23317 from: parseDate(from) || void 0,
23318 to: parseDate(to) || void 0
23319 };
23320 }, [value]);
23321 const [calendarMonth, setCalendarMonth] = (0, import_element65.useState)(() => {
23322 return selectedRange.from || /* @__PURE__ */ new Date();
23323 });
23324 const [isTouched, setIsTouched] = (0, import_element65.useState)(false);
23325 const fromInputRef = (0, import_element65.useRef)(null);
23326 const toInputRef = (0, import_element65.useRef)(null);
23327 const updateDateRange = (0, import_element65.useCallback)(
23328 (fromDate, toDate2) => {
23329 if (fromDate && toDate2) {
23330 onChangeCallback([
23331 formatDate(fromDate),
23332 formatDate(toDate2)
23333 ]);
23334 } else if (!fromDate && !toDate2) {
23335 onChangeCallback(void 0);
23336 }
23337 },
23338 [onChangeCallback]
23339 );
23340 const onSelectCalendarRange = (0, import_element65.useCallback)(
23341 (newRange) => {
23342 updateDateRange(newRange?.from, newRange?.to);
23343 setSelectedPresetId(null);
23344 setIsTouched(true);
23345 },
23346 [updateDateRange]
23347 );
23348 const handlePresetClick = (0, import_element65.useCallback)(
23349 (preset) => {
23350 const [startDate, endDate] = preset.getValue();
23351 setCalendarMonth(startDate);
23352 updateDateRange(startDate, endDate);
23353 setSelectedPresetId(preset.id);
23354 setIsTouched(true);
23355 },
23356 [updateDateRange]
23357 );
23358 const handleManualDateChange = (0, import_element65.useCallback)(
23359 (fromOrTo, newValue) => {
23360 const [currentFrom, currentTo] = value || [
23361 void 0,
23362 void 0
23363 ];
23364 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23365 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23366 updateDateRange(updatedFrom, updatedTo);
23367 if (newValue) {
23368 const parsedDate = parseDate(newValue);
23369 if (parsedDate) {
23370 setCalendarMonth(parsedDate);
23371 }
23372 }
23373 setSelectedPresetId(null);
23374 setIsTouched(true);
23375 },
23376 [value, updateDateRange]
23377 );
23378 const { timezone } = (0, import_date4.getSettings)();
23379 let displayLabel = label;
23380 if (field.isValid?.required && !markWhenOptional) {
23381 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23382 } else if (!field.isValid?.required && markWhenOptional) {
23383 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23384 }
23385 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23386 ValidatedDateControl,
23387 {
23388 field,
23389 validity,
23390 inputRefs: [fromInputRef, toInputRef],
23391 isTouched,
23392 setIsTouched,
23393 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23394 import_components31.BaseControl,
23395 {
23396 id,
23397 className: "dataviews-controls__date",
23398 label: displayLabel,
23399 help: description,
23400 hideLabelFromVision,
23401 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23402 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23403 Stack,
23404 {
23405 direction: "row",
23406 gap: "sm",
23407 wrap: "wrap",
23408 justify: "flex-start",
23409 children: [
23410 DATE_RANGE_PRESETS.map((preset) => {
23411 const isSelected2 = selectedPresetId === preset.id;
23412 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23413 import_components31.Button,
23414 {
23415 className: "dataviews-controls__date-preset",
23416 variant: "tertiary",
23417 isPressed: isSelected2,
23418 size: "small",
23419 disabled: disabled2,
23420 accessibleWhenDisabled: true,
23421 onClick: () => handlePresetClick(preset),
23422 children: preset.label
23423 },
23424 preset.id
23425 );
23426 }),
23427 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23428 import_components31.Button,
23429 {
23430 className: "dataviews-controls__date-preset",
23431 variant: "tertiary",
23432 isPressed: !selectedPresetId,
23433 size: "small",
23434 accessibleWhenDisabled: true,
23435 disabled: !!selectedPresetId || disabled2,
23436 children: (0, import_i18n34.__)("Custom")
23437 }
23438 )
23439 ]
23440 }
23441 ),
23442 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23443 Stack,
23444 {
23445 direction: "row",
23446 gap: "sm",
23447 justify: "space-between",
23448 className: "dataviews-controls__date-range-inputs",
23449 children: [
23450 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23451 import_components31.__experimentalInputControl,
23452 {
23453 __next40pxDefaultSize: true,
23454 ref: fromInputRef,
23455 type: "date",
23456 label: (0, import_i18n34.__)("From"),
23457 hideLabelFromVision: true,
23458 value: value?.[0],
23459 onChange: (newValue) => handleManualDateChange("from", newValue),
23460 required: !!field.isValid?.required,
23461 disabled: disabled2,
23462 min: minConstraint,
23463 max: maxConstraint
23464 }
23465 ),
23466 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23467 import_components31.__experimentalInputControl,
23468 {
23469 __next40pxDefaultSize: true,
23470 ref: toInputRef,
23471 type: "date",
23472 label: (0, import_i18n34.__)("To"),
23473 hideLabelFromVision: true,
23474 value: value?.[1],
23475 onChange: (newValue) => handleManualDateChange("to", newValue),
23476 required: !!field.isValid?.required,
23477 disabled: disabled2,
23478 min: minConstraint,
23479 max: maxConstraint
23480 }
23481 )
23482 ]
23483 }
23484 ),
23485 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23486 DateRangeCalendar,
23487 {
23488 style: { width: "100%" },
23489 selected: selectedRange,
23490 onSelect: onSelectCalendarRange,
23491 month: calendarMonth,
23492 onMonthChange: setCalendarMonth,
23493 timeZone: timezone.string || void 0,
23494 weekStartsOn,
23495 disabled: disabled2 || disabledMatchers
23496 }
23497 )
23498 ] })
23499 }
23500 )
23501 }
23502 );
23503 }
23504 function DateControl({
23505 data,
23506 field,
23507 onChange,
23508 hideLabelFromVision,
23509 markWhenOptional,
23510 operator,
23511 validity
23512 }) {
23513 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23514 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23515 RelativeDateControl,
23516 {
23517 className: "dataviews-controls__date",
23518 data,
23519 field,
23520 onChange,
23521 hideLabelFromVision,
23522 operator
23523 }
23524 );
23525 }
23526 if (operator === OPERATOR_BETWEEN) {
23527 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23528 CalendarDateRangeControl,
23529 {
23530 data,
23531 field,
23532 onChange,
23533 hideLabelFromVision,
23534 markWhenOptional,
23535 validity
23536 }
23537 );
23538 }
23539 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23540 CalendarDateControl,
23541 {
23542 data,
23543 field,
23544 onChange,
23545 hideLabelFromVision,
23546 markWhenOptional,
23547 validity
23548 }
23549 );
23550 }
23551
23552 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23553 var import_components32 = __toESM(require_components(), 1);
23554 var import_element66 = __toESM(require_element(), 1);
23555 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23556 var { ValidatedSelectControl } = unlock2(import_components32.privateApis);
23557 function Select({
23558 data,
23559 field,
23560 onChange,
23561 hideLabelFromVision,
23562 markWhenOptional,
23563 validity
23564 }) {
23565 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23566 const disabled2 = field.isDisabled({ item: data, field });
23567 const isMultiple = type === "array";
23568 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23569 const onChangeControl = (0, import_element66.useCallback)(
23570 (newValue) => onChange(setValue({ item: data, value: newValue })),
23571 [data, onChange, setValue]
23572 );
23573 const { elements, isLoading } = useElements({
23574 elements: field.elements,
23575 getElements: field.getElements
23576 });
23577 if (isLoading) {
23578 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components32.Spinner, {});
23579 }
23580 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23581 ValidatedSelectControl,
23582 {
23583 required: !!field.isValid?.required,
23584 markWhenOptional,
23585 customValidity: getCustomValidity(isValid2, validity),
23586 label,
23587 value,
23588 help: description,
23589 options: elements,
23590 onChange: onChangeControl,
23591 __next40pxDefaultSize: true,
23592 hideLabelFromVision,
23593 multiple: isMultiple,
23594 disabled: disabled2
23595 }
23596 );
23597 }
23598
23599 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23600 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23601 var ELEMENTS_THRESHOLD = 10;
23602 function AdaptiveSelect(props) {
23603 const { field } = props;
23604 const { elements } = useElements({
23605 elements: field.elements,
23606 getElements: field.getElements
23607 });
23608 if (elements.length >= ELEMENTS_THRESHOLD) {
23609 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Combobox3, { ...props });
23610 }
23611 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Select, { ...props });
23612 }
23613
23614 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23615 var import_components34 = __toESM(require_components(), 1);
23616
23617 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23618 var import_components33 = __toESM(require_components(), 1);
23619 var import_element67 = __toESM(require_element(), 1);
23620 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23621 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components33.privateApis);
23622 function ValidatedText({
23623 data,
23624 field,
23625 onChange,
23626 hideLabelFromVision,
23627 markWhenOptional,
23628 type,
23629 prefix,
23630 suffix,
23631 validity
23632 }) {
23633 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23634 const value = getValue({ item: data });
23635 const disabled2 = field.isDisabled({ item: data, field });
23636 const onChangeControl = (0, import_element67.useCallback)(
23637 (newValue) => onChange(
23638 setValue({
23639 item: data,
23640 value: newValue
23641 })
23642 ),
23643 [data, setValue, onChange]
23644 );
23645 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23646 ValidatedInputControl2,
23647 {
23648 required: !!isValid2.required,
23649 markWhenOptional,
23650 customValidity: getCustomValidity(isValid2, validity),
23651 label,
23652 placeholder,
23653 value: value ?? "",
23654 help: description,
23655 onChange: onChangeControl,
23656 hideLabelFromVision,
23657 type,
23658 prefix,
23659 suffix,
23660 disabled: disabled2,
23661 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23662 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23663 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23664 __next40pxDefaultSize: true
23665 }
23666 );
23667 }
23668
23669 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23670 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23671 function Email({
23672 data,
23673 field,
23674 onChange,
23675 hideLabelFromVision,
23676 markWhenOptional,
23677 validity
23678 }) {
23679 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23680 ValidatedText,
23681 {
23682 ...{
23683 data,
23684 field,
23685 onChange,
23686 hideLabelFromVision,
23687 markWhenOptional,
23688 validity,
23689 type: "email",
23690 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components34.Icon, { icon: envelope_default }) })
23691 }
23692 }
23693 );
23694 }
23695
23696 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23697 var import_components35 = __toESM(require_components(), 1);
23698 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23699 function Telephone({
23700 data,
23701 field,
23702 onChange,
23703 hideLabelFromVision,
23704 markWhenOptional,
23705 validity
23706 }) {
23707 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23708 ValidatedText,
23709 {
23710 ...{
23711 data,
23712 field,
23713 onChange,
23714 hideLabelFromVision,
23715 markWhenOptional,
23716 validity,
23717 type: "tel",
23718 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.Icon, { icon: mobile_default }) })
23719 }
23720 }
23721 );
23722 }
23723
23724 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23725 var import_components36 = __toESM(require_components(), 1);
23726 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23727 function Url({
23728 data,
23729 field,
23730 onChange,
23731 hideLabelFromVision,
23732 markWhenOptional,
23733 validity
23734 }) {
23735 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23736 ValidatedText,
23737 {
23738 ...{
23739 data,
23740 field,
23741 onChange,
23742 hideLabelFromVision,
23743 markWhenOptional,
23744 validity,
23745 type: "url",
23746 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.Icon, { icon: link_default }) })
23747 }
23748 }
23749 );
23750 }
23751
23752 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23753 var import_components37 = __toESM(require_components(), 1);
23754 var import_element68 = __toESM(require_element(), 1);
23755 var import_i18n35 = __toESM(require_i18n(), 1);
23756 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23757 var { ValidatedNumberControl } = unlock2(import_components37.privateApis);
23758 function toNumberOrEmpty(value) {
23759 if (value === "" || value === void 0) {
23760 return "";
23761 }
23762 const number = Number(value);
23763 return Number.isFinite(number) ? number : "";
23764 }
23765 function BetweenControls({
23766 value,
23767 onChange,
23768 hideLabelFromVision,
23769 step
23770 }) {
23771 const [min2 = "", max2 = ""] = value;
23772 const onChangeMin = (0, import_element68.useCallback)(
23773 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23774 [onChange, max2]
23775 );
23776 const onChangeMax = (0, import_element68.useCallback)(
23777 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23778 [onChange, min2]
23779 );
23780 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23781 import_components37.BaseControl,
23782 {
23783 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23784 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
23785 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23786 import_components37.__experimentalNumberControl,
23787 {
23788 label: (0, import_i18n35.__)("Min."),
23789 value: min2,
23790 max: max2 ? Number(max2) - step : void 0,
23791 onChange: onChangeMin,
23792 __next40pxDefaultSize: true,
23793 hideLabelFromVision,
23794 step
23795 }
23796 ),
23797 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23798 import_components37.__experimentalNumberControl,
23799 {
23800 label: (0, import_i18n35.__)("Max."),
23801 value: max2,
23802 min: min2 ? Number(min2) + step : void 0,
23803 onChange: onChangeMax,
23804 __next40pxDefaultSize: true,
23805 hideLabelFromVision,
23806 step
23807 }
23808 )
23809 ] })
23810 }
23811 );
23812 }
23813 function ValidatedNumber({
23814 data,
23815 field,
23816 onChange,
23817 hideLabelFromVision,
23818 markWhenOptional,
23819 operator,
23820 validity
23821 }) {
23822 const decimals = field.format?.decimals ?? 0;
23823 const step = Math.pow(10, Math.abs(decimals) * -1);
23824 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23825 const value = getValue({ item: data }) ?? "";
23826 const disabled2 = field.isDisabled({ item: data, field });
23827 const onChangeControl = (0, import_element68.useCallback)(
23828 (newValue) => {
23829 onChange(
23830 setValue({
23831 item: data,
23832 // Do not convert an empty string or undefined to a number,
23833 // otherwise there's a mismatch between the UI control (empty)
23834 // and the data relied by onChange (0).
23835 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23836 })
23837 );
23838 },
23839 [data, onChange, setValue]
23840 );
23841 const onChangeBetweenControls = (0, import_element68.useCallback)(
23842 (newValue) => {
23843 onChange(
23844 setValue({
23845 item: data,
23846 value: newValue
23847 })
23848 );
23849 },
23850 [data, onChange, setValue]
23851 );
23852 if (operator === OPERATOR_BETWEEN) {
23853 let valueBetween = ["", ""];
23854 if (Array.isArray(value) && value.length === 2 && value.every(
23855 (element) => typeof element === "number" || element === ""
23856 )) {
23857 valueBetween = value;
23858 }
23859 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23860 BetweenControls,
23861 {
23862 value: valueBetween,
23863 onChange: onChangeBetweenControls,
23864 hideLabelFromVision,
23865 step
23866 }
23867 );
23868 }
23869 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23870 ValidatedNumberControl,
23871 {
23872 required: !!isValid2.required,
23873 markWhenOptional,
23874 customValidity: getCustomValidity(isValid2, validity),
23875 label,
23876 help: description,
23877 value,
23878 onChange: onChangeControl,
23879 __next40pxDefaultSize: true,
23880 hideLabelFromVision,
23881 step,
23882 min: isValid2.min ? isValid2.min.constraint : void 0,
23883 max: isValid2.max ? isValid2.max.constraint : void 0,
23884 disabled: disabled2
23885 }
23886 );
23887 }
23888
23889 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23890 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23891 function Integer(props) {
23892 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
23893 }
23894
23895 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23896 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
23897 function Number2(props) {
23898 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
23899 }
23900
23901 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23902 var import_components38 = __toESM(require_components(), 1);
23903 var import_element69 = __toESM(require_element(), 1);
23904 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
23905 var { ValidatedRadioControl } = unlock2(import_components38.privateApis);
23906 function Radio({
23907 data,
23908 field,
23909 onChange,
23910 hideLabelFromVision,
23911 markWhenOptional,
23912 validity
23913 }) {
23914 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23915 const disabled2 = field.isDisabled({ item: data, field });
23916 const { elements, isLoading } = useElements({
23917 elements: field.elements,
23918 getElements: field.getElements
23919 });
23920 const value = getValue({ item: data });
23921 const onChangeControl = (0, import_element69.useCallback)(
23922 (newValue) => onChange(setValue({ item: data, value: newValue })),
23923 [data, onChange, setValue]
23924 );
23925 if (isLoading) {
23926 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components38.Spinner, {});
23927 }
23928 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
23929 ValidatedRadioControl,
23930 {
23931 required: !!field.isValid?.required,
23932 markWhenOptional,
23933 customValidity: getCustomValidity(isValid2, validity),
23934 label,
23935 help: description,
23936 onChange: onChangeControl,
23937 options: elements,
23938 selected: value,
23939 hideLabelFromVision,
23940 disabled: disabled2
23941 }
23942 );
23943 }
23944
23945 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23946 var import_element70 = __toESM(require_element(), 1);
23947 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
23948 function Text3({
23949 data,
23950 field,
23951 onChange,
23952 hideLabelFromVision,
23953 markWhenOptional,
23954 config,
23955 validity
23956 }) {
23957 const { prefix, suffix } = config || {};
23958 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
23959 ValidatedText,
23960 {
23961 ...{
23962 data,
23963 field,
23964 onChange,
23965 hideLabelFromVision,
23966 markWhenOptional,
23967 validity,
23968 prefix: prefix ? (0, import_element70.createElement)(prefix) : void 0,
23969 suffix: suffix ? (0, import_element70.createElement)(suffix) : void 0
23970 }
23971 }
23972 );
23973 }
23974
23975 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23976 var import_components39 = __toESM(require_components(), 1);
23977 var import_element71 = __toESM(require_element(), 1);
23978 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
23979 var { ValidatedToggleControl } = unlock2(import_components39.privateApis);
23980 function Toggle({
23981 field,
23982 onChange,
23983 data,
23984 hideLabelFromVision,
23985 markWhenOptional,
23986 validity
23987 }) {
23988 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23989 const disabled2 = field.isDisabled({ item: data, field });
23990 const onChangeControl = (0, import_element71.useCallback)(() => {
23991 onChange(
23992 setValue({ item: data, value: !getValue({ item: data }) })
23993 );
23994 }, [onChange, setValue, data, getValue]);
23995 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
23996 ValidatedToggleControl,
23997 {
23998 required: !!isValid2.required,
23999 markWhenOptional,
24000 customValidity: getCustomValidity(isValid2, validity),
24001 hidden: hideLabelFromVision,
24002 label,
24003 help: description,
24004 checked: getValue({ item: data }),
24005 onChange: onChangeControl,
24006 disabled: disabled2
24007 }
24008 );
24009 }
24010
24011 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24012 var import_components40 = __toESM(require_components(), 1);
24013 var import_element72 = __toESM(require_element(), 1);
24014 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24015 var { ValidatedTextareaControl } = unlock2(import_components40.privateApis);
24016 function Textarea({
24017 data,
24018 field,
24019 onChange,
24020 hideLabelFromVision,
24021 markWhenOptional,
24022 config,
24023 validity
24024 }) {
24025 const { rows = 4 } = config || {};
24026 const disabled2 = field.isDisabled({ item: data, field });
24027 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24028 const value = field.getValue({ item: data });
24029 const onChangeControl = (0, import_element72.useCallback)(
24030 (newValue) => onChange(setValue({ item: data, value: newValue })),
24031 [data, onChange, setValue]
24032 );
24033 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24034 ValidatedTextareaControl,
24035 {
24036 required: !!isValid2.required,
24037 markWhenOptional,
24038 customValidity: getCustomValidity(isValid2, validity),
24039 label,
24040 placeholder,
24041 value: value ?? "",
24042 help: description,
24043 onChange: onChangeControl,
24044 rows,
24045 disabled: disabled2,
24046 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24047 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24048 __next40pxDefaultSize: true,
24049 hideLabelFromVision
24050 }
24051 );
24052 }
24053
24054 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24055 var import_components41 = __toESM(require_components(), 1);
24056 var import_element73 = __toESM(require_element(), 1);
24057 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24058 var { ValidatedToggleGroupControl } = unlock2(import_components41.privateApis);
24059 function ToggleGroup({
24060 data,
24061 field,
24062 onChange,
24063 hideLabelFromVision,
24064 markWhenOptional,
24065 validity
24066 }) {
24067 const { getValue, setValue, isValid: isValid2 } = field;
24068 const disabled2 = field.isDisabled({ item: data, field });
24069 const value = getValue({ item: data });
24070 const onChangeControl = (0, import_element73.useCallback)(
24071 (newValue) => onChange(setValue({ item: data, value: newValue })),
24072 [data, onChange, setValue]
24073 );
24074 const { elements, isLoading } = useElements({
24075 elements: field.elements,
24076 getElements: field.getElements
24077 });
24078 if (isLoading) {
24079 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components41.Spinner, {});
24080 }
24081 if (elements.length === 0) {
24082 return null;
24083 }
24084 const selectedOption = elements.find((el) => el.value === value);
24085 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24086 ValidatedToggleGroupControl,
24087 {
24088 required: !!field.isValid?.required,
24089 markWhenOptional,
24090 customValidity: getCustomValidity(isValid2, validity),
24091 __next40pxDefaultSize: true,
24092 isBlock: true,
24093 label: field.label,
24094 help: selectedOption?.description || field.description,
24095 onChange: onChangeControl,
24096 value,
24097 hideLabelFromVision,
24098 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24099 import_components41.__experimentalToggleGroupControlOption,
24100 {
24101 label: el.label,
24102 value: el.value,
24103 disabled: disabled2
24104 },
24105 el.value
24106 ))
24107 }
24108 );
24109 }
24110
24111 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24112 var import_components42 = __toESM(require_components(), 1);
24113 var import_element74 = __toESM(require_element(), 1);
24114 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24115 var { ValidatedFormTokenField } = unlock2(import_components42.privateApis);
24116 function ArrayControl({
24117 data,
24118 field,
24119 onChange,
24120 hideLabelFromVision,
24121 markWhenOptional,
24122 validity
24123 }) {
24124 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24125 const value = getValue({ item: data });
24126 const disabled2 = field.isDisabled({ item: data, field });
24127 const { elements, isLoading } = useElements({
24128 elements: field.elements,
24129 getElements: field.getElements
24130 });
24131 const arrayValueAsElements = (0, import_element74.useMemo)(
24132 () => Array.isArray(value) ? value.map((token) => {
24133 const element = elements?.find(
24134 (suggestion) => suggestion.value === token
24135 );
24136 return element || { value: token, label: token };
24137 }) : [],
24138 [value, elements]
24139 );
24140 const onChangeControl = (0, import_element74.useCallback)(
24141 (tokens) => {
24142 const valueTokens = tokens.map((token) => {
24143 if (typeof token === "object" && "value" in token) {
24144 return token.value;
24145 }
24146 return token;
24147 });
24148 onChange(setValue({ item: data, value: valueTokens }));
24149 },
24150 [onChange, setValue, data]
24151 );
24152 if (isLoading) {
24153 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components42.Spinner, {});
24154 }
24155 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24156 ValidatedFormTokenField,
24157 {
24158 required: !!isValid2?.required,
24159 markWhenOptional,
24160 customValidity: getCustomValidity(isValid2, validity),
24161 label: hideLabelFromVision ? void 0 : label,
24162 value: arrayValueAsElements,
24163 onChange: onChangeControl,
24164 placeholder,
24165 suggestions: elements?.map((element) => element.value),
24166 disabled: disabled2,
24167 __experimentalValidateInput: (token) => {
24168 if (field.isValid?.elements && elements) {
24169 return elements.some(
24170 (element) => element.value === token || element.label === token
24171 );
24172 }
24173 return true;
24174 },
24175 __experimentalExpandOnFocus: elements && elements.length > 0,
24176 help: description ?? (field.isValid?.elements ? "" : void 0),
24177 displayTransform: (token) => {
24178 if (typeof token === "object" && "label" in token) {
24179 return token.label;
24180 }
24181 if (typeof token === "string" && elements) {
24182 const element = elements.find(
24183 (el) => el.value === token
24184 );
24185 return element?.label || token;
24186 }
24187 return token;
24188 },
24189 __experimentalRenderItem: ({ item }) => {
24190 if (typeof item === "string" && elements) {
24191 const element = elements.find(
24192 (el) => el.value === item
24193 );
24194 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: element?.label || item });
24195 }
24196 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: item });
24197 }
24198 }
24199 );
24200 }
24201
24202 // node_modules/colord/index.mjs
24203 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24204 var t = function(r3) {
24205 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24206 };
24207 var n = function(r3, t2, n2) {
24208 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24209 };
24210 var e = function(r3, t2, n2) {
24211 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24212 };
24213 var u = function(r3) {
24214 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24215 };
24216 var a = function(r3) {
24217 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24218 };
24219 var o = function(r3) {
24220 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24221 };
24222 var i = /^#([0-9a-f]{3,8})$/i;
24223 var s = function(r3) {
24224 var t2 = r3.toString(16);
24225 return t2.length < 2 ? "0" + t2 : t2;
24226 };
24227 var h = function(r3) {
24228 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;
24229 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24230 };
24231 var b = function(r3) {
24232 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24233 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24234 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;
24235 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 };
24236 };
24237 var g = function(r3) {
24238 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24239 };
24240 var d = function(r3) {
24241 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24242 };
24243 var f = function(r3) {
24244 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 }));
24245 var t2, n2, e2;
24246 };
24247 var c = function(r3) {
24248 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 };
24249 var t2, n2, e2, u2;
24250 };
24251 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24252 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24253 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24254 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24255 var y = { string: [[function(r3) {
24256 var t2 = i.exec(r3);
24257 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;
24258 }, "hex"], [function(r3) {
24259 var t2 = v.exec(r3) || m.exec(r3);
24260 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;
24261 }, "rgb"], [function(t2) {
24262 var n2 = l.exec(t2) || p.exec(t2);
24263 if (!n2) return null;
24264 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) });
24265 return f(a2);
24266 }, "hsl"]], object: [[function(r3) {
24267 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24268 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24269 }, "rgb"], [function(r3) {
24270 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24271 if (!t(n2) || !t(e2) || !t(u2)) return null;
24272 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24273 return f(i2);
24274 }, "hsl"], [function(r3) {
24275 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24276 if (!t(n2) || !t(a2) || !t(o2)) return null;
24277 var h2 = (function(r4) {
24278 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24279 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24280 return b(h2);
24281 }, "hsv"]] };
24282 var N = function(r3, t2) {
24283 for (var n2 = 0; n2 < t2.length; n2++) {
24284 var e2 = t2[n2][0](r3);
24285 if (e2) return [e2, t2[n2][1]];
24286 }
24287 return [null, void 0];
24288 };
24289 var x = function(r3) {
24290 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24291 };
24292 var M = function(r3, t2) {
24293 var n2 = c(r3);
24294 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24295 };
24296 var H = function(r3) {
24297 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24298 };
24299 var $ = function(r3, t2) {
24300 var n2 = c(r3);
24301 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24302 };
24303 var j = (function() {
24304 function r3(r4) {
24305 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24306 }
24307 return r3.prototype.isValid = function() {
24308 return null !== this.parsed;
24309 }, r3.prototype.brightness = function() {
24310 return n(H(this.rgba), 2);
24311 }, r3.prototype.isDark = function() {
24312 return H(this.rgba) < 0.5;
24313 }, r3.prototype.isLight = function() {
24314 return H(this.rgba) >= 0.5;
24315 }, r3.prototype.toHex = function() {
24316 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;
24317 var r4, t2, e2, u2, a2, i2;
24318 }, r3.prototype.toRgb = function() {
24319 return o(this.rgba);
24320 }, r3.prototype.toRgbString = function() {
24321 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 + ")";
24322 var r4, t2, n2, e2, u2;
24323 }, r3.prototype.toHsl = function() {
24324 return d(c(this.rgba));
24325 }, r3.prototype.toHslString = function() {
24326 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 + "%)";
24327 var r4, t2, n2, e2, u2;
24328 }, r3.prototype.toHsv = function() {
24329 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24330 var r4;
24331 }, r3.prototype.invert = function() {
24332 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24333 var r4;
24334 }, r3.prototype.saturate = function(r4) {
24335 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24336 }, r3.prototype.desaturate = function(r4) {
24337 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24338 }, r3.prototype.grayscale = function() {
24339 return w(M(this.rgba, -1));
24340 }, r3.prototype.lighten = function(r4) {
24341 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24342 }, r3.prototype.darken = function(r4) {
24343 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24344 }, r3.prototype.rotate = function(r4) {
24345 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24346 }, r3.prototype.alpha = function(r4) {
24347 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24348 var t2;
24349 }, r3.prototype.hue = function(r4) {
24350 var t2 = c(this.rgba);
24351 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24352 }, r3.prototype.isEqual = function(r4) {
24353 return this.toHex() === w(r4).toHex();
24354 }, r3;
24355 })();
24356 var w = function(r3) {
24357 return r3 instanceof j ? r3 : new j(r3);
24358 };
24359
24360 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24361 var import_components43 = __toESM(require_components(), 1);
24362 var import_element75 = __toESM(require_element(), 1);
24363 var import_i18n36 = __toESM(require_i18n(), 1);
24364 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24365 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components43.privateApis);
24366 var ColorPickerDropdown = ({
24367 color,
24368 onColorChange,
24369 disabled: disabled2
24370 }) => {
24371 const validColor = color && w(color).isValid() ? color : "#ffffff";
24372 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24373 import_components43.Dropdown,
24374 {
24375 className: "dataviews-controls__color-picker-dropdown",
24376 popoverProps: { resize: false },
24377 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24378 import_components43.Button,
24379 {
24380 onClick: onToggle,
24381 "aria-label": (0, import_i18n36.__)("Open color picker"),
24382 size: "small",
24383 disabled: disabled2,
24384 accessibleWhenDisabled: true,
24385 icon: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
24386 }
24387 ),
24388 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24389 import_components43.ColorPicker,
24390 {
24391 color: validColor,
24392 onChange: onColorChange,
24393 enableAlpha: true
24394 }
24395 ) })
24396 }
24397 );
24398 };
24399 function Color({
24400 data,
24401 field,
24402 onChange,
24403 hideLabelFromVision,
24404 markWhenOptional,
24405 validity
24406 }) {
24407 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24408 const disabled2 = field.isDisabled({ item: data, field });
24409 const value = field.getValue({ item: data }) || "";
24410 const handleColorChange = (0, import_element75.useCallback)(
24411 (newColor) => {
24412 onChange(setValue({ item: data, value: newColor }));
24413 },
24414 [data, onChange, setValue]
24415 );
24416 const handleInputChange = (0, import_element75.useCallback)(
24417 (newValue) => {
24418 onChange(setValue({ item: data, value: newValue || "" }));
24419 },
24420 [data, onChange, setValue]
24421 );
24422 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24423 ValidatedInputControl3,
24424 {
24425 required: !!field.isValid?.required,
24426 markWhenOptional,
24427 customValidity: getCustomValidity(isValid2, validity),
24428 label,
24429 placeholder,
24430 value,
24431 help: description,
24432 onChange: handleInputChange,
24433 hideLabelFromVision,
24434 type: "text",
24435 disabled: disabled2,
24436 prefix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24437 ColorPickerDropdown,
24438 {
24439 color: value,
24440 onColorChange: handleColorChange,
24441 disabled: disabled2
24442 }
24443 ) })
24444 }
24445 );
24446 }
24447
24448 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24449 var import_components44 = __toESM(require_components(), 1);
24450 var import_element76 = __toESM(require_element(), 1);
24451 var import_i18n37 = __toESM(require_i18n(), 1);
24452 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24453 function Password({
24454 data,
24455 field,
24456 onChange,
24457 hideLabelFromVision,
24458 markWhenOptional,
24459 validity
24460 }) {
24461 const [isVisible2, setIsVisible] = (0, import_element76.useState)(false);
24462 const disabled2 = field.isDisabled({ item: data, field });
24463 const toggleVisibility = (0, import_element76.useCallback)(() => {
24464 setIsVisible((prev) => !prev);
24465 }, []);
24466 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24467 ValidatedText,
24468 {
24469 ...{
24470 data,
24471 field,
24472 onChange,
24473 hideLabelFromVision,
24474 markWhenOptional,
24475 validity,
24476 type: isVisible2 ? "text" : "password",
24477 suffix: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24478 import_components44.Button,
24479 {
24480 icon: isVisible2 ? unseen_default : seen_default,
24481 onClick: toggleVisibility,
24482 size: "small",
24483 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
24484 disabled: disabled2,
24485 accessibleWhenDisabled: true
24486 }
24487 ) })
24488 }
24489 }
24490 );
24491 }
24492
24493 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24494 function hasElements(field) {
24495 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24496 }
24497
24498 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24499 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24500 var FORM_CONTROLS = {
24501 adaptiveSelect: AdaptiveSelect,
24502 array: ArrayControl,
24503 checkbox: Checkbox,
24504 color: Color,
24505 combobox: Combobox3,
24506 datetime: DateTime,
24507 date: DateControl,
24508 email: Email,
24509 telephone: Telephone,
24510 url: Url,
24511 integer: Integer,
24512 number: Number2,
24513 password: Password,
24514 radio: Radio,
24515 select: Select,
24516 text: Text3,
24517 toggle: Toggle,
24518 textarea: Textarea,
24519 toggleGroup: ToggleGroup
24520 };
24521 function isEditConfig(value) {
24522 return value && typeof value === "object" && typeof value.control === "string";
24523 }
24524 function createConfiguredControl(config) {
24525 const { control, ...controlConfig } = config;
24526 const BaseControlType = getControlByType(control);
24527 if (BaseControlType === null) {
24528 return null;
24529 }
24530 return function ConfiguredControl(props) {
24531 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(BaseControlType, { ...props, config: controlConfig });
24532 };
24533 }
24534 function getControl(field, fallback) {
24535 if (typeof field.Edit === "function") {
24536 return field.Edit;
24537 }
24538 if (typeof field.Edit === "string") {
24539 return getControlByType(field.Edit);
24540 }
24541 if (isEditConfig(field.Edit)) {
24542 return createConfiguredControl(field.Edit);
24543 }
24544 if (hasElements(field) && field.type !== "array") {
24545 return getControlByType("adaptiveSelect");
24546 }
24547 if (fallback === null) {
24548 return null;
24549 }
24550 return getControlByType(fallback);
24551 }
24552 function getControlByType(type) {
24553 if (Object.keys(FORM_CONTROLS).includes(type)) {
24554 return FORM_CONTROLS[type];
24555 }
24556 return null;
24557 }
24558
24559 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24560 function getFilterBy(field, defaultOperators, validOperators) {
24561 if (field.filterBy === false) {
24562 return false;
24563 }
24564 const operators = field.filterBy?.operators?.filter(
24565 (op) => validOperators.includes(op)
24566 ) ?? defaultOperators;
24567 if (operators.length === 0) {
24568 return false;
24569 }
24570 return {
24571 isPrimary: !!field.filterBy?.isPrimary,
24572 operators
24573 };
24574 }
24575 var get_filter_by_default = getFilterBy;
24576
24577 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24578 var getValueFromId = (id) => ({ item }) => {
24579 const path = id.split(".");
24580 let value = item;
24581 for (const segment of path) {
24582 if (value.hasOwnProperty(segment)) {
24583 value = value[segment];
24584 } else {
24585 value = void 0;
24586 }
24587 }
24588 return value;
24589 };
24590 var get_value_from_id_default = getValueFromId;
24591
24592 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24593 var setValueFromId = (id) => ({ value }) => {
24594 const path = id.split(".");
24595 const result = {};
24596 let current = result;
24597 for (const segment of path.slice(0, -1)) {
24598 current[segment] = {};
24599 current = current[segment];
24600 }
24601 current[path.at(-1)] = value;
24602 return result;
24603 };
24604 var set_value_from_id_default = setValueFromId;
24605
24606 // packages/dataviews/build-module/field-types/email.mjs
24607 var import_i18n38 = __toESM(require_i18n(), 1);
24608
24609 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24610 function RenderFromElements({
24611 item,
24612 field
24613 }) {
24614 const { elements, isLoading } = useElements({
24615 elements: field.elements,
24616 getElements: field.getElements
24617 });
24618 const value = field.getValue({ item });
24619 if (isLoading) {
24620 return value;
24621 }
24622 if (elements.length === 0) {
24623 return value;
24624 }
24625 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24626 }
24627
24628 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24629 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
24630 function render({
24631 item,
24632 field
24633 }) {
24634 if (field.hasElements) {
24635 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(RenderFromElements, { item, field });
24636 }
24637 return field.getValueFormatted({ item, field });
24638 }
24639
24640 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24641 var sort_text_default = (a2, b2, direction) => {
24642 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24643 };
24644
24645 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24646 function isValidRequired(item, field) {
24647 const value = field.getValue({ item });
24648 return ![void 0, "", null].includes(value);
24649 }
24650
24651 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24652 function isValidMinLength(item, field) {
24653 if (typeof field.isValid.minLength?.constraint !== "number") {
24654 return false;
24655 }
24656 const value = field.getValue({ item });
24657 if ([void 0, "", null].includes(value)) {
24658 return true;
24659 }
24660 return String(value).length >= field.isValid.minLength.constraint;
24661 }
24662
24663 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24664 function isValidMaxLength(item, field) {
24665 if (typeof field.isValid.maxLength?.constraint !== "number") {
24666 return false;
24667 }
24668 const value = field.getValue({ item });
24669 if ([void 0, "", null].includes(value)) {
24670 return true;
24671 }
24672 return String(value).length <= field.isValid.maxLength.constraint;
24673 }
24674
24675 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24676 function isValidPattern(item, field) {
24677 if (field.isValid.pattern?.constraint === void 0) {
24678 return true;
24679 }
24680 try {
24681 const regexp = new RegExp(field.isValid.pattern.constraint);
24682 const value = field.getValue({ item });
24683 if ([void 0, "", null].includes(value)) {
24684 return true;
24685 }
24686 return regexp.test(String(value));
24687 } catch {
24688 return false;
24689 }
24690 }
24691
24692 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24693 function isValidElements(item, field) {
24694 const elements = field.elements ?? [];
24695 const validValues = elements.map((el) => el.value);
24696 if (validValues.length === 0) {
24697 return true;
24698 }
24699 const value = field.getValue({ item });
24700 return [].concat(value).every((v2) => validValues.includes(v2));
24701 }
24702
24703 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24704 function getValueFormatted({
24705 item,
24706 field
24707 }) {
24708 return field.getValue({ item });
24709 }
24710 var get_value_formatted_default_default = getValueFormatted;
24711
24712 // packages/dataviews/build-module/field-types/email.mjs
24713 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])?)*$/;
24714 function isValidCustom(item, field) {
24715 const value = field.getValue({ item });
24716 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24717 return (0, import_i18n38.__)("Value must be a valid email address.");
24718 }
24719 return null;
24720 }
24721 var email_default = {
24722 type: "email",
24723 render,
24724 Edit: "email",
24725 sort: sort_text_default,
24726 enableSorting: true,
24727 enableGlobalSearch: false,
24728 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24729 validOperators: [
24730 OPERATOR_IS,
24731 OPERATOR_IS_NOT,
24732 OPERATOR_CONTAINS,
24733 OPERATOR_NOT_CONTAINS,
24734 OPERATOR_STARTS_WITH,
24735 // Multiple selection
24736 OPERATOR_IS_ANY,
24737 OPERATOR_IS_NONE,
24738 OPERATOR_IS_ALL,
24739 OPERATOR_IS_NOT_ALL
24740 ],
24741 format: {},
24742 getValueFormatted: get_value_formatted_default_default,
24743 validate: {
24744 required: isValidRequired,
24745 pattern: isValidPattern,
24746 minLength: isValidMinLength,
24747 maxLength: isValidMaxLength,
24748 elements: isValidElements,
24749 custom: isValidCustom
24750 }
24751 };
24752
24753 // packages/dataviews/build-module/field-types/integer.mjs
24754 var import_i18n39 = __toESM(require_i18n(), 1);
24755
24756 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24757 var sort_number_default = (a2, b2, direction) => {
24758 return direction === "asc" ? a2 - b2 : b2 - a2;
24759 };
24760
24761 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24762 function isValidMin(item, field) {
24763 if (typeof field.isValid.min?.constraint !== "number") {
24764 return false;
24765 }
24766 const value = field.getValue({ item });
24767 if ([void 0, "", null].includes(value)) {
24768 return true;
24769 }
24770 return Number(value) >= field.isValid.min.constraint;
24771 }
24772
24773 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24774 function isValidMax(item, field) {
24775 if (typeof field.isValid.max?.constraint !== "number") {
24776 return false;
24777 }
24778 const value = field.getValue({ item });
24779 if ([void 0, "", null].includes(value)) {
24780 return true;
24781 }
24782 return Number(value) <= field.isValid.max.constraint;
24783 }
24784
24785 // packages/dataviews/build-module/field-types/integer.mjs
24786 var format2 = {
24787 separatorThousand: ","
24788 };
24789 function getValueFormatted2({
24790 item,
24791 field
24792 }) {
24793 let value = field.getValue({ item });
24794 if (value === null || value === void 0) {
24795 return "";
24796 }
24797 value = Number(value);
24798 if (!Number.isFinite(value)) {
24799 return String(value);
24800 }
24801 let formatInteger;
24802 if (field.type !== "integer") {
24803 formatInteger = format2;
24804 } else {
24805 formatInteger = field.format;
24806 }
24807 const { separatorThousand } = formatInteger;
24808 const integerValue = Math.trunc(value);
24809 if (!separatorThousand) {
24810 return String(integerValue);
24811 }
24812 return String(integerValue).replace(
24813 /\B(?=(\d{3})+(?!\d))/g,
24814 separatorThousand
24815 );
24816 }
24817 function isValidCustom2(item, field) {
24818 const value = field.getValue({ item });
24819 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24820 return (0, import_i18n39.__)("Value must be an integer.");
24821 }
24822 return null;
24823 }
24824 var integer_default = {
24825 type: "integer",
24826 render,
24827 Edit: "integer",
24828 sort: sort_number_default,
24829 enableSorting: true,
24830 enableGlobalSearch: false,
24831 defaultOperators: [
24832 OPERATOR_IS,
24833 OPERATOR_IS_NOT,
24834 OPERATOR_LESS_THAN,
24835 OPERATOR_GREATER_THAN,
24836 OPERATOR_LESS_THAN_OR_EQUAL,
24837 OPERATOR_GREATER_THAN_OR_EQUAL,
24838 OPERATOR_BETWEEN
24839 ],
24840 validOperators: [
24841 // Single-selection
24842 OPERATOR_IS,
24843 OPERATOR_IS_NOT,
24844 OPERATOR_LESS_THAN,
24845 OPERATOR_GREATER_THAN,
24846 OPERATOR_LESS_THAN_OR_EQUAL,
24847 OPERATOR_GREATER_THAN_OR_EQUAL,
24848 OPERATOR_BETWEEN,
24849 // Multiple-selection
24850 OPERATOR_IS_ANY,
24851 OPERATOR_IS_NONE,
24852 OPERATOR_IS_ALL,
24853 OPERATOR_IS_NOT_ALL
24854 ],
24855 format: format2,
24856 getValueFormatted: getValueFormatted2,
24857 validate: {
24858 required: isValidRequired,
24859 min: isValidMin,
24860 max: isValidMax,
24861 elements: isValidElements,
24862 custom: isValidCustom2
24863 }
24864 };
24865
24866 // packages/dataviews/build-module/field-types/number.mjs
24867 var import_i18n40 = __toESM(require_i18n(), 1);
24868 var format3 = {
24869 separatorThousand: ",",
24870 separatorDecimal: ".",
24871 decimals: 2
24872 };
24873 function getValueFormatted3({
24874 item,
24875 field
24876 }) {
24877 let value = field.getValue({ item });
24878 if (value === null || value === void 0) {
24879 return "";
24880 }
24881 value = Number(value);
24882 if (!Number.isFinite(value)) {
24883 return String(value);
24884 }
24885 let formatNumber;
24886 if (field.type !== "number") {
24887 formatNumber = format3;
24888 } else {
24889 formatNumber = field.format;
24890 }
24891 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24892 const fixedValue = value.toFixed(decimals);
24893 const [integerPart, decimalPart] = fixedValue.split(".");
24894 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24895 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24896 }
24897 function isEmpty2(value) {
24898 return value === "" || value === void 0 || value === null;
24899 }
24900 function isValidCustom3(item, field) {
24901 const value = field.getValue({ item });
24902 if (!isEmpty2(value) && !Number.isFinite(value)) {
24903 return (0, import_i18n40.__)("Value must be a number.");
24904 }
24905 return null;
24906 }
24907 var number_default = {
24908 type: "number",
24909 render,
24910 Edit: "number",
24911 sort: sort_number_default,
24912 enableSorting: true,
24913 enableGlobalSearch: false,
24914 defaultOperators: [
24915 OPERATOR_IS,
24916 OPERATOR_IS_NOT,
24917 OPERATOR_LESS_THAN,
24918 OPERATOR_GREATER_THAN,
24919 OPERATOR_LESS_THAN_OR_EQUAL,
24920 OPERATOR_GREATER_THAN_OR_EQUAL,
24921 OPERATOR_BETWEEN
24922 ],
24923 validOperators: [
24924 // Single-selection
24925 OPERATOR_IS,
24926 OPERATOR_IS_NOT,
24927 OPERATOR_LESS_THAN,
24928 OPERATOR_GREATER_THAN,
24929 OPERATOR_LESS_THAN_OR_EQUAL,
24930 OPERATOR_GREATER_THAN_OR_EQUAL,
24931 OPERATOR_BETWEEN,
24932 // Multiple-selection
24933 OPERATOR_IS_ANY,
24934 OPERATOR_IS_NONE,
24935 OPERATOR_IS_ALL,
24936 OPERATOR_IS_NOT_ALL
24937 ],
24938 format: format3,
24939 getValueFormatted: getValueFormatted3,
24940 validate: {
24941 required: isValidRequired,
24942 min: isValidMin,
24943 max: isValidMax,
24944 elements: isValidElements,
24945 custom: isValidCustom3
24946 }
24947 };
24948
24949 // packages/dataviews/build-module/field-types/text.mjs
24950 var text_default = {
24951 type: "text",
24952 render,
24953 Edit: "text",
24954 sort: sort_text_default,
24955 enableSorting: true,
24956 enableGlobalSearch: false,
24957 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24958 validOperators: [
24959 // Single selection
24960 OPERATOR_IS,
24961 OPERATOR_IS_NOT,
24962 OPERATOR_CONTAINS,
24963 OPERATOR_NOT_CONTAINS,
24964 OPERATOR_STARTS_WITH,
24965 // Multiple selection
24966 OPERATOR_IS_ANY,
24967 OPERATOR_IS_NONE,
24968 OPERATOR_IS_ALL,
24969 OPERATOR_IS_NOT_ALL
24970 ],
24971 format: {},
24972 getValueFormatted: get_value_formatted_default_default,
24973 validate: {
24974 required: isValidRequired,
24975 pattern: isValidPattern,
24976 minLength: isValidMinLength,
24977 maxLength: isValidMaxLength,
24978 elements: isValidElements
24979 }
24980 };
24981
24982 // packages/dataviews/build-module/field-types/datetime.mjs
24983 var import_date7 = __toESM(require_date(), 1);
24984
24985 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24986 var import_date6 = __toESM(require_date(), 1);
24987 function parseDateLike(value) {
24988 if (!value) {
24989 return null;
24990 }
24991 if (!isValid(new Date(value))) {
24992 return null;
24993 }
24994 const parsed = (0, import_date6.getDate)(value);
24995 return parsed && isValid(parsed) ? parsed : null;
24996 }
24997 function validateDateLikeBoundary(item, field, boundary) {
24998 const constraint = field.isValid[boundary]?.constraint;
24999 if (typeof constraint !== "string") {
25000 return false;
25001 }
25002 const value = field.getValue({ item });
25003 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25004 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25005 return true;
25006 }
25007 const parsedConstraint = parseDateLike(constraint);
25008 const parsedValue = parseDateLike(String(boundaryValue));
25009 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25010 }
25011 function isValidMinDate(item, field) {
25012 return validateDateLikeBoundary(item, field, "min");
25013 }
25014 function isValidMaxDate(item, field) {
25015 return validateDateLikeBoundary(item, field, "max");
25016 }
25017
25018 // packages/dataviews/build-module/field-types/datetime.mjs
25019 var format4 = {
25020 datetime: (0, import_date7.getSettings)().formats.datetime,
25021 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25022 };
25023 function getValueFormatted4({
25024 item,
25025 field
25026 }) {
25027 const value = field.getValue({ item });
25028 if (["", void 0, null].includes(value)) {
25029 return "";
25030 }
25031 let formatDatetime;
25032 if (field.type !== "datetime") {
25033 formatDatetime = format4;
25034 } else {
25035 formatDatetime = field.format;
25036 }
25037 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25038 }
25039 var sort = (a2, b2, direction) => {
25040 const timeA = new Date(a2).getTime();
25041 const timeB = new Date(b2).getTime();
25042 return direction === "asc" ? timeA - timeB : timeB - timeA;
25043 };
25044 var datetime_default = {
25045 type: "datetime",
25046 render,
25047 Edit: "datetime",
25048 sort,
25049 enableSorting: true,
25050 enableGlobalSearch: false,
25051 defaultOperators: [
25052 OPERATOR_ON,
25053 OPERATOR_NOT_ON,
25054 OPERATOR_BEFORE,
25055 OPERATOR_AFTER,
25056 OPERATOR_BEFORE_INC,
25057 OPERATOR_AFTER_INC,
25058 OPERATOR_IN_THE_PAST,
25059 OPERATOR_OVER
25060 ],
25061 validOperators: [
25062 OPERATOR_ON,
25063 OPERATOR_NOT_ON,
25064 OPERATOR_BEFORE,
25065 OPERATOR_AFTER,
25066 OPERATOR_BEFORE_INC,
25067 OPERATOR_AFTER_INC,
25068 OPERATOR_IN_THE_PAST,
25069 OPERATOR_OVER
25070 ],
25071 format: format4,
25072 getValueFormatted: getValueFormatted4,
25073 validate: {
25074 required: isValidRequired,
25075 elements: isValidElements,
25076 min: isValidMinDate,
25077 max: isValidMaxDate
25078 }
25079 };
25080
25081 // packages/dataviews/build-module/field-types/date.mjs
25082 var import_date8 = __toESM(require_date(), 1);
25083 var format5 = {
25084 date: (0, import_date8.getSettings)().formats.date,
25085 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25086 };
25087 function getValueFormatted5({
25088 item,
25089 field
25090 }) {
25091 const value = field.getValue({ item });
25092 if (["", void 0, null].includes(value)) {
25093 return "";
25094 }
25095 let formatDate2;
25096 if (field.type !== "date") {
25097 formatDate2 = format5;
25098 } else {
25099 formatDate2 = field.format;
25100 }
25101 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25102 }
25103 var sort2 = (a2, b2, direction) => {
25104 const timeA = new Date(a2).getTime();
25105 const timeB = new Date(b2).getTime();
25106 return direction === "asc" ? timeA - timeB : timeB - timeA;
25107 };
25108 var date_default = {
25109 type: "date",
25110 render,
25111 Edit: "date",
25112 sort: sort2,
25113 enableSorting: true,
25114 enableGlobalSearch: false,
25115 defaultOperators: [
25116 OPERATOR_ON,
25117 OPERATOR_NOT_ON,
25118 OPERATOR_BEFORE,
25119 OPERATOR_AFTER,
25120 OPERATOR_BEFORE_INC,
25121 OPERATOR_AFTER_INC,
25122 OPERATOR_IN_THE_PAST,
25123 OPERATOR_OVER,
25124 OPERATOR_BETWEEN
25125 ],
25126 validOperators: [
25127 OPERATOR_ON,
25128 OPERATOR_NOT_ON,
25129 OPERATOR_BEFORE,
25130 OPERATOR_AFTER,
25131 OPERATOR_BEFORE_INC,
25132 OPERATOR_AFTER_INC,
25133 OPERATOR_IN_THE_PAST,
25134 OPERATOR_OVER,
25135 OPERATOR_BETWEEN
25136 ],
25137 format: format5,
25138 getValueFormatted: getValueFormatted5,
25139 validate: {
25140 required: isValidRequired,
25141 elements: isValidElements,
25142 min: isValidMinDate,
25143 max: isValidMaxDate
25144 }
25145 };
25146
25147 // packages/dataviews/build-module/field-types/boolean.mjs
25148 var import_i18n41 = __toESM(require_i18n(), 1);
25149
25150 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25151 function isValidRequiredForBool(item, field) {
25152 const value = field.getValue({ item });
25153 return value === true;
25154 }
25155
25156 // packages/dataviews/build-module/field-types/boolean.mjs
25157 function getValueFormatted6({
25158 item,
25159 field
25160 }) {
25161 const value = field.getValue({ item });
25162 if (value === true) {
25163 return (0, import_i18n41.__)("True");
25164 }
25165 if (value === false) {
25166 return (0, import_i18n41.__)("False");
25167 }
25168 return "";
25169 }
25170 function isValidCustom4(item, field) {
25171 const value = field.getValue({ item });
25172 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25173 return (0, import_i18n41.__)("Value must be true, false, or undefined");
25174 }
25175 return null;
25176 }
25177 var sort3 = (a2, b2, direction) => {
25178 const boolA = Boolean(a2);
25179 const boolB = Boolean(b2);
25180 if (boolA === boolB) {
25181 return 0;
25182 }
25183 if (direction === "asc") {
25184 return boolA ? 1 : -1;
25185 }
25186 return boolA ? -1 : 1;
25187 };
25188 var boolean_default = {
25189 type: "boolean",
25190 render,
25191 Edit: "checkbox",
25192 sort: sort3,
25193 validate: {
25194 required: isValidRequiredForBool,
25195 elements: isValidElements,
25196 custom: isValidCustom4
25197 },
25198 enableSorting: true,
25199 enableGlobalSearch: false,
25200 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25201 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25202 format: {},
25203 getValueFormatted: getValueFormatted6
25204 };
25205
25206 // packages/dataviews/build-module/field-types/media.mjs
25207 var media_default = {
25208 type: "media",
25209 render: () => null,
25210 Edit: null,
25211 sort: () => 0,
25212 enableSorting: false,
25213 enableGlobalSearch: false,
25214 defaultOperators: [],
25215 validOperators: [],
25216 format: {},
25217 getValueFormatted: get_value_formatted_default_default,
25218 // cannot validate any constraint, so
25219 // the only available validation for the field author
25220 // would be providing a custom validator.
25221 validate: {}
25222 };
25223
25224 // packages/dataviews/build-module/field-types/array.mjs
25225 var import_i18n42 = __toESM(require_i18n(), 1);
25226
25227 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25228 function isValidRequiredForArray(item, field) {
25229 const value = field.getValue({ item });
25230 return Array.isArray(value) && value.length > 0 && value.every(
25231 (element) => ![void 0, "", null].includes(element)
25232 );
25233 }
25234
25235 // packages/dataviews/build-module/field-types/array.mjs
25236 function getValueFormatted7({
25237 item,
25238 field
25239 }) {
25240 const value = field.getValue({ item });
25241 const arr = Array.isArray(value) ? value : [];
25242 return arr.join(", ");
25243 }
25244 function render2({ item, field }) {
25245 return getValueFormatted7({ item, field });
25246 }
25247 function isValidCustom5(item, field) {
25248 const value = field.getValue({ item });
25249 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25250 return (0, import_i18n42.__)("Value must be an array.");
25251 }
25252 if (!value.every((v2) => typeof v2 === "string")) {
25253 return (0, import_i18n42.__)("Every value must be a string.");
25254 }
25255 return null;
25256 }
25257 var sort4 = (a2, b2, direction) => {
25258 const arrA = Array.isArray(a2) ? a2 : [];
25259 const arrB = Array.isArray(b2) ? b2 : [];
25260 if (arrA.length !== arrB.length) {
25261 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25262 }
25263 const joinedA = arrA.join(",");
25264 const joinedB = arrB.join(",");
25265 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25266 };
25267 var array_default = {
25268 type: "array",
25269 render: render2,
25270 Edit: "array",
25271 sort: sort4,
25272 enableSorting: true,
25273 enableGlobalSearch: false,
25274 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25275 validOperators: [
25276 OPERATOR_IS_ANY,
25277 OPERATOR_IS_NONE,
25278 OPERATOR_IS_ALL,
25279 OPERATOR_IS_NOT_ALL
25280 ],
25281 format: {},
25282 getValueFormatted: getValueFormatted7,
25283 validate: {
25284 required: isValidRequiredForArray,
25285 elements: isValidElements,
25286 custom: isValidCustom5
25287 }
25288 };
25289
25290 // packages/dataviews/build-module/field-types/password.mjs
25291 function getValueFormatted8({
25292 item,
25293 field
25294 }) {
25295 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25296 }
25297 var password_default = {
25298 type: "password",
25299 render,
25300 Edit: "password",
25301 sort: () => 0,
25302 // Passwords should not be sortable for security reasons
25303 enableSorting: false,
25304 enableGlobalSearch: false,
25305 defaultOperators: [],
25306 validOperators: [],
25307 format: {},
25308 getValueFormatted: getValueFormatted8,
25309 validate: {
25310 required: isValidRequired,
25311 pattern: isValidPattern,
25312 minLength: isValidMinLength,
25313 maxLength: isValidMaxLength,
25314 elements: isValidElements
25315 }
25316 };
25317
25318 // packages/dataviews/build-module/field-types/telephone.mjs
25319 var telephone_default = {
25320 type: "telephone",
25321 render,
25322 Edit: "telephone",
25323 sort: sort_text_default,
25324 enableSorting: true,
25325 enableGlobalSearch: false,
25326 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25327 validOperators: [
25328 OPERATOR_IS,
25329 OPERATOR_IS_NOT,
25330 OPERATOR_CONTAINS,
25331 OPERATOR_NOT_CONTAINS,
25332 OPERATOR_STARTS_WITH,
25333 // Multiple selection
25334 OPERATOR_IS_ANY,
25335 OPERATOR_IS_NONE,
25336 OPERATOR_IS_ALL,
25337 OPERATOR_IS_NOT_ALL
25338 ],
25339 format: {},
25340 getValueFormatted: get_value_formatted_default_default,
25341 validate: {
25342 required: isValidRequired,
25343 pattern: isValidPattern,
25344 minLength: isValidMinLength,
25345 maxLength: isValidMaxLength,
25346 elements: isValidElements
25347 }
25348 };
25349
25350 // packages/dataviews/build-module/field-types/color.mjs
25351 var import_i18n43 = __toESM(require_i18n(), 1);
25352 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25353 function render3({ item, field }) {
25354 if (field.hasElements) {
25355 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(RenderFromElements, { item, field });
25356 }
25357 const value = get_value_formatted_default_default({ item, field });
25358 if (!value || !w(value).isValid()) {
25359 return value;
25360 }
25361 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25362 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25363 "div",
25364 {
25365 style: {
25366 width: "16px",
25367 height: "16px",
25368 borderRadius: "50%",
25369 backgroundColor: value,
25370 border: "1px solid #ddd",
25371 flexShrink: 0
25372 }
25373 }
25374 ),
25375 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { children: value })
25376 ] });
25377 }
25378 function isValidCustom6(item, field) {
25379 const value = field.getValue({ item });
25380 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25381 return (0, import_i18n43.__)("Value must be a valid color.");
25382 }
25383 return null;
25384 }
25385 var sort5 = (a2, b2, direction) => {
25386 const colorA = w(a2);
25387 const colorB = w(b2);
25388 if (!colorA.isValid() && !colorB.isValid()) {
25389 return 0;
25390 }
25391 if (!colorA.isValid()) {
25392 return direction === "asc" ? 1 : -1;
25393 }
25394 if (!colorB.isValid()) {
25395 return direction === "asc" ? -1 : 1;
25396 }
25397 const hslA = colorA.toHsl();
25398 const hslB = colorB.toHsl();
25399 if (hslA.h !== hslB.h) {
25400 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25401 }
25402 if (hslA.s !== hslB.s) {
25403 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25404 }
25405 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25406 };
25407 var color_default = {
25408 type: "color",
25409 render: render3,
25410 Edit: "color",
25411 sort: sort5,
25412 enableSorting: true,
25413 enableGlobalSearch: false,
25414 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25415 validOperators: [
25416 OPERATOR_IS,
25417 OPERATOR_IS_NOT,
25418 OPERATOR_IS_ANY,
25419 OPERATOR_IS_NONE
25420 ],
25421 format: {},
25422 getValueFormatted: get_value_formatted_default_default,
25423 validate: {
25424 required: isValidRequired,
25425 elements: isValidElements,
25426 custom: isValidCustom6
25427 }
25428 };
25429
25430 // packages/dataviews/build-module/field-types/url.mjs
25431 var url_default = {
25432 type: "url",
25433 render,
25434 Edit: "url",
25435 sort: sort_text_default,
25436 enableSorting: true,
25437 enableGlobalSearch: false,
25438 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25439 validOperators: [
25440 OPERATOR_IS,
25441 OPERATOR_IS_NOT,
25442 OPERATOR_CONTAINS,
25443 OPERATOR_NOT_CONTAINS,
25444 OPERATOR_STARTS_WITH,
25445 // Multiple selection
25446 OPERATOR_IS_ANY,
25447 OPERATOR_IS_NONE,
25448 OPERATOR_IS_ALL,
25449 OPERATOR_IS_NOT_ALL
25450 ],
25451 format: {},
25452 getValueFormatted: get_value_formatted_default_default,
25453 validate: {
25454 required: isValidRequired,
25455 pattern: isValidPattern,
25456 minLength: isValidMinLength,
25457 maxLength: isValidMaxLength,
25458 elements: isValidElements
25459 }
25460 };
25461
25462 // packages/dataviews/build-module/field-types/no-type.mjs
25463 var sort6 = (a2, b2, direction) => {
25464 if (typeof a2 === "number" && typeof b2 === "number") {
25465 return sort_number_default(a2, b2, direction);
25466 }
25467 return sort_text_default(a2, b2, direction);
25468 };
25469 var no_type_default = {
25470 // type: no type for this one
25471 render,
25472 Edit: null,
25473 sort: sort6,
25474 enableSorting: true,
25475 enableGlobalSearch: false,
25476 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25477 validOperators: getAllOperatorNames(),
25478 format: {},
25479 getValueFormatted: get_value_formatted_default_default,
25480 validate: {
25481 required: isValidRequired,
25482 elements: isValidElements
25483 }
25484 };
25485
25486 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25487 function supportsNumericRangeConstraint(type) {
25488 return type === "integer" || type === "number";
25489 }
25490 function supportsDateRangeConstraint(type) {
25491 return type === "date" || type === "datetime";
25492 }
25493 function normalizeRangeRule(value, fieldType, key) {
25494 const validator = fieldType.validate[key];
25495 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25496 return { constraint: value, validate: validator };
25497 }
25498 return void 0;
25499 }
25500 function getIsValid(field, fieldType) {
25501 const rules = field.isValid;
25502 let required;
25503 if (rules?.required === true && fieldType.validate.required !== void 0) {
25504 required = {
25505 constraint: true,
25506 validate: fieldType.validate.required
25507 };
25508 }
25509 let elements;
25510 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25511 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25512 elements = {
25513 constraint: true,
25514 validate: fieldType.validate.elements
25515 };
25516 }
25517 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25518 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25519 const minLengthValue = rules?.minLength;
25520 let minLength;
25521 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25522 minLength = {
25523 constraint: minLengthValue,
25524 validate: fieldType.validate.minLength
25525 };
25526 }
25527 const maxLengthValue = rules?.maxLength;
25528 let maxLength;
25529 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25530 maxLength = {
25531 constraint: maxLengthValue,
25532 validate: fieldType.validate.maxLength
25533 };
25534 }
25535 const patternValue = rules?.pattern;
25536 let pattern;
25537 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25538 pattern = {
25539 constraint: patternValue,
25540 validate: fieldType.validate.pattern
25541 };
25542 }
25543 const custom = rules?.custom ?? fieldType.validate.custom;
25544 return {
25545 required,
25546 elements,
25547 min: min2,
25548 max: max2,
25549 minLength,
25550 maxLength,
25551 pattern,
25552 custom
25553 };
25554 }
25555
25556 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25557 function getFilter(fieldType) {
25558 return fieldType.validOperators.reduce((accumulator, operator) => {
25559 const operatorObj = getOperatorByName(operator);
25560 if (operatorObj?.filter) {
25561 accumulator[operator] = operatorObj.filter;
25562 }
25563 return accumulator;
25564 }, {});
25565 }
25566
25567 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25568 function getFormat(field, fieldType) {
25569 return {
25570 ...fieldType.format,
25571 ...field.format
25572 };
25573 }
25574 var get_format_default = getFormat;
25575
25576 // packages/dataviews/build-module/field-types/index.mjs
25577 function getFieldTypeByName(type) {
25578 const found = [
25579 email_default,
25580 integer_default,
25581 number_default,
25582 text_default,
25583 datetime_default,
25584 date_default,
25585 boolean_default,
25586 media_default,
25587 array_default,
25588 password_default,
25589 telephone_default,
25590 color_default,
25591 url_default
25592 ].find((fieldType) => fieldType?.type === type);
25593 if (!!found) {
25594 return found;
25595 }
25596 return no_type_default;
25597 }
25598 function normalizeFields(fields) {
25599 return fields.map((field) => {
25600 const fieldType = getFieldTypeByName(field.type);
25601 const getValue = field.getValue || get_value_from_id_default(field.id);
25602 const sort7 = function(a2, b2, direction) {
25603 const aValue = getValue({ item: a2 });
25604 const bValue = getValue({ item: b2 });
25605 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25606 };
25607 return {
25608 id: field.id,
25609 label: field.label || field.id,
25610 header: field.header || field.label || field.id,
25611 description: field.description,
25612 placeholder: field.placeholder,
25613 getValue,
25614 setValue: field.setValue || set_value_from_id_default(field.id),
25615 elements: field.elements,
25616 getElements: field.getElements,
25617 hasElements: hasElements(field),
25618 isVisible: field.isVisible,
25619 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25620 enableHiding: field.enableHiding ?? true,
25621 readOnly: field.readOnly ?? false,
25622 // The type provides defaults for the following props
25623 type: fieldType.type,
25624 render: field.render ?? fieldType.render,
25625 Edit: getControl(field, fieldType.Edit),
25626 sort: sort7,
25627 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25628 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25629 isValid: getIsValid(field, fieldType),
25630 filterBy: get_filter_by_default(
25631 field,
25632 fieldType.defaultOperators,
25633 fieldType.validOperators
25634 ),
25635 filter: getFilter(fieldType),
25636 format: get_format_default(field, fieldType),
25637 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25638 };
25639 });
25640 }
25641
25642 // packages/dataviews/build-module/hooks/use-data.mjs
25643 var import_element77 = __toESM(require_element(), 1);
25644 function useData({
25645 view,
25646 data: shownData,
25647 getItemId,
25648 isLoading,
25649 paginationInfo,
25650 selection
25651 }) {
25652 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25653 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element77.useState)(
25654 !isLoading
25655 );
25656 (0, import_element77.useEffect)(() => {
25657 if (!isLoading) {
25658 setHasInitiallyLoaded(true);
25659 }
25660 }, [isLoading]);
25661 const previousDataRef = (0, import_element77.useRef)(shownData);
25662 const previousPaginationInfoRef = (0, import_element77.useRef)(paginationInfo);
25663 (0, import_element77.useEffect)(() => {
25664 if (!isLoading) {
25665 previousDataRef.current = shownData;
25666 previousPaginationInfoRef.current = paginationInfo;
25667 }
25668 }, [shownData, isLoading, paginationInfo]);
25669 const [visibleEntries, setVisibleEntries] = (0, import_element77.useState)([]);
25670 const positionMapRef = (0, import_element77.useRef)(/* @__PURE__ */ new Map());
25671 const allLoadedRecordsRef = (0, import_element77.useRef)([]);
25672 const prevViewParamsRef = (0, import_element77.useRef)({
25673 search: void 0,
25674 filters: void 0,
25675 perPage: void 0
25676 });
25677 const scrollDirectionRef = (0, import_element77.useRef)(void 0);
25678 const prevStartPositionRef = (0, import_element77.useRef)(void 0);
25679 const hasInitializedRef = (0, import_element77.useRef)(false);
25680 const allLoadedRecords = (0, import_element77.useMemo)(() => {
25681 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25682 if (view.startPosition < prevStartPositionRef.current) {
25683 scrollDirectionRef.current = "up";
25684 } else if (view.startPosition > prevStartPositionRef.current) {
25685 scrollDirectionRef.current = "down";
25686 }
25687 }
25688 prevStartPositionRef.current = view.startPosition;
25689 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25690 const prevFiltersKey = prevViewParamsRef.current.filters;
25691 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25692 hasInitializedRef.current = true;
25693 prevViewParamsRef.current = {
25694 search: view.search,
25695 filters: currentFiltersKey,
25696 perPage: view.perPage
25697 };
25698 if (shouldReset) {
25699 positionMapRef.current.clear();
25700 scrollDirectionRef.current = void 0;
25701 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25702 const records = shownData.map((record, index2) => {
25703 const position = startPosition + index2;
25704 positionMapRef.current.set(getItemId(record), position);
25705 return {
25706 ...record,
25707 position
25708 };
25709 });
25710 allLoadedRecordsRef.current = records;
25711 return records;
25712 }
25713 const prev = allLoadedRecordsRef.current;
25714 const shownDataIds = new Set(shownData.map(getItemId));
25715 const scrollDirection = scrollDirectionRef.current;
25716 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25717 const newRecords = shownData.map((record, index2) => {
25718 const itemId = getItemId(record);
25719 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25720 if (position !== void 0) {
25721 positionMapRef.current.set(itemId, position);
25722 }
25723 return {
25724 ...record,
25725 position
25726 };
25727 });
25728 if (newRecords.length === 0) {
25729 return prev;
25730 }
25731 const prevWithoutDuplicates = prev.filter(
25732 (record) => !shownDataIds.has(getItemId(record))
25733 );
25734 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25735 allRecords.sort((a2, b2) => {
25736 const posA = a2.position;
25737 const posB = b2.position;
25738 return posA - posB;
25739 });
25740 let result = allRecords;
25741 if (visibleEntries.length > 0) {
25742 const visibleMin = Math.min(...visibleEntries);
25743 const visibleMax = Math.max(...visibleEntries);
25744 const buffer = 20;
25745 const recordPositions = allRecords.map(
25746 (r3) => r3.position
25747 );
25748 const minRecordPos = Math.min(...recordPositions);
25749 const maxRecordPos = Math.max(...recordPositions);
25750 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25751 if (hasOverlap) {
25752 result = allRecords.filter((record) => {
25753 const itemId = getItemId(record);
25754 const isSelected2 = selection?.includes(itemId);
25755 if (isSelected2) {
25756 return true;
25757 }
25758 const itemPosition = record.position;
25759 if (scrollDirection === "up") {
25760 return itemPosition <= visibleMax + buffer;
25761 } else if (scrollDirection === "down") {
25762 return itemPosition >= visibleMin - buffer;
25763 }
25764 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25765 });
25766 }
25767 }
25768 allLoadedRecordsRef.current = result;
25769 return result;
25770 }, [
25771 shownData,
25772 view.search,
25773 view.filters,
25774 view.perPage,
25775 view.startPosition,
25776 view.infiniteScrollEnabled,
25777 visibleEntries,
25778 selection,
25779 getItemId
25780 ]);
25781 if (!isInfiniteScrollEnabled) {
25782 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25783 return {
25784 data: dataToReturn.map((item) => ({
25785 ...item,
25786 position: void 0
25787 })),
25788 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25789 hasInitiallyLoaded,
25790 setVisibleEntries: void 0
25791 };
25792 }
25793 return {
25794 data: allLoadedRecords,
25795 paginationInfo,
25796 hasInitiallyLoaded,
25797 setVisibleEntries
25798 };
25799 }
25800
25801 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25802 var import_element78 = __toESM(require_element(), 1);
25803 var import_compose11 = __toESM(require_compose(), 1);
25804 function captureAnchorElement(container, anchorElementRef, direction) {
25805 const containerRect = container.getBoundingClientRect();
25806 const centerY = containerRect.top + containerRect.height / 2;
25807 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25808 if (items.length === 0) {
25809 return false;
25810 }
25811 const bestAnchor = items.reduce((best, item) => {
25812 const itemRect = item.getBoundingClientRect();
25813 const itemCenterY = itemRect.top + itemRect.height / 2;
25814 const distance = Math.abs(itemCenterY - centerY);
25815 const bestRect = best.getBoundingClientRect();
25816 const bestCenterY = bestRect.top + bestRect.height / 2;
25817 const bestDistance = Math.abs(bestCenterY - centerY);
25818 return distance < bestDistance ? item : best;
25819 });
25820 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25821 const anchorRect = bestAnchor.getBoundingClientRect();
25822 anchorElementRef.current = {
25823 posinset,
25824 viewportOffset: anchorRect.top - containerRect.top,
25825 direction
25826 };
25827 return true;
25828 }
25829 function useInfiniteScroll({
25830 view,
25831 onChangeView,
25832 isLoading,
25833 paginationInfo,
25834 containerRef,
25835 setVisibleEntries
25836 }) {
25837 const anchorElementRef = (0, import_element78.useRef)(null);
25838 const viewRef = (0, import_element78.useRef)(view);
25839 const isLoadingRef = (0, import_element78.useRef)(isLoading);
25840 const onChangeViewRef = (0, import_element78.useRef)(onChangeView);
25841 const totalItemsRef = (0, import_element78.useRef)(paginationInfo.totalItems);
25842 (0, import_element78.useLayoutEffect)(() => {
25843 viewRef.current = view;
25844 isLoadingRef.current = isLoading;
25845 onChangeViewRef.current = onChangeView;
25846 totalItemsRef.current = paginationInfo.totalItems;
25847 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25848 const intersectionObserverCallback = (0, import_element78.useCallback)(
25849 (entries) => {
25850 if (!setVisibleEntries) {
25851 return;
25852 }
25853 setVisibleEntries((prev) => {
25854 const newVisibleEntries = new Set(prev);
25855 let hasChanged = false;
25856 entries.forEach((entry) => {
25857 const posInSet = Number(
25858 entry.target?.attributes?.getNamedItem(
25859 "aria-posinset"
25860 )?.value
25861 );
25862 if (isNaN(posInSet)) {
25863 return;
25864 }
25865 if (entry.isIntersecting) {
25866 if (!newVisibleEntries.has(posInSet)) {
25867 newVisibleEntries.add(posInSet);
25868 hasChanged = true;
25869 }
25870 } else if (newVisibleEntries.has(posInSet)) {
25871 newVisibleEntries.delete(posInSet);
25872 hasChanged = true;
25873 }
25874 });
25875 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25876 });
25877 },
25878 [setVisibleEntries]
25879 );
25880 (0, import_element78.useLayoutEffect)(() => {
25881 const container = containerRef.current;
25882 const anchor = anchorElementRef.current;
25883 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25884 return;
25885 }
25886 const anchorElement = container.querySelector(
25887 `[aria-posinset="${anchor.posinset}"]`
25888 );
25889 if (anchorElement) {
25890 const containerRect = container.getBoundingClientRect();
25891 const anchorRect = anchorElement.getBoundingClientRect();
25892 const currentOffset = anchorRect.top - containerRect.top;
25893 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25894 if (Math.abs(scrollAdjustment) > 1) {
25895 container.scrollTop += scrollAdjustment;
25896 }
25897 }
25898 anchorElementRef.current = null;
25899 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25900 const intersectionObserverRef = (0, import_element78.useRef)(
25901 null
25902 );
25903 (0, import_element78.useEffect)(() => {
25904 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25905 if (intersectionObserverRef.current) {
25906 intersectionObserverRef.current.disconnect();
25907 intersectionObserverRef.current = null;
25908 }
25909 return;
25910 }
25911 intersectionObserverRef.current = new IntersectionObserver(
25912 intersectionObserverCallback,
25913 { root: null, rootMargin: "0px", threshold: 0.1 }
25914 );
25915 return () => {
25916 if (intersectionObserverRef.current) {
25917 intersectionObserverRef.current.disconnect();
25918 intersectionObserverRef.current = null;
25919 }
25920 };
25921 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25922 (0, import_element78.useEffect)(() => {
25923 if (!view.infiniteScrollEnabled || !containerRef.current) {
25924 return;
25925 }
25926 let lastScrollTop = 0;
25927 const BOTTOM_THRESHOLD = 600;
25928 const TOP_THRESHOLD = 800;
25929 const handleScroll = (0, import_compose11.throttle)((event) => {
25930 const currentView = viewRef.current;
25931 const totalItems = totalItemsRef.current;
25932 const target = event.target;
25933 const scrollTop = target.scrollTop;
25934 const scrollHeight = target.scrollHeight;
25935 const clientHeight = target.clientHeight;
25936 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25937 lastScrollTop = scrollTop;
25938 if (isLoadingRef.current) {
25939 return;
25940 }
25941 const currentStartPosition = currentView.startPosition || 1;
25942 const batchSize = currentView.perPage || 10;
25943 const currentEndPosition = Math.min(
25944 currentStartPosition + batchSize,
25945 totalItems
25946 );
25947 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25948 if (currentEndPosition < totalItems) {
25949 const newStartPosition = currentEndPosition;
25950 captureAnchorElement(target, anchorElementRef, "down");
25951 onChangeViewRef.current({
25952 ...currentView,
25953 startPosition: newStartPosition
25954 });
25955 }
25956 }
25957 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25958 if (currentStartPosition > 1) {
25959 const calculatedStartPosition = currentStartPosition - batchSize;
25960 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25961 captureAnchorElement(target, anchorElementRef, "up");
25962 onChangeViewRef.current({
25963 ...currentView,
25964 startPosition: newStartPosition
25965 });
25966 }
25967 }
25968 }, 50);
25969 const container = containerRef.current;
25970 container.addEventListener("scroll", handleScroll);
25971 return () => {
25972 container.removeEventListener("scroll", handleScroll);
25973 handleScroll.cancel();
25974 };
25975 }, [containerRef, view.infiniteScrollEnabled]);
25976 return {
25977 intersectionObserver: intersectionObserverRef.current
25978 };
25979 }
25980
25981 // packages/dataviews/build-module/dataviews/index.mjs
25982 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25983 var defaultGetItemId = (item) => item.id;
25984 var defaultIsItemClickable = () => true;
25985 var EMPTY_ARRAY6 = [];
25986 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25987 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25988 (viewLayout) => !viewLayout.isPicker
25989 );
25990 function DefaultUI({
25991 header,
25992 search = true,
25993 searchLabel = void 0
25994 }) {
25995 const { view } = (0, import_element79.useContext)(dataviews_context_default);
25996 const isInfiniteScroll = view.infiniteScrollEnabled;
25997 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
25998 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
25999 Stack,
26000 {
26001 direction: "row",
26002 align: "top",
26003 justify: "space-between",
26004 className: clsx_default("dataviews__view-actions", {
26005 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26006 }),
26007 gap: "xs",
26008 children: [
26009 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
26010 Stack,
26011 {
26012 direction: "row",
26013 justify: "start",
26014 gap: "sm",
26015 className: "dataviews__search",
26016 children: [
26017 search && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_search_default, { label: searchLabel }),
26018 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(toggle_default, {})
26019 ]
26020 }
26021 ),
26022 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26023 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_view_config_default, {}),
26024 header
26025 ] })
26026 ]
26027 }
26028 ),
26029 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26030 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsLayout, {}),
26031 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsFooter, {})
26032 ] });
26033 }
26034 function DataViews({
26035 view,
26036 onChangeView,
26037 fields,
26038 search = true,
26039 searchLabel = void 0,
26040 actions = EMPTY_ARRAY6,
26041 data,
26042 getItemId = defaultGetItemId,
26043 getItemLevel,
26044 isLoading = false,
26045 paginationInfo,
26046 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26047 selection: selectionProperty,
26048 onChangeSelection,
26049 onClickItem,
26050 renderItemLink,
26051 isItemClickable = defaultIsItemClickable,
26052 header,
26053 children,
26054 config = { perPageSizes: [10, 20, 50, 100] },
26055 empty,
26056 onReset
26057 }) {
26058 const [selectionState, setSelectionState] = (0, import_element79.useState)([]);
26059 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26060 const selection = isUncontrolled ? selectionState : selectionProperty;
26061 const {
26062 data: displayData,
26063 paginationInfo: displayPaginationInfo,
26064 hasInitiallyLoaded,
26065 setVisibleEntries
26066 } = useData({
26067 view,
26068 data,
26069 getItemId,
26070 isLoading,
26071 selection,
26072 paginationInfo
26073 });
26074 const containerRef = (0, import_element79.useRef)(null);
26075 const [containerWidth, setContainerWidth] = (0, import_element79.useState)(0);
26076 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
26077 (resizeObserverEntries) => {
26078 setContainerWidth(
26079 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26080 );
26081 },
26082 { box: "border-box" }
26083 );
26084 const [openedFilter, setOpenedFilter] = (0, import_element79.useState)(null);
26085 function setSelectionWithChange(value) {
26086 const newValue = typeof value === "function" ? value(selection) : value;
26087 if (isUncontrolled) {
26088 setSelectionState(newValue);
26089 }
26090 if (onChangeSelection) {
26091 onChangeSelection(newValue);
26092 }
26093 }
26094 const _fields = (0, import_element79.useMemo)(() => normalizeFields(fields), [fields]);
26095 const _selection = (0, import_element79.useMemo)(() => {
26096 if (view.infiniteScrollEnabled) {
26097 return selection;
26098 }
26099 return selection.filter(
26100 (id) => data.some((item) => getItemId(item) === id)
26101 );
26102 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26103 const filters = use_filters_default(_fields, view);
26104 const hasPrimaryOrLockedFilters = (0, import_element79.useMemo)(
26105 () => (filters || []).some(
26106 (filter) => filter.isPrimary || filter.isLocked
26107 ),
26108 [filters]
26109 );
26110 const [isShowingFilter, setIsShowingFilter] = (0, import_element79.useState)(
26111 hasPrimaryOrLockedFilters
26112 );
26113 const { intersectionObserver } = useInfiniteScroll({
26114 view,
26115 onChangeView,
26116 isLoading,
26117 paginationInfo,
26118 containerRef,
26119 setVisibleEntries
26120 });
26121 (0, import_element79.useEffect)(() => {
26122 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26123 setIsShowingFilter(true);
26124 }
26125 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26126 const defaultLayouts = (0, import_element79.useMemo)(
26127 () => Object.fromEntries(
26128 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26129 return dataViewsLayouts.some(
26130 (viewLayout) => viewLayout.type === layoutType
26131 );
26132 }).map(([key, value]) => [
26133 key,
26134 value === true ? {} : value
26135 ])
26136 ),
26137 [defaultLayoutsProperty]
26138 );
26139 if (!defaultLayouts[view.type]) {
26140 return null;
26141 }
26142 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26143 dataviews_context_default.Provider,
26144 {
26145 value: {
26146 view,
26147 onChangeView,
26148 fields: _fields,
26149 actions,
26150 data: displayData,
26151 isLoading,
26152 paginationInfo: displayPaginationInfo,
26153 selection: _selection,
26154 onChangeSelection: setSelectionWithChange,
26155 openedFilter,
26156 setOpenedFilter,
26157 getItemId,
26158 getItemLevel,
26159 isItemClickable,
26160 onClickItem,
26161 renderItemLink,
26162 containerWidth,
26163 containerRef,
26164 resizeObserverRef,
26165 defaultLayouts,
26166 filters,
26167 isShowingFilter,
26168 setIsShowingFilter,
26169 config,
26170 empty,
26171 hasInitiallyLoaded,
26172 onReset,
26173 intersectionObserver
26174 },
26175 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26176 DefaultUI,
26177 {
26178 header,
26179 search,
26180 searchLabel
26181 }
26182 ) })
26183 }
26184 );
26185 }
26186 var DataViewsSubComponents = DataViews;
26187 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26188 DataViewsSubComponents.Filters = filters_default;
26189 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26190 DataViewsSubComponents.FiltersToggle = toggle_default;
26191 DataViewsSubComponents.Layout = DataViewsLayout;
26192 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26193 DataViewsSubComponents.Pagination = DataViewsPagination;
26194 DataViewsSubComponents.Search = dataviews_search_default;
26195 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26196 DataViewsSubComponents.Footer = DataViewsFooter;
26197 var dataviews_default = DataViewsSubComponents;
26198
26199 // widgets/news/components/news-list/news-list.tsx
26200 var import_date10 = __toESM(require_date());
26201 var import_element80 = __toESM(require_element());
26202 var import_html_entities = __toESM(require_html_entities());
26203 var import_i18n44 = __toESM(require_i18n());
26204
26205 // packages/style-runtime/src/index.ts
26206 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26207 function getRuntime14() {
26208 const globalScope = globalThis;
26209 if (globalScope.__wpStyleRuntime) {
26210 return globalScope.__wpStyleRuntime;
26211 }
26212 globalScope.__wpStyleRuntime = {
26213 documents: /* @__PURE__ */ new Map(),
26214 styles: /* @__PURE__ */ new Map(),
26215 injectedStyles: /* @__PURE__ */ new WeakMap()
26216 };
26217 if (typeof document !== "undefined") {
26218 registerDocument14(document);
26219 }
26220 return globalScope.__wpStyleRuntime;
26221 }
26222 function documentContainsStyleHash14(targetDocument, hash) {
26223 if (!targetDocument.head) {
26224 return false;
26225 }
26226 for (const style of targetDocument.head.querySelectorAll(
26227 `style[${STYLE_HASH_ATTRIBUTE14}]`
26228 )) {
26229 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26230 return true;
26231 }
26232 }
26233 return false;
26234 }
26235 function injectStyle14(targetDocument, hash, css) {
26236 if (!targetDocument.head) {
26237 return;
26238 }
26239 const runtime = getRuntime14();
26240 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26241 if (!injectedStyles) {
26242 injectedStyles = /* @__PURE__ */ new Set();
26243 runtime.injectedStyles.set(targetDocument, injectedStyles);
26244 }
26245 if (injectedStyles.has(hash)) {
26246 return;
26247 }
26248 if (documentContainsStyleHash14(targetDocument, hash)) {
26249 injectedStyles.add(hash);
26250 return;
26251 }
26252 const style = targetDocument.createElement("style");
26253 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26254 style.appendChild(targetDocument.createTextNode(css));
26255 targetDocument.head.appendChild(style);
26256 injectedStyles.add(hash);
26257 }
26258 function registerDocument14(targetDocument) {
26259 const runtime = getRuntime14();
26260 runtime.documents.set(
26261 targetDocument,
26262 (runtime.documents.get(targetDocument) ?? 0) + 1
26263 );
26264 for (const [hash, css] of runtime.styles) {
26265 injectStyle14(targetDocument, hash, css);
26266 }
26267 return () => {
26268 const count = runtime.documents.get(targetDocument);
26269 if (count === void 0) {
26270 return;
26271 }
26272 if (count <= 1) {
26273 runtime.documents.delete(targetDocument);
26274 return;
26275 }
26276 runtime.documents.set(targetDocument, count - 1);
26277 };
26278 }
26279 function registerStyle14(hash, css) {
26280 const runtime = getRuntime14();
26281 runtime.styles.set(hash, css);
26282 for (const targetDocument of runtime.documents.keys()) {
26283 injectStyle14(targetDocument, hash, css);
26284 }
26285 }
26286
26287 // widgets/news/components/news-list/news-list.module.css
26288 if (typeof process === "undefined" || true) {
26289 registerStyle14("98f9a3b1c2", ".bdaa5dfae93273b5__root{flex:1;min-height:0;min-width:0;overflow:auto}._2861fc2db3e2384a__feedIcon{align-items:center;background-color:var(--wpds-color-bg-track-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-md,4px);color:var(--wpds-color-fg-content-neutral-weak,#707070);display:flex;height:100%;justify-content:center;width:100%}._0b17b846e53f552a__titleLink{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._33e124d0c35f629a__meta{color:var(--wpds-color-fg-content-neutral-weak,#707070)}");
26290 }
26291 var news_list_default = { "root": "bdaa5dfae93273b5__root", "feedIcon": "_2861fc2db3e2384a__feedIcon", "titleLink": "_0b17b846e53f552a__titleLink", "meta": "_33e124d0c35f629a__meta" };
26292
26293 // widgets/news/components/news-list/news-list.tsx
26294 var import_jsx_runtime118 = __toESM(require_jsx_runtime());
26295 var NEWS_FEEDS = [
26296 {
26297 key: "news",
26298 label: (0, import_i18n44.__)("WordPress Blog"),
26299 siteUrl: (0, import_i18n44._x)("https://wordpress.org/news/", "News dashboard widget"),
26300 apiUrl: "https://wordpress.org/news/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26301 },
26302 {
26303 key: "planet",
26304 label: (0, import_i18n44.__)("Other WordPress News"),
26305 siteUrl: (0, import_i18n44._x)("https://planet.wordpress.org/", "News dashboard widget"),
26306 apiUrl: "https://planet.wordpress.org/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26307 }
26308 ];
26309 var DEFAULT_LAYOUTS2 = { list: {} };
26310 var INITIAL_VIEW = {
26311 type: "list",
26312 page: 1,
26313 perPage: 4,
26314 search: "",
26315 filters: [],
26316 fields: [],
26317 titleField: "title",
26318 descriptionField: "meta",
26319 mediaField: "feedIcon",
26320 showMedia: true,
26321 layout: { density: "compact" }
26322 };
26323 function FeedIcon({ item }) {
26324 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: news_list_default.feedIcon, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Icon, { icon: item.feedKey === "news" ? wordpress_default : globe_default }) });
26325 }
26326 function NewsTitle({ item }) {
26327 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Link, { href: item.url, openInNewTab: true, className: news_list_default.titleLink, children: item.title });
26328 }
26329 function NewsMeta({ item }) {
26330 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(Text, { variant: "body-sm", className: news_list_default.meta, children: [
26331 item.feedLabel,
26332 " \xB7 ",
26333 (0, import_date10.dateI18n)((0, import_i18n44.__)("M j, Y g:i a"), item.date)
26334 ] });
26335 }
26336 var emptyState = /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Stack, { align: "center", justify: "center", style: { margin: "24px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(empty_state_exports.Root, { children: [
26337 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
26338 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Title, { children: (0, import_i18n44.__)("Quiet for now \u2014 the next headline is on its way.") })
26339 ] }) });
26340 function combineFeedPosts(newsFeeds) {
26341 return newsFeeds.flatMap(
26342 (feed) => feed.posts.map((post) => ({
26343 id: `${feed.key}-${post.id}`,
26344 feedKey: feed.key,
26345 feedLabel: feed.label,
26346 title: (0, import_html_entities.decodeEntities)(post.title.rendered),
26347 url: post.link,
26348 date: post.date
26349 }))
26350 ).sort(
26351 (a2, b2) => new Date(b2.date).getTime() - new Date(a2.date).getTime()
26352 );
26353 }
26354 function NewsList() {
26355 const [view, setView] = (0, import_element80.useState)(INITIAL_VIEW);
26356 const [newsFeeds, setNewsFeeds] = (0, import_element80.useState)([]);
26357 const [isLoading, setIsLoading] = (0, import_element80.useState)(true);
26358 (0, import_element80.useEffect)(() => {
26359 Promise.all(
26360 NEWS_FEEDS.map(async (feed) => {
26361 try {
26362 const posts = await fetch(feed.apiUrl).then(
26363 (r3) => r3.json()
26364 );
26365 return {
26366 key: feed.key,
26367 label: feed.label,
26368 siteUrl: feed.siteUrl,
26369 posts
26370 };
26371 } catch {
26372 return {
26373 key: feed.key,
26374 label: feed.label,
26375 siteUrl: feed.siteUrl,
26376 posts: []
26377 };
26378 }
26379 })
26380 ).then(setNewsFeeds).finally(() => setIsLoading(false));
26381 }, []);
26382 const items = (0, import_element80.useMemo)(() => combineFeedPosts(newsFeeds), [newsFeeds]);
26383 const fields = (0, import_element80.useMemo)(
26384 () => [
26385 {
26386 id: "title",
26387 label: (0, import_i18n44.__)("Title"),
26388 enableSorting: false,
26389 enableHiding: false,
26390 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(NewsTitle, { item })
26391 },
26392 {
26393 id: "meta",
26394 label: (0, import_i18n44.__)("Source"),
26395 enableSorting: false,
26396 enableHiding: false,
26397 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(NewsMeta, { item })
26398 },
26399 {
26400 id: "feedIcon",
26401 label: (0, import_i18n44.__)("Source"),
26402 enableSorting: false,
26403 enableHiding: false,
26404 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(FeedIcon, { item })
26405 }
26406 ],
26407 []
26408 );
26409 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: news_list_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26410 dataviews_default,
26411 {
26412 data: items,
26413 fields,
26414 view,
26415 onChangeView: setView,
26416 getItemId: (item) => item.id,
26417 isLoading,
26418 paginationInfo: {
26419 totalItems: items.length,
26420 totalPages: 1
26421 },
26422 defaultLayouts: DEFAULT_LAYOUTS2,
26423 empty: emptyState,
26424 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_default.Layout, {})
26425 }
26426 ) });
26427 }
26428
26429 // widgets/news/render.module.css
26430 if (typeof process === "undefined" || true) {
26431 registerStyle14("41468018c3", "._2ab2c8be44ad767d__footer{border-block-start:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);padding-block:var(--wpds-dimension-padding-lg,16px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}");
26432 }
26433 var render_default = { "footer": "_2ab2c8be44ad767d__footer" };
26434
26435 // widgets/news/render.tsx
26436 var import_jsx_runtime119 = __toESM(require_jsx_runtime());
26437 function WordPressNews() {
26438 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(import_jsx_runtime119.Fragment, { children: [
26439 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(NewsList, {}),
26440 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: render_default.footer, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26441 Link,
26442 {
26443 href: (0, import_i18n45._x)(
26444 "https://wordpress.org/news/all-posts/",
26445 "News dashboard widget"
26446 ),
26447 openInNewTab: true,
26448 children: (0, import_i18n45.__)("See all")
26449 }
26450 ) })
26451 ] });
26452 }
26453 export {
26454 WordPressNews as default
26455 };
26456 /*! Bundled license information:
26457
26458 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26459 (**
26460 * @license React
26461 * use-sync-external-store-shim.development.js
26462 *
26463 * Copyright (c) Meta Platforms, Inc. and affiliates.
26464 *
26465 * This source code is licensed under the MIT license found in the
26466 * LICENSE file in the root directory of this source tree.
26467 *)
26468
26469 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26470 (**
26471 * @license React
26472 * use-sync-external-store-shim/with-selector.development.js
26473 *
26474 * Copyright (c) Meta Platforms, Inc. and affiliates.
26475 *
26476 * This source code is licensed under the MIT license found in the
26477 * LICENSE file in the root directory of this source tree.
26478 *)
26479 */
26480