PluginProbe
Gutenberg / 23.4.0
Gutenberg v23.4.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / widgets / news / render.js

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

26,902 lines 930.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot) {
75 didWarnOld18Alpha || void 0 === React50.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 useLayoutEffect5(
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 React50 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React50.useState, useEffect32 = React50.useEffect, useLayoutEffect5 = React50.useLayoutEffect, useDebugValue2 = React50.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 !== React50.useSyncExternalStore ? React50.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 React50 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef46 = React50.useRef, useEffect32 = React50.useEffect, useMemo40 = React50.useMemo, useDebugValue2 = React50.useDebugValue;
152 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
153 var instRef = useRef46(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_i18n46 = __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/safeReact.js
849 var React = __toESM(require_react(), 1);
850 var SafeReact = {
851 ...React
852 };
853
854 // node_modules/@base-ui/utils/esm/useRefWithInit.js
855 var React2 = __toESM(require_react(), 1);
856 var UNINITIALIZED = {};
857 function useRefWithInit(init2, initArg) {
858 const ref = React2.useRef(UNINITIALIZED);
859 if (ref.current === UNINITIALIZED) {
860 ref.current = init2(initArg);
861 }
862 return ref;
863 }
864
865 // node_modules/@base-ui/utils/esm/useStableCallback.js
866 var useInsertionEffect = SafeReact.useInsertionEffect;
867 var useSafeInsertionEffect = (
868 // React 17 doesn't have useInsertionEffect.
869 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
870 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
871 );
872 function useStableCallback(callback) {
873 const stable = useRefWithInit(createStableCallback).current;
874 stable.next = callback;
875 useSafeInsertionEffect(stable.effect);
876 return stable.trampoline;
877 }
878 function createStableCallback() {
879 const stable = {
880 next: void 0,
881 callback: assertNotCalled,
882 trampoline: (...args) => stable.callback?.(...args),
883 effect: () => {
884 stable.callback = stable.next;
885 }
886 };
887 return stable;
888 }
889 function assertNotCalled() {
890 if (true) {
891 throw (
892 /* minify-error-disabled */
893 new Error("Base UI: Cannot call an event handler while rendering.")
894 );
895 }
896 }
897
898 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
899 var React3 = __toESM(require_react(), 1);
900 var noop = () => {
901 };
902 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
903
904 // node_modules/@base-ui/utils/esm/warn.js
905 var set;
906 if (true) {
907 set = /* @__PURE__ */ new Set();
908 }
909 function warn(...messages) {
910 if (true) {
911 const messageKey = messages.join(" ");
912 if (!set.has(messageKey)) {
913 set.add(messageKey);
914 console.warn(`Base UI: ${messageKey}`);
915 }
916 }
917 }
918
919 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
920 var React4 = __toESM(require_react(), 1);
921 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
922 if (true) DirectionContext.displayName = "DirectionContext";
923 function useDirection() {
924 const context = React4.useContext(DirectionContext);
925 return context?.direction ?? "ltr";
926 }
927
928 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
929 var React7 = __toESM(require_react(), 1);
930
931 // node_modules/@base-ui/utils/esm/useMergedRefs.js
932 function useMergedRefs(a2, b2, c2, d2) {
933 const forkRef = useRefWithInit(createForkRef).current;
934 if (didChange(forkRef, a2, b2, c2, d2)) {
935 update(forkRef, [a2, b2, c2, d2]);
936 }
937 return forkRef.callback;
938 }
939 function useMergedRefsN(refs) {
940 const forkRef = useRefWithInit(createForkRef).current;
941 if (didChangeN(forkRef, refs)) {
942 update(forkRef, refs);
943 }
944 return forkRef.callback;
945 }
946 function createForkRef() {
947 return {
948 callback: null,
949 cleanup: null,
950 refs: []
951 };
952 }
953 function didChange(forkRef, a2, b2, c2, d2) {
954 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
955 }
956 function didChangeN(forkRef, newRefs) {
957 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
958 }
959 function update(forkRef, refs) {
960 forkRef.refs = refs;
961 if (refs.every((ref) => ref == null)) {
962 forkRef.callback = null;
963 return;
964 }
965 forkRef.callback = (instance) => {
966 if (forkRef.cleanup) {
967 forkRef.cleanup();
968 forkRef.cleanup = null;
969 }
970 if (instance != null) {
971 const cleanupCallbacks = Array(refs.length).fill(null);
972 for (let i2 = 0; i2 < refs.length; i2 += 1) {
973 const ref = refs[i2];
974 if (ref == null) {
975 continue;
976 }
977 switch (typeof ref) {
978 case "function": {
979 const refCleanup = ref(instance);
980 if (typeof refCleanup === "function") {
981 cleanupCallbacks[i2] = refCleanup;
982 }
983 break;
984 }
985 case "object": {
986 ref.current = instance;
987 break;
988 }
989 default:
990 }
991 }
992 forkRef.cleanup = () => {
993 for (let i2 = 0; i2 < refs.length; i2 += 1) {
994 const ref = refs[i2];
995 if (ref == null) {
996 continue;
997 }
998 switch (typeof ref) {
999 case "function": {
1000 const cleanupCallback = cleanupCallbacks[i2];
1001 if (typeof cleanupCallback === "function") {
1002 cleanupCallback();
1003 } else {
1004 ref(null);
1005 }
1006 break;
1007 }
1008 case "object": {
1009 ref.current = null;
1010 break;
1011 }
1012 default:
1013 }
1014 }
1015 };
1016 }
1017 };
1018 }
1019
1020 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1021 var React6 = __toESM(require_react(), 1);
1022
1023 // node_modules/@base-ui/utils/esm/reactVersion.js
1024 var React5 = __toESM(require_react(), 1);
1025 var majorVersion = parseInt(React5.version, 10);
1026 function isReactVersionAtLeast(reactVersionToCheck) {
1027 return majorVersion >= reactVersionToCheck;
1028 }
1029
1030 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1031 function getReactElementRef(element) {
1032 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1033 return null;
1034 }
1035 const reactElement = element;
1036 const propsWithRef = reactElement.props;
1037 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1038 }
1039
1040 // node_modules/@base-ui/utils/esm/mergeObjects.js
1041 function mergeObjects(a2, b2) {
1042 if (a2 && !b2) {
1043 return a2;
1044 }
1045 if (!a2 && b2) {
1046 return b2;
1047 }
1048 if (a2 || b2) {
1049 return {
1050 ...a2,
1051 ...b2
1052 };
1053 }
1054 return void 0;
1055 }
1056
1057 // node_modules/@base-ui/utils/esm/empty.js
1058 function NOOP() {
1059 }
1060 var EMPTY_ARRAY = Object.freeze([]);
1061 var EMPTY_OBJECT = Object.freeze({});
1062
1063 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1064 function getStateAttributesProps(state, customMapping) {
1065 const props = {};
1066 for (const key in state) {
1067 const value = state[key];
1068 if (customMapping?.hasOwnProperty(key)) {
1069 const customProps = customMapping[key](value);
1070 if (customProps != null) {
1071 Object.assign(props, customProps);
1072 }
1073 continue;
1074 }
1075 if (value === true) {
1076 props[`data-${key.toLowerCase()}`] = "";
1077 } else if (value) {
1078 props[`data-${key.toLowerCase()}`] = value.toString();
1079 }
1080 }
1081 return props;
1082 }
1083
1084 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1085 function resolveClassName(className, state) {
1086 return typeof className === "function" ? className(state) : className;
1087 }
1088
1089 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1090 function resolveStyle(style, state) {
1091 return typeof style === "function" ? style(state) : style;
1092 }
1093
1094 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1095 var EMPTY_PROPS = {};
1096 function mergeProps(a2, b2, c2, d2, e2) {
1097 if (!c2 && !d2 && !e2 && !a2) {
1098 return createInitialMergedProps(b2);
1099 }
1100 let merged = createInitialMergedProps(a2);
1101 if (b2) {
1102 merged = mergeInto(merged, b2);
1103 }
1104 if (c2) {
1105 merged = mergeInto(merged, c2);
1106 }
1107 if (d2) {
1108 merged = mergeInto(merged, d2);
1109 }
1110 if (e2) {
1111 merged = mergeInto(merged, e2);
1112 }
1113 return merged;
1114 }
1115 function mergePropsN(props) {
1116 if (props.length === 0) {
1117 return EMPTY_PROPS;
1118 }
1119 if (props.length === 1) {
1120 return createInitialMergedProps(props[0]);
1121 }
1122 let merged = createInitialMergedProps(props[0]);
1123 for (let i2 = 1; i2 < props.length; i2 += 1) {
1124 merged = mergeInto(merged, props[i2]);
1125 }
1126 return merged;
1127 }
1128 function createInitialMergedProps(inputProps) {
1129 if (isPropsGetter(inputProps)) {
1130 return {
1131 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1132 };
1133 }
1134 return copyInitialProps(inputProps);
1135 }
1136 function mergeInto(merged, inputProps) {
1137 if (isPropsGetter(inputProps)) {
1138 return resolvePropsGetter(inputProps, merged);
1139 }
1140 return mutablyMergeInto(merged, inputProps);
1141 }
1142 function copyInitialProps(inputProps) {
1143 const copiedProps = {
1144 ...inputProps
1145 };
1146 for (const propName in copiedProps) {
1147 const propValue = copiedProps[propName];
1148 if (isEventHandler(propName, propValue)) {
1149 copiedProps[propName] = wrapEventHandler(propValue);
1150 }
1151 }
1152 return copiedProps;
1153 }
1154 function mutablyMergeInto(mergedProps, externalProps) {
1155 if (!externalProps) {
1156 return mergedProps;
1157 }
1158 for (const propName in externalProps) {
1159 const externalPropValue = externalProps[propName];
1160 switch (propName) {
1161 case "style": {
1162 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1163 break;
1164 }
1165 case "className": {
1166 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1167 break;
1168 }
1169 default: {
1170 if (isEventHandler(propName, externalPropValue)) {
1171 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1172 } else {
1173 mergedProps[propName] = externalPropValue;
1174 }
1175 }
1176 }
1177 }
1178 return mergedProps;
1179 }
1180 function isEventHandler(key, value) {
1181 const code0 = key.charCodeAt(0);
1182 const code1 = key.charCodeAt(1);
1183 const code2 = key.charCodeAt(2);
1184 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1185 }
1186 function isPropsGetter(inputProps) {
1187 return typeof inputProps === "function";
1188 }
1189 function resolvePropsGetter(inputProps, previousProps) {
1190 if (isPropsGetter(inputProps)) {
1191 return inputProps(previousProps);
1192 }
1193 return inputProps ?? EMPTY_PROPS;
1194 }
1195 function mergeEventHandlers(ourHandler, theirHandler) {
1196 if (!theirHandler) {
1197 return ourHandler;
1198 }
1199 if (!ourHandler) {
1200 return wrapEventHandler(theirHandler);
1201 }
1202 return (...args) => {
1203 const event = args[0];
1204 if (isSyntheticEvent(event)) {
1205 const baseUIEvent = event;
1206 makeEventPreventable(baseUIEvent);
1207 const result2 = theirHandler(...args);
1208 if (!baseUIEvent.baseUIHandlerPrevented) {
1209 ourHandler?.(...args);
1210 }
1211 return result2;
1212 }
1213 const result = theirHandler(...args);
1214 ourHandler?.(...args);
1215 return result;
1216 };
1217 }
1218 function wrapEventHandler(handler) {
1219 if (!handler) {
1220 return handler;
1221 }
1222 return (...args) => {
1223 const event = args[0];
1224 if (isSyntheticEvent(event)) {
1225 makeEventPreventable(event);
1226 }
1227 return handler(...args);
1228 };
1229 }
1230 function makeEventPreventable(event) {
1231 event.preventBaseUIHandler = () => {
1232 event.baseUIHandlerPrevented = true;
1233 };
1234 return event;
1235 }
1236 function mergeClassNames(ourClassName, theirClassName) {
1237 if (theirClassName) {
1238 if (ourClassName) {
1239 return theirClassName + " " + ourClassName;
1240 }
1241 return theirClassName;
1242 }
1243 return ourClassName;
1244 }
1245 function isSyntheticEvent(event) {
1246 return event != null && typeof event === "object" && "nativeEvent" in event;
1247 }
1248
1249 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1250 var import_react = __toESM(require_react(), 1);
1251 function useRenderElement(element, componentProps, params = {}) {
1252 const renderProp = componentProps.render;
1253 const outProps = useRenderElementProps(componentProps, params);
1254 if (params.enabled === false) {
1255 return null;
1256 }
1257 const state = params.state ?? EMPTY_OBJECT;
1258 return evaluateRenderProp(element, renderProp, outProps, state);
1259 }
1260 function useRenderElementProps(componentProps, params = {}) {
1261 const {
1262 className: classNameProp,
1263 style: styleProp,
1264 render: renderProp
1265 } = componentProps;
1266 const {
1267 state = EMPTY_OBJECT,
1268 ref,
1269 props,
1270 stateAttributesMapping: stateAttributesMapping3,
1271 enabled = true
1272 } = params;
1273 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1274 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1275 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1276 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1277 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1278 if (typeof document !== "undefined") {
1279 if (!enabled) {
1280 useMergedRefs(null, null);
1281 } else if (Array.isArray(ref)) {
1282 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1283 } else {
1284 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1285 }
1286 }
1287 if (!enabled) {
1288 return EMPTY_OBJECT;
1289 }
1290 if (className !== void 0) {
1291 outProps.className = mergeClassNames(outProps.className, className);
1292 }
1293 if (style !== void 0) {
1294 outProps.style = mergeObjects(outProps.style, style);
1295 }
1296 return outProps;
1297 }
1298 function resolveRenderFunctionProps(props) {
1299 if (Array.isArray(props)) {
1300 return mergePropsN(props);
1301 }
1302 return mergeProps(void 0, props);
1303 }
1304 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1305 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1306 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1307 function evaluateRenderProp(element, render4, props, state) {
1308 if (render4) {
1309 if (typeof render4 === "function") {
1310 if (true) {
1311 warnIfRenderPropLooksLikeComponent(render4);
1312 }
1313 return render4(props, state);
1314 }
1315 const mergedProps = mergeProps(props, render4.props);
1316 mergedProps.ref = props.ref;
1317 let newElement = render4;
1318 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1319 const children = React7.Children.toArray(render4);
1320 newElement = children[0];
1321 }
1322 if (true) {
1323 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1324 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"));
1325 }
1326 }
1327 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1328 }
1329 if (element) {
1330 if (typeof element === "string") {
1331 return renderTag(element, props);
1332 }
1333 }
1334 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1335 }
1336 function warnIfRenderPropLooksLikeComponent(renderFn) {
1337 const functionName = renderFn.name;
1338 if (functionName.length === 0) {
1339 return;
1340 }
1341 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1342 return;
1343 }
1344 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1345 return;
1346 }
1347 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");
1348 }
1349 function renderTag(Tag, props) {
1350 if (Tag === "button") {
1351 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1352 type: "button",
1353 ...props,
1354 key: props.key
1355 });
1356 }
1357 if (Tag === "img") {
1358 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1359 alt: "",
1360 ...props,
1361 key: props.key
1362 });
1363 }
1364 return /* @__PURE__ */ React7.createElement(Tag, props);
1365 }
1366
1367 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1368 var reason_parts_exports = {};
1369 __export(reason_parts_exports, {
1370 cancelOpen: () => cancelOpen,
1371 chipRemovePress: () => chipRemovePress,
1372 clearPress: () => clearPress,
1373 closePress: () => closePress,
1374 closeWatcher: () => closeWatcher,
1375 decrementPress: () => decrementPress,
1376 disabled: () => disabled,
1377 drag: () => drag,
1378 escapeKey: () => escapeKey,
1379 focusOut: () => focusOut,
1380 imperativeAction: () => imperativeAction,
1381 incrementPress: () => incrementPress,
1382 initial: () => initial,
1383 inputBlur: () => inputBlur,
1384 inputChange: () => inputChange,
1385 inputClear: () => inputClear,
1386 inputPaste: () => inputPaste,
1387 inputPress: () => inputPress,
1388 itemPress: () => itemPress,
1389 keyboard: () => keyboard,
1390 linkPress: () => linkPress,
1391 listNavigation: () => listNavigation,
1392 missing: () => missing,
1393 none: () => none,
1394 outsidePress: () => outsidePress,
1395 pointer: () => pointer,
1396 scrub: () => scrub,
1397 siblingOpen: () => siblingOpen,
1398 swipe: () => swipe,
1399 trackPress: () => trackPress,
1400 triggerFocus: () => triggerFocus,
1401 triggerHover: () => triggerHover,
1402 triggerPress: () => triggerPress,
1403 wheel: () => wheel,
1404 windowResize: () => windowResize
1405 });
1406 var none = "none";
1407 var triggerPress = "trigger-press";
1408 var triggerHover = "trigger-hover";
1409 var triggerFocus = "trigger-focus";
1410 var outsidePress = "outside-press";
1411 var itemPress = "item-press";
1412 var closePress = "close-press";
1413 var linkPress = "link-press";
1414 var clearPress = "clear-press";
1415 var chipRemovePress = "chip-remove-press";
1416 var trackPress = "track-press";
1417 var incrementPress = "increment-press";
1418 var decrementPress = "decrement-press";
1419 var inputChange = "input-change";
1420 var inputClear = "input-clear";
1421 var inputBlur = "input-blur";
1422 var inputPaste = "input-paste";
1423 var inputPress = "input-press";
1424 var focusOut = "focus-out";
1425 var escapeKey = "escape-key";
1426 var closeWatcher = "close-watcher";
1427 var listNavigation = "list-navigation";
1428 var keyboard = "keyboard";
1429 var pointer = "pointer";
1430 var drag = "drag";
1431 var wheel = "wheel";
1432 var scrub = "scrub";
1433 var cancelOpen = "cancel-open";
1434 var siblingOpen = "sibling-open";
1435 var disabled = "disabled";
1436 var missing = "missing";
1437 var initial = "initial";
1438 var imperativeAction = "imperative-action";
1439 var swipe = "swipe";
1440 var windowResize = "window-resize";
1441
1442 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1443 function createChangeEventDetails(reason, event, trigger, customProperties) {
1444 let canceled = false;
1445 let allowPropagation = false;
1446 const custom = customProperties ?? EMPTY_OBJECT;
1447 const details = {
1448 reason,
1449 event: event ?? new Event("base-ui"),
1450 cancel() {
1451 canceled = true;
1452 },
1453 allowPropagation() {
1454 allowPropagation = true;
1455 },
1456 get isCanceled() {
1457 return canceled;
1458 },
1459 get isPropagationAllowed() {
1460 return allowPropagation;
1461 },
1462 trigger,
1463 ...custom
1464 };
1465 return details;
1466 }
1467
1468 // node_modules/@base-ui/utils/esm/useId.js
1469 var React8 = __toESM(require_react(), 1);
1470 var globalId = 0;
1471 function useGlobalId(idOverride, prefix = "mui") {
1472 const [defaultId, setDefaultId] = React8.useState(idOverride);
1473 const id = idOverride || defaultId;
1474 React8.useEffect(() => {
1475 if (defaultId == null) {
1476 globalId += 1;
1477 setDefaultId(`${prefix}-${globalId}`);
1478 }
1479 }, [defaultId, prefix]);
1480 return id;
1481 }
1482 var maybeReactUseId = SafeReact.useId;
1483 function useId(idOverride, prefix) {
1484 if (maybeReactUseId !== void 0) {
1485 const reactId = maybeReactUseId();
1486 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1487 }
1488 return useGlobalId(idOverride, prefix);
1489 }
1490
1491 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1492 function useBaseUiId(idOverride) {
1493 return useId(idOverride, "base-ui");
1494 }
1495
1496 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1497 var React10 = __toESM(require_react(), 1);
1498
1499 // node_modules/@base-ui/utils/esm/useOnMount.js
1500 var React9 = __toESM(require_react(), 1);
1501 var EMPTY = [];
1502 function useOnMount(fn) {
1503 React9.useEffect(fn, EMPTY);
1504 }
1505
1506 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1507 var EMPTY2 = null;
1508 var LAST_RAF = globalThis.requestAnimationFrame;
1509 var Scheduler = class {
1510 /* This implementation uses an array as a backing data-structure for frame callbacks.
1511 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1512 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1513 * be much more efficient if there is a call pattern that alterns as
1514 * "request-cancel-request-cancel-…".
1515 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1516 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1517 callbacks = [];
1518 callbacksCount = 0;
1519 nextId = 1;
1520 startId = 1;
1521 isScheduled = false;
1522 tick = (timestamp) => {
1523 this.isScheduled = false;
1524 const currentCallbacks = this.callbacks;
1525 const currentCallbacksCount = this.callbacksCount;
1526 this.callbacks = [];
1527 this.callbacksCount = 0;
1528 this.startId = this.nextId;
1529 if (currentCallbacksCount > 0) {
1530 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1531 currentCallbacks[i2]?.(timestamp);
1532 }
1533 }
1534 };
1535 request(fn) {
1536 const id = this.nextId;
1537 this.nextId += 1;
1538 this.callbacks.push(fn);
1539 this.callbacksCount += 1;
1540 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1541 if (!this.isScheduled || didRAFChange) {
1542 requestAnimationFrame(this.tick);
1543 this.isScheduled = true;
1544 }
1545 return id;
1546 }
1547 cancel(id) {
1548 const index2 = id - this.startId;
1549 if (index2 < 0 || index2 >= this.callbacks.length) {
1550 return;
1551 }
1552 this.callbacks[index2] = null;
1553 this.callbacksCount -= 1;
1554 }
1555 };
1556 var scheduler = new Scheduler();
1557 var AnimationFrame = class _AnimationFrame {
1558 static create() {
1559 return new _AnimationFrame();
1560 }
1561 static request(fn) {
1562 return scheduler.request(fn);
1563 }
1564 static cancel(id) {
1565 return scheduler.cancel(id);
1566 }
1567 currentId = EMPTY2;
1568 /**
1569 * Executes `fn` after `delay`, clearing any previously scheduled call.
1570 */
1571 request(fn) {
1572 this.cancel();
1573 this.currentId = scheduler.request(() => {
1574 this.currentId = EMPTY2;
1575 fn();
1576 });
1577 }
1578 cancel = () => {
1579 if (this.currentId !== EMPTY2) {
1580 scheduler.cancel(this.currentId);
1581 this.currentId = EMPTY2;
1582 }
1583 };
1584 disposeEffect = () => {
1585 return this.cancel;
1586 };
1587 };
1588 function useAnimationFrame() {
1589 const timeout = useRefWithInit(AnimationFrame.create).current;
1590 useOnMount(timeout.disposeEffect);
1591 return timeout;
1592 }
1593
1594 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1595 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1596 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
1597 const [mounted, setMounted] = React10.useState(open);
1598 if (open && !mounted) {
1599 setMounted(true);
1600 setTransitionStatus("starting");
1601 }
1602 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1603 setTransitionStatus("ending");
1604 }
1605 if (!open && !mounted && transitionStatus === "ending") {
1606 setTransitionStatus(void 0);
1607 }
1608 useIsoLayoutEffect(() => {
1609 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1610 const frame = AnimationFrame.request(() => {
1611 setTransitionStatus("ending");
1612 });
1613 return () => {
1614 AnimationFrame.cancel(frame);
1615 };
1616 }
1617 return void 0;
1618 }, [open, mounted, transitionStatus, deferEndingState]);
1619 useIsoLayoutEffect(() => {
1620 if (!open || enableIdleState) {
1621 return void 0;
1622 }
1623 const frame = AnimationFrame.request(() => {
1624 setTransitionStatus(void 0);
1625 });
1626 return () => {
1627 AnimationFrame.cancel(frame);
1628 };
1629 }, [enableIdleState, open]);
1630 useIsoLayoutEffect(() => {
1631 if (!open || !enableIdleState) {
1632 return void 0;
1633 }
1634 if (open && mounted && transitionStatus !== "idle") {
1635 setTransitionStatus("starting");
1636 }
1637 const frame = AnimationFrame.request(() => {
1638 setTransitionStatus("idle");
1639 });
1640 return () => {
1641 AnimationFrame.cancel(frame);
1642 };
1643 }, [enableIdleState, open, mounted, transitionStatus]);
1644 return {
1645 mounted,
1646 setMounted,
1647 transitionStatus
1648 };
1649 }
1650
1651 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1652 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1653 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1654 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1655 return TransitionStatusDataAttributes2;
1656 })({});
1657 var STARTING_HOOK = {
1658 [TransitionStatusDataAttributes.startingStyle]: ""
1659 };
1660 var ENDING_HOOK = {
1661 [TransitionStatusDataAttributes.endingStyle]: ""
1662 };
1663 var transitionStatusMapping = {
1664 transitionStatus(value) {
1665 if (value === "starting") {
1666 return STARTING_HOOK;
1667 }
1668 if (value === "ending") {
1669 return ENDING_HOOK;
1670 }
1671 return null;
1672 }
1673 };
1674
1675 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1676 function hasWindow() {
1677 return typeof window !== "undefined";
1678 }
1679 function getNodeName(node) {
1680 if (isNode(node)) {
1681 return (node.nodeName || "").toLowerCase();
1682 }
1683 return "#document";
1684 }
1685 function getWindow(node) {
1686 var _node$ownerDocument;
1687 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1688 }
1689 function getDocumentElement(node) {
1690 var _ref;
1691 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1692 }
1693 function isNode(value) {
1694 if (!hasWindow()) {
1695 return false;
1696 }
1697 return value instanceof Node || value instanceof getWindow(value).Node;
1698 }
1699 function isElement(value) {
1700 if (!hasWindow()) {
1701 return false;
1702 }
1703 return value instanceof Element || value instanceof getWindow(value).Element;
1704 }
1705 function isHTMLElement(value) {
1706 if (!hasWindow()) {
1707 return false;
1708 }
1709 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1710 }
1711 function isShadowRoot(value) {
1712 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1713 return false;
1714 }
1715 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1716 }
1717 function isOverflowElement(element) {
1718 const {
1719 overflow,
1720 overflowX,
1721 overflowY,
1722 display
1723 } = getComputedStyle2(element);
1724 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1725 }
1726 function isTableElement(element) {
1727 return /^(table|td|th)$/.test(getNodeName(element));
1728 }
1729 function isTopLayer(element) {
1730 try {
1731 if (element.matches(":popover-open")) {
1732 return true;
1733 }
1734 } catch (_e) {
1735 }
1736 try {
1737 return element.matches(":modal");
1738 } catch (_e) {
1739 return false;
1740 }
1741 }
1742 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1743 var containRe = /paint|layout|strict|content/;
1744 var isNotNone = (value) => !!value && value !== "none";
1745 var isWebKitValue;
1746 function isContainingBlock(elementOrCss) {
1747 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1748 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 || "");
1749 }
1750 function getContainingBlock(element) {
1751 let currentNode = getParentNode(element);
1752 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1753 if (isContainingBlock(currentNode)) {
1754 return currentNode;
1755 } else if (isTopLayer(currentNode)) {
1756 return null;
1757 }
1758 currentNode = getParentNode(currentNode);
1759 }
1760 return null;
1761 }
1762 function isWebKit() {
1763 if (isWebKitValue == null) {
1764 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1765 }
1766 return isWebKitValue;
1767 }
1768 function isLastTraversableNode(node) {
1769 return /^(html|body|#document)$/.test(getNodeName(node));
1770 }
1771 function getComputedStyle2(element) {
1772 return getWindow(element).getComputedStyle(element);
1773 }
1774 function getNodeScroll(element) {
1775 if (isElement(element)) {
1776 return {
1777 scrollLeft: element.scrollLeft,
1778 scrollTop: element.scrollTop
1779 };
1780 }
1781 return {
1782 scrollLeft: element.scrollX,
1783 scrollTop: element.scrollY
1784 };
1785 }
1786 function getParentNode(node) {
1787 if (getNodeName(node) === "html") {
1788 return node;
1789 }
1790 const result = (
1791 // Step into the shadow DOM of the parent of a slotted node.
1792 node.assignedSlot || // DOM Element detected.
1793 node.parentNode || // ShadowRoot detected.
1794 isShadowRoot(node) && node.host || // Fallback.
1795 getDocumentElement(node)
1796 );
1797 return isShadowRoot(result) ? result.host : result;
1798 }
1799 function getNearestOverflowAncestor(node) {
1800 const parentNode = getParentNode(node);
1801 if (isLastTraversableNode(parentNode)) {
1802 return node.ownerDocument ? node.ownerDocument.body : node.body;
1803 }
1804 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1805 return parentNode;
1806 }
1807 return getNearestOverflowAncestor(parentNode);
1808 }
1809 function getOverflowAncestors(node, list, traverseIframes) {
1810 var _node$ownerDocument2;
1811 if (list === void 0) {
1812 list = [];
1813 }
1814 if (traverseIframes === void 0) {
1815 traverseIframes = true;
1816 }
1817 const scrollableAncestor = getNearestOverflowAncestor(node);
1818 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1819 const win = getWindow(scrollableAncestor);
1820 if (isBody) {
1821 const frameElement = getFrameElement(win);
1822 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1823 } else {
1824 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1825 }
1826 }
1827 function getFrameElement(win) {
1828 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1829 }
1830
1831 // node_modules/@base-ui/utils/esm/detectBrowser.js
1832 var hasNavigator = typeof navigator !== "undefined";
1833 var nav = getNavigatorData();
1834 var platform = getPlatform();
1835 var userAgent = getUserAgent();
1836 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1837 var isIOS = (
1838 // iPads can claim to be MacIntel
1839 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
1840 );
1841 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
1842 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
1843 var isEdge = hasNavigator && /Edg/i.test(userAgent);
1844 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
1845 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
1846 var isJSDOM = userAgent.includes("jsdom/");
1847 function getNavigatorData() {
1848 if (!hasNavigator) {
1849 return {
1850 platform: "",
1851 maxTouchPoints: -1
1852 };
1853 }
1854 const uaData = navigator.userAgentData;
1855 if (uaData?.platform) {
1856 return {
1857 platform: uaData.platform,
1858 maxTouchPoints: navigator.maxTouchPoints
1859 };
1860 }
1861 return {
1862 platform: navigator.platform ?? "",
1863 maxTouchPoints: navigator.maxTouchPoints ?? -1
1864 };
1865 }
1866 function getUserAgent() {
1867 if (!hasNavigator) {
1868 return "";
1869 }
1870 const uaData = navigator.userAgentData;
1871 if (uaData && Array.isArray(uaData.brands)) {
1872 return uaData.brands.map(({
1873 brand,
1874 version: version2
1875 }) => `${brand}/${version2}`).join(" ");
1876 }
1877 return navigator.userAgent;
1878 }
1879 function getPlatform() {
1880 if (!hasNavigator) {
1881 return "";
1882 }
1883 const uaData = navigator.userAgentData;
1884 if (uaData?.platform) {
1885 return uaData.platform;
1886 }
1887 return navigator.platform ?? "";
1888 }
1889
1890 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
1891 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
1892 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
1893
1894 // node_modules/@base-ui/react/esm/internals/shadowDom.js
1895 function activeElement(doc) {
1896 let element = doc.activeElement;
1897 while (element?.shadowRoot?.activeElement != null) {
1898 element = element.shadowRoot.activeElement;
1899 }
1900 return element;
1901 }
1902 function contains(parent, child) {
1903 if (!parent || !child) {
1904 return false;
1905 }
1906 const rootNode = child.getRootNode?.();
1907 if (parent.contains(child)) {
1908 return true;
1909 }
1910 if (rootNode && isShadowRoot(rootNode)) {
1911 let next = child;
1912 while (next) {
1913 if (parent === next) {
1914 return true;
1915 }
1916 next = next.parentNode || next.host;
1917 }
1918 }
1919 return false;
1920 }
1921 function getTarget(event) {
1922 if ("composedPath" in event) {
1923 return event.composedPath()[0];
1924 }
1925 return event.target;
1926 }
1927
1928 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
1929 function isTargetInsideEnabledTrigger(target, triggerElements) {
1930 if (!isElement(target)) {
1931 return false;
1932 }
1933 const targetElement = target;
1934 if (triggerElements.hasElement(targetElement)) {
1935 return !targetElement.hasAttribute("data-trigger-disabled");
1936 }
1937 for (const [, trigger] of triggerElements.entries()) {
1938 if (contains(trigger, targetElement)) {
1939 return !trigger.hasAttribute("data-trigger-disabled");
1940 }
1941 }
1942 return false;
1943 }
1944 function isEventTargetWithin(event, node) {
1945 if (node == null) {
1946 return false;
1947 }
1948 if ("composedPath" in event) {
1949 return event.composedPath().includes(node);
1950 }
1951 const eventAgain = event;
1952 return eventAgain.target != null && node.contains(eventAgain.target);
1953 }
1954 function isRootElement(element) {
1955 return element.matches("html,body");
1956 }
1957 function isTypeableElement(element) {
1958 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
1959 }
1960 function isInteractiveElement(element) {
1961 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
1962 }
1963 function matchesFocusVisible(element) {
1964 if (!element || isJSDOM) {
1965 return true;
1966 }
1967 try {
1968 return element.matches(":focus-visible");
1969 } catch (_e) {
1970 return true;
1971 }
1972 }
1973
1974 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
1975 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
1976 const directChildren = nodes.filter((node) => node.parentId === id);
1977 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
1978 }
1979
1980 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
1981 function isReactEvent(event) {
1982 return "nativeEvent" in event;
1983 }
1984 function isMouseLikePointerType(pointerType, strict) {
1985 const values = ["mouse", "pen"];
1986 if (!strict) {
1987 values.push("", void 0);
1988 }
1989 return values.includes(pointerType);
1990 }
1991 function isClickLikeEvent(event) {
1992 const type = event.type;
1993 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
1994 }
1995
1996 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
1997 var sides = ["top", "right", "bottom", "left"];
1998 var min = Math.min;
1999 var max = Math.max;
2000 var round = Math.round;
2001 var floor = Math.floor;
2002 var createCoords = (v2) => ({
2003 x: v2,
2004 y: v2
2005 });
2006 var oppositeSideMap = {
2007 left: "right",
2008 right: "left",
2009 bottom: "top",
2010 top: "bottom"
2011 };
2012 function clamp(start, value, end) {
2013 return max(start, min(value, end));
2014 }
2015 function evaluate(value, param) {
2016 return typeof value === "function" ? value(param) : value;
2017 }
2018 function getSide(placement) {
2019 return placement.split("-")[0];
2020 }
2021 function getAlignment(placement) {
2022 return placement.split("-")[1];
2023 }
2024 function getOppositeAxis(axis) {
2025 return axis === "x" ? "y" : "x";
2026 }
2027 function getAxisLength(axis) {
2028 return axis === "y" ? "height" : "width";
2029 }
2030 function getSideAxis(placement) {
2031 const firstChar = placement[0];
2032 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2033 }
2034 function getAlignmentAxis(placement) {
2035 return getOppositeAxis(getSideAxis(placement));
2036 }
2037 function getAlignmentSides(placement, rects, rtl) {
2038 if (rtl === void 0) {
2039 rtl = false;
2040 }
2041 const alignment = getAlignment(placement);
2042 const alignmentAxis = getAlignmentAxis(placement);
2043 const length = getAxisLength(alignmentAxis);
2044 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2045 if (rects.reference[length] > rects.floating[length]) {
2046 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2047 }
2048 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2049 }
2050 function getExpandedPlacements(placement) {
2051 const oppositePlacement = getOppositePlacement(placement);
2052 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2053 }
2054 function getOppositeAlignmentPlacement(placement) {
2055 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2056 }
2057 var lrPlacement = ["left", "right"];
2058 var rlPlacement = ["right", "left"];
2059 var tbPlacement = ["top", "bottom"];
2060 var btPlacement = ["bottom", "top"];
2061 function getSideList(side, isStart, rtl) {
2062 switch (side) {
2063 case "top":
2064 case "bottom":
2065 if (rtl) return isStart ? rlPlacement : lrPlacement;
2066 return isStart ? lrPlacement : rlPlacement;
2067 case "left":
2068 case "right":
2069 return isStart ? tbPlacement : btPlacement;
2070 default:
2071 return [];
2072 }
2073 }
2074 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2075 const alignment = getAlignment(placement);
2076 let list = getSideList(getSide(placement), direction === "start", rtl);
2077 if (alignment) {
2078 list = list.map((side) => side + "-" + alignment);
2079 if (flipAlignment) {
2080 list = list.concat(list.map(getOppositeAlignmentPlacement));
2081 }
2082 }
2083 return list;
2084 }
2085 function getOppositePlacement(placement) {
2086 const side = getSide(placement);
2087 return oppositeSideMap[side] + placement.slice(side.length);
2088 }
2089 function expandPaddingObject(padding) {
2090 return {
2091 top: 0,
2092 right: 0,
2093 bottom: 0,
2094 left: 0,
2095 ...padding
2096 };
2097 }
2098 function getPaddingObject(padding) {
2099 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2100 top: padding,
2101 right: padding,
2102 bottom: padding,
2103 left: padding
2104 };
2105 }
2106 function rectToClientRect(rect) {
2107 const {
2108 x: x2,
2109 y: y2,
2110 width,
2111 height
2112 } = rect;
2113 return {
2114 width,
2115 height,
2116 top: y2,
2117 left: x2,
2118 right: x2 + width,
2119 bottom: y2 + height,
2120 x: x2,
2121 y: y2
2122 };
2123 }
2124
2125 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2126 function isHiddenByStyles(styles) {
2127 return styles.visibility === "hidden" || styles.visibility === "collapse";
2128 }
2129 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2130 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2131 return false;
2132 }
2133 if (typeof element.checkVisibility === "function") {
2134 return element.checkVisibility();
2135 }
2136 return styles.display !== "none" && styles.display !== "contents";
2137 }
2138
2139 // node_modules/@base-ui/utils/esm/owner.js
2140 function ownerDocument(node) {
2141 return node?.ownerDocument || document;
2142 }
2143
2144 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2145 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2146 function getParentElement(element) {
2147 const assignedSlot = element.assignedSlot;
2148 if (assignedSlot) {
2149 return assignedSlot;
2150 }
2151 if (element.parentElement) {
2152 return element.parentElement;
2153 }
2154 const rootNode = element.getRootNode();
2155 return isShadowRoot(rootNode) ? rootNode.host : null;
2156 }
2157 function getDetailsSummary(details) {
2158 for (const child of Array.from(details.children)) {
2159 if (getNodeName(child) === "summary") {
2160 return child;
2161 }
2162 }
2163 return null;
2164 }
2165 function isWithinOpenDetailsSummary(element, details) {
2166 const summary = getDetailsSummary(details);
2167 return !!summary && (element === summary || contains(summary, element));
2168 }
2169 function isFocusableCandidate(element) {
2170 const nodeName = element ? getNodeName(element) : "";
2171 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");
2172 }
2173 function isFocusableElement(element) {
2174 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2175 return false;
2176 }
2177 for (let current = element; current; current = getParentElement(current)) {
2178 const isAncestor = current !== element;
2179 const isSlot = getNodeName(current) === "slot";
2180 if (current.hasAttribute("inert")) {
2181 return false;
2182 }
2183 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2184 return false;
2185 }
2186 }
2187 return true;
2188 }
2189 function isVisibleInTabbableTree(element, isAncestor) {
2190 const styles = getComputedStyle2(element);
2191 if (!isAncestor) {
2192 return isElementVisible(element, styles);
2193 }
2194 return styles.display !== "none";
2195 }
2196 function getTabIndex(element) {
2197 const tabIndex = element.tabIndex;
2198 if (tabIndex < 0) {
2199 const nodeName = getNodeName(element);
2200 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2201 return 0;
2202 }
2203 }
2204 return tabIndex;
2205 }
2206 function getNamedRadioInput(element) {
2207 if (getNodeName(element) !== "input") {
2208 return null;
2209 }
2210 const input = element;
2211 return input.type === "radio" && input.name !== "" ? input : null;
2212 }
2213 function isTabbableRadio(element, candidates) {
2214 const input = getNamedRadioInput(element);
2215 if (!input) {
2216 return true;
2217 }
2218 const checkedRadio = candidates.find((candidate) => {
2219 const radio = getNamedRadioInput(candidate);
2220 return radio?.name === input.name && radio.form === input.form && radio.checked;
2221 });
2222 if (checkedRadio) {
2223 return checkedRadio === input;
2224 }
2225 return candidates.find((candidate) => {
2226 const radio = getNamedRadioInput(candidate);
2227 return radio?.name === input.name && radio.form === input.form;
2228 }) === input;
2229 }
2230 function getComposedChildren(container) {
2231 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2232 const assignedElements = container.assignedElements({
2233 flatten: true
2234 });
2235 if (assignedElements.length > 0) {
2236 return assignedElements;
2237 }
2238 }
2239 if (isHTMLElement(container) && container.shadowRoot) {
2240 return Array.from(container.shadowRoot.children);
2241 }
2242 return Array.from(container.children);
2243 }
2244 function appendCandidates(container, list) {
2245 getComposedChildren(container).forEach((child) => {
2246 if (isFocusableCandidate(child)) {
2247 list.push(child);
2248 }
2249 appendCandidates(child, list);
2250 });
2251 }
2252 function appendMatchingElements(container, selector2, list) {
2253 getComposedChildren(container).forEach((child) => {
2254 if (isHTMLElement(child) && child.matches(selector2)) {
2255 list.push(child);
2256 }
2257 appendMatchingElements(child, selector2, list);
2258 });
2259 }
2260 function focusable(container) {
2261 const candidates = [];
2262 appendCandidates(container, candidates);
2263 return candidates.filter(isFocusableElement);
2264 }
2265 function tabbable(container) {
2266 const candidates = focusable(container);
2267 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2268 }
2269 function getTabbableIn(container, dir) {
2270 const list = tabbable(container);
2271 const len = list.length;
2272 if (len === 0) {
2273 return void 0;
2274 }
2275 const active = activeElement(ownerDocument(container));
2276 const index2 = list.indexOf(active);
2277 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2278 return list[nextIndex];
2279 }
2280 function getNextTabbable(referenceElement) {
2281 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2282 }
2283 function getPreviousTabbable(referenceElement) {
2284 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2285 }
2286 function isOutsideEvent(event, container) {
2287 const containerElement = container || event.currentTarget;
2288 const relatedTarget = event.relatedTarget;
2289 return !relatedTarget || !contains(containerElement, relatedTarget);
2290 }
2291 function disableFocusInside(container) {
2292 const tabbableElements = tabbable(container);
2293 tabbableElements.forEach((element) => {
2294 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2295 element.setAttribute("tabindex", "-1");
2296 });
2297 }
2298 function enableFocusInside(container) {
2299 const elements = [];
2300 appendMatchingElements(container, "[data-tabindex]", elements);
2301 elements.forEach((element) => {
2302 const tabindex = element.dataset.tabindex;
2303 delete element.dataset.tabindex;
2304 if (tabindex) {
2305 element.setAttribute("tabindex", tabindex);
2306 } else {
2307 element.removeAttribute("tabindex");
2308 }
2309 });
2310 }
2311
2312 // node_modules/@base-ui/utils/esm/addEventListener.js
2313 function addEventListener(target, type, listener, options) {
2314 target.addEventListener(type, listener, options);
2315 return () => {
2316 target.removeEventListener(type, listener, options);
2317 };
2318 }
2319
2320 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2321 function useValueAsRef(value) {
2322 const latest = useRefWithInit(createLatestRef, value).current;
2323 latest.next = value;
2324 useIsoLayoutEffect(latest.effect);
2325 return latest;
2326 }
2327 function createLatestRef(value) {
2328 const latest = {
2329 current: value,
2330 next: value,
2331 effect: () => {
2332 latest.current = latest.next;
2333 }
2334 };
2335 return latest;
2336 }
2337
2338 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2339 var React11 = __toESM(require_react(), 1);
2340
2341 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2342 var ReactDOM = __toESM(require_react_dom(), 1);
2343
2344 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2345 function resolveRef(maybeRef) {
2346 if (maybeRef == null) {
2347 return maybeRef;
2348 }
2349 return "current" in maybeRef ? maybeRef.current : maybeRef;
2350 }
2351
2352 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2353 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2354 const frame = useAnimationFrame();
2355 return useStableCallback((fnToExecute, signal = null) => {
2356 frame.cancel();
2357 const element = resolveRef(elementOrRef);
2358 if (element == null) {
2359 return;
2360 }
2361 const resolvedElement = element;
2362 const done = () => {
2363 ReactDOM.flushSync(fnToExecute);
2364 };
2365 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2366 fnToExecute();
2367 return;
2368 }
2369 function exec() {
2370 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2371 if (!signal?.aborted) {
2372 done();
2373 }
2374 }).catch(() => {
2375 if (treatAbortedAsFinished) {
2376 if (!signal?.aborted) {
2377 done();
2378 }
2379 return;
2380 }
2381 const currentAnimations = resolvedElement.getAnimations();
2382 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2383 exec();
2384 }
2385 });
2386 }
2387 if (waitForStartingStyleRemoved) {
2388 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2389 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2390 frame.request(exec);
2391 return;
2392 }
2393 const attributeObserver = new MutationObserver(() => {
2394 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2395 attributeObserver.disconnect();
2396 exec();
2397 }
2398 });
2399 attributeObserver.observe(resolvedElement, {
2400 attributes: true,
2401 attributeFilter: [startingStyleAttribute]
2402 });
2403 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2404 once: true
2405 });
2406 return;
2407 }
2408 frame.request(exec);
2409 });
2410 }
2411
2412 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2413 function useOpenChangeComplete(parameters) {
2414 const {
2415 enabled = true,
2416 open,
2417 ref,
2418 onComplete: onCompleteParam
2419 } = parameters;
2420 const onComplete = useStableCallback(onCompleteParam);
2421 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2422 React11.useEffect(() => {
2423 if (!enabled) {
2424 return void 0;
2425 }
2426 const abortController = new AbortController();
2427 runOnceAnimationsFinish(onComplete, abortController.signal);
2428 return () => {
2429 abortController.abort();
2430 };
2431 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2432 }
2433
2434 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2435 var React12 = __toESM(require_react(), 1);
2436 function useOnFirstRender(fn) {
2437 const ref = React12.useRef(true);
2438 if (ref.current) {
2439 ref.current = false;
2440 fn();
2441 }
2442 }
2443
2444 // node_modules/@base-ui/utils/esm/useTimeout.js
2445 var EMPTY3 = 0;
2446 var Timeout = class _Timeout {
2447 static create() {
2448 return new _Timeout();
2449 }
2450 currentId = EMPTY3;
2451 /**
2452 * Executes `fn` after `delay`, clearing any previously scheduled call.
2453 */
2454 start(delay, fn) {
2455 this.clear();
2456 this.currentId = setTimeout(() => {
2457 this.currentId = EMPTY3;
2458 fn();
2459 }, delay);
2460 }
2461 isStarted() {
2462 return this.currentId !== EMPTY3;
2463 }
2464 clear = () => {
2465 if (this.currentId !== EMPTY3) {
2466 clearTimeout(this.currentId);
2467 this.currentId = EMPTY3;
2468 }
2469 };
2470 disposeEffect = () => {
2471 return this.clear;
2472 };
2473 };
2474 function useTimeout() {
2475 const timeout = useRefWithInit(Timeout.create).current;
2476 useOnMount(timeout.disposeEffect);
2477 return timeout;
2478 }
2479
2480 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2481 var React13 = __toESM(require_react(), 1);
2482
2483 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2484 function resolveValue(value, pointerType) {
2485 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2486 return 0;
2487 }
2488 if (typeof value === "function") {
2489 return value();
2490 }
2491 return value;
2492 }
2493 function getDelay(value, prop, pointerType) {
2494 const result = resolveValue(value, pointerType);
2495 if (typeof result === "number") {
2496 return result;
2497 }
2498 return result?.[prop];
2499 }
2500 function getRestMs(value) {
2501 if (typeof value === "function") {
2502 return value();
2503 }
2504 return value;
2505 }
2506 function isClickLikeOpenEvent(openEventType, interactedInside) {
2507 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2508 }
2509 function isHoverOpenEvent(openEventType) {
2510 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2511 }
2512
2513 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2514 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2515 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
2516 hasProvider: false,
2517 timeoutMs: 0,
2518 delayRef: {
2519 current: 0
2520 },
2521 initialDelayRef: {
2522 current: 0
2523 },
2524 timeout: new Timeout(),
2525 currentIdRef: {
2526 current: null
2527 },
2528 currentContextRef: {
2529 current: null
2530 }
2531 });
2532 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2533 function FloatingDelayGroup(props) {
2534 const {
2535 children,
2536 delay,
2537 timeoutMs = 0
2538 } = props;
2539 const delayRef = React13.useRef(delay);
2540 const initialDelayRef = React13.useRef(delay);
2541 const currentIdRef = React13.useRef(null);
2542 const currentContextRef = React13.useRef(null);
2543 const timeout = useTimeout();
2544 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2545 value: React13.useMemo(() => ({
2546 hasProvider: true,
2547 delayRef,
2548 initialDelayRef,
2549 currentIdRef,
2550 timeoutMs,
2551 currentContextRef,
2552 timeout
2553 }), [timeoutMs, timeout]),
2554 children
2555 });
2556 }
2557 function useDelayGroup(context, options = {
2558 open: false
2559 }) {
2560 const {
2561 open
2562 } = options;
2563 const store = "rootStore" in context ? context.rootStore : context;
2564 const floatingId = store.useState("floatingId");
2565 const groupContext = React13.useContext(FloatingDelayGroupContext);
2566 const {
2567 currentIdRef,
2568 delayRef,
2569 timeoutMs,
2570 initialDelayRef,
2571 currentContextRef,
2572 hasProvider,
2573 timeout
2574 } = groupContext;
2575 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
2576 useIsoLayoutEffect(() => {
2577 function unset() {
2578 setIsInstantPhase(false);
2579 currentContextRef.current?.setIsInstantPhase(false);
2580 currentIdRef.current = null;
2581 currentContextRef.current = null;
2582 delayRef.current = initialDelayRef.current;
2583 }
2584 if (!currentIdRef.current) {
2585 return void 0;
2586 }
2587 if (!open && currentIdRef.current === floatingId) {
2588 setIsInstantPhase(false);
2589 if (timeoutMs) {
2590 const closingId = floatingId;
2591 timeout.start(timeoutMs, () => {
2592 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2593 return;
2594 }
2595 unset();
2596 });
2597 return () => {
2598 timeout.clear();
2599 };
2600 }
2601 unset();
2602 }
2603 return void 0;
2604 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2605 useIsoLayoutEffect(() => {
2606 if (!open) {
2607 return;
2608 }
2609 const prevContext = currentContextRef.current;
2610 const prevId = currentIdRef.current;
2611 timeout.clear();
2612 currentContextRef.current = {
2613 onOpenChange: store.setOpen,
2614 setIsInstantPhase
2615 };
2616 currentIdRef.current = floatingId;
2617 delayRef.current = {
2618 open: 0,
2619 close: getDelay(initialDelayRef.current, "close")
2620 };
2621 if (prevId !== null && prevId !== floatingId) {
2622 setIsInstantPhase(true);
2623 prevContext?.setIsInstantPhase(true);
2624 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2625 } else {
2626 setIsInstantPhase(false);
2627 prevContext?.setIsInstantPhase(false);
2628 }
2629 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2630 useIsoLayoutEffect(() => {
2631 return () => {
2632 currentContextRef.current = null;
2633 };
2634 }, [currentContextRef]);
2635 return React13.useMemo(() => ({
2636 hasProvider,
2637 delayRef,
2638 isInstantPhase
2639 }), [hasProvider, delayRef, isInstantPhase]);
2640 }
2641
2642 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2643 function mergeCleanups(...cleanups) {
2644 return () => {
2645 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2646 const cleanup = cleanups[i2];
2647 if (cleanup) {
2648 cleanup();
2649 }
2650 }
2651 };
2652 }
2653
2654 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2655 var React14 = __toESM(require_react(), 1);
2656
2657 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2658 var visuallyHiddenBase = {
2659 clipPath: "inset(50%)",
2660 overflow: "hidden",
2661 whiteSpace: "nowrap",
2662 border: 0,
2663 padding: 0,
2664 width: 1,
2665 height: 1,
2666 margin: -1
2667 };
2668 var visuallyHidden = {
2669 ...visuallyHiddenBase,
2670 position: "fixed",
2671 top: 0,
2672 left: 0
2673 };
2674 var visuallyHiddenInput = {
2675 ...visuallyHiddenBase,
2676 position: "absolute"
2677 };
2678
2679 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2680 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2681 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
2682 const [role, setRole] = React14.useState();
2683 useIsoLayoutEffect(() => {
2684 if (isSafari) {
2685 setRole("button");
2686 }
2687 }, []);
2688 const restProps = {
2689 tabIndex: 0,
2690 // Role is only for VoiceOver
2691 role
2692 };
2693 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
2694 ...props,
2695 ref,
2696 style: visuallyHidden,
2697 "aria-hidden": role ? void 0 : true,
2698 ...restProps,
2699 "data-base-ui-focus-guard": ""
2700 });
2701 });
2702 if (true) FocusGuard.displayName = "FocusGuard";
2703
2704 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2705 function createAttribute(name) {
2706 return `data-base-ui-${name}`;
2707 }
2708
2709 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2710 var React15 = __toESM(require_react(), 1);
2711 var ReactDOM2 = __toESM(require_react_dom(), 1);
2712
2713 // node_modules/@base-ui/react/esm/internals/constants.js
2714 var DISABLED_TRANSITIONS_STYLE = {
2715 style: {
2716 transition: "none"
2717 }
2718 };
2719 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2720 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2721 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2722 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2723 var POPUP_COLLISION_AVOIDANCE = {
2724 fallbackAxisSide: "end"
2725 };
2726 var ownerVisuallyHidden = {
2727 clipPath: "inset(50%)",
2728 position: "fixed",
2729 top: 0,
2730 left: 0
2731 };
2732
2733 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2734 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2735 var PortalContext = /* @__PURE__ */ React15.createContext(null);
2736 if (true) PortalContext.displayName = "PortalContext";
2737 var usePortalContext = () => React15.useContext(PortalContext);
2738 var attr = createAttribute("portal");
2739 function useFloatingPortalNode(props = {}) {
2740 const {
2741 ref,
2742 container: containerProp,
2743 componentProps = EMPTY_OBJECT,
2744 elementProps
2745 } = props;
2746 const uniqueId = useId();
2747 const portalContext = usePortalContext();
2748 const parentPortalNode = portalContext?.portalNode;
2749 const [containerElement, setContainerElement] = React15.useState(null);
2750 const [portalNode, setPortalNode] = React15.useState(null);
2751 const setPortalNodeRef = useStableCallback((node) => {
2752 if (node !== null) {
2753 setPortalNode(node);
2754 }
2755 });
2756 const containerRef = React15.useRef(null);
2757 useIsoLayoutEffect(() => {
2758 if (containerProp === null) {
2759 if (containerRef.current) {
2760 containerRef.current = null;
2761 setPortalNode(null);
2762 setContainerElement(null);
2763 }
2764 return;
2765 }
2766 if (uniqueId == null) {
2767 return;
2768 }
2769 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2770 if (resolvedContainer == null) {
2771 if (containerRef.current) {
2772 containerRef.current = null;
2773 setPortalNode(null);
2774 setContainerElement(null);
2775 }
2776 return;
2777 }
2778 if (containerRef.current !== resolvedContainer) {
2779 containerRef.current = resolvedContainer;
2780 setPortalNode(null);
2781 setContainerElement(resolvedContainer);
2782 }
2783 }, [containerProp, parentPortalNode, uniqueId]);
2784 const portalElement = useRenderElement("div", componentProps, {
2785 ref: [ref, setPortalNodeRef],
2786 props: [{
2787 id: uniqueId,
2788 [attr]: ""
2789 }, elementProps]
2790 });
2791 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2792 return {
2793 portalNode,
2794 portalSubtree
2795 };
2796 }
2797 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2798 const {
2799 render: render4,
2800 className,
2801 style,
2802 children,
2803 container,
2804 renderGuards,
2805 ...elementProps
2806 } = componentProps;
2807 const {
2808 portalNode,
2809 portalSubtree
2810 } = useFloatingPortalNode({
2811 container,
2812 ref: forwardedRef,
2813 componentProps,
2814 elementProps
2815 });
2816 const beforeOutsideRef = React15.useRef(null);
2817 const afterOutsideRef = React15.useRef(null);
2818 const beforeInsideRef = React15.useRef(null);
2819 const afterInsideRef = React15.useRef(null);
2820 const [focusManagerState, setFocusManagerState] = React15.useState(null);
2821 const focusInsideDisabledRef = React15.useRef(false);
2822 const modal = focusManagerState?.modal;
2823 const open = focusManagerState?.open;
2824 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2825 React15.useEffect(() => {
2826 if (!portalNode || modal) {
2827 return void 0;
2828 }
2829 function onFocus(event) {
2830 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2831 if (event.type === "focusin") {
2832 if (focusInsideDisabledRef.current) {
2833 enableFocusInside(portalNode);
2834 focusInsideDisabledRef.current = false;
2835 }
2836 } else {
2837 disableFocusInside(portalNode);
2838 focusInsideDisabledRef.current = true;
2839 }
2840 }
2841 }
2842 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
2843 }, [portalNode, modal]);
2844 React15.useEffect(() => {
2845 if (!portalNode || open !== false) {
2846 return;
2847 }
2848 enableFocusInside(portalNode);
2849 focusInsideDisabledRef.current = false;
2850 }, [open, portalNode]);
2851 const portalContextValue = React15.useMemo(() => ({
2852 beforeOutsideRef,
2853 afterOutsideRef,
2854 beforeInsideRef,
2855 afterInsideRef,
2856 portalNode,
2857 setFocusManagerState
2858 }), [portalNode]);
2859 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React15.Fragment, {
2860 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
2861 value: portalContextValue,
2862 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2863 "data-type": "outside",
2864 ref: beforeOutsideRef,
2865 onFocus: (event) => {
2866 if (isOutsideEvent(event, portalNode)) {
2867 beforeInsideRef.current?.focus();
2868 } else {
2869 const domReference = focusManagerState ? focusManagerState.domReference : null;
2870 const prevTabbable = getPreviousTabbable(domReference);
2871 prevTabbable?.focus();
2872 }
2873 }
2874 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
2875 "aria-owns": portalNode.id,
2876 style: ownerVisuallyHidden
2877 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
2878 "data-type": "outside",
2879 ref: afterOutsideRef,
2880 onFocus: (event) => {
2881 if (isOutsideEvent(event, portalNode)) {
2882 afterInsideRef.current?.focus();
2883 } else {
2884 const domReference = focusManagerState ? focusManagerState.domReference : null;
2885 const nextTabbable = getNextTabbable(domReference);
2886 nextTabbable?.focus();
2887 if (focusManagerState?.closeOnFocusOut) {
2888 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
2889 }
2890 }
2891 }
2892 })]
2893 })]
2894 });
2895 });
2896 if (true) FloatingPortal.displayName = "FloatingPortal";
2897
2898 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2899 var React16 = __toESM(require_react(), 1);
2900
2901 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
2902 function createEventEmitter() {
2903 const map = /* @__PURE__ */ new Map();
2904 return {
2905 emit(event, data) {
2906 map.get(event)?.forEach((listener) => listener(data));
2907 },
2908 on(event, listener) {
2909 if (!map.has(event)) {
2910 map.set(event, /* @__PURE__ */ new Set());
2911 }
2912 map.get(event).add(listener);
2913 },
2914 off(event, listener) {
2915 map.get(event)?.delete(listener);
2916 }
2917 };
2918 }
2919
2920 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
2921 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2922 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
2923 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
2924 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
2925 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
2926 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
2927 var useFloatingTree = (externalTree) => {
2928 const contextTree = React16.useContext(FloatingTreeContext);
2929 return externalTree ?? contextTree;
2930 };
2931
2932 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
2933 var React17 = __toESM(require_react(), 1);
2934 function createVirtualElement(domElement, data) {
2935 let offsetX = null;
2936 let offsetY = null;
2937 let isAutoUpdateEvent = false;
2938 return {
2939 contextElement: domElement || void 0,
2940 getBoundingClientRect() {
2941 const domRect = domElement?.getBoundingClientRect() || {
2942 width: 0,
2943 height: 0,
2944 x: 0,
2945 y: 0
2946 };
2947 const isXAxis = data.axis === "x" || data.axis === "both";
2948 const isYAxis = data.axis === "y" || data.axis === "both";
2949 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
2950 let width = domRect.width;
2951 let height = domRect.height;
2952 let x2 = domRect.x;
2953 let y2 = domRect.y;
2954 if (offsetX == null && data.x && isXAxis) {
2955 offsetX = domRect.x - data.x;
2956 }
2957 if (offsetY == null && data.y && isYAxis) {
2958 offsetY = domRect.y - data.y;
2959 }
2960 x2 -= offsetX || 0;
2961 y2 -= offsetY || 0;
2962 width = 0;
2963 height = 0;
2964 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
2965 width = data.axis === "y" ? domRect.width : 0;
2966 height = data.axis === "x" ? domRect.height : 0;
2967 x2 = isXAxis && data.x != null ? data.x : x2;
2968 y2 = isYAxis && data.y != null ? data.y : y2;
2969 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
2970 height = data.axis === "x" ? domRect.height : height;
2971 width = data.axis === "y" ? domRect.width : width;
2972 }
2973 isAutoUpdateEvent = true;
2974 return {
2975 width,
2976 height,
2977 x: x2,
2978 y: y2,
2979 top: y2,
2980 right: x2 + width,
2981 bottom: y2 + height,
2982 left: x2
2983 };
2984 }
2985 };
2986 }
2987 function isMouseBasedEvent(event) {
2988 return event != null && event.clientX != null;
2989 }
2990 function useClientPoint(context, props = {}) {
2991 const {
2992 enabled = true,
2993 axis = "both"
2994 } = props;
2995 const store = "rootStore" in context ? context.rootStore : context;
2996 const open = store.useState("open");
2997 const floating = store.useState("floatingElement");
2998 const domReference = store.useState("domReferenceElement");
2999 const dataRef = store.context.dataRef;
3000 const initialRef = React17.useRef(false);
3001 const cleanupListenerRef = React17.useRef(null);
3002 const [pointerType, setPointerType] = React17.useState();
3003 const [reactive, setReactive] = React17.useState([]);
3004 const resetReference = useStableCallback((reference2) => {
3005 store.set("positionReference", reference2);
3006 });
3007 const setReference = useStableCallback((newX, newY, referenceElement) => {
3008 if (initialRef.current) {
3009 return;
3010 }
3011 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3012 return;
3013 }
3014 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3015 x: newX,
3016 y: newY,
3017 axis,
3018 dataRef,
3019 pointerType
3020 }));
3021 });
3022 const handleReferenceEnterOrMove = useStableCallback((event) => {
3023 if (!open) {
3024 setReference(event.clientX, event.clientY, event.currentTarget);
3025 } else if (!cleanupListenerRef.current) {
3026 setReference(event.clientX, event.clientY, event.currentTarget);
3027 setReactive([]);
3028 }
3029 });
3030 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3031 React17.useEffect(() => {
3032 if (!enabled) {
3033 resetReference(domReference);
3034 return void 0;
3035 }
3036 if (!openCheck) {
3037 return void 0;
3038 }
3039 function cleanupListener() {
3040 cleanupListenerRef.current?.();
3041 cleanupListenerRef.current = null;
3042 }
3043 const win = getWindow(floating);
3044 function handleMouseMove(event) {
3045 const target = getTarget(event);
3046 if (!contains(floating, target)) {
3047 setReference(event.clientX, event.clientY);
3048 } else {
3049 cleanupListener();
3050 }
3051 }
3052 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3053 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3054 } else {
3055 resetReference(domReference);
3056 }
3057 return cleanupListener;
3058 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3059 React17.useEffect(() => () => {
3060 store.set("positionReference", null);
3061 }, [store]);
3062 React17.useEffect(() => {
3063 if (enabled && !floating) {
3064 initialRef.current = false;
3065 }
3066 }, [enabled, floating]);
3067 React17.useEffect(() => {
3068 if (!enabled && open) {
3069 initialRef.current = true;
3070 }
3071 }, [enabled, open]);
3072 const reference = React17.useMemo(() => {
3073 function setPointerTypeRef(event) {
3074 setPointerType(event.pointerType);
3075 }
3076 return {
3077 onPointerDown: setPointerTypeRef,
3078 onPointerEnter: setPointerTypeRef,
3079 onMouseMove: handleReferenceEnterOrMove,
3080 onMouseEnter: handleReferenceEnterOrMove
3081 };
3082 }, [handleReferenceEnterOrMove]);
3083 return React17.useMemo(() => enabled ? {
3084 reference,
3085 trigger: reference
3086 } : {}, [enabled, reference]);
3087 }
3088
3089 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3090 var React18 = __toESM(require_react(), 1);
3091 var bubbleHandlerKeys = {
3092 intentional: "onClick",
3093 sloppy: "onPointerDown"
3094 };
3095 function alwaysFalse() {
3096 return false;
3097 }
3098 function normalizeProp(normalizable) {
3099 return {
3100 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3101 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3102 };
3103 }
3104 function useDismiss(context, props = {}) {
3105 const {
3106 enabled = true,
3107 escapeKey: escapeKey2 = true,
3108 outsidePress: outsidePressProp = true,
3109 outsidePressEvent = "sloppy",
3110 referencePress = alwaysFalse,
3111 referencePressEvent = "sloppy",
3112 bubbles,
3113 externalTree
3114 } = props;
3115 const store = "rootStore" in context ? context.rootStore : context;
3116 const open = store.useState("open");
3117 const floatingElement = store.useState("floatingElement");
3118 const {
3119 dataRef
3120 } = store.context;
3121 const tree = useFloatingTree(externalTree);
3122 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3123 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3124 const outsidePressEnabled = outsidePress2 !== false;
3125 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3126 const {
3127 escapeKey: escapeKeyBubbles,
3128 outsidePress: outsidePressBubbles
3129 } = normalizeProp(bubbles);
3130 const pressStartedInsideRef = React18.useRef(false);
3131 const pressStartPreventedRef = React18.useRef(false);
3132 const suppressNextOutsideClickRef = React18.useRef(false);
3133 const isComposingRef = React18.useRef(false);
3134 const currentPointerTypeRef = React18.useRef("");
3135 const touchStateRef = React18.useRef(null);
3136 const cancelDismissOnEndTimeout = useTimeout();
3137 const clearInsideReactTreeTimeout = useTimeout();
3138 const clearInsideReactTree = useStableCallback(() => {
3139 clearInsideReactTreeTimeout.clear();
3140 dataRef.current.insideReactTree = false;
3141 });
3142 const hasBlockingChild = useStableCallback((bubbleKey) => {
3143 const nodeId = dataRef.current.floatingContext?.nodeId;
3144 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3145 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3146 });
3147 const isEventWithinOwnElements = useStableCallback((event) => {
3148 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3149 });
3150 const closeOnReferencePress = useStableCallback((event) => {
3151 if (!referencePress()) {
3152 return;
3153 }
3154 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3155 });
3156 const closeOnEscapeKeyDown = useStableCallback((event) => {
3157 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3158 return;
3159 }
3160 if (isComposingRef.current) {
3161 return;
3162 }
3163 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3164 return;
3165 }
3166 const native = isReactEvent(event) ? event.nativeEvent : event;
3167 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3168 store.setOpen(false, eventDetails);
3169 if (!eventDetails.isCanceled) {
3170 event.preventDefault();
3171 }
3172 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3173 event.stopPropagation();
3174 }
3175 });
3176 const markInsideReactTree = useStableCallback(() => {
3177 dataRef.current.insideReactTree = true;
3178 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3179 });
3180 const markPressStartedInsideReactTree = useStableCallback((event) => {
3181 if (!open || !enabled || event.button !== 0) {
3182 return;
3183 }
3184 const target = getTarget(event.nativeEvent);
3185 if (!contains(store.select("floatingElement"), target)) {
3186 return;
3187 }
3188 if (!pressStartedInsideRef.current) {
3189 pressStartedInsideRef.current = true;
3190 pressStartPreventedRef.current = false;
3191 }
3192 });
3193 const markInsidePressStartPrevented = useStableCallback((event) => {
3194 if (!open || !enabled) {
3195 return;
3196 }
3197 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3198 return;
3199 }
3200 if (pressStartedInsideRef.current) {
3201 pressStartPreventedRef.current = true;
3202 }
3203 });
3204 React18.useEffect(() => {
3205 if (!open || !enabled) {
3206 return void 0;
3207 }
3208 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3209 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3210 const compositionTimeout = new Timeout();
3211 const preventedPressSuppressionTimeout = new Timeout();
3212 function handleCompositionStart() {
3213 compositionTimeout.clear();
3214 isComposingRef.current = true;
3215 }
3216 function handleCompositionEnd() {
3217 compositionTimeout.start(
3218 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3219 // Only apply to WebKit for the test to remain 0ms.
3220 isWebKit() ? 5 : 0,
3221 () => {
3222 isComposingRef.current = false;
3223 }
3224 );
3225 }
3226 function suppressImmediateOutsideClickAfterPreventedStart() {
3227 suppressNextOutsideClickRef.current = true;
3228 preventedPressSuppressionTimeout.start(0, () => {
3229 suppressNextOutsideClickRef.current = false;
3230 });
3231 }
3232 function resetPressStartState() {
3233 pressStartedInsideRef.current = false;
3234 pressStartPreventedRef.current = false;
3235 }
3236 function getOutsidePressEvent() {
3237 const type = currentPointerTypeRef.current;
3238 const computedType = type === "pen" || !type ? "mouse" : type;
3239 const outsidePressEventValue = getOutsidePressEventProp();
3240 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3241 if (typeof resolved === "string") {
3242 return resolved;
3243 }
3244 return resolved[computedType];
3245 }
3246 function shouldIgnoreEvent(event) {
3247 const computedOutsidePressEvent = getOutsidePressEvent();
3248 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3249 }
3250 function isEventWithinFloatingTree(event) {
3251 const nodeId = dataRef.current.floatingContext?.nodeId;
3252 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3253 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3254 }
3255 function closeOnPressOutside(event) {
3256 if (shouldIgnoreEvent(event)) {
3257 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3258 preventedPressSuppressionTimeout.clear();
3259 suppressNextOutsideClickRef.current = false;
3260 }
3261 clearInsideReactTree();
3262 return;
3263 }
3264 if (dataRef.current.insideReactTree) {
3265 clearInsideReactTree();
3266 return;
3267 }
3268 const target = getTarget(event);
3269 const inertSelector = `[${createAttribute("inert")}]`;
3270 const targetRoot = isElement(target) ? target.getRootNode() : null;
3271 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3272 const triggers = store.context.triggerElements;
3273 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3274 return;
3275 }
3276 let targetRootAncestor = isElement(target) ? target : null;
3277 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3278 const nextParent = getParentNode(targetRootAncestor);
3279 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3280 break;
3281 }
3282 targetRootAncestor = nextParent;
3283 }
3284 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3285 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3286 // element was injected after the floating element rendered.
3287 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3288 return;
3289 }
3290 if (isHTMLElement(target) && !("touches" in event)) {
3291 const lastTraversableNode = isLastTraversableNode(target);
3292 const style = getComputedStyle2(target);
3293 const scrollRe = /auto|scroll/;
3294 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3295 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3296 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3297 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3298 const isRTL7 = style.direction === "rtl";
3299 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3300 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3301 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3302 return;
3303 }
3304 }
3305 if (isEventWithinFloatingTree(event)) {
3306 return;
3307 }
3308 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3309 preventedPressSuppressionTimeout.clear();
3310 suppressNextOutsideClickRef.current = false;
3311 return;
3312 }
3313 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3314 return;
3315 }
3316 if (hasBlockingChild("__outsidePressBubbles")) {
3317 return;
3318 }
3319 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3320 clearInsideReactTree();
3321 }
3322 function handlePointerDown(event) {
3323 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3324 return;
3325 }
3326 closeOnPressOutside(event);
3327 }
3328 function handleTouchStart(event) {
3329 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3330 return;
3331 }
3332 const touch = event.touches[0];
3333 if (touch) {
3334 touchStateRef.current = {
3335 startTime: Date.now(),
3336 startX: touch.clientX,
3337 startY: touch.clientY,
3338 dismissOnTouchEnd: false,
3339 dismissOnMouseDown: true
3340 };
3341 cancelDismissOnEndTimeout.start(1e3, () => {
3342 if (touchStateRef.current) {
3343 touchStateRef.current.dismissOnTouchEnd = false;
3344 touchStateRef.current.dismissOnMouseDown = false;
3345 }
3346 });
3347 }
3348 }
3349 function addTargetEventListenerOnce(event, listener) {
3350 const target = getTarget(event);
3351 if (!target) {
3352 return;
3353 }
3354 const unsubscribe2 = addEventListener(target, event.type, () => {
3355 listener(event);
3356 unsubscribe2();
3357 });
3358 }
3359 function handleTouchStartCapture(event) {
3360 currentPointerTypeRef.current = "touch";
3361 addTargetEventListenerOnce(event, handleTouchStart);
3362 }
3363 function closeOnPressOutsideCapture(event) {
3364 cancelDismissOnEndTimeout.clear();
3365 if (event.type === "pointerdown") {
3366 currentPointerTypeRef.current = event.pointerType;
3367 }
3368 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3369 return;
3370 }
3371 addTargetEventListenerOnce(event, (targetEvent) => {
3372 if (targetEvent.type === "pointerdown") {
3373 handlePointerDown(targetEvent);
3374 } else {
3375 closeOnPressOutside(targetEvent);
3376 }
3377 });
3378 }
3379 function handlePressEndCapture(event) {
3380 if (!pressStartedInsideRef.current) {
3381 return;
3382 }
3383 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3384 resetPressStartState();
3385 if (getOutsidePressEvent() !== "intentional") {
3386 return;
3387 }
3388 if (event.type === "pointercancel") {
3389 if (pressStartedInsideDefaultPrevented) {
3390 suppressImmediateOutsideClickAfterPreventedStart();
3391 }
3392 return;
3393 }
3394 if (isEventWithinFloatingTree(event)) {
3395 return;
3396 }
3397 if (pressStartedInsideDefaultPrevented) {
3398 suppressImmediateOutsideClickAfterPreventedStart();
3399 return;
3400 }
3401 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3402 return;
3403 }
3404 preventedPressSuppressionTimeout.clear();
3405 suppressNextOutsideClickRef.current = true;
3406 clearInsideReactTree();
3407 }
3408 function handleTouchMove(event) {
3409 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3410 return;
3411 }
3412 const touch = event.touches[0];
3413 if (!touch) {
3414 return;
3415 }
3416 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3417 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3418 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3419 if (distance > 5) {
3420 touchStateRef.current.dismissOnTouchEnd = true;
3421 }
3422 if (distance > 10) {
3423 closeOnPressOutside(event);
3424 cancelDismissOnEndTimeout.clear();
3425 touchStateRef.current = null;
3426 }
3427 }
3428 function handleTouchMoveCapture(event) {
3429 addTargetEventListenerOnce(event, handleTouchMove);
3430 }
3431 function handleTouchEnd(event) {
3432 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3433 return;
3434 }
3435 if (touchStateRef.current.dismissOnTouchEnd) {
3436 closeOnPressOutside(event);
3437 }
3438 cancelDismissOnEndTimeout.clear();
3439 touchStateRef.current = null;
3440 }
3441 function handleTouchEndCapture(event) {
3442 addTargetEventListenerOnce(event, handleTouchEnd);
3443 }
3444 const doc = ownerDocument(floatingElement);
3445 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)));
3446 return () => {
3447 unsubscribe();
3448 compositionTimeout.clear();
3449 preventedPressSuppressionTimeout.clear();
3450 resetPressStartState();
3451 suppressNextOutsideClickRef.current = false;
3452 };
3453 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3454 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3455 const reference = React18.useMemo(() => ({
3456 onKeyDown: closeOnEscapeKeyDown,
3457 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3458 ...referencePressEvent !== "intentional" && {
3459 onClick: closeOnReferencePress
3460 }
3461 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3462 const floating = React18.useMemo(() => ({
3463 onKeyDown: closeOnEscapeKeyDown,
3464 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3465 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3466 // See https://github.com/mui/base-ui/pull/3379
3467 onPointerDown: markInsidePressStartPrevented,
3468 onMouseDown: markInsidePressStartPrevented,
3469 onClickCapture: markInsideReactTree,
3470 onMouseDownCapture(event) {
3471 markInsideReactTree();
3472 markPressStartedInsideReactTree(event);
3473 },
3474 onPointerDownCapture(event) {
3475 markInsideReactTree();
3476 markPressStartedInsideReactTree(event);
3477 },
3478 onMouseUpCapture: markInsideReactTree,
3479 onTouchEndCapture: markInsideReactTree,
3480 onTouchMoveCapture: markInsideReactTree
3481 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3482 return React18.useMemo(() => enabled ? {
3483 reference,
3484 floating,
3485 trigger: reference
3486 } : {}, [enabled, reference, floating]);
3487 }
3488
3489 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3490 var React25 = __toESM(require_react(), 1);
3491
3492 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3493 function computeCoordsFromPlacement(_ref, placement, rtl) {
3494 let {
3495 reference,
3496 floating
3497 } = _ref;
3498 const sideAxis = getSideAxis(placement);
3499 const alignmentAxis = getAlignmentAxis(placement);
3500 const alignLength = getAxisLength(alignmentAxis);
3501 const side = getSide(placement);
3502 const isVertical = sideAxis === "y";
3503 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3504 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3505 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3506 let coords;
3507 switch (side) {
3508 case "top":
3509 coords = {
3510 x: commonX,
3511 y: reference.y - floating.height
3512 };
3513 break;
3514 case "bottom":
3515 coords = {
3516 x: commonX,
3517 y: reference.y + reference.height
3518 };
3519 break;
3520 case "right":
3521 coords = {
3522 x: reference.x + reference.width,
3523 y: commonY
3524 };
3525 break;
3526 case "left":
3527 coords = {
3528 x: reference.x - floating.width,
3529 y: commonY
3530 };
3531 break;
3532 default:
3533 coords = {
3534 x: reference.x,
3535 y: reference.y
3536 };
3537 }
3538 switch (getAlignment(placement)) {
3539 case "start":
3540 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3541 break;
3542 case "end":
3543 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3544 break;
3545 }
3546 return coords;
3547 }
3548 async function detectOverflow(state, options) {
3549 var _await$platform$isEle;
3550 if (options === void 0) {
3551 options = {};
3552 }
3553 const {
3554 x: x2,
3555 y: y2,
3556 platform: platform3,
3557 rects,
3558 elements,
3559 strategy
3560 } = state;
3561 const {
3562 boundary = "clippingAncestors",
3563 rootBoundary = "viewport",
3564 elementContext = "floating",
3565 altBoundary = false,
3566 padding = 0
3567 } = evaluate(options, state);
3568 const paddingObject = getPaddingObject(padding);
3569 const altContext = elementContext === "floating" ? "reference" : "floating";
3570 const element = elements[altBoundary ? altContext : elementContext];
3571 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3572 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)),
3573 boundary,
3574 rootBoundary,
3575 strategy
3576 }));
3577 const rect = elementContext === "floating" ? {
3578 x: x2,
3579 y: y2,
3580 width: rects.floating.width,
3581 height: rects.floating.height
3582 } : rects.reference;
3583 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3584 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3585 x: 1,
3586 y: 1
3587 } : {
3588 x: 1,
3589 y: 1
3590 };
3591 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3592 elements,
3593 rect,
3594 offsetParent,
3595 strategy
3596 }) : rect);
3597 return {
3598 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3599 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3600 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3601 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3602 };
3603 }
3604 var MAX_RESET_COUNT = 50;
3605 var computePosition = async (reference, floating, config) => {
3606 const {
3607 placement = "bottom",
3608 strategy = "absolute",
3609 middleware = [],
3610 platform: platform3
3611 } = config;
3612 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3613 ...platform3,
3614 detectOverflow
3615 };
3616 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3617 let rects = await platform3.getElementRects({
3618 reference,
3619 floating,
3620 strategy
3621 });
3622 let {
3623 x: x2,
3624 y: y2
3625 } = computeCoordsFromPlacement(rects, placement, rtl);
3626 let statefulPlacement = placement;
3627 let resetCount = 0;
3628 const middlewareData = {};
3629 for (let i2 = 0; i2 < middleware.length; i2++) {
3630 const currentMiddleware = middleware[i2];
3631 if (!currentMiddleware) {
3632 continue;
3633 }
3634 const {
3635 name,
3636 fn
3637 } = currentMiddleware;
3638 const {
3639 x: nextX,
3640 y: nextY,
3641 data,
3642 reset
3643 } = await fn({
3644 x: x2,
3645 y: y2,
3646 initialPlacement: placement,
3647 placement: statefulPlacement,
3648 strategy,
3649 middlewareData,
3650 rects,
3651 platform: platformWithDetectOverflow,
3652 elements: {
3653 reference,
3654 floating
3655 }
3656 });
3657 x2 = nextX != null ? nextX : x2;
3658 y2 = nextY != null ? nextY : y2;
3659 middlewareData[name] = {
3660 ...middlewareData[name],
3661 ...data
3662 };
3663 if (reset && resetCount < MAX_RESET_COUNT) {
3664 resetCount++;
3665 if (typeof reset === "object") {
3666 if (reset.placement) {
3667 statefulPlacement = reset.placement;
3668 }
3669 if (reset.rects) {
3670 rects = reset.rects === true ? await platform3.getElementRects({
3671 reference,
3672 floating,
3673 strategy
3674 }) : reset.rects;
3675 }
3676 ({
3677 x: x2,
3678 y: y2
3679 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3680 }
3681 i2 = -1;
3682 }
3683 }
3684 return {
3685 x: x2,
3686 y: y2,
3687 placement: statefulPlacement,
3688 strategy,
3689 middlewareData
3690 };
3691 };
3692 var flip = function(options) {
3693 if (options === void 0) {
3694 options = {};
3695 }
3696 return {
3697 name: "flip",
3698 options,
3699 async fn(state) {
3700 var _middlewareData$arrow, _middlewareData$flip;
3701 const {
3702 placement,
3703 middlewareData,
3704 rects,
3705 initialPlacement,
3706 platform: platform3,
3707 elements
3708 } = state;
3709 const {
3710 mainAxis: checkMainAxis = true,
3711 crossAxis: checkCrossAxis = true,
3712 fallbackPlacements: specifiedFallbackPlacements,
3713 fallbackStrategy = "bestFit",
3714 fallbackAxisSideDirection = "none",
3715 flipAlignment = true,
3716 ...detectOverflowOptions
3717 } = evaluate(options, state);
3718 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3719 return {};
3720 }
3721 const side = getSide(placement);
3722 const initialSideAxis = getSideAxis(initialPlacement);
3723 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3724 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3725 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3726 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3727 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3728 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3729 }
3730 const placements2 = [initialPlacement, ...fallbackPlacements];
3731 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3732 const overflows = [];
3733 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3734 if (checkMainAxis) {
3735 overflows.push(overflow[side]);
3736 }
3737 if (checkCrossAxis) {
3738 const sides2 = getAlignmentSides(placement, rects, rtl);
3739 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3740 }
3741 overflowsData = [...overflowsData, {
3742 placement,
3743 overflows
3744 }];
3745 if (!overflows.every((side2) => side2 <= 0)) {
3746 var _middlewareData$flip2, _overflowsData$filter;
3747 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3748 const nextPlacement = placements2[nextIndex];
3749 if (nextPlacement) {
3750 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3751 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3752 // overflows the main axis.
3753 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3754 return {
3755 data: {
3756 index: nextIndex,
3757 overflows: overflowsData
3758 },
3759 reset: {
3760 placement: nextPlacement
3761 }
3762 };
3763 }
3764 }
3765 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;
3766 if (!resetPlacement) {
3767 switch (fallbackStrategy) {
3768 case "bestFit": {
3769 var _overflowsData$filter2;
3770 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3771 if (hasFallbackAxisSideDirection) {
3772 const currentSideAxis = getSideAxis(d2.placement);
3773 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3774 // reading directions favoring greater width.
3775 currentSideAxis === "y";
3776 }
3777 return true;
3778 }).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];
3779 if (placement2) {
3780 resetPlacement = placement2;
3781 }
3782 break;
3783 }
3784 case "initialPlacement":
3785 resetPlacement = initialPlacement;
3786 break;
3787 }
3788 }
3789 if (placement !== resetPlacement) {
3790 return {
3791 reset: {
3792 placement: resetPlacement
3793 }
3794 };
3795 }
3796 }
3797 return {};
3798 }
3799 };
3800 };
3801 function getSideOffsets(overflow, rect) {
3802 return {
3803 top: overflow.top - rect.height,
3804 right: overflow.right - rect.width,
3805 bottom: overflow.bottom - rect.height,
3806 left: overflow.left - rect.width
3807 };
3808 }
3809 function isAnySideFullyClipped(overflow) {
3810 return sides.some((side) => overflow[side] >= 0);
3811 }
3812 var hide = function(options) {
3813 if (options === void 0) {
3814 options = {};
3815 }
3816 return {
3817 name: "hide",
3818 options,
3819 async fn(state) {
3820 const {
3821 rects,
3822 platform: platform3
3823 } = state;
3824 const {
3825 strategy = "referenceHidden",
3826 ...detectOverflowOptions
3827 } = evaluate(options, state);
3828 switch (strategy) {
3829 case "referenceHidden": {
3830 const overflow = await platform3.detectOverflow(state, {
3831 ...detectOverflowOptions,
3832 elementContext: "reference"
3833 });
3834 const offsets = getSideOffsets(overflow, rects.reference);
3835 return {
3836 data: {
3837 referenceHiddenOffsets: offsets,
3838 referenceHidden: isAnySideFullyClipped(offsets)
3839 }
3840 };
3841 }
3842 case "escaped": {
3843 const overflow = await platform3.detectOverflow(state, {
3844 ...detectOverflowOptions,
3845 altBoundary: true
3846 });
3847 const offsets = getSideOffsets(overflow, rects.floating);
3848 return {
3849 data: {
3850 escapedOffsets: offsets,
3851 escaped: isAnySideFullyClipped(offsets)
3852 }
3853 };
3854 }
3855 default: {
3856 return {};
3857 }
3858 }
3859 }
3860 };
3861 };
3862 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
3863 async function convertValueToCoords(state, options) {
3864 const {
3865 placement,
3866 platform: platform3,
3867 elements
3868 } = state;
3869 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3870 const side = getSide(placement);
3871 const alignment = getAlignment(placement);
3872 const isVertical = getSideAxis(placement) === "y";
3873 const mainAxisMulti = originSides.has(side) ? -1 : 1;
3874 const crossAxisMulti = rtl && isVertical ? -1 : 1;
3875 const rawValue = evaluate(options, state);
3876 let {
3877 mainAxis,
3878 crossAxis,
3879 alignmentAxis
3880 } = typeof rawValue === "number" ? {
3881 mainAxis: rawValue,
3882 crossAxis: 0,
3883 alignmentAxis: null
3884 } : {
3885 mainAxis: rawValue.mainAxis || 0,
3886 crossAxis: rawValue.crossAxis || 0,
3887 alignmentAxis: rawValue.alignmentAxis
3888 };
3889 if (alignment && typeof alignmentAxis === "number") {
3890 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
3891 }
3892 return isVertical ? {
3893 x: crossAxis * crossAxisMulti,
3894 y: mainAxis * mainAxisMulti
3895 } : {
3896 x: mainAxis * mainAxisMulti,
3897 y: crossAxis * crossAxisMulti
3898 };
3899 }
3900 var offset = function(options) {
3901 if (options === void 0) {
3902 options = 0;
3903 }
3904 return {
3905 name: "offset",
3906 options,
3907 async fn(state) {
3908 var _middlewareData$offse, _middlewareData$arrow;
3909 const {
3910 x: x2,
3911 y: y2,
3912 placement,
3913 middlewareData
3914 } = state;
3915 const diffCoords = await convertValueToCoords(state, options);
3916 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3917 return {};
3918 }
3919 return {
3920 x: x2 + diffCoords.x,
3921 y: y2 + diffCoords.y,
3922 data: {
3923 ...diffCoords,
3924 placement
3925 }
3926 };
3927 }
3928 };
3929 };
3930 var shift = function(options) {
3931 if (options === void 0) {
3932 options = {};
3933 }
3934 return {
3935 name: "shift",
3936 options,
3937 async fn(state) {
3938 const {
3939 x: x2,
3940 y: y2,
3941 placement,
3942 platform: platform3
3943 } = state;
3944 const {
3945 mainAxis: checkMainAxis = true,
3946 crossAxis: checkCrossAxis = false,
3947 limiter = {
3948 fn: (_ref) => {
3949 let {
3950 x: x3,
3951 y: y3
3952 } = _ref;
3953 return {
3954 x: x3,
3955 y: y3
3956 };
3957 }
3958 },
3959 ...detectOverflowOptions
3960 } = evaluate(options, state);
3961 const coords = {
3962 x: x2,
3963 y: y2
3964 };
3965 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3966 const crossAxis = getSideAxis(getSide(placement));
3967 const mainAxis = getOppositeAxis(crossAxis);
3968 let mainAxisCoord = coords[mainAxis];
3969 let crossAxisCoord = coords[crossAxis];
3970 if (checkMainAxis) {
3971 const minSide = mainAxis === "y" ? "top" : "left";
3972 const maxSide = mainAxis === "y" ? "bottom" : "right";
3973 const min2 = mainAxisCoord + overflow[minSide];
3974 const max2 = mainAxisCoord - overflow[maxSide];
3975 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
3976 }
3977 if (checkCrossAxis) {
3978 const minSide = crossAxis === "y" ? "top" : "left";
3979 const maxSide = crossAxis === "y" ? "bottom" : "right";
3980 const min2 = crossAxisCoord + overflow[minSide];
3981 const max2 = crossAxisCoord - overflow[maxSide];
3982 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
3983 }
3984 const limitedCoords = limiter.fn({
3985 ...state,
3986 [mainAxis]: mainAxisCoord,
3987 [crossAxis]: crossAxisCoord
3988 });
3989 return {
3990 ...limitedCoords,
3991 data: {
3992 x: limitedCoords.x - x2,
3993 y: limitedCoords.y - y2,
3994 enabled: {
3995 [mainAxis]: checkMainAxis,
3996 [crossAxis]: checkCrossAxis
3997 }
3998 }
3999 };
4000 }
4001 };
4002 };
4003 var limitShift = function(options) {
4004 if (options === void 0) {
4005 options = {};
4006 }
4007 return {
4008 options,
4009 fn(state) {
4010 const {
4011 x: x2,
4012 y: y2,
4013 placement,
4014 rects,
4015 middlewareData
4016 } = state;
4017 const {
4018 offset: offset4 = 0,
4019 mainAxis: checkMainAxis = true,
4020 crossAxis: checkCrossAxis = true
4021 } = evaluate(options, state);
4022 const coords = {
4023 x: x2,
4024 y: y2
4025 };
4026 const crossAxis = getSideAxis(placement);
4027 const mainAxis = getOppositeAxis(crossAxis);
4028 let mainAxisCoord = coords[mainAxis];
4029 let crossAxisCoord = coords[crossAxis];
4030 const rawOffset = evaluate(offset4, state);
4031 const computedOffset = typeof rawOffset === "number" ? {
4032 mainAxis: rawOffset,
4033 crossAxis: 0
4034 } : {
4035 mainAxis: 0,
4036 crossAxis: 0,
4037 ...rawOffset
4038 };
4039 if (checkMainAxis) {
4040 const len = mainAxis === "y" ? "height" : "width";
4041 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4042 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4043 if (mainAxisCoord < limitMin) {
4044 mainAxisCoord = limitMin;
4045 } else if (mainAxisCoord > limitMax) {
4046 mainAxisCoord = limitMax;
4047 }
4048 }
4049 if (checkCrossAxis) {
4050 var _middlewareData$offse, _middlewareData$offse2;
4051 const len = mainAxis === "y" ? "width" : "height";
4052 const isOriginSide = originSides.has(getSide(placement));
4053 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);
4054 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);
4055 if (crossAxisCoord < limitMin) {
4056 crossAxisCoord = limitMin;
4057 } else if (crossAxisCoord > limitMax) {
4058 crossAxisCoord = limitMax;
4059 }
4060 }
4061 return {
4062 [mainAxis]: mainAxisCoord,
4063 [crossAxis]: crossAxisCoord
4064 };
4065 }
4066 };
4067 };
4068 var size = function(options) {
4069 if (options === void 0) {
4070 options = {};
4071 }
4072 return {
4073 name: "size",
4074 options,
4075 async fn(state) {
4076 var _state$middlewareData, _state$middlewareData2;
4077 const {
4078 placement,
4079 rects,
4080 platform: platform3,
4081 elements
4082 } = state;
4083 const {
4084 apply = () => {
4085 },
4086 ...detectOverflowOptions
4087 } = evaluate(options, state);
4088 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4089 const side = getSide(placement);
4090 const alignment = getAlignment(placement);
4091 const isYAxis = getSideAxis(placement) === "y";
4092 const {
4093 width,
4094 height
4095 } = rects.floating;
4096 let heightSide;
4097 let widthSide;
4098 if (side === "top" || side === "bottom") {
4099 heightSide = side;
4100 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4101 } else {
4102 widthSide = side;
4103 heightSide = alignment === "end" ? "top" : "bottom";
4104 }
4105 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4106 const maximumClippingWidth = width - overflow.left - overflow.right;
4107 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4108 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4109 const noShift = !state.middlewareData.shift;
4110 let availableHeight = overflowAvailableHeight;
4111 let availableWidth = overflowAvailableWidth;
4112 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4113 availableWidth = maximumClippingWidth;
4114 }
4115 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4116 availableHeight = maximumClippingHeight;
4117 }
4118 if (noShift && !alignment) {
4119 const xMin = max(overflow.left, 0);
4120 const xMax = max(overflow.right, 0);
4121 const yMin = max(overflow.top, 0);
4122 const yMax = max(overflow.bottom, 0);
4123 if (isYAxis) {
4124 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4125 } else {
4126 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4127 }
4128 }
4129 await apply({
4130 ...state,
4131 availableWidth,
4132 availableHeight
4133 });
4134 const nextDimensions = await platform3.getDimensions(elements.floating);
4135 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4136 return {
4137 reset: {
4138 rects: true
4139 }
4140 };
4141 }
4142 return {};
4143 }
4144 };
4145 };
4146
4147 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4148 function getCssDimensions(element) {
4149 const css = getComputedStyle2(element);
4150 let width = parseFloat(css.width) || 0;
4151 let height = parseFloat(css.height) || 0;
4152 const hasOffset = isHTMLElement(element);
4153 const offsetWidth = hasOffset ? element.offsetWidth : width;
4154 const offsetHeight = hasOffset ? element.offsetHeight : height;
4155 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4156 if (shouldFallback) {
4157 width = offsetWidth;
4158 height = offsetHeight;
4159 }
4160 return {
4161 width,
4162 height,
4163 $: shouldFallback
4164 };
4165 }
4166 function unwrapElement(element) {
4167 return !isElement(element) ? element.contextElement : element;
4168 }
4169 function getScale(element) {
4170 const domElement = unwrapElement(element);
4171 if (!isHTMLElement(domElement)) {
4172 return createCoords(1);
4173 }
4174 const rect = domElement.getBoundingClientRect();
4175 const {
4176 width,
4177 height,
4178 $: $2
4179 } = getCssDimensions(domElement);
4180 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4181 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4182 if (!x2 || !Number.isFinite(x2)) {
4183 x2 = 1;
4184 }
4185 if (!y2 || !Number.isFinite(y2)) {
4186 y2 = 1;
4187 }
4188 return {
4189 x: x2,
4190 y: y2
4191 };
4192 }
4193 var noOffsets = /* @__PURE__ */ createCoords(0);
4194 function getVisualOffsets(element) {
4195 const win = getWindow(element);
4196 if (!isWebKit() || !win.visualViewport) {
4197 return noOffsets;
4198 }
4199 return {
4200 x: win.visualViewport.offsetLeft,
4201 y: win.visualViewport.offsetTop
4202 };
4203 }
4204 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4205 if (isFixed === void 0) {
4206 isFixed = false;
4207 }
4208 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4209 return false;
4210 }
4211 return isFixed;
4212 }
4213 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4214 if (includeScale === void 0) {
4215 includeScale = false;
4216 }
4217 if (isFixedStrategy === void 0) {
4218 isFixedStrategy = false;
4219 }
4220 const clientRect = element.getBoundingClientRect();
4221 const domElement = unwrapElement(element);
4222 let scale = createCoords(1);
4223 if (includeScale) {
4224 if (offsetParent) {
4225 if (isElement(offsetParent)) {
4226 scale = getScale(offsetParent);
4227 }
4228 } else {
4229 scale = getScale(element);
4230 }
4231 }
4232 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4233 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4234 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4235 let width = clientRect.width / scale.x;
4236 let height = clientRect.height / scale.y;
4237 if (domElement) {
4238 const win = getWindow(domElement);
4239 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4240 let currentWin = win;
4241 let currentIFrame = getFrameElement(currentWin);
4242 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4243 const iframeScale = getScale(currentIFrame);
4244 const iframeRect = currentIFrame.getBoundingClientRect();
4245 const css = getComputedStyle2(currentIFrame);
4246 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4247 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4248 x2 *= iframeScale.x;
4249 y2 *= iframeScale.y;
4250 width *= iframeScale.x;
4251 height *= iframeScale.y;
4252 x2 += left;
4253 y2 += top;
4254 currentWin = getWindow(currentIFrame);
4255 currentIFrame = getFrameElement(currentWin);
4256 }
4257 }
4258 return rectToClientRect({
4259 width,
4260 height,
4261 x: x2,
4262 y: y2
4263 });
4264 }
4265 function getWindowScrollBarX(element, rect) {
4266 const leftScroll = getNodeScroll(element).scrollLeft;
4267 if (!rect) {
4268 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4269 }
4270 return rect.left + leftScroll;
4271 }
4272 function getHTMLOffset(documentElement, scroll) {
4273 const htmlRect = documentElement.getBoundingClientRect();
4274 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4275 const y2 = htmlRect.top + scroll.scrollTop;
4276 return {
4277 x: x2,
4278 y: y2
4279 };
4280 }
4281 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4282 let {
4283 elements,
4284 rect,
4285 offsetParent,
4286 strategy
4287 } = _ref;
4288 const isFixed = strategy === "fixed";
4289 const documentElement = getDocumentElement(offsetParent);
4290 const topLayer = elements ? isTopLayer(elements.floating) : false;
4291 if (offsetParent === documentElement || topLayer && isFixed) {
4292 return rect;
4293 }
4294 let scroll = {
4295 scrollLeft: 0,
4296 scrollTop: 0
4297 };
4298 let scale = createCoords(1);
4299 const offsets = createCoords(0);
4300 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4301 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4302 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4303 scroll = getNodeScroll(offsetParent);
4304 }
4305 if (isOffsetParentAnElement) {
4306 const offsetRect = getBoundingClientRect(offsetParent);
4307 scale = getScale(offsetParent);
4308 offsets.x = offsetRect.x + offsetParent.clientLeft;
4309 offsets.y = offsetRect.y + offsetParent.clientTop;
4310 }
4311 }
4312 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4313 return {
4314 width: rect.width * scale.x,
4315 height: rect.height * scale.y,
4316 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4317 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4318 };
4319 }
4320 function getClientRects(element) {
4321 return Array.from(element.getClientRects());
4322 }
4323 function getDocumentRect(element) {
4324 const html = getDocumentElement(element);
4325 const scroll = getNodeScroll(element);
4326 const body = element.ownerDocument.body;
4327 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4328 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4329 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4330 const y2 = -scroll.scrollTop;
4331 if (getComputedStyle2(body).direction === "rtl") {
4332 x2 += max(html.clientWidth, body.clientWidth) - width;
4333 }
4334 return {
4335 width,
4336 height,
4337 x: x2,
4338 y: y2
4339 };
4340 }
4341 var SCROLLBAR_MAX = 25;
4342 function getViewportRect(element, strategy) {
4343 const win = getWindow(element);
4344 const html = getDocumentElement(element);
4345 const visualViewport = win.visualViewport;
4346 let width = html.clientWidth;
4347 let height = html.clientHeight;
4348 let x2 = 0;
4349 let y2 = 0;
4350 if (visualViewport) {
4351 width = visualViewport.width;
4352 height = visualViewport.height;
4353 const visualViewportBased = isWebKit();
4354 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4355 x2 = visualViewport.offsetLeft;
4356 y2 = visualViewport.offsetTop;
4357 }
4358 }
4359 const windowScrollbarX = getWindowScrollBarX(html);
4360 if (windowScrollbarX <= 0) {
4361 const doc = html.ownerDocument;
4362 const body = doc.body;
4363 const bodyStyles = getComputedStyle(body);
4364 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4365 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4366 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4367 width -= clippingStableScrollbarWidth;
4368 }
4369 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4370 width += windowScrollbarX;
4371 }
4372 return {
4373 width,
4374 height,
4375 x: x2,
4376 y: y2
4377 };
4378 }
4379 function getInnerBoundingClientRect(element, strategy) {
4380 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4381 const top = clientRect.top + element.clientTop;
4382 const left = clientRect.left + element.clientLeft;
4383 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4384 const width = element.clientWidth * scale.x;
4385 const height = element.clientHeight * scale.y;
4386 const x2 = left * scale.x;
4387 const y2 = top * scale.y;
4388 return {
4389 width,
4390 height,
4391 x: x2,
4392 y: y2
4393 };
4394 }
4395 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4396 let rect;
4397 if (clippingAncestor === "viewport") {
4398 rect = getViewportRect(element, strategy);
4399 } else if (clippingAncestor === "document") {
4400 rect = getDocumentRect(getDocumentElement(element));
4401 } else if (isElement(clippingAncestor)) {
4402 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4403 } else {
4404 const visualOffsets = getVisualOffsets(element);
4405 rect = {
4406 x: clippingAncestor.x - visualOffsets.x,
4407 y: clippingAncestor.y - visualOffsets.y,
4408 width: clippingAncestor.width,
4409 height: clippingAncestor.height
4410 };
4411 }
4412 return rectToClientRect(rect);
4413 }
4414 function hasFixedPositionAncestor(element, stopNode) {
4415 const parentNode = getParentNode(element);
4416 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4417 return false;
4418 }
4419 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4420 }
4421 function getClippingElementAncestors(element, cache) {
4422 const cachedResult = cache.get(element);
4423 if (cachedResult) {
4424 return cachedResult;
4425 }
4426 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4427 let currentContainingBlockComputedStyle = null;
4428 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4429 let currentNode = elementIsFixed ? getParentNode(element) : element;
4430 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4431 const computedStyle = getComputedStyle2(currentNode);
4432 const currentNodeIsContaining = isContainingBlock(currentNode);
4433 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4434 currentContainingBlockComputedStyle = null;
4435 }
4436 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4437 if (shouldDropCurrentNode) {
4438 result = result.filter((ancestor) => ancestor !== currentNode);
4439 } else {
4440 currentContainingBlockComputedStyle = computedStyle;
4441 }
4442 currentNode = getParentNode(currentNode);
4443 }
4444 cache.set(element, result);
4445 return result;
4446 }
4447 function getClippingRect(_ref) {
4448 let {
4449 element,
4450 boundary,
4451 rootBoundary,
4452 strategy
4453 } = _ref;
4454 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4455 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4456 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4457 let top = firstRect.top;
4458 let right = firstRect.right;
4459 let bottom = firstRect.bottom;
4460 let left = firstRect.left;
4461 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4462 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4463 top = max(rect.top, top);
4464 right = min(rect.right, right);
4465 bottom = min(rect.bottom, bottom);
4466 left = max(rect.left, left);
4467 }
4468 return {
4469 width: right - left,
4470 height: bottom - top,
4471 x: left,
4472 y: top
4473 };
4474 }
4475 function getDimensions(element) {
4476 const {
4477 width,
4478 height
4479 } = getCssDimensions(element);
4480 return {
4481 width,
4482 height
4483 };
4484 }
4485 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4486 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4487 const documentElement = getDocumentElement(offsetParent);
4488 const isFixed = strategy === "fixed";
4489 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4490 let scroll = {
4491 scrollLeft: 0,
4492 scrollTop: 0
4493 };
4494 const offsets = createCoords(0);
4495 function setLeftRTLScrollbarOffset() {
4496 offsets.x = getWindowScrollBarX(documentElement);
4497 }
4498 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4499 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4500 scroll = getNodeScroll(offsetParent);
4501 }
4502 if (isOffsetParentAnElement) {
4503 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4504 offsets.x = offsetRect.x + offsetParent.clientLeft;
4505 offsets.y = offsetRect.y + offsetParent.clientTop;
4506 } else if (documentElement) {
4507 setLeftRTLScrollbarOffset();
4508 }
4509 }
4510 if (isFixed && !isOffsetParentAnElement && documentElement) {
4511 setLeftRTLScrollbarOffset();
4512 }
4513 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4514 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4515 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4516 return {
4517 x: x2,
4518 y: y2,
4519 width: rect.width,
4520 height: rect.height
4521 };
4522 }
4523 function isStaticPositioned(element) {
4524 return getComputedStyle2(element).position === "static";
4525 }
4526 function getTrueOffsetParent(element, polyfill) {
4527 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4528 return null;
4529 }
4530 if (polyfill) {
4531 return polyfill(element);
4532 }
4533 let rawOffsetParent = element.offsetParent;
4534 if (getDocumentElement(element) === rawOffsetParent) {
4535 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4536 }
4537 return rawOffsetParent;
4538 }
4539 function getOffsetParent(element, polyfill) {
4540 const win = getWindow(element);
4541 if (isTopLayer(element)) {
4542 return win;
4543 }
4544 if (!isHTMLElement(element)) {
4545 let svgOffsetParent = getParentNode(element);
4546 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4547 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4548 return svgOffsetParent;
4549 }
4550 svgOffsetParent = getParentNode(svgOffsetParent);
4551 }
4552 return win;
4553 }
4554 let offsetParent = getTrueOffsetParent(element, polyfill);
4555 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4556 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4557 }
4558 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4559 return win;
4560 }
4561 return offsetParent || getContainingBlock(element) || win;
4562 }
4563 var getElementRects = async function(data) {
4564 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4565 const getDimensionsFn = this.getDimensions;
4566 const floatingDimensions = await getDimensionsFn(data.floating);
4567 return {
4568 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4569 floating: {
4570 x: 0,
4571 y: 0,
4572 width: floatingDimensions.width,
4573 height: floatingDimensions.height
4574 }
4575 };
4576 };
4577 function isRTL(element) {
4578 return getComputedStyle2(element).direction === "rtl";
4579 }
4580 var platform2 = {
4581 convertOffsetParentRelativeRectToViewportRelativeRect,
4582 getDocumentElement,
4583 getClippingRect,
4584 getOffsetParent,
4585 getElementRects,
4586 getClientRects,
4587 getDimensions,
4588 getScale,
4589 isElement,
4590 isRTL
4591 };
4592 function rectsAreEqual(a2, b2) {
4593 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4594 }
4595 function observeMove(element, onMove) {
4596 let io = null;
4597 let timeoutId;
4598 const root = getDocumentElement(element);
4599 function cleanup() {
4600 var _io;
4601 clearTimeout(timeoutId);
4602 (_io = io) == null || _io.disconnect();
4603 io = null;
4604 }
4605 function refresh(skip, threshold) {
4606 if (skip === void 0) {
4607 skip = false;
4608 }
4609 if (threshold === void 0) {
4610 threshold = 1;
4611 }
4612 cleanup();
4613 const elementRectForRootMargin = element.getBoundingClientRect();
4614 const {
4615 left,
4616 top,
4617 width,
4618 height
4619 } = elementRectForRootMargin;
4620 if (!skip) {
4621 onMove();
4622 }
4623 if (!width || !height) {
4624 return;
4625 }
4626 const insetTop = floor(top);
4627 const insetRight = floor(root.clientWidth - (left + width));
4628 const insetBottom = floor(root.clientHeight - (top + height));
4629 const insetLeft = floor(left);
4630 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4631 const options = {
4632 rootMargin,
4633 threshold: max(0, min(1, threshold)) || 1
4634 };
4635 let isFirstUpdate = true;
4636 function handleObserve(entries) {
4637 const ratio = entries[0].intersectionRatio;
4638 if (ratio !== threshold) {
4639 if (!isFirstUpdate) {
4640 return refresh();
4641 }
4642 if (!ratio) {
4643 timeoutId = setTimeout(() => {
4644 refresh(false, 1e-7);
4645 }, 1e3);
4646 } else {
4647 refresh(false, ratio);
4648 }
4649 }
4650 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4651 refresh();
4652 }
4653 isFirstUpdate = false;
4654 }
4655 try {
4656 io = new IntersectionObserver(handleObserve, {
4657 ...options,
4658 // Handle <iframe>s
4659 root: root.ownerDocument
4660 });
4661 } catch (_e) {
4662 io = new IntersectionObserver(handleObserve, options);
4663 }
4664 io.observe(element);
4665 }
4666 refresh(true);
4667 return cleanup;
4668 }
4669 function autoUpdate(reference, floating, update2, options) {
4670 if (options === void 0) {
4671 options = {};
4672 }
4673 const {
4674 ancestorScroll = true,
4675 ancestorResize = true,
4676 elementResize = typeof ResizeObserver === "function",
4677 layoutShift = typeof IntersectionObserver === "function",
4678 animationFrame = false
4679 } = options;
4680 const referenceEl = unwrapElement(reference);
4681 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4682 ancestors.forEach((ancestor) => {
4683 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4684 passive: true
4685 });
4686 ancestorResize && ancestor.addEventListener("resize", update2);
4687 });
4688 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4689 let reobserveFrame = -1;
4690 let resizeObserver = null;
4691 if (elementResize) {
4692 resizeObserver = new ResizeObserver((_ref) => {
4693 let [firstEntry] = _ref;
4694 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4695 resizeObserver.unobserve(floating);
4696 cancelAnimationFrame(reobserveFrame);
4697 reobserveFrame = requestAnimationFrame(() => {
4698 var _resizeObserver;
4699 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4700 });
4701 }
4702 update2();
4703 });
4704 if (referenceEl && !animationFrame) {
4705 resizeObserver.observe(referenceEl);
4706 }
4707 if (floating) {
4708 resizeObserver.observe(floating);
4709 }
4710 }
4711 let frameId;
4712 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4713 if (animationFrame) {
4714 frameLoop();
4715 }
4716 function frameLoop() {
4717 const nextRefRect = getBoundingClientRect(reference);
4718 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4719 update2();
4720 }
4721 prevRefRect = nextRefRect;
4722 frameId = requestAnimationFrame(frameLoop);
4723 }
4724 update2();
4725 return () => {
4726 var _resizeObserver2;
4727 ancestors.forEach((ancestor) => {
4728 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4729 ancestorResize && ancestor.removeEventListener("resize", update2);
4730 });
4731 cleanupIo == null || cleanupIo();
4732 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4733 resizeObserver = null;
4734 if (animationFrame) {
4735 cancelAnimationFrame(frameId);
4736 }
4737 };
4738 }
4739 var offset2 = offset;
4740 var shift2 = shift;
4741 var flip2 = flip;
4742 var size2 = size;
4743 var hide2 = hide;
4744 var limitShift2 = limitShift;
4745 var computePosition2 = (reference, floating, options) => {
4746 const cache = /* @__PURE__ */ new Map();
4747 const mergedOptions = {
4748 platform: platform2,
4749 ...options
4750 };
4751 const platformWithCache = {
4752 ...mergedOptions.platform,
4753 _c: cache
4754 };
4755 return computePosition(reference, floating, {
4756 ...mergedOptions,
4757 platform: platformWithCache
4758 });
4759 };
4760
4761 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4762 var React19 = __toESM(require_react(), 1);
4763 var import_react2 = __toESM(require_react(), 1);
4764 var ReactDOM3 = __toESM(require_react_dom(), 1);
4765 var isClient = typeof document !== "undefined";
4766 var noop2 = function noop3() {
4767 };
4768 var index = isClient ? import_react2.useLayoutEffect : noop2;
4769 function deepEqual(a2, b2) {
4770 if (a2 === b2) {
4771 return true;
4772 }
4773 if (typeof a2 !== typeof b2) {
4774 return false;
4775 }
4776 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4777 return true;
4778 }
4779 let length;
4780 let i2;
4781 let keys;
4782 if (a2 && b2 && typeof a2 === "object") {
4783 if (Array.isArray(a2)) {
4784 length = a2.length;
4785 if (length !== b2.length) return false;
4786 for (i2 = length; i2-- !== 0; ) {
4787 if (!deepEqual(a2[i2], b2[i2])) {
4788 return false;
4789 }
4790 }
4791 return true;
4792 }
4793 keys = Object.keys(a2);
4794 length = keys.length;
4795 if (length !== Object.keys(b2).length) {
4796 return false;
4797 }
4798 for (i2 = length; i2-- !== 0; ) {
4799 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4800 return false;
4801 }
4802 }
4803 for (i2 = length; i2-- !== 0; ) {
4804 const key = keys[i2];
4805 if (key === "_owner" && a2.$$typeof) {
4806 continue;
4807 }
4808 if (!deepEqual(a2[key], b2[key])) {
4809 return false;
4810 }
4811 }
4812 return true;
4813 }
4814 return a2 !== a2 && b2 !== b2;
4815 }
4816 function getDPR(element) {
4817 if (typeof window === "undefined") {
4818 return 1;
4819 }
4820 const win = element.ownerDocument.defaultView || window;
4821 return win.devicePixelRatio || 1;
4822 }
4823 function roundByDPR(element, value) {
4824 const dpr = getDPR(element);
4825 return Math.round(value * dpr) / dpr;
4826 }
4827 function useLatestRef(value) {
4828 const ref = React19.useRef(value);
4829 index(() => {
4830 ref.current = value;
4831 });
4832 return ref;
4833 }
4834 function useFloating(options) {
4835 if (options === void 0) {
4836 options = {};
4837 }
4838 const {
4839 placement = "bottom",
4840 strategy = "absolute",
4841 middleware = [],
4842 platform: platform3,
4843 elements: {
4844 reference: externalReference,
4845 floating: externalFloating
4846 } = {},
4847 transform = true,
4848 whileElementsMounted,
4849 open
4850 } = options;
4851 const [data, setData] = React19.useState({
4852 x: 0,
4853 y: 0,
4854 strategy,
4855 placement,
4856 middlewareData: {},
4857 isPositioned: false
4858 });
4859 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
4860 if (!deepEqual(latestMiddleware, middleware)) {
4861 setLatestMiddleware(middleware);
4862 }
4863 const [_reference, _setReference] = React19.useState(null);
4864 const [_floating, _setFloating] = React19.useState(null);
4865 const setReference = React19.useCallback((node) => {
4866 if (node !== referenceRef.current) {
4867 referenceRef.current = node;
4868 _setReference(node);
4869 }
4870 }, []);
4871 const setFloating = React19.useCallback((node) => {
4872 if (node !== floatingRef.current) {
4873 floatingRef.current = node;
4874 _setFloating(node);
4875 }
4876 }, []);
4877 const referenceEl = externalReference || _reference;
4878 const floatingEl = externalFloating || _floating;
4879 const referenceRef = React19.useRef(null);
4880 const floatingRef = React19.useRef(null);
4881 const dataRef = React19.useRef(data);
4882 const hasWhileElementsMounted = whileElementsMounted != null;
4883 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
4884 const platformRef = useLatestRef(platform3);
4885 const openRef = useLatestRef(open);
4886 const update2 = React19.useCallback(() => {
4887 if (!referenceRef.current || !floatingRef.current) {
4888 return;
4889 }
4890 const config = {
4891 placement,
4892 strategy,
4893 middleware: latestMiddleware
4894 };
4895 if (platformRef.current) {
4896 config.platform = platformRef.current;
4897 }
4898 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
4899 const fullData = {
4900 ...data2,
4901 // The floating element's position may be recomputed while it's closed
4902 // but still mounted (such as when transitioning out). To ensure
4903 // `isPositioned` will be `false` initially on the next open, avoid
4904 // setting it to `true` when `open === false` (must be specified).
4905 isPositioned: openRef.current !== false
4906 };
4907 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
4908 dataRef.current = fullData;
4909 ReactDOM3.flushSync(() => {
4910 setData(fullData);
4911 });
4912 }
4913 });
4914 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
4915 index(() => {
4916 if (open === false && dataRef.current.isPositioned) {
4917 dataRef.current.isPositioned = false;
4918 setData((data2) => ({
4919 ...data2,
4920 isPositioned: false
4921 }));
4922 }
4923 }, [open]);
4924 const isMountedRef = React19.useRef(false);
4925 index(() => {
4926 isMountedRef.current = true;
4927 return () => {
4928 isMountedRef.current = false;
4929 };
4930 }, []);
4931 index(() => {
4932 if (referenceEl) referenceRef.current = referenceEl;
4933 if (floatingEl) floatingRef.current = floatingEl;
4934 if (referenceEl && floatingEl) {
4935 if (whileElementsMountedRef.current) {
4936 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
4937 }
4938 update2();
4939 }
4940 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
4941 const refs = React19.useMemo(() => ({
4942 reference: referenceRef,
4943 floating: floatingRef,
4944 setReference,
4945 setFloating
4946 }), [setReference, setFloating]);
4947 const elements = React19.useMemo(() => ({
4948 reference: referenceEl,
4949 floating: floatingEl
4950 }), [referenceEl, floatingEl]);
4951 const floatingStyles = React19.useMemo(() => {
4952 const initialStyles = {
4953 position: strategy,
4954 left: 0,
4955 top: 0
4956 };
4957 if (!elements.floating) {
4958 return initialStyles;
4959 }
4960 const x2 = roundByDPR(elements.floating, data.x);
4961 const y2 = roundByDPR(elements.floating, data.y);
4962 if (transform) {
4963 return {
4964 ...initialStyles,
4965 transform: "translate(" + x2 + "px, " + y2 + "px)",
4966 ...getDPR(elements.floating) >= 1.5 && {
4967 willChange: "transform"
4968 }
4969 };
4970 }
4971 return {
4972 position: strategy,
4973 left: x2,
4974 top: y2
4975 };
4976 }, [strategy, transform, elements.floating, data.x, data.y]);
4977 return React19.useMemo(() => ({
4978 ...data,
4979 update: update2,
4980 refs,
4981 elements,
4982 floatingStyles
4983 }), [data, update2, refs, elements, floatingStyles]);
4984 }
4985 var offset3 = (options, deps) => {
4986 const result = offset2(options);
4987 return {
4988 name: result.name,
4989 fn: result.fn,
4990 options: [options, deps]
4991 };
4992 };
4993 var shift3 = (options, deps) => {
4994 const result = shift2(options);
4995 return {
4996 name: result.name,
4997 fn: result.fn,
4998 options: [options, deps]
4999 };
5000 };
5001 var limitShift3 = (options, deps) => {
5002 const result = limitShift2(options);
5003 return {
5004 fn: result.fn,
5005 options: [options, deps]
5006 };
5007 };
5008 var flip3 = (options, deps) => {
5009 const result = flip2(options);
5010 return {
5011 name: result.name,
5012 fn: result.fn,
5013 options: [options, deps]
5014 };
5015 };
5016 var size3 = (options, deps) => {
5017 const result = size2(options);
5018 return {
5019 name: result.name,
5020 fn: result.fn,
5021 options: [options, deps]
5022 };
5023 };
5024 var hide3 = (options, deps) => {
5025 const result = hide2(options);
5026 return {
5027 name: result.name,
5028 fn: result.fn,
5029 options: [options, deps]
5030 };
5031 };
5032
5033 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5034 var React24 = __toESM(require_react(), 1);
5035
5036 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5037 var React23 = __toESM(require_react(), 1);
5038
5039 // node_modules/@base-ui/utils/esm/store/createSelector.js
5040 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5041 if (other.length > 0) {
5042 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5043 }
5044 let selector2;
5045 if (a2 && b2 && c2 && d2 && e2 && f2) {
5046 selector2 = (state, a1, a22, a3) => {
5047 const va = a2(state, a1, a22, a3);
5048 const vb = b2(state, a1, a22, a3);
5049 const vc = c2(state, a1, a22, a3);
5050 const vd = d2(state, a1, a22, a3);
5051 const ve = e2(state, a1, a22, a3);
5052 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5053 };
5054 } else if (a2 && b2 && c2 && d2 && e2) {
5055 selector2 = (state, a1, a22, a3) => {
5056 const va = a2(state, a1, a22, a3);
5057 const vb = b2(state, a1, a22, a3);
5058 const vc = c2(state, a1, a22, a3);
5059 const vd = d2(state, a1, a22, a3);
5060 return e2(va, vb, vc, vd, a1, a22, a3);
5061 };
5062 } else if (a2 && b2 && c2 && d2) {
5063 selector2 = (state, a1, a22, a3) => {
5064 const va = a2(state, a1, a22, a3);
5065 const vb = b2(state, a1, a22, a3);
5066 const vc = c2(state, a1, a22, a3);
5067 return d2(va, vb, vc, a1, a22, a3);
5068 };
5069 } else if (a2 && b2 && c2) {
5070 selector2 = (state, a1, a22, a3) => {
5071 const va = a2(state, a1, a22, a3);
5072 const vb = b2(state, a1, a22, a3);
5073 return c2(va, vb, a1, a22, a3);
5074 };
5075 } else if (a2 && b2) {
5076 selector2 = (state, a1, a22, a3) => {
5077 const va = a2(state, a1, a22, a3);
5078 return b2(va, a1, a22, a3);
5079 };
5080 } else if (a2) {
5081 selector2 = a2;
5082 } else {
5083 throw (
5084 /* minify-error-disabled */
5085 new Error("Missing arguments")
5086 );
5087 }
5088 return selector2;
5089 };
5090
5091 // node_modules/@base-ui/utils/esm/store/useStore.js
5092 var React21 = __toESM(require_react(), 1);
5093 var import_shim = __toESM(require_shim(), 1);
5094 var import_with_selector = __toESM(require_with_selector(), 1);
5095
5096 // node_modules/@base-ui/utils/esm/fastHooks.js
5097 var React20 = __toESM(require_react(), 1);
5098 var hooks = [];
5099 var currentInstance = void 0;
5100 function getInstance() {
5101 return currentInstance;
5102 }
5103 function register(hook) {
5104 hooks.push(hook);
5105 }
5106 function fastComponent(fn) {
5107 const FastComponent = (props, forwardedRef) => {
5108 const instance = useRefWithInit(createInstance).current;
5109 let result;
5110 try {
5111 currentInstance = instance;
5112 for (const hook of hooks) {
5113 hook.before(instance);
5114 }
5115 result = fn(props, forwardedRef);
5116 for (const hook of hooks) {
5117 hook.after(instance);
5118 }
5119 instance.didInitialize = true;
5120 } finally {
5121 currentInstance = void 0;
5122 }
5123 return result;
5124 };
5125 FastComponent.displayName = fn.displayName || fn.name;
5126 return FastComponent;
5127 }
5128 function fastComponentRef(fn) {
5129 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
5130 }
5131 function createInstance() {
5132 return {
5133 didInitialize: false
5134 };
5135 }
5136
5137 // node_modules/@base-ui/utils/esm/store/useStore.js
5138 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5139 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5140 function useStore(store, selector2, a1, a2, a3) {
5141 return useStoreImplementation(store, selector2, a1, a2, a3);
5142 }
5143 function useStoreR19(store, selector2, a1, a2, a3) {
5144 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5145 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5146 }
5147 register({
5148 before(instance) {
5149 instance.syncIndex = 0;
5150 if (!instance.didInitialize) {
5151 instance.syncTick = 1;
5152 instance.syncHooks = [];
5153 instance.didChangeStore = true;
5154 instance.getSnapshot = () => {
5155 let didChange2 = false;
5156 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5157 const hook = instance.syncHooks[i2];
5158 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5159 if (hook.didChange || !Object.is(hook.value, value)) {
5160 didChange2 = true;
5161 hook.value = value;
5162 hook.didChange = false;
5163 }
5164 }
5165 if (didChange2) {
5166 instance.syncTick += 1;
5167 }
5168 return instance.syncTick;
5169 };
5170 }
5171 },
5172 after(instance) {
5173 if (instance.syncHooks.length > 0) {
5174 if (instance.didChangeStore) {
5175 instance.didChangeStore = false;
5176 instance.subscribe = (onStoreChange) => {
5177 const stores = /* @__PURE__ */ new Set();
5178 for (const hook of instance.syncHooks) {
5179 stores.add(hook.store);
5180 }
5181 const unsubscribes = [];
5182 for (const store of stores) {
5183 unsubscribes.push(store.subscribe(onStoreChange));
5184 }
5185 return () => {
5186 for (const unsubscribe of unsubscribes) {
5187 unsubscribe();
5188 }
5189 };
5190 };
5191 }
5192 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5193 }
5194 }
5195 });
5196 function useStoreFast(store, selector2, a1, a2, a3) {
5197 const instance = getInstance();
5198 if (!instance) {
5199 return useStoreR19(store, selector2, a1, a2, a3);
5200 }
5201 const index2 = instance.syncIndex;
5202 instance.syncIndex += 1;
5203 let hook;
5204 if (!instance.didInitialize) {
5205 hook = {
5206 store,
5207 selector: selector2,
5208 a1,
5209 a2,
5210 a3,
5211 value: selector2(store.getSnapshot(), a1, a2, a3),
5212 didChange: false
5213 };
5214 instance.syncHooks.push(hook);
5215 } else {
5216 hook = instance.syncHooks[index2];
5217 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5218 if (hook.store !== store) {
5219 instance.didChangeStore = true;
5220 }
5221 hook.store = store;
5222 hook.selector = selector2;
5223 hook.a1 = a1;
5224 hook.a2 = a2;
5225 hook.a3 = a3;
5226 hook.didChange = true;
5227 }
5228 }
5229 return hook.value;
5230 }
5231 function useStoreLegacy(store, selector2, a1, a2, a3) {
5232 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5233 }
5234
5235 // node_modules/@base-ui/utils/esm/store/Store.js
5236 var Store = class {
5237 /**
5238 * The current state of the store.
5239 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5240 * 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).
5241 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5242 *
5243 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5244 */
5245 // Internal state to handle recursive `setState()` calls
5246 constructor(state) {
5247 this.state = state;
5248 this.listeners = /* @__PURE__ */ new Set();
5249 this.updateTick = 0;
5250 }
5251 /**
5252 * Registers a listener that will be called whenever the store's state changes.
5253 *
5254 * @param fn The listener function to be called on state changes.
5255 * @returns A function to unsubscribe the listener.
5256 */
5257 subscribe = (fn) => {
5258 this.listeners.add(fn);
5259 return () => {
5260 this.listeners.delete(fn);
5261 };
5262 };
5263 /**
5264 * Returns the current state of the store.
5265 */
5266 getSnapshot = () => {
5267 return this.state;
5268 };
5269 /**
5270 * Updates the entire store's state and notifies all registered listeners.
5271 *
5272 * @param newState The new state to set for the store.
5273 */
5274 setState(newState) {
5275 if (this.state === newState) {
5276 return;
5277 }
5278 this.state = newState;
5279 this.updateTick += 1;
5280 const currentTick = this.updateTick;
5281 for (const listener of this.listeners) {
5282 if (currentTick !== this.updateTick) {
5283 return;
5284 }
5285 listener(newState);
5286 }
5287 }
5288 /**
5289 * Merges the provided changes into the current state and notifies listeners if there are changes.
5290 *
5291 * @param changes An object containing the changes to apply to the current state.
5292 */
5293 update(changes) {
5294 for (const key in changes) {
5295 if (!Object.is(this.state[key], changes[key])) {
5296 this.setState({
5297 ...this.state,
5298 ...changes
5299 });
5300 return;
5301 }
5302 }
5303 }
5304 /**
5305 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5306 *
5307 * @param key The key in the store's state to update.
5308 * @param value The new value to set for the specified key.
5309 */
5310 set(key, value) {
5311 if (!Object.is(this.state[key], value)) {
5312 this.setState({
5313 ...this.state,
5314 [key]: value
5315 });
5316 }
5317 }
5318 /**
5319 * Gives the state a new reference and updates all registered listeners.
5320 */
5321 notifyAll() {
5322 const newState = {
5323 ...this.state
5324 };
5325 this.setState(newState);
5326 }
5327 use(selector2, a1, a2, a3) {
5328 return useStore(this, selector2, a1, a2, a3);
5329 }
5330 };
5331
5332 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5333 var React22 = __toESM(require_react(), 1);
5334 var ReactStore = class extends Store {
5335 /**
5336 * Creates a new ReactStore instance.
5337 *
5338 * @param state Initial state of the store.
5339 * @param context Non-reactive context values.
5340 * @param selectors Optional selectors for use with `useState`.
5341 */
5342 constructor(state, context = {}, selectors3) {
5343 super(state);
5344 this.context = context;
5345 this.selectors = selectors3;
5346 }
5347 /**
5348 * Non-reactive values such as refs, callbacks, etc.
5349 */
5350 /**
5351 * Synchronizes a single external value into the store.
5352 *
5353 * Note that the while the value in `state` is updated immediately, the value returned
5354 * by `useState` is updated before the next render (similarly to React's `useState`).
5355 */
5356 useSyncedValue(key, value) {
5357 React22.useDebugValue(key);
5358 const store = this;
5359 useIsoLayoutEffect(() => {
5360 if (store.state[key] !== value) {
5361 store.set(key, value);
5362 }
5363 }, [store, key, value]);
5364 }
5365 /**
5366 * Synchronizes a single external value into the store and
5367 * cleans it up (sets to `undefined`) on unmount.
5368 *
5369 * Note that the while the value in `state` is updated immediately, the value returned
5370 * by `useState` is updated before the next render (similarly to React's `useState`).
5371 */
5372 useSyncedValueWithCleanup(key, value) {
5373 const store = this;
5374 useIsoLayoutEffect(() => {
5375 if (store.state[key] !== value) {
5376 store.set(key, value);
5377 }
5378 return () => {
5379 store.set(key, void 0);
5380 };
5381 }, [store, key, value]);
5382 }
5383 /**
5384 * Synchronizes multiple external values into the store.
5385 *
5386 * Note that the while the values in `state` are updated immediately, the values returned
5387 * by `useState` are updated before the next render (similarly to React's `useState`).
5388 */
5389 useSyncedValues(statePart) {
5390 const store = this;
5391 if (true) {
5392 React22.useDebugValue(statePart, (p2) => Object.keys(p2));
5393 const keys = React22.useRef(Object.keys(statePart)).current;
5394 const nextKeys = Object.keys(statePart);
5395 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5396 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5397 }
5398 }
5399 const dependencies = Object.values(statePart);
5400 useIsoLayoutEffect(() => {
5401 store.update(statePart);
5402 }, [store, ...dependencies]);
5403 }
5404 /**
5405 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5406 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5407 */
5408 useControlledProp(key, controlled) {
5409 React22.useDebugValue(key);
5410 const store = this;
5411 const isControlled = controlled !== void 0;
5412 useIsoLayoutEffect(() => {
5413 if (isControlled && !Object.is(store.state[key], controlled)) {
5414 store.setState({
5415 ...store.state,
5416 [key]: controlled
5417 });
5418 }
5419 }, [store, key, controlled, isControlled]);
5420 if (true) {
5421 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5422 if (!cache.has(key)) {
5423 cache.set(key, isControlled);
5424 }
5425 const previouslyControlled = cache.get(key);
5426 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5427 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).`);
5428 }
5429 }
5430 }
5431 /** Gets the current value from the store using a selector with the provided key.
5432 *
5433 * @param key Key of the selector to use.
5434 */
5435 select(key, a1, a2, a3) {
5436 const selector2 = this.selectors[key];
5437 return selector2(this.state, a1, a2, a3);
5438 }
5439 /**
5440 * Returns a value from the store's state using a selector function.
5441 * Used to subscribe to specific parts of the state.
5442 * This methods causes a rerender whenever the selected state changes.
5443 *
5444 * @param key Key of the selector to use.
5445 */
5446 useState(key, a1, a2, a3) {
5447 React22.useDebugValue(key);
5448 return useStore(this, this.selectors[key], a1, a2, a3);
5449 }
5450 /**
5451 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5452 * and assigns it to the context.
5453 *
5454 * @param key Key of the event callback. Must be a function in the context.
5455 * @param fn Function to assign.
5456 */
5457 useContextCallback(key, fn) {
5458 React22.useDebugValue(key);
5459 const stableFunction = useStableCallback(fn ?? NOOP);
5460 this.context[key] = stableFunction;
5461 }
5462 /**
5463 * Returns a stable setter function for a specific key in the store's state.
5464 * It's commonly used to pass as a ref callback to React elements.
5465 *
5466 * @param key Key of the state to set.
5467 */
5468 useStateSetter(key) {
5469 const ref = React22.useRef(void 0);
5470 if (ref.current === void 0) {
5471 ref.current = (value) => {
5472 this.set(key, value);
5473 };
5474 }
5475 return ref.current;
5476 }
5477 /**
5478 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5479 *
5480 * @param key Key of the selector to observe.
5481 * @param listener Listener function called when the selector result changes.
5482 */
5483 observe(selector2, listener) {
5484 let selectFn;
5485 if (typeof selector2 === "function") {
5486 selectFn = selector2;
5487 } else {
5488 selectFn = this.selectors[selector2];
5489 }
5490 let prevValue = selectFn(this.state);
5491 listener(prevValue, prevValue, this);
5492 return this.subscribe((nextState) => {
5493 const nextValue = selectFn(nextState);
5494 if (!Object.is(prevValue, nextValue)) {
5495 const oldValue = prevValue;
5496 prevValue = nextValue;
5497 listener(nextValue, oldValue, this);
5498 }
5499 });
5500 }
5501 };
5502
5503 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5504 var selectors = {
5505 open: createSelector((state) => state.open),
5506 transitionStatus: createSelector((state) => state.transitionStatus),
5507 domReferenceElement: createSelector((state) => state.domReferenceElement),
5508 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5509 floatingElement: createSelector((state) => state.floatingElement),
5510 floatingId: createSelector((state) => state.floatingId)
5511 };
5512 var FloatingRootStore = class extends ReactStore {
5513 constructor(options) {
5514 const {
5515 syncOnly,
5516 nested,
5517 onOpenChange,
5518 triggerElements,
5519 ...initialState
5520 } = options;
5521 super({
5522 ...initialState,
5523 positionReference: initialState.referenceElement,
5524 domReferenceElement: initialState.referenceElement
5525 }, {
5526 onOpenChange,
5527 dataRef: {
5528 current: {}
5529 },
5530 events: createEventEmitter(),
5531 nested,
5532 triggerElements
5533 }, selectors);
5534 this.syncOnly = syncOnly;
5535 }
5536 /**
5537 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5538 */
5539 syncOpenEvent = (newOpen, event) => {
5540 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5541 // click events to upgrade a hover-open.
5542 event != null && isClickLikeEvent(event)) {
5543 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5544 }
5545 };
5546 /**
5547 * Runs the root-owned side effects for an open state change.
5548 */
5549 dispatchOpenChange = (newOpen, eventDetails) => {
5550 this.syncOpenEvent(newOpen, eventDetails.event);
5551 const details = {
5552 open: newOpen,
5553 reason: eventDetails.reason,
5554 nativeEvent: eventDetails.event,
5555 nested: this.context.nested,
5556 triggerElement: eventDetails.trigger
5557 };
5558 this.context.events.emit("openchange", details);
5559 };
5560 /**
5561 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5562 *
5563 * @param newOpen The new open state.
5564 * @param eventDetails Details about the event that triggered the open state change.
5565 */
5566 setOpen = (newOpen, eventDetails) => {
5567 if (this.syncOnly) {
5568 this.context.onOpenChange?.(newOpen, eventDetails);
5569 return;
5570 }
5571 this.dispatchOpenChange(newOpen, eventDetails);
5572 this.context.onOpenChange?.(newOpen, eventDetails);
5573 };
5574 };
5575
5576 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5577 function useSyncedFloatingRootContext(options) {
5578 const {
5579 popupStore,
5580 treatPopupAsFloatingElement = false,
5581 floatingRootContext: floatingRootContextProp,
5582 floatingId,
5583 nested,
5584 onOpenChange
5585 } = options;
5586 const open = popupStore.useState("open");
5587 const referenceElement = popupStore.useState("activeTriggerElement");
5588 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5589 const triggerElements = popupStore.context.triggerElements;
5590 const handleOpenChange = onOpenChange;
5591 const internalStoreRef = React23.useRef(null);
5592 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5593 internalStoreRef.current = new FloatingRootStore({
5594 open,
5595 transitionStatus: void 0,
5596 referenceElement,
5597 floatingElement,
5598 triggerElements,
5599 onOpenChange: handleOpenChange,
5600 floatingId,
5601 syncOnly: true,
5602 nested
5603 });
5604 }
5605 const store = floatingRootContextProp ?? internalStoreRef.current;
5606 popupStore.useSyncedValue("floatingId", floatingId);
5607 useIsoLayoutEffect(() => {
5608 const valuesToSync = {
5609 open,
5610 floatingId,
5611 referenceElement,
5612 floatingElement
5613 };
5614 if (isElement(referenceElement)) {
5615 valuesToSync.domReferenceElement = referenceElement;
5616 }
5617 if (store.state.positionReference === store.state.referenceElement) {
5618 valuesToSync.positionReference = referenceElement;
5619 }
5620 store.update(valuesToSync);
5621 }, [open, floatingId, referenceElement, floatingElement, store]);
5622 store.context.onOpenChange = handleOpenChange;
5623 store.context.nested = nested;
5624 return store;
5625 }
5626
5627 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5628 var FOCUSABLE_POPUP_PROPS = {
5629 tabIndex: -1,
5630 [FOCUSABLE_ATTRIBUTE]: ""
5631 };
5632 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
5633 const floatingId = useId();
5634 const nested = useFloatingParentNodeId() != null;
5635 const internalStoreRef = React24.useRef(null);
5636 if (externalStore === void 0 && internalStoreRef.current === null) {
5637 internalStoreRef.current = createStore2(floatingId, nested);
5638 }
5639 const store = externalStore ?? internalStoreRef.current;
5640 useSyncedFloatingRootContext({
5641 popupStore: store,
5642 treatPopupAsFloatingElement,
5643 floatingRootContext: store.state.floatingRootContext,
5644 floatingId,
5645 nested,
5646 onOpenChange: store.setOpen
5647 });
5648 return {
5649 store,
5650 internalStore: internalStoreRef.current
5651 };
5652 }
5653 function useTriggerRegistration(id, store) {
5654 const registeredElementIdRef = React24.useRef(null);
5655 const registeredElementRef = React24.useRef(null);
5656 return React24.useCallback((element) => {
5657 if (id === void 0) {
5658 return;
5659 }
5660 let shouldSyncTriggerCount = false;
5661 if (registeredElementIdRef.current !== null) {
5662 const registeredId = registeredElementIdRef.current;
5663 const registeredElement = registeredElementRef.current;
5664 const currentElement = store.context.triggerElements.getById(registeredId);
5665 if (registeredElement && currentElement === registeredElement) {
5666 store.context.triggerElements.delete(registeredId);
5667 shouldSyncTriggerCount = true;
5668 }
5669 registeredElementIdRef.current = null;
5670 registeredElementRef.current = null;
5671 }
5672 if (element !== null) {
5673 registeredElementIdRef.current = id;
5674 registeredElementRef.current = element;
5675 store.context.triggerElements.add(id, element);
5676 shouldSyncTriggerCount = true;
5677 }
5678 if (shouldSyncTriggerCount) {
5679 const triggerCount = store.context.triggerElements.size;
5680 if (store.select("open") && store.state.triggerCount !== triggerCount) {
5681 store.set("triggerCount", triggerCount);
5682 }
5683 }
5684 }, [store, id]);
5685 }
5686 function setOpenTriggerState(state, open, trigger) {
5687 const triggerId = trigger?.id ?? null;
5688 if (triggerId || open) {
5689 state.activeTriggerId = triggerId;
5690 state.activeTriggerElement = trigger ?? null;
5691 }
5692 }
5693 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5694 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5695 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5696 const registerTrigger = useStableCallback((element) => {
5697 baseRegisterTrigger(element);
5698 if (!element) {
5699 return;
5700 }
5701 const open = store.select("open");
5702 const activeTriggerId = store.select("activeTriggerId");
5703 if (activeTriggerId === triggerId) {
5704 store.update({
5705 activeTriggerElement: element,
5706 ...open ? stateUpdates : null
5707 });
5708 return;
5709 }
5710 if (activeTriggerId == null && open) {
5711 store.update({
5712 activeTriggerId: triggerId,
5713 activeTriggerElement: element,
5714 ...stateUpdates
5715 });
5716 }
5717 });
5718 useIsoLayoutEffect(() => {
5719 if (isMountedByThisTrigger) {
5720 store.update({
5721 activeTriggerElement: triggerElementRef.current,
5722 ...stateUpdates
5723 });
5724 }
5725 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5726 return {
5727 registerTrigger,
5728 isMountedByThisTrigger
5729 };
5730 }
5731 function useImplicitActiveTrigger(store) {
5732 const open = store.useState("open");
5733 const reactiveTriggerCount = store.useState("triggerCount");
5734 useIsoLayoutEffect(() => {
5735 if (!open) {
5736 if (store.state.triggerCount !== 0) {
5737 store.set("triggerCount", 0);
5738 }
5739 return;
5740 }
5741 const triggerCount = store.context.triggerElements.size;
5742 const stateUpdates = {};
5743 if (store.state.triggerCount !== triggerCount) {
5744 stateUpdates.triggerCount = triggerCount;
5745 }
5746 if (!store.select("activeTriggerId") && triggerCount === 1) {
5747 const iteratorResult = store.context.triggerElements.entries().next();
5748 if (!iteratorResult.done) {
5749 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5750 stateUpdates.activeTriggerId = implicitTriggerId;
5751 stateUpdates.activeTriggerElement = implicitTriggerElement;
5752 }
5753 }
5754 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
5755 store.update(stateUpdates);
5756 }
5757 }, [open, store, reactiveTriggerCount]);
5758 }
5759 function useOpenStateTransitions(open, store, onUnmount) {
5760 const {
5761 mounted,
5762 setMounted,
5763 transitionStatus
5764 } = useTransitionStatus(open);
5765 store.useSyncedValues({
5766 mounted,
5767 transitionStatus
5768 });
5769 const forceUnmount = useStableCallback(() => {
5770 setMounted(false);
5771 store.update({
5772 activeTriggerId: null,
5773 activeTriggerElement: null,
5774 mounted: false,
5775 preventUnmountingOnClose: false
5776 });
5777 onUnmount?.();
5778 store.context.onOpenChangeComplete?.(false);
5779 });
5780 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5781 useOpenChangeComplete({
5782 enabled: mounted && !open && !preventUnmountingOnClose,
5783 open,
5784 ref: store.context.popupRef,
5785 onComplete() {
5786 if (!open) {
5787 forceUnmount();
5788 }
5789 }
5790 });
5791 return {
5792 forceUnmount,
5793 transitionStatus
5794 };
5795 }
5796 function usePopupInteractionProps(store, statePart) {
5797 store.useSyncedValues(statePart);
5798 useIsoLayoutEffect(() => () => {
5799 store.update({
5800 activeTriggerProps: EMPTY_OBJECT,
5801 inactiveTriggerProps: EMPTY_OBJECT,
5802 popupProps: EMPTY_OBJECT
5803 });
5804 }, [store]);
5805 }
5806
5807 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5808 var PopupTriggerMap = class {
5809 constructor() {
5810 this.elementsSet = /* @__PURE__ */ new Set();
5811 this.idMap = /* @__PURE__ */ new Map();
5812 }
5813 /**
5814 * Adds a trigger element with the given ID.
5815 *
5816 * Note: The provided element is assumed to not be registered under multiple IDs.
5817 */
5818 add(id, element) {
5819 const existingElement = this.idMap.get(id);
5820 if (existingElement === element) {
5821 return;
5822 }
5823 if (existingElement !== void 0) {
5824 this.elementsSet.delete(existingElement);
5825 }
5826 this.elementsSet.add(element);
5827 this.idMap.set(id, element);
5828 if (true) {
5829 if (this.elementsSet.size !== this.idMap.size) {
5830 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5831 }
5832 }
5833 }
5834 /**
5835 * Removes the trigger element with the given ID.
5836 */
5837 delete(id) {
5838 const element = this.idMap.get(id);
5839 if (element) {
5840 this.elementsSet.delete(element);
5841 this.idMap.delete(id);
5842 }
5843 }
5844 /**
5845 * Whether the given element is registered as a trigger.
5846 */
5847 hasElement(element) {
5848 return this.elementsSet.has(element);
5849 }
5850 /**
5851 * Whether there is a registered trigger element matching the given predicate.
5852 */
5853 hasMatchingElement(predicate) {
5854 for (const element of this.elementsSet) {
5855 if (predicate(element)) {
5856 return true;
5857 }
5858 }
5859 return false;
5860 }
5861 /**
5862 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
5863 */
5864 getById(id) {
5865 return this.idMap.get(id);
5866 }
5867 /**
5868 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
5869 */
5870 entries() {
5871 return this.idMap.entries();
5872 }
5873 /**
5874 * Returns an iterable of all registered trigger elements.
5875 */
5876 elements() {
5877 return this.elementsSet.values();
5878 }
5879 /**
5880 * Returns the number of registered trigger elements.
5881 */
5882 get size() {
5883 return this.idMap.size;
5884 }
5885 };
5886
5887 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
5888 function getEmptyRootContext() {
5889 return new FloatingRootStore({
5890 open: false,
5891 transitionStatus: void 0,
5892 floatingElement: null,
5893 referenceElement: null,
5894 triggerElements: new PopupTriggerMap(),
5895 floatingId: void 0,
5896 syncOnly: false,
5897 nested: false,
5898 onOpenChange: void 0
5899 });
5900 }
5901
5902 // node_modules/@base-ui/react/esm/utils/popups/store.js
5903 function createInitialPopupStoreState() {
5904 return {
5905 open: false,
5906 openProp: void 0,
5907 mounted: false,
5908 transitionStatus: void 0,
5909 floatingRootContext: getEmptyRootContext(),
5910 floatingId: void 0,
5911 triggerCount: 0,
5912 preventUnmountingOnClose: false,
5913 payload: void 0,
5914 activeTriggerId: null,
5915 activeTriggerElement: null,
5916 triggerIdProp: void 0,
5917 popupElement: null,
5918 positionerElement: null,
5919 activeTriggerProps: EMPTY_OBJECT,
5920 inactiveTriggerProps: EMPTY_OBJECT,
5921 popupProps: EMPTY_OBJECT
5922 };
5923 }
5924 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
5925 return new FloatingRootStore({
5926 open: false,
5927 transitionStatus: void 0,
5928 floatingElement: null,
5929 referenceElement: null,
5930 triggerElements,
5931 floatingId,
5932 syncOnly: true,
5933 nested,
5934 onOpenChange: void 0
5935 });
5936 }
5937 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
5938 var openSelector = createSelector((state) => state.openProp ?? state.open);
5939 var popupIdSelector = createSelector((state) => {
5940 const popupId = state.popupElement?.id ?? state.floatingId;
5941 return popupId || void 0;
5942 });
5943 function triggerOwnsOpenPopup(state, triggerId) {
5944 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
5945 }
5946 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
5947 if (triggerOwnsOpenPopup(state, triggerId)) {
5948 return true;
5949 }
5950 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
5951 }
5952 var popupStoreSelectors = {
5953 open: openSelector,
5954 mounted: createSelector((state) => state.mounted),
5955 transitionStatus: createSelector((state) => state.transitionStatus),
5956 floatingRootContext: createSelector((state) => state.floatingRootContext),
5957 triggerCount: createSelector((state) => state.triggerCount),
5958 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
5959 payload: createSelector((state) => state.payload),
5960 activeTriggerId: activeTriggerIdSelector,
5961 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
5962 popupId: popupIdSelector,
5963 /**
5964 * Whether the trigger with the given ID was used to open the popup.
5965 */
5966 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
5967 /**
5968 * Whether the popup is open and was activated by a trigger with the given ID.
5969 */
5970 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
5971 /**
5972 * Whether the popup is mounted and was activated by a trigger with the given ID.
5973 */
5974 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
5975 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
5976 /**
5977 * Popup id for the trigger that currently owns the open popup.
5978 */
5979 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
5980 popupProps: createSelector((state) => state.popupProps),
5981 popupElement: createSelector((state) => state.popupElement),
5982 positionerElement: createSelector((state) => state.positionerElement)
5983 };
5984
5985 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
5986 function useFloatingRootContext(options) {
5987 const {
5988 open = false,
5989 onOpenChange,
5990 elements = {}
5991 } = options;
5992 const floatingId = useId();
5993 const nested = useFloatingParentNodeId() != null;
5994 if (true) {
5995 const optionDomReference = elements.reference;
5996 if (optionDomReference && !isElement(optionDomReference)) {
5997 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
5998 }
5999 }
6000 const store = useRefWithInit(() => new FloatingRootStore({
6001 open,
6002 transitionStatus: void 0,
6003 onOpenChange,
6004 referenceElement: elements.reference ?? null,
6005 floatingElement: elements.floating ?? null,
6006 triggerElements: new PopupTriggerMap(),
6007 floatingId,
6008 syncOnly: false,
6009 nested
6010 })).current;
6011 useIsoLayoutEffect(() => {
6012 const valuesToSync = {
6013 open,
6014 floatingId
6015 };
6016 if (elements.reference !== void 0) {
6017 valuesToSync.referenceElement = elements.reference;
6018 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6019 }
6020 if (elements.floating !== void 0) {
6021 valuesToSync.floatingElement = elements.floating;
6022 }
6023 store.update(valuesToSync);
6024 }, [open, floatingId, elements.reference, elements.floating, store]);
6025 store.context.onOpenChange = onOpenChange;
6026 store.context.nested = nested;
6027 return store;
6028 }
6029
6030 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6031 function useFloating2(options = {}) {
6032 const {
6033 nodeId,
6034 externalTree
6035 } = options;
6036 const internalStore = useFloatingRootContext(options);
6037 const store = options.rootContext || internalStore;
6038 const referenceElement = store.useState("referenceElement");
6039 const floatingElement = store.useState("floatingElement");
6040 const domReferenceElement = store.useState("domReferenceElement");
6041 const open = store.useState("open");
6042 const floatingId = store.useState("floatingId");
6043 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6044 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6045 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
6046 const domReferenceRef = React25.useRef(null);
6047 const tree = useFloatingTree(externalTree);
6048 const storeElements = React25.useMemo(() => ({
6049 reference: referenceElement,
6050 floating: floatingElement,
6051 domReference: domReferenceElement
6052 }), [referenceElement, floatingElement, domReferenceElement]);
6053 const position = useFloating({
6054 ...options,
6055 elements: {
6056 ...storeElements,
6057 ...positionReference && {
6058 reference: positionReference
6059 }
6060 }
6061 });
6062 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6063 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6064 store.useSyncedValue("referenceElement", localDomReference ?? null);
6065 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6066 store.useSyncedValue("floatingElement", syncedFloatingElement);
6067 const setPositionReference = React25.useCallback((node) => {
6068 const computedPositionReference = isElement(node) ? {
6069 getBoundingClientRect: () => node.getBoundingClientRect(),
6070 getClientRects: () => node.getClientRects(),
6071 contextElement: node
6072 } : node;
6073 setPositionReferenceRaw(computedPositionReference);
6074 position.refs.setReference(computedPositionReference);
6075 }, [position.refs]);
6076 const setReference = React25.useCallback((node) => {
6077 if (isElement(node) || node === null) {
6078 domReferenceRef.current = node;
6079 setLocalDomReference(node);
6080 }
6081 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6082 // `null` to support `positionReference` + an unstable `reference`
6083 // callback ref.
6084 node !== null && !isElement(node)) {
6085 position.refs.setReference(node);
6086 }
6087 }, [position.refs, setLocalDomReference]);
6088 const setFloating = React25.useCallback((node) => {
6089 setLocalFloatingElement(node);
6090 position.refs.setFloating(node);
6091 }, [position.refs]);
6092 const refs = React25.useMemo(() => ({
6093 ...position.refs,
6094 setReference,
6095 setFloating,
6096 setPositionReference,
6097 domReference: domReferenceRef
6098 }), [position.refs, setReference, setFloating, setPositionReference]);
6099 const elements = React25.useMemo(() => ({
6100 ...position.elements,
6101 domReference: domReferenceElement
6102 }), [position.elements, domReferenceElement]);
6103 const context = React25.useMemo(() => ({
6104 ...position,
6105 dataRef: store.context.dataRef,
6106 open,
6107 onOpenChange: store.setOpen,
6108 events: store.context.events,
6109 floatingId,
6110 refs,
6111 elements,
6112 nodeId,
6113 rootStore: store
6114 }), [position, refs, elements, nodeId, store, open, floatingId]);
6115 useIsoLayoutEffect(() => {
6116 if (domReferenceElement) {
6117 domReferenceRef.current = domReferenceElement;
6118 }
6119 }, [domReferenceElement]);
6120 useIsoLayoutEffect(() => {
6121 store.context.dataRef.current.floatingContext = context;
6122 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6123 if (node) {
6124 node.context = context;
6125 }
6126 });
6127 return React25.useMemo(() => ({
6128 ...position,
6129 context,
6130 refs,
6131 elements,
6132 rootStore: store
6133 }), [position, refs, elements, context, store]);
6134 }
6135
6136 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6137 var React26 = __toESM(require_react(), 1);
6138 var isMacSafari = isMac && isSafari;
6139 function useFocus(context, props = {}) {
6140 const {
6141 enabled = true,
6142 delay
6143 } = props;
6144 const store = "rootStore" in context ? context.rootStore : context;
6145 const {
6146 events,
6147 dataRef
6148 } = store.context;
6149 const blockFocusRef = React26.useRef(false);
6150 const blockedReferenceRef = React26.useRef(null);
6151 const keyboardModalityRef = React26.useRef(true);
6152 const timeout = useTimeout();
6153 React26.useEffect(() => {
6154 const domReference = store.select("domReferenceElement");
6155 if (!enabled) {
6156 return void 0;
6157 }
6158 const win = getWindow(domReference);
6159 function onBlur() {
6160 const currentDomReference = store.select("domReferenceElement");
6161 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6162 blockFocusRef.current = true;
6163 }
6164 }
6165 function onKeyDown() {
6166 keyboardModalityRef.current = true;
6167 }
6168 function onPointerDown() {
6169 keyboardModalityRef.current = false;
6170 }
6171 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6172 }, [store, enabled]);
6173 React26.useEffect(() => {
6174 if (!enabled) {
6175 return void 0;
6176 }
6177 function onOpenChangeLocal(details) {
6178 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6179 const referenceElement = store.select("domReferenceElement");
6180 if (isElement(referenceElement)) {
6181 blockedReferenceRef.current = referenceElement;
6182 blockFocusRef.current = true;
6183 }
6184 }
6185 }
6186 events.on("openchange", onOpenChangeLocal);
6187 return () => {
6188 events.off("openchange", onOpenChangeLocal);
6189 };
6190 }, [events, enabled, store]);
6191 const reference = React26.useMemo(() => {
6192 function resetBlockedFocus() {
6193 blockFocusRef.current = false;
6194 blockedReferenceRef.current = null;
6195 }
6196 return {
6197 onMouseLeave() {
6198 resetBlockedFocus();
6199 },
6200 onFocus(event) {
6201 const focusTarget = event.currentTarget;
6202 if (blockFocusRef.current) {
6203 if (blockedReferenceRef.current === focusTarget) {
6204 return;
6205 }
6206 resetBlockedFocus();
6207 }
6208 const target = getTarget(event.nativeEvent);
6209 if (isElement(target)) {
6210 if (isMacSafari && !event.relatedTarget) {
6211 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6212 return;
6213 }
6214 } else if (!matchesFocusVisible(target)) {
6215 return;
6216 }
6217 }
6218 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6219 const {
6220 nativeEvent,
6221 currentTarget
6222 } = event;
6223 const delayValue = typeof delay === "function" ? delay() : delay;
6224 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6225 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6226 return;
6227 }
6228 timeout.start(delayValue, () => {
6229 if (blockFocusRef.current) {
6230 return;
6231 }
6232 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6233 });
6234 },
6235 onBlur(event) {
6236 resetBlockedFocus();
6237 const relatedTarget = event.relatedTarget;
6238 const nativeEvent = event.nativeEvent;
6239 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6240 timeout.start(0, () => {
6241 const domReference = store.select("domReferenceElement");
6242 const activeEl = activeElement(ownerDocument(domReference));
6243 if (!relatedTarget && activeEl === domReference) {
6244 return;
6245 }
6246 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6247 return;
6248 }
6249 const nextFocusedElement = relatedTarget ?? activeEl;
6250 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6251 return;
6252 }
6253 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6254 });
6255 }
6256 };
6257 }, [dataRef, delay, store, timeout]);
6258 return React26.useMemo(() => enabled ? {
6259 reference,
6260 trigger: reference
6261 } : {}, [enabled, reference]);
6262 }
6263
6264 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6265 var React27 = __toESM(require_react(), 1);
6266
6267 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6268 var HoverInteraction = class _HoverInteraction {
6269 constructor() {
6270 this.pointerType = void 0;
6271 this.interactedInside = false;
6272 this.handler = void 0;
6273 this.blockMouseMove = true;
6274 this.performedPointerEventsMutation = false;
6275 this.pointerEventsScopeElement = null;
6276 this.pointerEventsReferenceElement = null;
6277 this.pointerEventsFloatingElement = null;
6278 this.restTimeoutPending = false;
6279 this.openChangeTimeout = new Timeout();
6280 this.restTimeout = new Timeout();
6281 this.handleCloseOptions = void 0;
6282 }
6283 static create() {
6284 return new _HoverInteraction();
6285 }
6286 dispose = () => {
6287 this.openChangeTimeout.clear();
6288 this.restTimeout.clear();
6289 };
6290 disposeEffect = () => {
6291 return this.dispose;
6292 };
6293 };
6294 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6295 function clearSafePolygonPointerEventsMutation(instance) {
6296 if (!instance.performedPointerEventsMutation) {
6297 return;
6298 }
6299 const scopeElement = instance.pointerEventsScopeElement;
6300 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6301 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6302 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6303 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6304 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6305 }
6306 instance.performedPointerEventsMutation = false;
6307 instance.pointerEventsScopeElement = null;
6308 instance.pointerEventsReferenceElement = null;
6309 instance.pointerEventsFloatingElement = null;
6310 }
6311 function applySafePolygonPointerEventsMutation(instance, options) {
6312 const {
6313 scopeElement,
6314 referenceElement,
6315 floatingElement
6316 } = options;
6317 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6318 if (existingOwner && existingOwner !== instance) {
6319 clearSafePolygonPointerEventsMutation(existingOwner);
6320 }
6321 clearSafePolygonPointerEventsMutation(instance);
6322 instance.performedPointerEventsMutation = true;
6323 instance.pointerEventsScopeElement = scopeElement;
6324 instance.pointerEventsReferenceElement = referenceElement;
6325 instance.pointerEventsFloatingElement = floatingElement;
6326 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6327 scopeElement.style.pointerEvents = "none";
6328 referenceElement.style.pointerEvents = "auto";
6329 floatingElement.style.pointerEvents = "auto";
6330 }
6331 function useHoverInteractionSharedState(store) {
6332 const data = store.context.dataRef.current;
6333 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6334 if (!data.hoverInteractionState) {
6335 data.hoverInteractionState = instance;
6336 }
6337 useOnMount(data.hoverInteractionState.disposeEffect);
6338 return data.hoverInteractionState;
6339 }
6340
6341 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6342 function useHoverFloatingInteraction(context, parameters = {}) {
6343 const {
6344 enabled = true,
6345 closeDelay: closeDelayProp = 0,
6346 nodeId: nodeIdProp
6347 } = parameters;
6348 const store = "rootStore" in context ? context.rootStore : context;
6349 const open = store.useState("open");
6350 const floatingElement = store.useState("floatingElement");
6351 const domReferenceElement = store.useState("domReferenceElement");
6352 const {
6353 dataRef
6354 } = store.context;
6355 const tree = useFloatingTree();
6356 const parentId = useFloatingParentNodeId();
6357 const instance = useHoverInteractionSharedState(store);
6358 const childClosedTimeout = useTimeout();
6359 const isClickLikeOpenEvent2 = useStableCallback(() => {
6360 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6361 });
6362 const isHoverOpen = useStableCallback(() => {
6363 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6364 });
6365 const clearPointerEvents = useStableCallback(() => {
6366 clearSafePolygonPointerEventsMutation(instance);
6367 });
6368 useIsoLayoutEffect(() => {
6369 if (!open) {
6370 instance.pointerType = void 0;
6371 instance.restTimeoutPending = false;
6372 instance.interactedInside = false;
6373 clearPointerEvents();
6374 }
6375 }, [open, instance, clearPointerEvents]);
6376 React27.useEffect(() => {
6377 return clearPointerEvents;
6378 }, [clearPointerEvents]);
6379 useIsoLayoutEffect(() => {
6380 if (!enabled) {
6381 return void 0;
6382 }
6383 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6384 const ref = domReferenceElement;
6385 const floatingEl = floatingElement;
6386 const doc = ownerDocument(floatingElement);
6387 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6388 if (parentFloating) {
6389 parentFloating.style.pointerEvents = "";
6390 }
6391 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6392 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6393 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6394 applySafePolygonPointerEventsMutation(instance, {
6395 scopeElement,
6396 referenceElement: ref,
6397 floatingElement: floatingEl
6398 });
6399 return () => {
6400 clearPointerEvents();
6401 };
6402 }
6403 return void 0;
6404 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6405 React27.useEffect(() => {
6406 if (!enabled) {
6407 return void 0;
6408 }
6409 function hasParentChildren() {
6410 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6411 }
6412 function closeWithDelay(event) {
6413 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6414 const close = () => {
6415 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6416 tree?.events.emit("floating.closed", event);
6417 };
6418 if (closeDelay) {
6419 instance.openChangeTimeout.start(closeDelay, close);
6420 } else {
6421 instance.openChangeTimeout.clear();
6422 close();
6423 }
6424 }
6425 function handleInteractInside(event) {
6426 const target = getTarget(event);
6427 if (!isInteractiveElement(target)) {
6428 instance.interactedInside = false;
6429 return;
6430 }
6431 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6432 }
6433 function onFloatingMouseEnter() {
6434 instance.openChangeTimeout.clear();
6435 childClosedTimeout.clear();
6436 tree?.events.off("floating.closed", onNodeClosed);
6437 clearPointerEvents();
6438 }
6439 function onFloatingMouseLeave(event) {
6440 if (hasParentChildren() && tree) {
6441 tree.events.on("floating.closed", onNodeClosed);
6442 return;
6443 }
6444 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6445 return;
6446 }
6447 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6448 const relatedTarget = event.relatedTarget;
6449 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6450 if (isMovingIntoDescendantFloating) {
6451 return;
6452 }
6453 if (instance.handler) {
6454 instance.handler(event);
6455 return;
6456 }
6457 clearPointerEvents();
6458 if (!isClickLikeOpenEvent2()) {
6459 closeWithDelay(event);
6460 }
6461 }
6462 function onNodeClosed(event) {
6463 if (!tree || !parentId || hasParentChildren()) {
6464 return;
6465 }
6466 childClosedTimeout.start(0, () => {
6467 tree.events.off("floating.closed", onNodeClosed);
6468 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6469 tree.events.emit("floating.closed", event);
6470 });
6471 }
6472 const floating = floatingElement;
6473 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6474 tree?.events.off("floating.closed", onNodeClosed);
6475 });
6476 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6477 }
6478
6479 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6480 var React28 = __toESM(require_react(), 1);
6481 var ReactDOM4 = __toESM(require_react_dom(), 1);
6482 var EMPTY_REF = {
6483 current: null
6484 };
6485 function useHoverReferenceInteraction(context, props = {}) {
6486 const {
6487 enabled = true,
6488 delay = 0,
6489 handleClose = null,
6490 mouseOnly = false,
6491 restMs = 0,
6492 move = true,
6493 triggerElementRef = EMPTY_REF,
6494 externalTree,
6495 isActiveTrigger = true,
6496 getHandleCloseContext,
6497 isClosing,
6498 shouldOpen: shouldOpenProp
6499 } = props;
6500 const store = "rootStore" in context ? context.rootStore : context;
6501 const {
6502 dataRef,
6503 events
6504 } = store.context;
6505 const tree = useFloatingTree(externalTree);
6506 const instance = useHoverInteractionSharedState(store);
6507 const isHoverCloseActiveRef = React28.useRef(false);
6508 const handleCloseRef = useValueAsRef(handleClose);
6509 const delayRef = useValueAsRef(delay);
6510 const restMsRef = useValueAsRef(restMs);
6511 const enabledRef = useValueAsRef(enabled);
6512 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6513 const isClosingRef = useValueAsRef(isClosing);
6514 const isClickLikeOpenEvent2 = useStableCallback(() => {
6515 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6516 });
6517 const checkShouldOpen = useStableCallback(() => {
6518 return shouldOpenRef.current?.() !== false;
6519 });
6520 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6521 const allTriggers = store.context.triggerElements;
6522 if (allTriggers.hasElement(currentTarget)) {
6523 return !currentDomReference || !contains(currentDomReference, currentTarget);
6524 }
6525 if (!isElement(target)) {
6526 return false;
6527 }
6528 const targetElement = target;
6529 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6530 });
6531 const cleanupMouseMoveHandler = useStableCallback(() => {
6532 if (!instance.handler) {
6533 return;
6534 }
6535 const doc = ownerDocument(store.select("domReferenceElement"));
6536 doc.removeEventListener("mousemove", instance.handler);
6537 instance.handler = void 0;
6538 });
6539 const clearPointerEvents = useStableCallback(() => {
6540 clearSafePolygonPointerEventsMutation(instance);
6541 });
6542 if (isActiveTrigger) {
6543 instance.handleCloseOptions = handleCloseRef.current?.__options;
6544 }
6545 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6546 React28.useEffect(() => {
6547 if (!enabled) {
6548 return void 0;
6549 }
6550 function onOpenChangeLocal(details) {
6551 if (!details.open) {
6552 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6553 cleanupMouseMoveHandler();
6554 instance.openChangeTimeout.clear();
6555 instance.restTimeout.clear();
6556 instance.blockMouseMove = true;
6557 instance.restTimeoutPending = false;
6558 } else {
6559 isHoverCloseActiveRef.current = false;
6560 }
6561 }
6562 events.on("openchange", onOpenChangeLocal);
6563 return () => {
6564 events.off("openchange", onOpenChangeLocal);
6565 };
6566 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6567 React28.useEffect(() => {
6568 if (!enabled) {
6569 return void 0;
6570 }
6571 function closeWithDelay(event, runElseBranch = true) {
6572 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6573 if (closeDelay) {
6574 instance.openChangeTimeout.start(closeDelay, () => {
6575 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6576 tree?.events.emit("floating.closed", event);
6577 });
6578 } else if (runElseBranch) {
6579 instance.openChangeTimeout.clear();
6580 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6581 tree?.events.emit("floating.closed", event);
6582 }
6583 }
6584 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6585 if (!isElement(trigger)) {
6586 return void 0;
6587 }
6588 function onMouseEnter(event) {
6589 instance.openChangeTimeout.clear();
6590 instance.blockMouseMove = false;
6591 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6592 return;
6593 }
6594 const restMsValue = getRestMs(restMsRef.current);
6595 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6596 const eventTarget = getTarget(event);
6597 const currentTarget = event.currentTarget ?? null;
6598 const currentDomReference = store.select("domReferenceElement");
6599 let triggerNode = currentTarget;
6600 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6601 for (const triggerElement of store.context.triggerElements.elements()) {
6602 if (contains(triggerElement, eventTarget)) {
6603 triggerNode = triggerElement;
6604 break;
6605 }
6606 }
6607 }
6608 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6609 triggerNode = currentDomReference;
6610 }
6611 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6612 const isOpen = store.select("open");
6613 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6614 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6615 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6616 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6617 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6618 const shouldOpen = !isOpen || isOverInactive;
6619 if (shouldOpenImmediately) {
6620 if (checkShouldOpen()) {
6621 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6622 }
6623 return;
6624 }
6625 if (isRestOnlyDelay) {
6626 return;
6627 }
6628 if (openDelay) {
6629 instance.openChangeTimeout.start(openDelay, () => {
6630 if (shouldOpen && checkShouldOpen()) {
6631 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6632 }
6633 });
6634 } else if (shouldOpen) {
6635 if (checkShouldOpen()) {
6636 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6637 }
6638 }
6639 }
6640 function onMouseLeave(event) {
6641 if (isClickLikeOpenEvent2()) {
6642 clearPointerEvents();
6643 return;
6644 }
6645 cleanupMouseMoveHandler();
6646 const domReferenceElement = store.select("domReferenceElement");
6647 const doc = ownerDocument(domReferenceElement);
6648 instance.restTimeout.clear();
6649 instance.restTimeoutPending = false;
6650 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6651 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6652 return;
6653 }
6654 if (handleCloseRef.current && handleCloseContextBase) {
6655 if (!store.select("open")) {
6656 instance.openChangeTimeout.clear();
6657 }
6658 const currentTrigger = triggerElementRef.current;
6659 instance.handler = handleCloseRef.current({
6660 ...handleCloseContextBase,
6661 tree,
6662 x: event.clientX,
6663 y: event.clientY,
6664 onClose() {
6665 clearPointerEvents();
6666 cleanupMouseMoveHandler();
6667 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6668 closeWithDelay(event, true);
6669 }
6670 }
6671 });
6672 doc.addEventListener("mousemove", instance.handler);
6673 instance.handler(event);
6674 return;
6675 }
6676 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6677 if (shouldClose) {
6678 closeWithDelay(event);
6679 }
6680 }
6681 if (move) {
6682 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6683 once: true
6684 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6685 }
6686 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6687 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
6688 return React28.useMemo(() => {
6689 if (!enabled) {
6690 return void 0;
6691 }
6692 function setPointerRef(event) {
6693 instance.pointerType = event.pointerType;
6694 }
6695 return {
6696 onPointerDown: setPointerRef,
6697 onPointerEnter: setPointerRef,
6698 onMouseMove(event) {
6699 const {
6700 nativeEvent
6701 } = event;
6702 const trigger = event.currentTarget;
6703 const currentDomReference = store.select("domReferenceElement");
6704 const currentOpen = store.select("open");
6705 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6706 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6707 return;
6708 }
6709 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6710 const floatingElement = store.select("floatingElement");
6711 if (floatingElement) {
6712 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6713 applySafePolygonPointerEventsMutation(instance, {
6714 scopeElement,
6715 referenceElement: trigger,
6716 floatingElement
6717 });
6718 }
6719 }
6720 const restMsValue = getRestMs(restMsRef.current);
6721 if (currentOpen && !isOverInactive || restMsValue === 0) {
6722 return;
6723 }
6724 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6725 return;
6726 }
6727 instance.restTimeout.clear();
6728 function handleMouseMove() {
6729 instance.restTimeoutPending = false;
6730 if (isClickLikeOpenEvent2()) {
6731 return;
6732 }
6733 const latestOpen = store.select("open");
6734 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
6735 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6736 }
6737 }
6738 if (instance.pointerType === "touch") {
6739 ReactDOM4.flushSync(() => {
6740 handleMouseMove();
6741 });
6742 } else if (isOverInactive && currentOpen) {
6743 handleMouseMove();
6744 } else {
6745 instance.restTimeoutPending = true;
6746 instance.restTimeout.start(restMsValue, handleMouseMove);
6747 }
6748 }
6749 };
6750 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
6751 }
6752
6753 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6754 var CURSOR_SPEED_THRESHOLD = 0.1;
6755 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6756 var POLYGON_BUFFER = 0.5;
6757 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6758 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6759 }
6760 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6761 let isInsideValue = false;
6762 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6763 isInsideValue = !isInsideValue;
6764 }
6765 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6766 isInsideValue = !isInsideValue;
6767 }
6768 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6769 isInsideValue = !isInsideValue;
6770 }
6771 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6772 isInsideValue = !isInsideValue;
6773 }
6774 return isInsideValue;
6775 }
6776 function isInsideRect(pointX, pointY, rect) {
6777 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6778 }
6779 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6780 const minX = Math.min(x1, x2);
6781 const maxX = Math.max(x1, x2);
6782 const minY = Math.min(y1, y2);
6783 const maxY = Math.max(y1, y2);
6784 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6785 }
6786 function safePolygon(options = {}) {
6787 const {
6788 blockPointerEvents = false
6789 } = options;
6790 const timeout = new Timeout();
6791 const fn = ({
6792 x: x2,
6793 y: y2,
6794 placement,
6795 elements,
6796 onClose,
6797 nodeId,
6798 tree
6799 }) => {
6800 const side = placement?.split("-")[0];
6801 let hasLanded = false;
6802 let lastX = null;
6803 let lastY = null;
6804 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6805 function isCursorMovingSlowly(nextX, nextY) {
6806 const currentTime = performance.now();
6807 const elapsedTime = currentTime - lastCursorTime;
6808 if (lastX === null || lastY === null || elapsedTime === 0) {
6809 lastX = nextX;
6810 lastY = nextY;
6811 lastCursorTime = currentTime;
6812 return false;
6813 }
6814 const deltaX = nextX - lastX;
6815 const deltaY = nextY - lastY;
6816 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6817 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6818 lastX = nextX;
6819 lastY = nextY;
6820 lastCursorTime = currentTime;
6821 return distanceSquared < thresholdSquared;
6822 }
6823 function close() {
6824 timeout.clear();
6825 onClose();
6826 }
6827 return function onMouseMove(event) {
6828 timeout.clear();
6829 const domReference = elements.domReference;
6830 const floating = elements.floating;
6831 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6832 return void 0;
6833 }
6834 const {
6835 clientX,
6836 clientY
6837 } = event;
6838 const target = getTarget(event);
6839 const isLeave = event.type === "mouseleave";
6840 const isOverFloatingEl = contains(floating, target);
6841 const isOverReferenceEl = contains(domReference, target);
6842 if (isOverFloatingEl) {
6843 hasLanded = true;
6844 if (!isLeave) {
6845 return void 0;
6846 }
6847 }
6848 if (isOverReferenceEl) {
6849 hasLanded = false;
6850 if (!isLeave) {
6851 hasLanded = true;
6852 return void 0;
6853 }
6854 }
6855 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
6856 return void 0;
6857 }
6858 function hasOpenChildNode() {
6859 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
6860 }
6861 function closeIfNoOpenChild() {
6862 if (!hasOpenChildNode()) {
6863 close();
6864 }
6865 }
6866 if (hasOpenChildNode()) {
6867 return void 0;
6868 }
6869 const refRect = domReference.getBoundingClientRect();
6870 const rect = floating.getBoundingClientRect();
6871 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
6872 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
6873 const isFloatingWider = rect.width > refRect.width;
6874 const isFloatingTaller = rect.height > refRect.height;
6875 const left = (isFloatingWider ? refRect : rect).left;
6876 const right = (isFloatingWider ? refRect : rect).right;
6877 const top = (isFloatingTaller ? refRect : rect).top;
6878 const bottom = (isFloatingTaller ? refRect : rect).bottom;
6879 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) {
6880 closeIfNoOpenChild();
6881 return void 0;
6882 }
6883 let isInsideTroughRect = false;
6884 switch (side) {
6885 case "top":
6886 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
6887 break;
6888 case "bottom":
6889 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
6890 break;
6891 case "left":
6892 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
6893 break;
6894 case "right":
6895 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
6896 break;
6897 default:
6898 }
6899 if (isInsideTroughRect) {
6900 return void 0;
6901 }
6902 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
6903 closeIfNoOpenChild();
6904 return void 0;
6905 }
6906 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
6907 closeIfNoOpenChild();
6908 return void 0;
6909 }
6910 let isInsidePolygon = false;
6911 switch (side) {
6912 case "top": {
6913 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6914 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6915 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6916 const cursorPointY = y2 + POLYGON_BUFFER + 1;
6917 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
6918 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
6919 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6920 break;
6921 }
6922 case "bottom": {
6923 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6924 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6925 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
6926 const cursorPointY = y2 - POLYGON_BUFFER;
6927 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
6928 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
6929 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
6930 break;
6931 }
6932 case "left": {
6933 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6934 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6935 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6936 const cursorPointX = x2 + POLYGON_BUFFER + 1;
6937 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
6938 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
6939 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
6940 break;
6941 }
6942 case "right": {
6943 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
6944 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6945 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
6946 const cursorPointX = x2 - POLYGON_BUFFER;
6947 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
6948 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
6949 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
6950 break;
6951 }
6952 default:
6953 }
6954 if (!isInsidePolygon) {
6955 closeIfNoOpenChild();
6956 } else if (!hasLanded) {
6957 timeout.start(40, closeIfNoOpenChild);
6958 }
6959 return void 0;
6960 };
6961 };
6962 fn.__options = {
6963 ...options,
6964 blockPointerEvents
6965 };
6966 return fn;
6967 }
6968
6969 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
6970 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
6971 CommonPopupDataAttributes2["open"] = "data-open";
6972 CommonPopupDataAttributes2["closed"] = "data-closed";
6973 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
6974 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
6975 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
6976 CommonPopupDataAttributes2["side"] = "data-side";
6977 CommonPopupDataAttributes2["align"] = "data-align";
6978 return CommonPopupDataAttributes2;
6979 })({});
6980 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
6981 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
6982 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
6983 return CommonTriggerDataAttributes2;
6984 })({});
6985 var TRIGGER_HOOK = {
6986 [CommonTriggerDataAttributes.popupOpen]: ""
6987 };
6988 var PRESSABLE_TRIGGER_HOOK = {
6989 [CommonTriggerDataAttributes.popupOpen]: "",
6990 [CommonTriggerDataAttributes.pressed]: ""
6991 };
6992 var POPUP_OPEN_HOOK = {
6993 [CommonPopupDataAttributes.open]: ""
6994 };
6995 var POPUP_CLOSED_HOOK = {
6996 [CommonPopupDataAttributes.closed]: ""
6997 };
6998 var ANCHOR_HIDDEN_HOOK = {
6999 [CommonPopupDataAttributes.anchorHidden]: ""
7000 };
7001 var triggerOpenStateMapping = {
7002 open(value) {
7003 if (value) {
7004 return TRIGGER_HOOK;
7005 }
7006 return null;
7007 }
7008 };
7009 var popupStateMapping = {
7010 open(value) {
7011 if (value) {
7012 return POPUP_OPEN_HOOK;
7013 }
7014 return POPUP_CLOSED_HOOK;
7015 },
7016 anchorHidden(value) {
7017 if (value) {
7018 return ANCHOR_HIDDEN_HOOK;
7019 }
7020 return null;
7021 }
7022 };
7023
7024 // node_modules/@base-ui/utils/esm/inertValue.js
7025 function inertValue(value) {
7026 if (isReactVersionAtLeast(19)) {
7027 return value;
7028 }
7029 return value ? "true" : void 0;
7030 }
7031
7032 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7033 var React29 = __toESM(require_react(), 1);
7034
7035 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7036 var baseArrow = (options) => ({
7037 name: "arrow",
7038 options,
7039 async fn(state) {
7040 const {
7041 x: x2,
7042 y: y2,
7043 placement,
7044 rects,
7045 platform: platform3,
7046 elements,
7047 middlewareData
7048 } = state;
7049 const {
7050 element,
7051 padding = 0,
7052 offsetParent = "real"
7053 } = evaluate(options, state) || {};
7054 if (element == null) {
7055 return {};
7056 }
7057 const paddingObject = getPaddingObject(padding);
7058 const coords = {
7059 x: x2,
7060 y: y2
7061 };
7062 const axis = getAlignmentAxis(placement);
7063 const length = getAxisLength(axis);
7064 const arrowDimensions = await platform3.getDimensions(element);
7065 const isYAxis = axis === "y";
7066 const minProp = isYAxis ? "top" : "left";
7067 const maxProp = isYAxis ? "bottom" : "right";
7068 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7069 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7070 const startDiff = coords[axis] - rects.reference[axis];
7071 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7072 let clientSize = elements.floating[clientProp] || rects.floating[length];
7073 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7074 clientSize = elements.floating[clientProp] || rects.floating[length];
7075 }
7076 const centerToReference = endDiff / 2 - startDiff / 2;
7077 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7078 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7079 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7080 const min2 = minPadding;
7081 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7082 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7083 const offset4 = clamp(min2, center, max2);
7084 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7085 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7086 return {
7087 [axis]: coords[axis] + alignmentOffset,
7088 data: {
7089 [axis]: offset4,
7090 centerOffset: center - offset4 - alignmentOffset,
7091 ...shouldAddOffset && {
7092 alignmentOffset
7093 }
7094 },
7095 reset: shouldAddOffset
7096 };
7097 }
7098 });
7099 var arrow4 = (options, deps) => ({
7100 ...baseArrow(options),
7101 options: [options, deps]
7102 });
7103
7104 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7105 var hide4 = {
7106 name: "hide",
7107 async fn(state) {
7108 const {
7109 width,
7110 height,
7111 x: x2,
7112 y: y2
7113 } = state.rects.reference;
7114 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7115 const nativeHideResult = await hide3().fn(state);
7116 return {
7117 data: {
7118 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7119 }
7120 };
7121 }
7122 };
7123
7124 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7125 var DEFAULT_SIDES = {
7126 sideX: "left",
7127 sideY: "top"
7128 };
7129 var adaptiveOrigin = {
7130 name: "adaptiveOrigin",
7131 async fn(state) {
7132 const {
7133 x: rawX,
7134 y: rawY,
7135 rects: {
7136 floating: floatRect
7137 },
7138 elements: {
7139 floating
7140 },
7141 platform: platform3,
7142 strategy,
7143 placement
7144 } = state;
7145 const win = getWindow(floating);
7146 const styles = win.getComputedStyle(floating);
7147 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7148 if (!hasTransition) {
7149 return {
7150 x: rawX,
7151 y: rawY,
7152 data: DEFAULT_SIDES
7153 };
7154 }
7155 const offsetParent = await platform3.getOffsetParent?.(floating);
7156 let offsetDimensions = {
7157 width: 0,
7158 height: 0
7159 };
7160 if (strategy === "fixed" && win?.visualViewport) {
7161 offsetDimensions = {
7162 width: win.visualViewport.width,
7163 height: win.visualViewport.height
7164 };
7165 } else if (offsetParent === win) {
7166 const doc = ownerDocument(floating);
7167 offsetDimensions = {
7168 width: doc.documentElement.clientWidth,
7169 height: doc.documentElement.clientHeight
7170 };
7171 } else if (await platform3.isElement?.(offsetParent)) {
7172 offsetDimensions = await platform3.getDimensions(offsetParent);
7173 }
7174 const currentSide = getSide(placement);
7175 let x2 = rawX;
7176 let y2 = rawY;
7177 if (currentSide === "left") {
7178 x2 = offsetDimensions.width - (rawX + floatRect.width);
7179 }
7180 if (currentSide === "top") {
7181 y2 = offsetDimensions.height - (rawY + floatRect.height);
7182 }
7183 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7184 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7185 return {
7186 x: x2,
7187 y: y2,
7188 data: {
7189 sideX,
7190 sideY
7191 }
7192 };
7193 }
7194 };
7195
7196 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7197 function getLogicalSide(sideParam, renderedSide, isRtl) {
7198 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7199 const logicalRight = isRtl ? "inline-start" : "inline-end";
7200 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7201 return {
7202 top: "top",
7203 right: isLogicalSideParam ? logicalRight : "right",
7204 bottom: "bottom",
7205 left: isLogicalSideParam ? logicalLeft : "left"
7206 }[renderedSide];
7207 }
7208 function getOffsetData(state, sideParam, isRtl) {
7209 const {
7210 rects,
7211 placement
7212 } = state;
7213 const data = {
7214 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7215 align: getAlignment(placement) || "center",
7216 anchor: {
7217 width: rects.reference.width,
7218 height: rects.reference.height
7219 },
7220 positioner: {
7221 width: rects.floating.width,
7222 height: rects.floating.height
7223 }
7224 };
7225 return data;
7226 }
7227 function useAnchorPositioning(params) {
7228 const {
7229 // Public parameters
7230 anchor,
7231 positionMethod = "absolute",
7232 side: sideParam = "bottom",
7233 sideOffset = 0,
7234 align = "center",
7235 alignOffset = 0,
7236 collisionBoundary,
7237 collisionPadding: collisionPaddingParam = 5,
7238 sticky = false,
7239 arrowPadding = 5,
7240 disableAnchorTracking = false,
7241 inline: inlineMiddleware,
7242 // Private parameters
7243 keepMounted = false,
7244 floatingRootContext,
7245 mounted,
7246 collisionAvoidance,
7247 shiftCrossAxis = false,
7248 nodeId,
7249 adaptiveOrigin: adaptiveOrigin2,
7250 lazyFlip = false,
7251 externalTree
7252 } = params;
7253 const [mountSide, setMountSide] = React29.useState(null);
7254 if (!mounted && mountSide !== null) {
7255 setMountSide(null);
7256 }
7257 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7258 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7259 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7260 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7261 const anchorFnCallback = useStableCallback(anchorFn);
7262 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7263 const anchorValueRef = useValueAsRef(anchor);
7264 const mountedRef = useValueAsRef(mounted);
7265 const direction = useDirection();
7266 const isRtl = direction === "rtl";
7267 const side = mountSide || {
7268 top: "top",
7269 right: "right",
7270 bottom: "bottom",
7271 left: "left",
7272 "inline-end": isRtl ? "left" : "right",
7273 "inline-start": isRtl ? "right" : "left"
7274 }[sideParam];
7275 const placement = align === "center" ? side : `${side}-${align}`;
7276 let collisionPadding = collisionPaddingParam;
7277 const bias = 1;
7278 const biasTop = sideParam === "bottom" ? bias : 0;
7279 const biasBottom = sideParam === "top" ? bias : 0;
7280 const biasLeft = sideParam === "right" ? bias : 0;
7281 const biasRight = sideParam === "left" ? bias : 0;
7282 if (typeof collisionPadding === "number") {
7283 collisionPadding = {
7284 top: collisionPadding + biasTop,
7285 right: collisionPadding + biasRight,
7286 bottom: collisionPadding + biasBottom,
7287 left: collisionPadding + biasLeft
7288 };
7289 } else if (collisionPadding) {
7290 collisionPadding = {
7291 top: (collisionPadding.top || 0) + biasTop,
7292 right: (collisionPadding.right || 0) + biasRight,
7293 bottom: (collisionPadding.bottom || 0) + biasBottom,
7294 left: (collisionPadding.left || 0) + biasLeft
7295 };
7296 }
7297 const commonCollisionProps = {
7298 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7299 padding: collisionPadding
7300 };
7301 const arrowRef = React29.useRef(null);
7302 const sideOffsetRef = useValueAsRef(sideOffset);
7303 const alignOffsetRef = useValueAsRef(alignOffset);
7304 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7305 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7306 const middleware = [];
7307 if (inlineMiddleware) {
7308 middleware.push(inlineMiddleware);
7309 }
7310 middleware.push(offset3((state) => {
7311 const data = getOffsetData(state, sideParam, isRtl);
7312 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7313 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7314 return {
7315 mainAxis: sideAxis,
7316 crossAxis: alignAxis,
7317 alignmentAxis: alignAxis
7318 };
7319 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7320 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7321 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7322 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7323 ...commonCollisionProps,
7324 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7325 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7326 padding: {
7327 top: collisionPadding.top + bias,
7328 right: collisionPadding.right + bias,
7329 bottom: collisionPadding.bottom + bias,
7330 left: collisionPadding.left + bias
7331 },
7332 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7333 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7334 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7335 });
7336 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7337 const html = ownerDocument(data.elements.floating).documentElement;
7338 return {
7339 ...commonCollisionProps,
7340 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7341 // for context menus.
7342 rootBoundary: shiftCrossAxis ? {
7343 x: 0,
7344 y: 0,
7345 width: html.clientWidth,
7346 height: html.clientHeight
7347 } : void 0,
7348 mainAxis: collisionAvoidanceAlign !== "none",
7349 crossAxis: crossAxisShiftEnabled,
7350 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7351 if (!arrowRef.current) {
7352 return {};
7353 }
7354 const {
7355 width,
7356 height
7357 } = arrowRef.current.getBoundingClientRect();
7358 const sideAxis = getSideAxis(getSide(limitData.placement));
7359 const arrowSize = sideAxis === "y" ? width : height;
7360 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7361 return {
7362 offset: arrowSize / 2 + offsetAmount / 2
7363 };
7364 })
7365 };
7366 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7367 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7368 middleware.push(shiftMiddleware, flipMiddleware);
7369 } else {
7370 middleware.push(flipMiddleware, shiftMiddleware);
7371 }
7372 middleware.push(size3({
7373 ...commonCollisionProps,
7374 apply({
7375 elements: {
7376 floating
7377 },
7378 availableWidth,
7379 availableHeight,
7380 rects
7381 }) {
7382 if (!mountedRef.current) {
7383 return;
7384 }
7385 const floatingStyle = floating.style;
7386 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7387 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7388 const dpr = getWindow(floating).devicePixelRatio || 1;
7389 const {
7390 x: x3,
7391 y: y3,
7392 width,
7393 height
7394 } = rects.reference;
7395 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7396 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7397 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7398 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7399 }
7400 }), arrow4((state) => ({
7401 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7402 // we'll create a fake element.
7403 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7404 padding: arrowPadding,
7405 offsetParent: "floating"
7406 }), [arrowPadding]), {
7407 name: "transformOrigin",
7408 fn(state) {
7409 const {
7410 elements: elements2,
7411 middlewareData: middlewareData2,
7412 placement: renderedPlacement2,
7413 rects,
7414 y: y3
7415 } = state;
7416 const currentRenderedSide = getSide(renderedPlacement2);
7417 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7418 const arrowEl = arrowRef.current;
7419 const arrowX = middlewareData2.arrow?.x || 0;
7420 const arrowY = middlewareData2.arrow?.y || 0;
7421 const arrowWidth = arrowEl?.clientWidth || 0;
7422 const arrowHeight = arrowEl?.clientHeight || 0;
7423 const transformX = arrowX + arrowWidth / 2;
7424 const transformY = arrowY + arrowHeight / 2;
7425 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7426 const halfAnchorHeight = rects.reference.height / 2;
7427 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7428 const isOverlappingAnchor = shiftY > sideOffsetValue;
7429 const adjacentTransformOrigin = {
7430 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7431 bottom: `${transformX}px ${-sideOffsetValue}px`,
7432 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7433 right: `${-sideOffsetValue}px ${transformY}px`
7434 }[currentRenderedSide];
7435 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7436 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7437 return {};
7438 }
7439 }, hide4, adaptiveOrigin2);
7440 useIsoLayoutEffect(() => {
7441 if (!mounted && floatingRootContext) {
7442 floatingRootContext.update({
7443 referenceElement: null,
7444 floatingElement: null,
7445 domReferenceElement: null,
7446 positionReference: null
7447 });
7448 }
7449 }, [mounted, floatingRootContext]);
7450 const autoUpdateOptions = React29.useMemo(() => ({
7451 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7452 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7453 }), [disableAnchorTracking]);
7454 const {
7455 refs,
7456 elements,
7457 x: x2,
7458 y: y2,
7459 middlewareData,
7460 update: update2,
7461 placement: renderedPlacement,
7462 context,
7463 isPositioned,
7464 floatingStyles: originalFloatingStyles
7465 } = useFloating2({
7466 rootContext: floatingRootContext,
7467 open: keepMounted ? mounted : void 0,
7468 placement,
7469 middleware,
7470 strategy: positionMethod,
7471 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7472 nodeId,
7473 externalTree
7474 });
7475 const {
7476 sideX,
7477 sideY
7478 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7479 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7480 const floatingStyles = React29.useMemo(() => {
7481 const base = adaptiveOrigin2 ? {
7482 position: resolvedPosition,
7483 [sideX]: x2,
7484 [sideY]: y2
7485 } : {
7486 position: resolvedPosition,
7487 ...originalFloatingStyles
7488 };
7489 if (!isPositioned) {
7490 base.opacity = 0;
7491 }
7492 return base;
7493 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7494 const registeredPositionReferenceRef = React29.useRef(null);
7495 useIsoLayoutEffect(() => {
7496 if (!mounted) {
7497 return;
7498 }
7499 const anchorValue = anchorValueRef.current;
7500 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7501 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7502 const finalAnchor = unwrappedElement || null;
7503 if (finalAnchor !== registeredPositionReferenceRef.current) {
7504 refs.setPositionReference(finalAnchor);
7505 registeredPositionReferenceRef.current = finalAnchor;
7506 }
7507 }, [mounted, refs, anchorDep, anchorValueRef]);
7508 React29.useEffect(() => {
7509 if (!mounted) {
7510 return;
7511 }
7512 const anchorValue = anchorValueRef.current;
7513 if (typeof anchorValue === "function") {
7514 return;
7515 }
7516 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7517 refs.setPositionReference(anchorValue.current);
7518 registeredPositionReferenceRef.current = anchorValue.current;
7519 }
7520 }, [mounted, refs, anchorDep, anchorValueRef]);
7521 React29.useEffect(() => {
7522 if (keepMounted && mounted && elements.domReference && elements.floating) {
7523 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7524 }
7525 return void 0;
7526 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7527 const renderedSide = getSide(renderedPlacement);
7528 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7529 const renderedAlign = getAlignment(renderedPlacement) || "center";
7530 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7531 useIsoLayoutEffect(() => {
7532 if (lazyFlip && mounted && isPositioned) {
7533 setMountSide(renderedSide);
7534 }
7535 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7536 const arrowStyles = React29.useMemo(() => ({
7537 position: "absolute",
7538 top: middlewareData.arrow?.y,
7539 left: middlewareData.arrow?.x
7540 }), [middlewareData.arrow]);
7541 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7542 return React29.useMemo(() => ({
7543 positionerStyles: floatingStyles,
7544 arrowStyles,
7545 arrowRef,
7546 arrowUncentered,
7547 side: logicalRenderedSide,
7548 align: renderedAlign,
7549 physicalSide: renderedSide,
7550 anchorHidden,
7551 refs,
7552 context,
7553 isPositioned,
7554 update: update2
7555 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7556 }
7557 function isRef(param) {
7558 return param != null && "current" in param;
7559 }
7560
7561 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7562 function getDisabledMountTransitionStyles(transitionStatus) {
7563 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7564 }
7565
7566 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7567 function usePositioner(componentProps, state, {
7568 styles,
7569 transitionStatus,
7570 props,
7571 refs,
7572 hidden,
7573 inert = false
7574 }) {
7575 const style = {
7576 ...styles
7577 };
7578 if (inert) {
7579 style.pointerEvents = "none";
7580 }
7581 return useRenderElement("div", componentProps, {
7582 state,
7583 ref: refs,
7584 props: [{
7585 role: "presentation",
7586 hidden,
7587 style
7588 }, getDisabledMountTransitionStyles(transitionStatus), props],
7589 stateAttributesMapping: popupStateMapping
7590 });
7591 }
7592
7593 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7594 var React32 = __toESM(require_react(), 1);
7595 var ReactDOM5 = __toESM(require_react_dom(), 1);
7596
7597 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7598 var React30 = __toESM(require_react(), 1);
7599 function usePreviousValue(value) {
7600 const [state, setState] = React30.useState({
7601 current: value,
7602 previous: null
7603 });
7604 if (value !== state.current) {
7605 setState({
7606 current: value,
7607 previous: state.current
7608 });
7609 }
7610 return state.previous;
7611 }
7612
7613 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7614 var React31 = __toESM(require_react(), 1);
7615
7616 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7617 function getCssDimensions2(element) {
7618 const css = getComputedStyle2(element);
7619 let width = parseFloat(css.width) || 0;
7620 let height = parseFloat(css.height) || 0;
7621 const hasOffset = isHTMLElement(element);
7622 const offsetWidth = hasOffset ? element.offsetWidth : width;
7623 const offsetHeight = hasOffset ? element.offsetHeight : height;
7624 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7625 if (shouldFallback) {
7626 width = offsetWidth;
7627 height = offsetHeight;
7628 }
7629 return {
7630 width,
7631 height
7632 };
7633 }
7634
7635 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7636 var DEFAULT_ENABLED = () => true;
7637 function usePopupAutoResize(parameters) {
7638 const {
7639 popupElement,
7640 positionerElement,
7641 content,
7642 mounted,
7643 enabled = DEFAULT_ENABLED,
7644 onMeasureLayout: onMeasureLayoutParam,
7645 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7646 side,
7647 direction
7648 } = parameters;
7649 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7650 const animationFrame = useAnimationFrame();
7651 const committedDimensionsRef = React31.useRef(null);
7652 const liveDimensionsRef = React31.useRef(null);
7653 const isInitialRenderRef = React31.useRef(true);
7654 const restoreAnchoringStylesRef = React31.useRef(NOOP);
7655 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7656 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7657 const anchoringStyles = React31.useMemo(() => {
7658 let isOriginSide = side === "top";
7659 let isPhysicalLeft = side === "left";
7660 if (direction === "rtl") {
7661 isOriginSide = isOriginSide || side === "inline-end";
7662 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7663 } else {
7664 isOriginSide = isOriginSide || side === "inline-start";
7665 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7666 }
7667 return isOriginSide ? {
7668 position: "absolute",
7669 [side === "top" ? "bottom" : "top"]: "0",
7670 [isPhysicalLeft ? "right" : "left"]: "0"
7671 } : EMPTY_OBJECT;
7672 }, [side, direction]);
7673 useIsoLayoutEffect(() => {
7674 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7675 restoreAnchoringStylesRef.current = NOOP;
7676 isInitialRenderRef.current = true;
7677 committedDimensionsRef.current = null;
7678 liveDimensionsRef.current = null;
7679 return void 0;
7680 }
7681 if (!popupElement || !positionerElement) {
7682 return void 0;
7683 }
7684 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7685 const observer = new ResizeObserver((entries) => {
7686 const entry = entries[0];
7687 if (entry) {
7688 liveDimensionsRef.current = {
7689 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7690 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7691 };
7692 }
7693 });
7694 observer.observe(popupElement);
7695 setPopupCssSize(popupElement, "auto");
7696 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7697 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7698 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7699 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7700 "--available-width": "max-content",
7701 "--available-height": "max-content"
7702 });
7703 function restoreMeasurementOverrides() {
7704 restorePopupPosition();
7705 restorePopupTransform();
7706 restorePositionerAvailableSize();
7707 }
7708 function restoreMeasurementOverridesIncludingScale() {
7709 restoreMeasurementOverrides();
7710 restorePopupScale();
7711 }
7712 onMeasureLayout?.();
7713 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7714 setPositionerCssSize(positionerElement, "max-content");
7715 const dimensions = getCssDimensions2(popupElement);
7716 committedDimensionsRef.current = dimensions;
7717 setPositionerCssSize(positionerElement, dimensions);
7718 restoreMeasurementOverridesIncludingScale();
7719 onMeasureLayoutComplete?.(null, dimensions);
7720 isInitialRenderRef.current = false;
7721 return () => {
7722 observer.disconnect();
7723 restoreAnchoringStylesRef.current();
7724 restoreAnchoringStylesRef.current = NOOP;
7725 };
7726 }
7727 setPopupCssSize(popupElement, "auto");
7728 setPositionerCssSize(positionerElement, "max-content");
7729 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7730 const newDimensions = getCssDimensions2(popupElement);
7731 committedDimensionsRef.current = newDimensions;
7732 if (!previousDimensions) {
7733 setPositionerCssSize(positionerElement, newDimensions);
7734 restoreMeasurementOverridesIncludingScale();
7735 onMeasureLayoutComplete?.(null, newDimensions);
7736 return () => {
7737 observer.disconnect();
7738 animationFrame.cancel();
7739 restoreAnchoringStylesRef.current();
7740 restoreAnchoringStylesRef.current = NOOP;
7741 };
7742 }
7743 setPopupCssSize(popupElement, previousDimensions);
7744 restoreMeasurementOverridesIncludingScale();
7745 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7746 setPositionerCssSize(positionerElement, newDimensions);
7747 const abortController = new AbortController();
7748 animationFrame.request(() => {
7749 setPopupCssSize(popupElement, newDimensions);
7750 runOnceAnimationsFinish(() => {
7751 popupElement.style.setProperty("--popup-width", "auto");
7752 popupElement.style.setProperty("--popup-height", "auto");
7753 }, abortController.signal);
7754 });
7755 return () => {
7756 observer.disconnect();
7757 abortController.abort();
7758 animationFrame.cancel();
7759 restoreAnchoringStylesRef.current();
7760 restoreAnchoringStylesRef.current = NOOP;
7761 };
7762 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7763 }
7764 function overrideElementStyle(element, property, value) {
7765 const originalValue = element.style.getPropertyValue(property);
7766 element.style.setProperty(property, value);
7767 return () => {
7768 element.style.setProperty(property, originalValue);
7769 };
7770 }
7771 function applyElementStyles(element, styles) {
7772 const restorers = [];
7773 for (const [key, value] of Object.entries(styles)) {
7774 restorers.push(overrideElementStyle(element, key, value));
7775 }
7776 return restorers.length ? () => {
7777 restorers.forEach((restore) => restore());
7778 } : NOOP;
7779 }
7780 function setPopupCssSize(popupElement, size4) {
7781 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7782 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7783 popupElement.style.setProperty("--popup-width", width);
7784 popupElement.style.setProperty("--popup-height", height);
7785 }
7786 function setPositionerCssSize(positionerElement, size4) {
7787 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7788 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7789 positionerElement.style.setProperty("--positioner-width", width);
7790 positionerElement.style.setProperty("--positioner-height", height);
7791 }
7792
7793 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7794 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
7795 function usePopupViewport(parameters) {
7796 const {
7797 store,
7798 side,
7799 cssVars,
7800 children
7801 } = parameters;
7802 const direction = useDirection();
7803 const activeTrigger = store.useState("activeTriggerElement");
7804 const activeTriggerId = store.useState("activeTriggerId");
7805 const open = store.useState("open");
7806 const payload = store.useState("payload");
7807 const mounted = store.useState("mounted");
7808 const popupElement = store.useState("popupElement");
7809 const positionerElement = store.useState("positionerElement");
7810 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7811 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7812 const capturedNodeRef = React32.useRef(null);
7813 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
7814 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
7815 const currentContainerRef = React32.useRef(null);
7816 const previousContainerRef = React32.useRef(null);
7817 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7818 const cleanupFrame = useAnimationFrame();
7819 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
7820 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
7821 useIsoLayoutEffect(() => {
7822 store.set("hasViewport", true);
7823 return () => {
7824 store.set("hasViewport", false);
7825 };
7826 }, [store]);
7827 const handleMeasureLayout = useStableCallback(() => {
7828 currentContainerRef.current?.style.setProperty("animation", "none");
7829 currentContainerRef.current?.style.setProperty("transition", "none");
7830 previousContainerRef.current?.style.setProperty("display", "none");
7831 });
7832 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7833 currentContainerRef.current?.style.removeProperty("animation");
7834 currentContainerRef.current?.style.removeProperty("transition");
7835 previousContainerRef.current?.style.removeProperty("display");
7836 if (previousDimensions) {
7837 setPreviousContentDimensions(previousDimensions);
7838 }
7839 });
7840 const lastHandledTriggerRef = React32.useRef(null);
7841 useIsoLayoutEffect(() => {
7842 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
7843 setPreviousContentNode(capturedNodeRef.current);
7844 setShowStartingStyleAttribute(true);
7845 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
7846 setNewTriggerOffset(offset4);
7847 cleanupFrame.request(() => {
7848 ReactDOM5.flushSync(() => {
7849 setShowStartingStyleAttribute(false);
7850 });
7851 onAnimationsFinished(() => {
7852 setPreviousContentNode(null);
7853 setPreviousContentDimensions(null);
7854 capturedNodeRef.current = null;
7855 });
7856 });
7857 lastHandledTriggerRef.current = activeTrigger;
7858 }
7859 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
7860 useIsoLayoutEffect(() => {
7861 const source = currentContainerRef.current;
7862 if (!source) {
7863 return;
7864 }
7865 const wrapper = ownerDocument(source).createElement("div");
7866 for (const child of Array.from(source.childNodes)) {
7867 wrapper.appendChild(child.cloneNode(true));
7868 }
7869 capturedNodeRef.current = wrapper;
7870 });
7871 const isTransitioning = previousContentNode != null;
7872 let childrenToRender;
7873 if (!isTransitioning) {
7874 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7875 "data-current": true,
7876 ref: currentContainerRef,
7877 children
7878 }, currentContentKey);
7879 } else {
7880 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React32.Fragment, {
7881 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7882 "data-previous": true,
7883 inert: inertValue(true),
7884 ref: previousContainerRef,
7885 style: {
7886 ...previousContentDimensions ? {
7887 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
7888 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
7889 } : null,
7890 position: "absolute"
7891 },
7892 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
7893 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
7894 "data-current": true,
7895 ref: currentContainerRef,
7896 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
7897 children
7898 }, currentContentKey)]
7899 });
7900 }
7901 useIsoLayoutEffect(() => {
7902 const container = previousContainerRef.current;
7903 if (!container || !previousContentNode) {
7904 return;
7905 }
7906 container.replaceChildren(...Array.from(previousContentNode.childNodes));
7907 }, [previousContentNode]);
7908 usePopupAutoResize({
7909 popupElement,
7910 positionerElement,
7911 mounted,
7912 content: payload,
7913 onMeasureLayout: handleMeasureLayout,
7914 onMeasureLayoutComplete: handleMeasureLayoutComplete,
7915 side,
7916 direction
7917 });
7918 const state = {
7919 activationDirection: getActivationDirection(newTriggerOffset),
7920 transitioning: isTransitioning
7921 };
7922 return {
7923 children: childrenToRender,
7924 state
7925 };
7926 }
7927 function getActivationDirection(offset4) {
7928 if (!offset4) {
7929 return void 0;
7930 }
7931 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
7932 }
7933 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
7934 if (value > tolerance) {
7935 return positiveLabel;
7936 }
7937 if (value < -tolerance) {
7938 return negativeLabel;
7939 }
7940 return "";
7941 }
7942 function calculateRelativePosition(from, to) {
7943 const fromRect = from.getBoundingClientRect();
7944 const toRect = to.getBoundingClientRect();
7945 const fromCenter = {
7946 x: fromRect.left + fromRect.width / 2,
7947 y: fromRect.top + fromRect.height / 2
7948 };
7949 const toCenter = {
7950 x: toRect.left + toRect.width / 2,
7951 y: toRect.top + toRect.height / 2
7952 };
7953 return {
7954 horizontal: toCenter.x - fromCenter.x,
7955 vertical: toCenter.y - fromCenter.y
7956 };
7957 }
7958 function usePopupContentKey(activeTriggerId, payload) {
7959 const [contentKey, setContentKey] = React32.useState(0);
7960 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
7961 const previousPayloadRef = React32.useRef(payload);
7962 const pendingPayloadUpdateRef = React32.useRef(false);
7963 useIsoLayoutEffect(() => {
7964 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
7965 const previousPayload = previousPayloadRef.current;
7966 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
7967 const payloadChanged = payload !== previousPayload;
7968 if (triggerIdChanged) {
7969 setContentKey((value) => value + 1);
7970 pendingPayloadUpdateRef.current = !payloadChanged;
7971 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
7972 setContentKey((value) => value + 1);
7973 pendingPayloadUpdateRef.current = false;
7974 }
7975 previousActiveTriggerIdRef.current = activeTriggerId;
7976 previousPayloadRef.current = payload;
7977 }, [activeTriggerId, payload]);
7978 return `${activeTriggerId ?? "current"}-${contentKey}`;
7979 }
7980
7981 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
7982 var React33 = __toESM(require_react(), 1);
7983 var ReactDOM6 = __toESM(require_react_dom(), 1);
7984 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
7985 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
7986 const {
7987 children,
7988 container,
7989 className,
7990 render: render4,
7991 style,
7992 ...elementProps
7993 } = componentProps;
7994 const {
7995 portalNode,
7996 portalSubtree
7997 } = useFloatingPortalNode({
7998 container,
7999 ref: forwardedRef,
8000 componentProps,
8001 elementProps
8002 });
8003 if (!portalSubtree && !portalNode) {
8004 return null;
8005 }
8006 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React33.Fragment, {
8007 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8008 });
8009 });
8010 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8011
8012 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8013 var index_parts_exports = {};
8014 __export(index_parts_exports, {
8015 Arrow: () => TooltipArrow,
8016 Handle: () => TooltipHandle,
8017 Popup: () => TooltipPopup,
8018 Portal: () => TooltipPortal,
8019 Positioner: () => TooltipPositioner,
8020 Provider: () => TooltipProvider,
8021 Root: () => TooltipRoot,
8022 Trigger: () => TooltipTrigger,
8023 Viewport: () => TooltipViewport,
8024 createHandle: () => createTooltipHandle
8025 });
8026
8027 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8028 var React36 = __toESM(require_react(), 1);
8029
8030 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8031 var React34 = __toESM(require_react(), 1);
8032 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
8033 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8034 function useTooltipRootContext(optional) {
8035 const context = React34.useContext(TooltipRootContext);
8036 if (context === void 0 && !optional) {
8037 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8038 }
8039 return context;
8040 }
8041
8042 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8043 var React35 = __toESM(require_react(), 1);
8044 var ReactDOM7 = __toESM(require_react_dom(), 1);
8045 var selectors2 = {
8046 ...popupStoreSelectors,
8047 disabled: createSelector((state) => state.disabled),
8048 instantType: createSelector((state) => state.instantType),
8049 isInstantPhase: createSelector((state) => state.isInstantPhase),
8050 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8051 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8052 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8053 closeOnClick: createSelector((state) => state.closeOnClick),
8054 closeDelay: createSelector((state) => state.closeDelay),
8055 hasViewport: createSelector((state) => state.hasViewport)
8056 };
8057 var TooltipStore = class _TooltipStore extends ReactStore {
8058 constructor(initialState, floatingId, nested = false) {
8059 const triggerElements = new PopupTriggerMap();
8060 const state = {
8061 ...createInitialState(),
8062 ...initialState
8063 };
8064 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8065 super(state, {
8066 popupRef: /* @__PURE__ */ React35.createRef(),
8067 onOpenChange: void 0,
8068 onOpenChangeComplete: void 0,
8069 triggerElements
8070 }, selectors2);
8071 }
8072 setOpen = (nextOpen, eventDetails) => {
8073 const reason = eventDetails.reason;
8074 const isHover = reason === reason_parts_exports.triggerHover;
8075 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8076 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8077 eventDetails.preventUnmountOnClose = () => {
8078 this.set("preventUnmountingOnClose", true);
8079 };
8080 this.context.onOpenChange?.(nextOpen, eventDetails);
8081 if (eventDetails.isCanceled) {
8082 return;
8083 }
8084 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8085 const changeState = () => {
8086 const updatedState = {
8087 open: nextOpen,
8088 openChangeReason: reason
8089 };
8090 if (isFocusOpen) {
8091 updatedState.instantType = "focus";
8092 } else if (isDismissClose) {
8093 updatedState.instantType = "dismiss";
8094 } else if (reason === reason_parts_exports.triggerHover) {
8095 updatedState.instantType = void 0;
8096 }
8097 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
8098 this.update(updatedState);
8099 };
8100 if (isHover) {
8101 ReactDOM7.flushSync(changeState);
8102 } else {
8103 changeState();
8104 }
8105 };
8106 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8107 cancelPendingOpen(event) {
8108 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8109 }
8110 static useStore(externalStore, initialState) {
8111 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8112 return store;
8113 }
8114 };
8115 function createInitialState() {
8116 return {
8117 ...createInitialPopupStoreState(),
8118 disabled: false,
8119 instantType: void 0,
8120 isInstantPhase: false,
8121 trackCursorAxis: "none",
8122 disableHoverablePopup: false,
8123 openChangeReason: null,
8124 closeOnClick: true,
8125 closeDelay: 0,
8126 hasViewport: false
8127 };
8128 }
8129
8130 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8131 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8132 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8133 const {
8134 disabled: disabled2 = false,
8135 defaultOpen = false,
8136 open: openProp,
8137 disableHoverablePopup = false,
8138 trackCursorAxis = "none",
8139 actionsRef,
8140 onOpenChange,
8141 onOpenChangeComplete,
8142 handle,
8143 triggerId: triggerIdProp,
8144 defaultTriggerId: defaultTriggerIdProp = null,
8145 children
8146 } = props;
8147 const store = TooltipStore.useStore(handle?.store, {
8148 open: defaultOpen,
8149 openProp,
8150 activeTriggerId: defaultTriggerIdProp,
8151 triggerIdProp
8152 });
8153 useOnFirstRender(() => {
8154 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8155 store.update({
8156 open: true,
8157 activeTriggerId: defaultTriggerIdProp
8158 });
8159 }
8160 });
8161 store.useControlledProp("openProp", openProp);
8162 store.useControlledProp("triggerIdProp", triggerIdProp);
8163 store.useContextCallback("onOpenChange", onOpenChange);
8164 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8165 const openState = store.useState("open");
8166 const open = !disabled2 && openState;
8167 const activeTriggerId = store.useState("activeTriggerId");
8168 const mounted = store.useState("mounted");
8169 const payload = store.useState("payload");
8170 store.useSyncedValues({
8171 trackCursorAxis,
8172 disableHoverablePopup
8173 });
8174 store.useSyncedValue("disabled", disabled2);
8175 useImplicitActiveTrigger(store);
8176 const {
8177 forceUnmount,
8178 transitionStatus
8179 } = useOpenStateTransitions(open, store);
8180 const isInstantPhase = store.useState("isInstantPhase");
8181 const instantType = store.useState("instantType");
8182 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8183 const previousInstantTypeRef = React36.useRef(null);
8184 useIsoLayoutEffect(() => {
8185 if (openState && disabled2) {
8186 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8187 }
8188 }, [openState, disabled2, store]);
8189 useIsoLayoutEffect(() => {
8190 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8191 if (instantType !== "delay") {
8192 previousInstantTypeRef.current = instantType;
8193 }
8194 store.set("instantType", "delay");
8195 } else if (previousInstantTypeRef.current !== null) {
8196 store.set("instantType", previousInstantTypeRef.current);
8197 previousInstantTypeRef.current = null;
8198 }
8199 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8200 useIsoLayoutEffect(() => {
8201 if (open) {
8202 if (activeTriggerId == null) {
8203 store.set("payload", void 0);
8204 }
8205 }
8206 }, [store, activeTriggerId, open]);
8207 const handleImperativeClose = React36.useCallback(() => {
8208 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8209 }, [store]);
8210 React36.useImperativeHandle(actionsRef, () => ({
8211 unmount: forceUnmount,
8212 close: handleImperativeClose
8213 }), [forceUnmount, handleImperativeClose]);
8214 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8215 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8216 value: store,
8217 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8218 store,
8219 disabled: disabled2,
8220 trackCursorAxis
8221 }), typeof children === "function" ? children({
8222 payload
8223 }) : children]
8224 });
8225 });
8226 if (true) TooltipRoot.displayName = "TooltipRoot";
8227 function TooltipInteractions({
8228 store,
8229 disabled: disabled2,
8230 trackCursorAxis
8231 }) {
8232 const floatingRootContext = store.useState("floatingRootContext");
8233 const dismiss = useDismiss(floatingRootContext, {
8234 enabled: !disabled2,
8235 referencePress: () => store.select("closeOnClick")
8236 });
8237 const clientPoint = useClientPoint(floatingRootContext, {
8238 enabled: !disabled2 && trackCursorAxis !== "none",
8239 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8240 });
8241 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8242 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8243 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8244 usePopupInteractionProps(store, {
8245 activeTriggerProps,
8246 inactiveTriggerProps,
8247 popupProps
8248 });
8249 return null;
8250 }
8251
8252 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8253 var React38 = __toESM(require_react(), 1);
8254
8255 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8256 var React37 = __toESM(require_react(), 1);
8257 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
8258 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8259 function useTooltipProviderContext() {
8260 return React37.useContext(TooltipProviderContext);
8261 }
8262
8263 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8264 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8265 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8266 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8267 return TooltipTriggerDataAttributes2;
8268 })({});
8269
8270 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8271 var OPEN_DELAY = 600;
8272
8273 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8274 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8275 function getTargetElement(event) {
8276 if ("composedPath" in event) {
8277 const path = event.composedPath();
8278 for (let i2 = 0; i2 < path.length; i2 += 1) {
8279 const element = path[i2];
8280 if (isElement(element)) {
8281 return element;
8282 }
8283 }
8284 }
8285 const target = event.target;
8286 if (isElement(target)) {
8287 return target;
8288 }
8289 return null;
8290 }
8291 function closestEnabledTooltipTrigger(element) {
8292 let current = element;
8293 while (current) {
8294 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8295 return current;
8296 }
8297 const parentElement = current.parentElement;
8298 if (parentElement) {
8299 current = parentElement;
8300 continue;
8301 }
8302 const root = current.getRootNode();
8303 current = "host" in root && isElement(root.host) ? root.host : null;
8304 }
8305 return null;
8306 }
8307 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8308 const {
8309 render: render4,
8310 className,
8311 style,
8312 handle,
8313 payload,
8314 disabled: disabledProp,
8315 delay,
8316 closeOnClick = true,
8317 closeDelay,
8318 id: idProp,
8319 ...elementProps
8320 } = componentProps;
8321 const rootContext = useTooltipRootContext(true);
8322 const store = handle?.store ?? rootContext;
8323 if (!store) {
8324 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));
8325 }
8326 const thisTriggerId = useBaseUiId(idProp);
8327 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8328 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8329 const floatingRootContext = store.useState("floatingRootContext");
8330 const triggerElementRef = React38.useRef(null);
8331 const delayWithDefault = delay ?? OPEN_DELAY;
8332 const closeDelayWithDefault = closeDelay ?? 0;
8333 const {
8334 registerTrigger,
8335 isMountedByThisTrigger
8336 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8337 payload,
8338 closeOnClick,
8339 closeDelay: closeDelayWithDefault
8340 });
8341 const providerContext = useTooltipProviderContext();
8342 const {
8343 delayRef,
8344 isInstantPhase,
8345 hasProvider
8346 } = useDelayGroup(floatingRootContext, {
8347 open: isOpenedByThisTrigger
8348 });
8349 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8350 store.useSyncedValue("isInstantPhase", isInstantPhase);
8351 const rootDisabled = store.useState("disabled");
8352 const disabled2 = disabledProp ?? rootDisabled;
8353 const disabledRef = useValueAsRef(disabled2);
8354 const trackCursorAxis = store.useState("trackCursorAxis");
8355 const disableHoverablePopup = store.useState("disableHoverablePopup");
8356 const isNestedTriggerHoveredRef = React38.useRef(false);
8357 const nestedTriggerOpenTimeout = useTimeout();
8358 const pointerTypeRef = React38.useRef(void 0);
8359 function getOpenDelay() {
8360 const providerDelay = providerContext?.delay;
8361 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8362 let computedOpenDelay = delayWithDefault;
8363 if (hasProvider) {
8364 if (groupOpenValue !== 0) {
8365 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8366 } else {
8367 computedOpenDelay = 0;
8368 }
8369 }
8370 return computedOpenDelay;
8371 }
8372 function isEnabledNestedTriggerTarget(target) {
8373 const triggerEl = triggerElementRef.current;
8374 if (!triggerEl || !target) {
8375 return false;
8376 }
8377 const nearestTrigger = closestEnabledTooltipTrigger(target);
8378 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8379 }
8380 function detectNestedTriggerHover(target) {
8381 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8382 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8383 if (nestedTriggerHovered) {
8384 hoverInteraction.openChangeTimeout.clear();
8385 hoverInteraction.restTimeout.clear();
8386 hoverInteraction.restTimeoutPending = false;
8387 nestedTriggerOpenTimeout.clear();
8388 }
8389 return nestedTriggerHovered;
8390 }
8391 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8392 enabled: !disabled2,
8393 mouseOnly: true,
8394 move: false,
8395 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8396 restMs: getOpenDelay,
8397 delay() {
8398 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8399 let computedCloseDelay = closeDelayWithDefault;
8400 if (closeDelay == null && hasProvider) {
8401 computedCloseDelay = closeValue;
8402 }
8403 return {
8404 close: computedCloseDelay
8405 };
8406 },
8407 triggerElementRef,
8408 isActiveTrigger: isTriggerActive,
8409 isClosing: () => store.select("transitionStatus") === "ending",
8410 shouldOpen() {
8411 return !isNestedTriggerHoveredRef.current;
8412 }
8413 });
8414 const focusProps = useFocus(floatingRootContext, {
8415 enabled: !disabled2
8416 }).reference;
8417 const handleNestedTriggerHover = (event) => {
8418 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8419 const target = getTargetElement(event);
8420 const nestedTriggerHovered = detectNestedTriggerHover(target);
8421 const triggerEl = triggerElementRef.current;
8422 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8423 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8424 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8425 return;
8426 }
8427 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8428 isMouseLikePointerType(pointerTypeRef.current)) {
8429 const open = () => {
8430 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8431 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8432 }
8433 };
8434 const openDelay = getOpenDelay();
8435 if (openDelay === 0) {
8436 nestedTriggerOpenTimeout.clear();
8437 open();
8438 } else {
8439 nestedTriggerOpenTimeout.start(openDelay, open);
8440 }
8441 }
8442 };
8443 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8444 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8445 const state = {
8446 open: isOpenedByThisTrigger
8447 };
8448 const element = useRenderElement("button", componentProps, {
8449 state,
8450 ref: [forwardedRef, registerTrigger, triggerElementRef],
8451 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8452 onMouseOver(event) {
8453 handleNestedTriggerHover(event.nativeEvent);
8454 },
8455 onFocus(event) {
8456 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8457 event.preventBaseUIHandler();
8458 }
8459 },
8460 onMouseLeave() {
8461 isNestedTriggerHoveredRef.current = false;
8462 nestedTriggerOpenTimeout.clear();
8463 pointerTypeRef.current = void 0;
8464 },
8465 onPointerEnter(event) {
8466 pointerTypeRef.current = event.pointerType;
8467 },
8468 onPointerDown(event) {
8469 pointerTypeRef.current = event.pointerType;
8470 store.set("closeOnClick", closeOnClick);
8471 if (closeOnClick && !store.select("open")) {
8472 store.cancelPendingOpen(event.nativeEvent);
8473 }
8474 },
8475 onClick(event) {
8476 if (closeOnClick && !store.select("open")) {
8477 store.cancelPendingOpen(event.nativeEvent);
8478 }
8479 },
8480 id: thisTriggerId,
8481 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8482 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8483 }, elementProps],
8484 stateAttributesMapping: triggerOpenStateMapping
8485 });
8486 return element;
8487 });
8488 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8489
8490 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8491 var React40 = __toESM(require_react(), 1);
8492
8493 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8494 var React39 = __toESM(require_react(), 1);
8495 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
8496 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8497 function useTooltipPortalContext() {
8498 const value = React39.useContext(TooltipPortalContext);
8499 if (value === void 0) {
8500 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8501 }
8502 return value;
8503 }
8504
8505 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8506 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8507 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
8508 const {
8509 keepMounted = false,
8510 ...portalProps
8511 } = props;
8512 const store = useTooltipRootContext();
8513 const mounted = store.useState("mounted");
8514 const shouldRender = mounted || keepMounted;
8515 if (!shouldRender) {
8516 return null;
8517 }
8518 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8519 value: keepMounted,
8520 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8521 ref: forwardedRef,
8522 ...portalProps
8523 })
8524 });
8525 });
8526 if (true) TooltipPortal.displayName = "TooltipPortal";
8527
8528 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8529 var React42 = __toESM(require_react(), 1);
8530
8531 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8532 var React41 = __toESM(require_react(), 1);
8533 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
8534 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8535 function useTooltipPositionerContext() {
8536 const context = React41.useContext(TooltipPositionerContext);
8537 if (context === void 0) {
8538 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8539 }
8540 return context;
8541 }
8542
8543 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8544 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8545 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8546 const {
8547 render: render4,
8548 className,
8549 anchor,
8550 positionMethod = "absolute",
8551 side = "top",
8552 align = "center",
8553 sideOffset = 0,
8554 alignOffset = 0,
8555 collisionBoundary = "clipping-ancestors",
8556 collisionPadding = 5,
8557 arrowPadding = 5,
8558 sticky = false,
8559 disableAnchorTracking = false,
8560 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8561 style,
8562 ...elementProps
8563 } = componentProps;
8564 const store = useTooltipRootContext();
8565 const keepMounted = useTooltipPortalContext();
8566 const open = store.useState("open");
8567 const mounted = store.useState("mounted");
8568 const trackCursorAxis = store.useState("trackCursorAxis");
8569 const disableHoverablePopup = store.useState("disableHoverablePopup");
8570 const floatingRootContext = store.useState("floatingRootContext");
8571 const instantType = store.useState("instantType");
8572 const transitionStatus = store.useState("transitionStatus");
8573 const hasViewport = store.useState("hasViewport");
8574 const positioning = useAnchorPositioning({
8575 anchor,
8576 positionMethod,
8577 floatingRootContext,
8578 mounted,
8579 side,
8580 sideOffset,
8581 align,
8582 alignOffset,
8583 collisionBoundary,
8584 collisionPadding,
8585 sticky,
8586 arrowPadding,
8587 disableAnchorTracking,
8588 keepMounted,
8589 collisionAvoidance,
8590 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8591 });
8592 const state = React42.useMemo(() => ({
8593 open,
8594 side: positioning.side,
8595 align: positioning.align,
8596 anchorHidden: positioning.anchorHidden,
8597 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8598 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8599 const element = usePositioner(componentProps, state, {
8600 styles: positioning.positionerStyles,
8601 transitionStatus,
8602 props: elementProps,
8603 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8604 hidden: !mounted,
8605 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8606 });
8607 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8608 value: positioning,
8609 children: element
8610 });
8611 });
8612 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8613
8614 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8615 var React43 = __toESM(require_react(), 1);
8616 var stateAttributesMapping = {
8617 ...popupStateMapping,
8618 ...transitionStatusMapping
8619 };
8620 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8621 const {
8622 render: render4,
8623 className,
8624 style,
8625 ...elementProps
8626 } = componentProps;
8627 const store = useTooltipRootContext();
8628 const {
8629 side,
8630 align
8631 } = useTooltipPositionerContext();
8632 const open = store.useState("open");
8633 const instantType = store.useState("instantType");
8634 const transitionStatus = store.useState("transitionStatus");
8635 const popupProps = store.useState("popupProps");
8636 const floatingContext = store.useState("floatingRootContext");
8637 const disabled2 = store.useState("disabled");
8638 const closeDelay = store.useState("closeDelay");
8639 useOpenChangeComplete({
8640 open,
8641 ref: store.context.popupRef,
8642 onComplete() {
8643 if (open) {
8644 store.context.onOpenChangeComplete?.(true);
8645 }
8646 }
8647 });
8648 useHoverFloatingInteraction(floatingContext, {
8649 enabled: !disabled2,
8650 closeDelay
8651 });
8652 const setPopupElement = store.useStateSetter("popupElement");
8653 const state = {
8654 open,
8655 side,
8656 align,
8657 instant: instantType,
8658 transitionStatus
8659 };
8660 const element = useRenderElement("div", componentProps, {
8661 state,
8662 ref: [forwardedRef, store.context.popupRef, setPopupElement],
8663 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8664 stateAttributesMapping
8665 });
8666 return element;
8667 });
8668 if (true) TooltipPopup.displayName = "TooltipPopup";
8669
8670 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8671 var React44 = __toESM(require_react(), 1);
8672 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8673 const {
8674 render: render4,
8675 className,
8676 style,
8677 ...elementProps
8678 } = componentProps;
8679 const store = useTooltipRootContext();
8680 const {
8681 arrowRef,
8682 side,
8683 align,
8684 arrowUncentered,
8685 arrowStyles
8686 } = useTooltipPositionerContext();
8687 const open = store.useState("open");
8688 const instantType = store.useState("instantType");
8689 const state = {
8690 open,
8691 side,
8692 align,
8693 uncentered: arrowUncentered,
8694 instant: instantType
8695 };
8696 const element = useRenderElement("div", componentProps, {
8697 state,
8698 ref: [forwardedRef, arrowRef],
8699 props: [{
8700 style: arrowStyles,
8701 "aria-hidden": true
8702 }, elementProps],
8703 stateAttributesMapping: popupStateMapping
8704 });
8705 return element;
8706 });
8707 if (true) TooltipArrow.displayName = "TooltipArrow";
8708
8709 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8710 var React45 = __toESM(require_react(), 1);
8711 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8712 var TooltipProvider = function TooltipProvider2(props) {
8713 const {
8714 delay,
8715 closeDelay,
8716 timeout = 400
8717 } = props;
8718 const contextValue = React45.useMemo(() => ({
8719 delay,
8720 closeDelay
8721 }), [delay, closeDelay]);
8722 const delayValue = React45.useMemo(() => ({
8723 open: delay,
8724 close: closeDelay
8725 }), [delay, closeDelay]);
8726 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8727 value: contextValue,
8728 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8729 delay: delayValue,
8730 timeoutMs: timeout,
8731 children: props.children
8732 })
8733 });
8734 };
8735 if (true) TooltipProvider.displayName = "TooltipProvider";
8736
8737 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8738 var React46 = __toESM(require_react(), 1);
8739
8740 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8741 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8742 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8743 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8744 return TooltipViewportCssVars2;
8745 })({});
8746
8747 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8748 var stateAttributesMapping2 = {
8749 activationDirection: (value) => value ? {
8750 "data-activation-direction": value
8751 } : null
8752 };
8753 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8754 const {
8755 render: render4,
8756 className,
8757 style,
8758 children,
8759 ...elementProps
8760 } = componentProps;
8761 const store = useTooltipRootContext();
8762 const positioner = useTooltipPositionerContext();
8763 const instantType = store.useState("instantType");
8764 const {
8765 children: childrenToRender,
8766 state: viewportState
8767 } = usePopupViewport({
8768 store,
8769 side: positioner.side,
8770 cssVars: TooltipViewportCssVars,
8771 children
8772 });
8773 const state = {
8774 activationDirection: viewportState.activationDirection,
8775 transitioning: viewportState.transitioning,
8776 instant: instantType
8777 };
8778 return useRenderElement("div", componentProps, {
8779 state,
8780 ref: forwardedRef,
8781 props: [elementProps, {
8782 children: childrenToRender
8783 }],
8784 stateAttributesMapping: stateAttributesMapping2
8785 });
8786 });
8787 if (true) TooltipViewport.displayName = "TooltipViewport";
8788
8789 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8790 var TooltipHandle = class {
8791 /**
8792 * Internal store holding the tooltip state.
8793 * @internal
8794 */
8795 constructor() {
8796 this.store = new TooltipStore();
8797 }
8798 /**
8799 * Opens the tooltip and associates it with the trigger with the given ID.
8800 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8801 *
8802 * This method should only be called in an event handler or an effect (not during rendering).
8803 *
8804 * @param triggerId ID of the trigger to associate with the tooltip.
8805 */
8806 open(triggerId) {
8807 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8808 if (triggerId && !triggerElement) {
8809 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8810 }
8811 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8812 }
8813 /**
8814 * Closes the tooltip.
8815 */
8816 close() {
8817 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8818 }
8819 /**
8820 * Indicates whether the tooltip is currently open.
8821 */
8822 get isOpen() {
8823 return this.store.select("open");
8824 }
8825 };
8826 function createTooltipHandle() {
8827 return new TooltipHandle();
8828 }
8829
8830 // node_modules/@base-ui/react/esm/use-render/useRender.js
8831 function useRender(params) {
8832 return useRenderElement(params.defaultTagName ?? "div", params, params);
8833 }
8834
8835 // packages/ui/build-module/text/text.mjs
8836 var import_element10 = __toESM(require_element(), 1);
8837 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8838 function getRuntime() {
8839 const globalScope = globalThis;
8840 if (globalScope.__wpStyleRuntime) {
8841 return globalScope.__wpStyleRuntime;
8842 }
8843 globalScope.__wpStyleRuntime = {
8844 documents: /* @__PURE__ */ new Map(),
8845 styles: /* @__PURE__ */ new Map(),
8846 injectedStyles: /* @__PURE__ */ new WeakMap()
8847 };
8848 if (typeof document !== "undefined") {
8849 registerDocument(document);
8850 }
8851 return globalScope.__wpStyleRuntime;
8852 }
8853 function documentContainsStyleHash(targetDocument, hash) {
8854 if (!targetDocument.head) {
8855 return false;
8856 }
8857 for (const style of targetDocument.head.querySelectorAll(
8858 `style[${STYLE_HASH_ATTRIBUTE}]`
8859 )) {
8860 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
8861 return true;
8862 }
8863 }
8864 return false;
8865 }
8866 function injectStyle(targetDocument, hash, css) {
8867 if (!targetDocument.head) {
8868 return;
8869 }
8870 const runtime = getRuntime();
8871 let injectedStyles = runtime.injectedStyles.get(targetDocument);
8872 if (!injectedStyles) {
8873 injectedStyles = /* @__PURE__ */ new Set();
8874 runtime.injectedStyles.set(targetDocument, injectedStyles);
8875 }
8876 if (injectedStyles.has(hash)) {
8877 return;
8878 }
8879 if (documentContainsStyleHash(targetDocument, hash)) {
8880 injectedStyles.add(hash);
8881 return;
8882 }
8883 const style = targetDocument.createElement("style");
8884 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
8885 style.appendChild(targetDocument.createTextNode(css));
8886 targetDocument.head.appendChild(style);
8887 injectedStyles.add(hash);
8888 }
8889 function registerDocument(targetDocument) {
8890 const runtime = getRuntime();
8891 runtime.documents.set(
8892 targetDocument,
8893 (runtime.documents.get(targetDocument) ?? 0) + 1
8894 );
8895 for (const [hash, css] of runtime.styles) {
8896 injectStyle(targetDocument, hash, css);
8897 }
8898 return () => {
8899 const count = runtime.documents.get(targetDocument);
8900 if (count === void 0) {
8901 return;
8902 }
8903 if (count <= 1) {
8904 runtime.documents.delete(targetDocument);
8905 return;
8906 }
8907 runtime.documents.set(targetDocument, count - 1);
8908 };
8909 }
8910 function registerStyle(hash, css) {
8911 const runtime = getRuntime();
8912 runtime.styles.set(hash, css);
8913 for (const targetDocument of runtime.documents.keys()) {
8914 injectStyle(targetDocument, hash, css);
8915 }
8916 }
8917 if (typeof process === "undefined" || true) {
8918 registerStyle("0c5702ddca", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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)}}}');
8919 }
8920 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" };
8921 if (typeof process === "undefined" || true) {
8922 registerStyle("d5c1b736fd", "._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,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);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,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);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 transparent)}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 transparent);transition:var(--_gcd-a-transition,none)}");
8923 }
8924 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" };
8925 var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
8926 const element = useRender({
8927 render: render4,
8928 defaultTagName: "span",
8929 ref,
8930 props: mergeProps(props, {
8931 className: clsx_default(
8932 style_default.text,
8933 global_css_defense_default.heading,
8934 global_css_defense_default.p,
8935 style_default[variant],
8936 className
8937 )
8938 })
8939 });
8940 return element;
8941 });
8942
8943 // packages/ui/build-module/icon/icon.mjs
8944 var import_element11 = __toESM(require_element(), 1);
8945 var import_primitives = __toESM(require_primitives(), 1);
8946 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
8947 var Icon = (0, import_element11.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
8948 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
8949 import_primitives.SVG,
8950 {
8951 ref,
8952 fill: "currentColor",
8953 ...icon.props,
8954 ...restProps,
8955 width: size4,
8956 height: size4
8957 }
8958 );
8959 });
8960
8961 // packages/icons/build-module/library/arrow-down.mjs
8962 var import_primitives2 = __toESM(require_primitives(), 1);
8963 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
8964 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" }) });
8965
8966 // packages/icons/build-module/library/arrow-left.mjs
8967 var import_primitives3 = __toESM(require_primitives(), 1);
8968 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
8969 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" }) });
8970
8971 // packages/icons/build-module/library/arrow-right.mjs
8972 var import_primitives4 = __toESM(require_primitives(), 1);
8973 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
8974 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" }) });
8975
8976 // packages/icons/build-module/library/arrow-up.mjs
8977 var import_primitives5 = __toESM(require_primitives(), 1);
8978 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
8979 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" }) });
8980
8981 // packages/icons/build-module/library/block-table.mjs
8982 var import_primitives6 = __toESM(require_primitives(), 1);
8983 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
8984 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" }) });
8985
8986 // packages/icons/build-module/library/category.mjs
8987 var import_primitives7 = __toESM(require_primitives(), 1);
8988 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
8989 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" }) });
8990
8991 // packages/icons/build-module/library/check.mjs
8992 var import_primitives8 = __toESM(require_primitives(), 1);
8993 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
8994 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" }) });
8995
8996 // packages/icons/build-module/library/close-small.mjs
8997 var import_primitives9 = __toESM(require_primitives(), 1);
8998 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
8999 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" }) });
9000
9001 // packages/icons/build-module/library/cog.mjs
9002 var import_primitives10 = __toESM(require_primitives(), 1);
9003 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9004 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" }) });
9005
9006 // packages/icons/build-module/library/envelope.mjs
9007 var import_primitives11 = __toESM(require_primitives(), 1);
9008 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9009 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" }) });
9010
9011 // packages/icons/build-module/library/error.mjs
9012 var import_primitives12 = __toESM(require_primitives(), 1);
9013 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9014 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" }) });
9015
9016 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9017 var import_primitives13 = __toESM(require_primitives(), 1);
9018 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9019 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" }) });
9020
9021 // packages/icons/build-module/library/format-list-bullets.mjs
9022 var import_primitives14 = __toESM(require_primitives(), 1);
9023 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9024 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" }) });
9025
9026 // packages/icons/build-module/library/funnel.mjs
9027 var import_primitives15 = __toESM(require_primitives(), 1);
9028 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9029 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" }) });
9030
9031 // packages/icons/build-module/library/globe.mjs
9032 var import_primitives16 = __toESM(require_primitives(), 1);
9033 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9034 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" }) });
9035
9036 // packages/icons/build-module/library/link.mjs
9037 var import_primitives17 = __toESM(require_primitives(), 1);
9038 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9039 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" }) });
9040
9041 // packages/icons/build-module/library/mobile.mjs
9042 var import_primitives18 = __toESM(require_primitives(), 1);
9043 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9044 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" }) });
9045
9046 // packages/icons/build-module/library/more-vertical.mjs
9047 var import_primitives19 = __toESM(require_primitives(), 1);
9048 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9049 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" }) });
9050
9051 // packages/icons/build-module/library/next.mjs
9052 var import_primitives20 = __toESM(require_primitives(), 1);
9053 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9054 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" }) });
9055
9056 // packages/icons/build-module/library/post-list.mjs
9057 var import_primitives21 = __toESM(require_primitives(), 1);
9058 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9059 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" }) });
9060
9061 // packages/icons/build-module/library/previous.mjs
9062 var import_primitives22 = __toESM(require_primitives(), 1);
9063 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9064 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" }) });
9065
9066 // packages/icons/build-module/library/scheduled.mjs
9067 var import_primitives23 = __toESM(require_primitives(), 1);
9068 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9069 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" }) });
9070
9071 // packages/icons/build-module/library/search.mjs
9072 var import_primitives24 = __toESM(require_primitives(), 1);
9073 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9074 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" }) });
9075
9076 // packages/icons/build-module/library/seen.mjs
9077 var import_primitives25 = __toESM(require_primitives(), 1);
9078 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9079 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" }) });
9080
9081 // packages/icons/build-module/library/unseen.mjs
9082 var import_primitives26 = __toESM(require_primitives(), 1);
9083 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9084 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" }) });
9085
9086 // packages/icons/build-module/library/wordpress.mjs
9087 var import_primitives27 = __toESM(require_primitives(), 1);
9088 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9089 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" }) });
9090
9091 // packages/ui/build-module/utils/render-slot-with-children.mjs
9092 var import_element12 = __toESM(require_element(), 1);
9093 function renderSlotWithChildren(slot, defaultSlot, children) {
9094 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
9095 }
9096
9097 // packages/ui/build-module/lock-unlock.mjs
9098 var import_private_apis = __toESM(require_private_apis(), 1);
9099 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9100 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9101 "@wordpress/ui"
9102 );
9103
9104 // packages/ui/build-module/stack/stack.mjs
9105 var import_element13 = __toESM(require_element(), 1);
9106 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9107 function getRuntime2() {
9108 const globalScope = globalThis;
9109 if (globalScope.__wpStyleRuntime) {
9110 return globalScope.__wpStyleRuntime;
9111 }
9112 globalScope.__wpStyleRuntime = {
9113 documents: /* @__PURE__ */ new Map(),
9114 styles: /* @__PURE__ */ new Map(),
9115 injectedStyles: /* @__PURE__ */ new WeakMap()
9116 };
9117 if (typeof document !== "undefined") {
9118 registerDocument2(document);
9119 }
9120 return globalScope.__wpStyleRuntime;
9121 }
9122 function documentContainsStyleHash2(targetDocument, hash) {
9123 if (!targetDocument.head) {
9124 return false;
9125 }
9126 for (const style of targetDocument.head.querySelectorAll(
9127 `style[${STYLE_HASH_ATTRIBUTE2}]`
9128 )) {
9129 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9130 return true;
9131 }
9132 }
9133 return false;
9134 }
9135 function injectStyle2(targetDocument, hash, css) {
9136 if (!targetDocument.head) {
9137 return;
9138 }
9139 const runtime = getRuntime2();
9140 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9141 if (!injectedStyles) {
9142 injectedStyles = /* @__PURE__ */ new Set();
9143 runtime.injectedStyles.set(targetDocument, injectedStyles);
9144 }
9145 if (injectedStyles.has(hash)) {
9146 return;
9147 }
9148 if (documentContainsStyleHash2(targetDocument, hash)) {
9149 injectedStyles.add(hash);
9150 return;
9151 }
9152 const style = targetDocument.createElement("style");
9153 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9154 style.appendChild(targetDocument.createTextNode(css));
9155 targetDocument.head.appendChild(style);
9156 injectedStyles.add(hash);
9157 }
9158 function registerDocument2(targetDocument) {
9159 const runtime = getRuntime2();
9160 runtime.documents.set(
9161 targetDocument,
9162 (runtime.documents.get(targetDocument) ?? 0) + 1
9163 );
9164 for (const [hash, css] of runtime.styles) {
9165 injectStyle2(targetDocument, hash, css);
9166 }
9167 return () => {
9168 const count = runtime.documents.get(targetDocument);
9169 if (count === void 0) {
9170 return;
9171 }
9172 if (count <= 1) {
9173 runtime.documents.delete(targetDocument);
9174 return;
9175 }
9176 runtime.documents.set(targetDocument, count - 1);
9177 };
9178 }
9179 function registerStyle2(hash, css) {
9180 const runtime = getRuntime2();
9181 runtime.styles.set(hash, css);
9182 for (const targetDocument of runtime.documents.keys()) {
9183 injectStyle2(targetDocument, hash, css);
9184 }
9185 }
9186 if (typeof process === "undefined" || true) {
9187 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9188 }
9189 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9190 var gapTokens = {
9191 xs: "var(--wpds-dimension-gap-xs, 4px)",
9192 sm: "var(--wpds-dimension-gap-sm, 8px)",
9193 md: "var(--wpds-dimension-gap-md, 12px)",
9194 lg: "var(--wpds-dimension-gap-lg, 16px)",
9195 xl: "var(--wpds-dimension-gap-xl, 24px)",
9196 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9197 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9198 };
9199 var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9200 const style = {
9201 gap: gap && gapTokens[gap],
9202 alignItems: align,
9203 justifyContent: justify,
9204 flexDirection: direction,
9205 flexWrap: wrap
9206 };
9207 const element = useRender({
9208 render: render4,
9209 ref,
9210 props: mergeProps(props, { style, className: style_default2.stack })
9211 });
9212 return element;
9213 });
9214
9215 // packages/ui/build-module/tooltip/index.mjs
9216 var tooltip_exports = {};
9217 __export(tooltip_exports, {
9218 Popup: () => Popup,
9219 Portal: () => Portal,
9220 Positioner: () => Positioner,
9221 Provider: () => Provider,
9222 Root: () => Root,
9223 Trigger: () => Trigger
9224 });
9225
9226 // packages/ui/build-module/tooltip/popup.mjs
9227 var import_element16 = __toESM(require_element(), 1);
9228 var import_theme = __toESM(require_theme(), 1);
9229
9230 // packages/ui/build-module/tooltip/portal.mjs
9231 var import_element14 = __toESM(require_element(), 1);
9232
9233 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9234 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9235 function getRuntime3() {
9236 const globalScope = globalThis;
9237 if (globalScope.__wpStyleRuntime) {
9238 return globalScope.__wpStyleRuntime;
9239 }
9240 globalScope.__wpStyleRuntime = {
9241 documents: /* @__PURE__ */ new Map(),
9242 styles: /* @__PURE__ */ new Map(),
9243 injectedStyles: /* @__PURE__ */ new WeakMap()
9244 };
9245 if (typeof document !== "undefined") {
9246 registerDocument3(document);
9247 }
9248 return globalScope.__wpStyleRuntime;
9249 }
9250 function documentContainsStyleHash3(targetDocument, hash) {
9251 if (!targetDocument.head) {
9252 return false;
9253 }
9254 for (const style of targetDocument.head.querySelectorAll(
9255 `style[${STYLE_HASH_ATTRIBUTE3}]`
9256 )) {
9257 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9258 return true;
9259 }
9260 }
9261 return false;
9262 }
9263 function injectStyle3(targetDocument, hash, css) {
9264 if (!targetDocument.head) {
9265 return;
9266 }
9267 const runtime = getRuntime3();
9268 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9269 if (!injectedStyles) {
9270 injectedStyles = /* @__PURE__ */ new Set();
9271 runtime.injectedStyles.set(targetDocument, injectedStyles);
9272 }
9273 if (injectedStyles.has(hash)) {
9274 return;
9275 }
9276 if (documentContainsStyleHash3(targetDocument, hash)) {
9277 injectedStyles.add(hash);
9278 return;
9279 }
9280 const style = targetDocument.createElement("style");
9281 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9282 style.appendChild(targetDocument.createTextNode(css));
9283 targetDocument.head.appendChild(style);
9284 injectedStyles.add(hash);
9285 }
9286 function registerDocument3(targetDocument) {
9287 const runtime = getRuntime3();
9288 runtime.documents.set(
9289 targetDocument,
9290 (runtime.documents.get(targetDocument) ?? 0) + 1
9291 );
9292 for (const [hash, css] of runtime.styles) {
9293 injectStyle3(targetDocument, hash, css);
9294 }
9295 return () => {
9296 const count = runtime.documents.get(targetDocument);
9297 if (count === void 0) {
9298 return;
9299 }
9300 if (count <= 1) {
9301 runtime.documents.delete(targetDocument);
9302 return;
9303 }
9304 runtime.documents.set(targetDocument, count - 1);
9305 };
9306 }
9307 function registerStyle3(hash, css) {
9308 const runtime = getRuntime3();
9309 runtime.styles.set(hash, css);
9310 for (const targetDocument of runtime.documents.keys()) {
9311 injectStyle3(targetDocument, hash, css);
9312 }
9313 }
9314 if (typeof process === "undefined" || true) {
9315 registerStyle3("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
9316 }
9317 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9318 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9319 function resolveOwnerDocument() {
9320 return typeof document === "undefined" ? null : document;
9321 }
9322 function isInWordPressEnvironment() {
9323 let topWp;
9324 try {
9325 topWp = window.top?.wp;
9326 } catch {
9327 }
9328 const wp = topWp ?? window.wp;
9329 return typeof wp?.components === "object" && wp.components !== null;
9330 }
9331 var cachedSlot = null;
9332 function createSlot(ownerDocument2) {
9333 const element = ownerDocument2.createElement("div");
9334 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9335 if (wp_compat_overlay_slot_default.slot) {
9336 element.classList.add(wp_compat_overlay_slot_default.slot);
9337 }
9338 ownerDocument2.body.appendChild(element);
9339 return element;
9340 }
9341 function getWpCompatOverlaySlot() {
9342 if (typeof window === "undefined") {
9343 return void 0;
9344 }
9345 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9346 return void 0;
9347 }
9348 const ownerDocument2 = resolveOwnerDocument();
9349 if (!ownerDocument2 || !ownerDocument2.body) {
9350 return void 0;
9351 }
9352 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9353 return cachedSlot;
9354 }
9355 const existing = ownerDocument2.querySelector(
9356 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9357 );
9358 if (existing instanceof HTMLDivElement) {
9359 cachedSlot = existing;
9360 return existing;
9361 }
9362 if (cachedSlot?.isConnected) {
9363 cachedSlot.remove();
9364 }
9365 cachedSlot = createSlot(ownerDocument2);
9366 return cachedSlot;
9367 }
9368
9369 // packages/ui/build-module/tooltip/portal.mjs
9370 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9371 var Portal = (0, import_element14.forwardRef)(
9372 function TooltipPortal3({ container, ...restProps }, ref) {
9373 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9374 index_parts_exports.Portal,
9375 {
9376 container: container ?? getWpCompatOverlaySlot(),
9377 ...restProps,
9378 ref
9379 }
9380 );
9381 }
9382 );
9383
9384 // packages/ui/build-module/tooltip/positioner.mjs
9385 var import_element15 = __toESM(require_element(), 1);
9386 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9387 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9388 function getRuntime4() {
9389 const globalScope = globalThis;
9390 if (globalScope.__wpStyleRuntime) {
9391 return globalScope.__wpStyleRuntime;
9392 }
9393 globalScope.__wpStyleRuntime = {
9394 documents: /* @__PURE__ */ new Map(),
9395 styles: /* @__PURE__ */ new Map(),
9396 injectedStyles: /* @__PURE__ */ new WeakMap()
9397 };
9398 if (typeof document !== "undefined") {
9399 registerDocument4(document);
9400 }
9401 return globalScope.__wpStyleRuntime;
9402 }
9403 function documentContainsStyleHash4(targetDocument, hash) {
9404 if (!targetDocument.head) {
9405 return false;
9406 }
9407 for (const style of targetDocument.head.querySelectorAll(
9408 `style[${STYLE_HASH_ATTRIBUTE4}]`
9409 )) {
9410 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9411 return true;
9412 }
9413 }
9414 return false;
9415 }
9416 function injectStyle4(targetDocument, hash, css) {
9417 if (!targetDocument.head) {
9418 return;
9419 }
9420 const runtime = getRuntime4();
9421 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9422 if (!injectedStyles) {
9423 injectedStyles = /* @__PURE__ */ new Set();
9424 runtime.injectedStyles.set(targetDocument, injectedStyles);
9425 }
9426 if (injectedStyles.has(hash)) {
9427 return;
9428 }
9429 if (documentContainsStyleHash4(targetDocument, hash)) {
9430 injectedStyles.add(hash);
9431 return;
9432 }
9433 const style = targetDocument.createElement("style");
9434 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9435 style.appendChild(targetDocument.createTextNode(css));
9436 targetDocument.head.appendChild(style);
9437 injectedStyles.add(hash);
9438 }
9439 function registerDocument4(targetDocument) {
9440 const runtime = getRuntime4();
9441 runtime.documents.set(
9442 targetDocument,
9443 (runtime.documents.get(targetDocument) ?? 0) + 1
9444 );
9445 for (const [hash, css] of runtime.styles) {
9446 injectStyle4(targetDocument, hash, css);
9447 }
9448 return () => {
9449 const count = runtime.documents.get(targetDocument);
9450 if (count === void 0) {
9451 return;
9452 }
9453 if (count <= 1) {
9454 runtime.documents.delete(targetDocument);
9455 return;
9456 }
9457 runtime.documents.set(targetDocument, count - 1);
9458 };
9459 }
9460 function registerStyle4(hash, css) {
9461 const runtime = getRuntime4();
9462 runtime.styles.set(hash, css);
9463 for (const targetDocument of runtime.documents.keys()) {
9464 injectStyle4(targetDocument, hash, css);
9465 }
9466 }
9467 if (typeof process === "undefined" || true) {
9468 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9469 }
9470 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9471 if (typeof process === "undefined" || true) {
9472 registerStyle4("4811d023d1", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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-md,4px);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}}}}');
9473 }
9474 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9475 var Positioner = (0, import_element15.forwardRef)(
9476 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9477 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9478 index_parts_exports.Positioner,
9479 {
9480 ref,
9481 align,
9482 side,
9483 sideOffset,
9484 ...props,
9485 className: clsx_default(
9486 resets_default["box-sizing"],
9487 style_default3.positioner,
9488 className
9489 )
9490 }
9491 );
9492 }
9493 );
9494
9495 // packages/ui/build-module/tooltip/popup.mjs
9496 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9497 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9498 function getRuntime5() {
9499 const globalScope = globalThis;
9500 if (globalScope.__wpStyleRuntime) {
9501 return globalScope.__wpStyleRuntime;
9502 }
9503 globalScope.__wpStyleRuntime = {
9504 documents: /* @__PURE__ */ new Map(),
9505 styles: /* @__PURE__ */ new Map(),
9506 injectedStyles: /* @__PURE__ */ new WeakMap()
9507 };
9508 if (typeof document !== "undefined") {
9509 registerDocument5(document);
9510 }
9511 return globalScope.__wpStyleRuntime;
9512 }
9513 function documentContainsStyleHash5(targetDocument, hash) {
9514 if (!targetDocument.head) {
9515 return false;
9516 }
9517 for (const style of targetDocument.head.querySelectorAll(
9518 `style[${STYLE_HASH_ATTRIBUTE5}]`
9519 )) {
9520 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9521 return true;
9522 }
9523 }
9524 return false;
9525 }
9526 function injectStyle5(targetDocument, hash, css) {
9527 if (!targetDocument.head) {
9528 return;
9529 }
9530 const runtime = getRuntime5();
9531 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9532 if (!injectedStyles) {
9533 injectedStyles = /* @__PURE__ */ new Set();
9534 runtime.injectedStyles.set(targetDocument, injectedStyles);
9535 }
9536 if (injectedStyles.has(hash)) {
9537 return;
9538 }
9539 if (documentContainsStyleHash5(targetDocument, hash)) {
9540 injectedStyles.add(hash);
9541 return;
9542 }
9543 const style = targetDocument.createElement("style");
9544 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9545 style.appendChild(targetDocument.createTextNode(css));
9546 targetDocument.head.appendChild(style);
9547 injectedStyles.add(hash);
9548 }
9549 function registerDocument5(targetDocument) {
9550 const runtime = getRuntime5();
9551 runtime.documents.set(
9552 targetDocument,
9553 (runtime.documents.get(targetDocument) ?? 0) + 1
9554 );
9555 for (const [hash, css] of runtime.styles) {
9556 injectStyle5(targetDocument, hash, css);
9557 }
9558 return () => {
9559 const count = runtime.documents.get(targetDocument);
9560 if (count === void 0) {
9561 return;
9562 }
9563 if (count <= 1) {
9564 runtime.documents.delete(targetDocument);
9565 return;
9566 }
9567 runtime.documents.set(targetDocument, count - 1);
9568 };
9569 }
9570 function registerStyle5(hash, css) {
9571 const runtime = getRuntime5();
9572 runtime.styles.set(hash, css);
9573 for (const targetDocument of runtime.documents.keys()) {
9574 injectStyle5(targetDocument, hash, css);
9575 }
9576 }
9577 if (typeof process === "undefined" || true) {
9578 registerStyle5("4811d023d1", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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-md,4px);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}}}}');
9579 }
9580 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9581 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
9582 var POPUP_COLOR = { background: "#1e1e1e" };
9583 var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9584 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
9585 index_parts_exports.Popup,
9586 {
9587 ref,
9588 className: clsx_default(style_default4.popup, className),
9589 ...props,
9590 children
9591 }
9592 ) });
9593 const positionedPopup = renderSlotWithChildren(
9594 positioner,
9595 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Positioner, {}),
9596 popupContent
9597 );
9598 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Portal, {}), positionedPopup);
9599 });
9600
9601 // packages/ui/build-module/tooltip/trigger.mjs
9602 var import_element17 = __toESM(require_element(), 1);
9603 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9604 var Trigger = (0, import_element17.forwardRef)(
9605 function TooltipTrigger3(props, ref) {
9606 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Trigger, { ref, ...props });
9607 }
9608 );
9609
9610 // packages/ui/build-module/tooltip/root.mjs
9611 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9612 function Root(props) {
9613 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Root, { ...props });
9614 }
9615
9616 // packages/ui/build-module/tooltip/provider.mjs
9617 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9618 function Provider({ ...props }) {
9619 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(index_parts_exports.Provider, { ...props });
9620 }
9621
9622 // packages/ui/build-module/empty-state/index.mjs
9623 var empty_state_exports = {};
9624 __export(empty_state_exports, {
9625 Actions: () => Actions,
9626 Description: () => Description,
9627 Icon: () => Icon3,
9628 Root: () => Root2,
9629 Title: () => Title,
9630 Visual: () => Visual
9631 });
9632
9633 // packages/ui/build-module/empty-state/root.mjs
9634 var import_element18 = __toESM(require_element(), 1);
9635 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9636 function getRuntime6() {
9637 const globalScope = globalThis;
9638 if (globalScope.__wpStyleRuntime) {
9639 return globalScope.__wpStyleRuntime;
9640 }
9641 globalScope.__wpStyleRuntime = {
9642 documents: /* @__PURE__ */ new Map(),
9643 styles: /* @__PURE__ */ new Map(),
9644 injectedStyles: /* @__PURE__ */ new WeakMap()
9645 };
9646 if (typeof document !== "undefined") {
9647 registerDocument6(document);
9648 }
9649 return globalScope.__wpStyleRuntime;
9650 }
9651 function documentContainsStyleHash6(targetDocument, hash) {
9652 if (!targetDocument.head) {
9653 return false;
9654 }
9655 for (const style of targetDocument.head.querySelectorAll(
9656 `style[${STYLE_HASH_ATTRIBUTE6}]`
9657 )) {
9658 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9659 return true;
9660 }
9661 }
9662 return false;
9663 }
9664 function injectStyle6(targetDocument, hash, css) {
9665 if (!targetDocument.head) {
9666 return;
9667 }
9668 const runtime = getRuntime6();
9669 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9670 if (!injectedStyles) {
9671 injectedStyles = /* @__PURE__ */ new Set();
9672 runtime.injectedStyles.set(targetDocument, injectedStyles);
9673 }
9674 if (injectedStyles.has(hash)) {
9675 return;
9676 }
9677 if (documentContainsStyleHash6(targetDocument, hash)) {
9678 injectedStyles.add(hash);
9679 return;
9680 }
9681 const style = targetDocument.createElement("style");
9682 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9683 style.appendChild(targetDocument.createTextNode(css));
9684 targetDocument.head.appendChild(style);
9685 injectedStyles.add(hash);
9686 }
9687 function registerDocument6(targetDocument) {
9688 const runtime = getRuntime6();
9689 runtime.documents.set(
9690 targetDocument,
9691 (runtime.documents.get(targetDocument) ?? 0) + 1
9692 );
9693 for (const [hash, css] of runtime.styles) {
9694 injectStyle6(targetDocument, hash, css);
9695 }
9696 return () => {
9697 const count = runtime.documents.get(targetDocument);
9698 if (count === void 0) {
9699 return;
9700 }
9701 if (count <= 1) {
9702 runtime.documents.delete(targetDocument);
9703 return;
9704 }
9705 runtime.documents.set(targetDocument, count - 1);
9706 };
9707 }
9708 function registerStyle6(hash, css) {
9709 const runtime = getRuntime6();
9710 runtime.styles.set(hash, css);
9711 for (const targetDocument of runtime.documents.keys()) {
9712 injectStyle6(targetDocument, hash, css);
9713 }
9714 }
9715 if (typeof process === "undefined" || true) {
9716 registerStyle6("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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,#f0f0f0);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}}}}');
9717 }
9718 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9719 var Root2 = (0, import_element18.forwardRef)(
9720 function EmptyStateRoot({ render: render4, ...props }, ref) {
9721 const className = clsx_default(style_default5.root);
9722 const element = useRender({
9723 defaultTagName: "div",
9724 render: render4,
9725 ref,
9726 props: mergeProps({ className }, props)
9727 });
9728 return element;
9729 }
9730 );
9731
9732 // packages/ui/build-module/empty-state/visual.mjs
9733 var import_element19 = __toESM(require_element(), 1);
9734 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9735 function getRuntime7() {
9736 const globalScope = globalThis;
9737 if (globalScope.__wpStyleRuntime) {
9738 return globalScope.__wpStyleRuntime;
9739 }
9740 globalScope.__wpStyleRuntime = {
9741 documents: /* @__PURE__ */ new Map(),
9742 styles: /* @__PURE__ */ new Map(),
9743 injectedStyles: /* @__PURE__ */ new WeakMap()
9744 };
9745 if (typeof document !== "undefined") {
9746 registerDocument7(document);
9747 }
9748 return globalScope.__wpStyleRuntime;
9749 }
9750 function documentContainsStyleHash7(targetDocument, hash) {
9751 if (!targetDocument.head) {
9752 return false;
9753 }
9754 for (const style of targetDocument.head.querySelectorAll(
9755 `style[${STYLE_HASH_ATTRIBUTE7}]`
9756 )) {
9757 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9758 return true;
9759 }
9760 }
9761 return false;
9762 }
9763 function injectStyle7(targetDocument, hash, css) {
9764 if (!targetDocument.head) {
9765 return;
9766 }
9767 const runtime = getRuntime7();
9768 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9769 if (!injectedStyles) {
9770 injectedStyles = /* @__PURE__ */ new Set();
9771 runtime.injectedStyles.set(targetDocument, injectedStyles);
9772 }
9773 if (injectedStyles.has(hash)) {
9774 return;
9775 }
9776 if (documentContainsStyleHash7(targetDocument, hash)) {
9777 injectedStyles.add(hash);
9778 return;
9779 }
9780 const style = targetDocument.createElement("style");
9781 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9782 style.appendChild(targetDocument.createTextNode(css));
9783 targetDocument.head.appendChild(style);
9784 injectedStyles.add(hash);
9785 }
9786 function registerDocument7(targetDocument) {
9787 const runtime = getRuntime7();
9788 runtime.documents.set(
9789 targetDocument,
9790 (runtime.documents.get(targetDocument) ?? 0) + 1
9791 );
9792 for (const [hash, css] of runtime.styles) {
9793 injectStyle7(targetDocument, hash, css);
9794 }
9795 return () => {
9796 const count = runtime.documents.get(targetDocument);
9797 if (count === void 0) {
9798 return;
9799 }
9800 if (count <= 1) {
9801 runtime.documents.delete(targetDocument);
9802 return;
9803 }
9804 runtime.documents.set(targetDocument, count - 1);
9805 };
9806 }
9807 function registerStyle7(hash, css) {
9808 const runtime = getRuntime7();
9809 runtime.styles.set(hash, css);
9810 for (const targetDocument of runtime.documents.keys()) {
9811 injectStyle7(targetDocument, hash, css);
9812 }
9813 }
9814 if (typeof process === "undefined" || true) {
9815 registerStyle7("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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,#f0f0f0);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}}}}');
9816 }
9817 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9818 var Visual = (0, import_element19.forwardRef)(
9819 function EmptyStateVisual({ render: render4, ...props }, ref) {
9820 const className = clsx_default(style_default6.visual);
9821 const element = useRender({
9822 defaultTagName: "div",
9823 render: render4,
9824 ref,
9825 props: mergeProps({ className }, props)
9826 });
9827 return element;
9828 }
9829 );
9830
9831 // packages/ui/build-module/empty-state/icon.mjs
9832 var import_element20 = __toESM(require_element(), 1);
9833 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9834 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9835 function getRuntime8() {
9836 const globalScope = globalThis;
9837 if (globalScope.__wpStyleRuntime) {
9838 return globalScope.__wpStyleRuntime;
9839 }
9840 globalScope.__wpStyleRuntime = {
9841 documents: /* @__PURE__ */ new Map(),
9842 styles: /* @__PURE__ */ new Map(),
9843 injectedStyles: /* @__PURE__ */ new WeakMap()
9844 };
9845 if (typeof document !== "undefined") {
9846 registerDocument8(document);
9847 }
9848 return globalScope.__wpStyleRuntime;
9849 }
9850 function documentContainsStyleHash8(targetDocument, hash) {
9851 if (!targetDocument.head) {
9852 return false;
9853 }
9854 for (const style of targetDocument.head.querySelectorAll(
9855 `style[${STYLE_HASH_ATTRIBUTE8}]`
9856 )) {
9857 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9858 return true;
9859 }
9860 }
9861 return false;
9862 }
9863 function injectStyle8(targetDocument, hash, css) {
9864 if (!targetDocument.head) {
9865 return;
9866 }
9867 const runtime = getRuntime8();
9868 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9869 if (!injectedStyles) {
9870 injectedStyles = /* @__PURE__ */ new Set();
9871 runtime.injectedStyles.set(targetDocument, injectedStyles);
9872 }
9873 if (injectedStyles.has(hash)) {
9874 return;
9875 }
9876 if (documentContainsStyleHash8(targetDocument, hash)) {
9877 injectedStyles.add(hash);
9878 return;
9879 }
9880 const style = targetDocument.createElement("style");
9881 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9882 style.appendChild(targetDocument.createTextNode(css));
9883 targetDocument.head.appendChild(style);
9884 injectedStyles.add(hash);
9885 }
9886 function registerDocument8(targetDocument) {
9887 const runtime = getRuntime8();
9888 runtime.documents.set(
9889 targetDocument,
9890 (runtime.documents.get(targetDocument) ?? 0) + 1
9891 );
9892 for (const [hash, css] of runtime.styles) {
9893 injectStyle8(targetDocument, hash, css);
9894 }
9895 return () => {
9896 const count = runtime.documents.get(targetDocument);
9897 if (count === void 0) {
9898 return;
9899 }
9900 if (count <= 1) {
9901 runtime.documents.delete(targetDocument);
9902 return;
9903 }
9904 runtime.documents.set(targetDocument, count - 1);
9905 };
9906 }
9907 function registerStyle8(hash, css) {
9908 const runtime = getRuntime8();
9909 runtime.styles.set(hash, css);
9910 for (const targetDocument of runtime.documents.keys()) {
9911 injectStyle8(targetDocument, hash, css);
9912 }
9913 }
9914 if (typeof process === "undefined" || true) {
9915 registerStyle8("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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,#f0f0f0);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}}}}');
9916 }
9917 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9918 var Icon3 = (0, import_element20.forwardRef)(
9919 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9920 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
9921 Visual,
9922 {
9923 ref,
9924 className: clsx_default(style_default7.icon, className),
9925 ...restProps,
9926 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Icon, { icon })
9927 }
9928 );
9929 }
9930 );
9931
9932 // packages/ui/build-module/empty-state/title.mjs
9933 var import_element21 = __toESM(require_element(), 1);
9934 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
9935 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9936 function getRuntime9() {
9937 const globalScope = globalThis;
9938 if (globalScope.__wpStyleRuntime) {
9939 return globalScope.__wpStyleRuntime;
9940 }
9941 globalScope.__wpStyleRuntime = {
9942 documents: /* @__PURE__ */ new Map(),
9943 styles: /* @__PURE__ */ new Map(),
9944 injectedStyles: /* @__PURE__ */ new WeakMap()
9945 };
9946 if (typeof document !== "undefined") {
9947 registerDocument9(document);
9948 }
9949 return globalScope.__wpStyleRuntime;
9950 }
9951 function documentContainsStyleHash9(targetDocument, hash) {
9952 if (!targetDocument.head) {
9953 return false;
9954 }
9955 for (const style of targetDocument.head.querySelectorAll(
9956 `style[${STYLE_HASH_ATTRIBUTE9}]`
9957 )) {
9958 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
9959 return true;
9960 }
9961 }
9962 return false;
9963 }
9964 function injectStyle9(targetDocument, hash, css) {
9965 if (!targetDocument.head) {
9966 return;
9967 }
9968 const runtime = getRuntime9();
9969 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9970 if (!injectedStyles) {
9971 injectedStyles = /* @__PURE__ */ new Set();
9972 runtime.injectedStyles.set(targetDocument, injectedStyles);
9973 }
9974 if (injectedStyles.has(hash)) {
9975 return;
9976 }
9977 if (documentContainsStyleHash9(targetDocument, hash)) {
9978 injectedStyles.add(hash);
9979 return;
9980 }
9981 const style = targetDocument.createElement("style");
9982 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
9983 style.appendChild(targetDocument.createTextNode(css));
9984 targetDocument.head.appendChild(style);
9985 injectedStyles.add(hash);
9986 }
9987 function registerDocument9(targetDocument) {
9988 const runtime = getRuntime9();
9989 runtime.documents.set(
9990 targetDocument,
9991 (runtime.documents.get(targetDocument) ?? 0) + 1
9992 );
9993 for (const [hash, css] of runtime.styles) {
9994 injectStyle9(targetDocument, hash, css);
9995 }
9996 return () => {
9997 const count = runtime.documents.get(targetDocument);
9998 if (count === void 0) {
9999 return;
10000 }
10001 if (count <= 1) {
10002 runtime.documents.delete(targetDocument);
10003 return;
10004 }
10005 runtime.documents.set(targetDocument, count - 1);
10006 };
10007 }
10008 function registerStyle9(hash, css) {
10009 const runtime = getRuntime9();
10010 runtime.styles.set(hash, css);
10011 for (const targetDocument of runtime.documents.keys()) {
10012 injectStyle9(targetDocument, hash, css);
10013 }
10014 }
10015 if (typeof process === "undefined" || true) {
10016 registerStyle9("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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,#f0f0f0);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}}}}');
10017 }
10018 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10019 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", {});
10020 var Title = (0, import_element21.forwardRef)(
10021 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
10022 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10023 Text,
10024 {
10025 ref,
10026 variant: "heading-lg",
10027 render: render4,
10028 className: clsx_default(style_default8.title, className),
10029 ...props,
10030 children
10031 }
10032 );
10033 }
10034 );
10035
10036 // packages/ui/build-module/empty-state/description.mjs
10037 var import_element22 = __toESM(require_element(), 1);
10038 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10039 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
10040 function getRuntime10() {
10041 const globalScope = globalThis;
10042 if (globalScope.__wpStyleRuntime) {
10043 return globalScope.__wpStyleRuntime;
10044 }
10045 globalScope.__wpStyleRuntime = {
10046 documents: /* @__PURE__ */ new Map(),
10047 styles: /* @__PURE__ */ new Map(),
10048 injectedStyles: /* @__PURE__ */ new WeakMap()
10049 };
10050 if (typeof document !== "undefined") {
10051 registerDocument10(document);
10052 }
10053 return globalScope.__wpStyleRuntime;
10054 }
10055 function documentContainsStyleHash10(targetDocument, hash) {
10056 if (!targetDocument.head) {
10057 return false;
10058 }
10059 for (const style of targetDocument.head.querySelectorAll(
10060 `style[${STYLE_HASH_ATTRIBUTE10}]`
10061 )) {
10062 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
10063 return true;
10064 }
10065 }
10066 return false;
10067 }
10068 function injectStyle10(targetDocument, hash, css) {
10069 if (!targetDocument.head) {
10070 return;
10071 }
10072 const runtime = getRuntime10();
10073 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10074 if (!injectedStyles) {
10075 injectedStyles = /* @__PURE__ */ new Set();
10076 runtime.injectedStyles.set(targetDocument, injectedStyles);
10077 }
10078 if (injectedStyles.has(hash)) {
10079 return;
10080 }
10081 if (documentContainsStyleHash10(targetDocument, hash)) {
10082 injectedStyles.add(hash);
10083 return;
10084 }
10085 const style = targetDocument.createElement("style");
10086 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
10087 style.appendChild(targetDocument.createTextNode(css));
10088 targetDocument.head.appendChild(style);
10089 injectedStyles.add(hash);
10090 }
10091 function registerDocument10(targetDocument) {
10092 const runtime = getRuntime10();
10093 runtime.documents.set(
10094 targetDocument,
10095 (runtime.documents.get(targetDocument) ?? 0) + 1
10096 );
10097 for (const [hash, css] of runtime.styles) {
10098 injectStyle10(targetDocument, hash, css);
10099 }
10100 return () => {
10101 const count = runtime.documents.get(targetDocument);
10102 if (count === void 0) {
10103 return;
10104 }
10105 if (count <= 1) {
10106 runtime.documents.delete(targetDocument);
10107 return;
10108 }
10109 runtime.documents.set(targetDocument, count - 1);
10110 };
10111 }
10112 function registerStyle10(hash, css) {
10113 const runtime = getRuntime10();
10114 runtime.styles.set(hash, css);
10115 for (const targetDocument of runtime.documents.keys()) {
10116 injectStyle10(targetDocument, hash, css);
10117 }
10118 }
10119 if (typeof process === "undefined" || true) {
10120 registerStyle10("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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,#f0f0f0);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}}}}');
10121 }
10122 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10123 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", {});
10124 var Description = (0, import_element22.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
10125 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10126 Text,
10127 {
10128 ref,
10129 variant: "body-md",
10130 render: render4,
10131 className: clsx_default(style_default9.description, className),
10132 ...props,
10133 children
10134 }
10135 );
10136 });
10137
10138 // packages/ui/build-module/empty-state/actions.mjs
10139 var import_element23 = __toESM(require_element(), 1);
10140 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
10141 function getRuntime11() {
10142 const globalScope = globalThis;
10143 if (globalScope.__wpStyleRuntime) {
10144 return globalScope.__wpStyleRuntime;
10145 }
10146 globalScope.__wpStyleRuntime = {
10147 documents: /* @__PURE__ */ new Map(),
10148 styles: /* @__PURE__ */ new Map(),
10149 injectedStyles: /* @__PURE__ */ new WeakMap()
10150 };
10151 if (typeof document !== "undefined") {
10152 registerDocument11(document);
10153 }
10154 return globalScope.__wpStyleRuntime;
10155 }
10156 function documentContainsStyleHash11(targetDocument, hash) {
10157 if (!targetDocument.head) {
10158 return false;
10159 }
10160 for (const style of targetDocument.head.querySelectorAll(
10161 `style[${STYLE_HASH_ATTRIBUTE11}]`
10162 )) {
10163 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10164 return true;
10165 }
10166 }
10167 return false;
10168 }
10169 function injectStyle11(targetDocument, hash, css) {
10170 if (!targetDocument.head) {
10171 return;
10172 }
10173 const runtime = getRuntime11();
10174 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10175 if (!injectedStyles) {
10176 injectedStyles = /* @__PURE__ */ new Set();
10177 runtime.injectedStyles.set(targetDocument, injectedStyles);
10178 }
10179 if (injectedStyles.has(hash)) {
10180 return;
10181 }
10182 if (documentContainsStyleHash11(targetDocument, hash)) {
10183 injectedStyles.add(hash);
10184 return;
10185 }
10186 const style = targetDocument.createElement("style");
10187 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10188 style.appendChild(targetDocument.createTextNode(css));
10189 targetDocument.head.appendChild(style);
10190 injectedStyles.add(hash);
10191 }
10192 function registerDocument11(targetDocument) {
10193 const runtime = getRuntime11();
10194 runtime.documents.set(
10195 targetDocument,
10196 (runtime.documents.get(targetDocument) ?? 0) + 1
10197 );
10198 for (const [hash, css] of runtime.styles) {
10199 injectStyle11(targetDocument, hash, css);
10200 }
10201 return () => {
10202 const count = runtime.documents.get(targetDocument);
10203 if (count === void 0) {
10204 return;
10205 }
10206 if (count <= 1) {
10207 runtime.documents.delete(targetDocument);
10208 return;
10209 }
10210 runtime.documents.set(targetDocument, count - 1);
10211 };
10212 }
10213 function registerStyle11(hash, css) {
10214 const runtime = getRuntime11();
10215 runtime.styles.set(hash, css);
10216 for (const targetDocument of runtime.documents.keys()) {
10217 injectStyle11(targetDocument, hash, css);
10218 }
10219 }
10220 if (typeof process === "undefined" || true) {
10221 registerStyle11("d331810ae3", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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,#f0f0f0);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}}}}');
10222 }
10223 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10224 var Actions = (0, import_element23.forwardRef)(
10225 function EmptyStateActions({ render: render4, ...props }, ref) {
10226 const className = clsx_default(style_default10.actions);
10227 const element = useRender({
10228 defaultTagName: "div",
10229 render: render4,
10230 ref,
10231 props: mergeProps({ className }, props)
10232 });
10233 return element;
10234 }
10235 );
10236
10237 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10238 var import_element24 = __toESM(require_element(), 1);
10239 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10240 function getRuntime12() {
10241 const globalScope = globalThis;
10242 if (globalScope.__wpStyleRuntime) {
10243 return globalScope.__wpStyleRuntime;
10244 }
10245 globalScope.__wpStyleRuntime = {
10246 documents: /* @__PURE__ */ new Map(),
10247 styles: /* @__PURE__ */ new Map(),
10248 injectedStyles: /* @__PURE__ */ new WeakMap()
10249 };
10250 if (typeof document !== "undefined") {
10251 registerDocument12(document);
10252 }
10253 return globalScope.__wpStyleRuntime;
10254 }
10255 function documentContainsStyleHash12(targetDocument, hash) {
10256 if (!targetDocument.head) {
10257 return false;
10258 }
10259 for (const style of targetDocument.head.querySelectorAll(
10260 `style[${STYLE_HASH_ATTRIBUTE12}]`
10261 )) {
10262 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10263 return true;
10264 }
10265 }
10266 return false;
10267 }
10268 function injectStyle12(targetDocument, hash, css) {
10269 if (!targetDocument.head) {
10270 return;
10271 }
10272 const runtime = getRuntime12();
10273 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10274 if (!injectedStyles) {
10275 injectedStyles = /* @__PURE__ */ new Set();
10276 runtime.injectedStyles.set(targetDocument, injectedStyles);
10277 }
10278 if (injectedStyles.has(hash)) {
10279 return;
10280 }
10281 if (documentContainsStyleHash12(targetDocument, hash)) {
10282 injectedStyles.add(hash);
10283 return;
10284 }
10285 const style = targetDocument.createElement("style");
10286 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10287 style.appendChild(targetDocument.createTextNode(css));
10288 targetDocument.head.appendChild(style);
10289 injectedStyles.add(hash);
10290 }
10291 function registerDocument12(targetDocument) {
10292 const runtime = getRuntime12();
10293 runtime.documents.set(
10294 targetDocument,
10295 (runtime.documents.get(targetDocument) ?? 0) + 1
10296 );
10297 for (const [hash, css] of runtime.styles) {
10298 injectStyle12(targetDocument, hash, css);
10299 }
10300 return () => {
10301 const count = runtime.documents.get(targetDocument);
10302 if (count === void 0) {
10303 return;
10304 }
10305 if (count <= 1) {
10306 runtime.documents.delete(targetDocument);
10307 return;
10308 }
10309 runtime.documents.set(targetDocument, count - 1);
10310 };
10311 }
10312 function registerStyle12(hash, css) {
10313 const runtime = getRuntime12();
10314 runtime.styles.set(hash, css);
10315 for (const targetDocument of runtime.documents.keys()) {
10316 injectStyle12(targetDocument, hash, css);
10317 }
10318 }
10319 if (typeof process === "undefined" || true) {
10320 registerStyle12("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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}}}");
10321 }
10322 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10323 var VisuallyHidden = (0, import_element24.forwardRef)(
10324 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10325 const element = useRender({
10326 render: render4,
10327 ref,
10328 props: mergeProps(
10329 { className: style_default11["visually-hidden"] },
10330 restProps,
10331 {
10332 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10333 "data-visually-hidden": ""
10334 }
10335 )
10336 });
10337 return element;
10338 }
10339 );
10340
10341 // packages/ui/build-module/link/link.mjs
10342 var import_element25 = __toESM(require_element(), 1);
10343 var import_i18n = __toESM(require_i18n(), 1);
10344 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10345 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10346 function getRuntime13() {
10347 const globalScope = globalThis;
10348 if (globalScope.__wpStyleRuntime) {
10349 return globalScope.__wpStyleRuntime;
10350 }
10351 globalScope.__wpStyleRuntime = {
10352 documents: /* @__PURE__ */ new Map(),
10353 styles: /* @__PURE__ */ new Map(),
10354 injectedStyles: /* @__PURE__ */ new WeakMap()
10355 };
10356 if (typeof document !== "undefined") {
10357 registerDocument13(document);
10358 }
10359 return globalScope.__wpStyleRuntime;
10360 }
10361 function documentContainsStyleHash13(targetDocument, hash) {
10362 if (!targetDocument.head) {
10363 return false;
10364 }
10365 for (const style of targetDocument.head.querySelectorAll(
10366 `style[${STYLE_HASH_ATTRIBUTE13}]`
10367 )) {
10368 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10369 return true;
10370 }
10371 }
10372 return false;
10373 }
10374 function injectStyle13(targetDocument, hash, css) {
10375 if (!targetDocument.head) {
10376 return;
10377 }
10378 const runtime = getRuntime13();
10379 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10380 if (!injectedStyles) {
10381 injectedStyles = /* @__PURE__ */ new Set();
10382 runtime.injectedStyles.set(targetDocument, injectedStyles);
10383 }
10384 if (injectedStyles.has(hash)) {
10385 return;
10386 }
10387 if (documentContainsStyleHash13(targetDocument, hash)) {
10388 injectedStyles.add(hash);
10389 return;
10390 }
10391 const style = targetDocument.createElement("style");
10392 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10393 style.appendChild(targetDocument.createTextNode(css));
10394 targetDocument.head.appendChild(style);
10395 injectedStyles.add(hash);
10396 }
10397 function registerDocument13(targetDocument) {
10398 const runtime = getRuntime13();
10399 runtime.documents.set(
10400 targetDocument,
10401 (runtime.documents.get(targetDocument) ?? 0) + 1
10402 );
10403 for (const [hash, css] of runtime.styles) {
10404 injectStyle13(targetDocument, hash, css);
10405 }
10406 return () => {
10407 const count = runtime.documents.get(targetDocument);
10408 if (count === void 0) {
10409 return;
10410 }
10411 if (count <= 1) {
10412 runtime.documents.delete(targetDocument);
10413 return;
10414 }
10415 runtime.documents.set(targetDocument, count - 1);
10416 };
10417 }
10418 function registerStyle13(hash, css) {
10419 const runtime = getRuntime13();
10420 runtime.styles.set(hash, css);
10421 for (const targetDocument of runtime.documents.keys()) {
10422 injectStyle13(targetDocument, hash, css);
10423 }
10424 }
10425 if (typeof process === "undefined" || true) {
10426 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10427 }
10428 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10429 if (typeof process === "undefined" || true) {
10430 registerStyle13("693cd16544", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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 transparent;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))}}}");
10431 }
10432 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" };
10433 if (typeof process === "undefined" || true) {
10434 registerStyle13("9f01019e30", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer 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"}}}');
10435 }
10436 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" };
10437 if (typeof process === "undefined" || true) {
10438 registerStyle13("d5c1b736fd", "._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,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);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,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);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 transparent)}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 transparent);transition:var(--_gcd-a-transition,none)}");
10439 }
10440 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" };
10441 var Link = (0, import_element25.forwardRef)(function Link2({
10442 children,
10443 variant = "default",
10444 tone = "brand",
10445 openInNewTab = false,
10446 render: render4,
10447 className,
10448 ...props
10449 }, ref) {
10450 const element = useRender({
10451 render: render4,
10452 defaultTagName: "a",
10453 ref,
10454 props: mergeProps(props, {
10455 className: clsx_default(
10456 global_css_defense_default2.a,
10457 resets_default2["box-sizing"],
10458 focus_default["outset-ring--focus"],
10459 variant !== "unstyled" && style_default12.link,
10460 variant !== "unstyled" && style_default12[`is-${tone}`],
10461 variant === "unstyled" && style_default12["is-unstyled"],
10462 className
10463 ),
10464 target: openInNewTab ? "_blank" : void 0,
10465 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
10466 children,
10467 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10468 "span",
10469 {
10470 className: style_default12["link-icon"],
10471 role: "img",
10472 "aria-label": (
10473 /* translators: accessibility text appended to link text */
10474 (0, import_i18n.__)("(opens in a new tab)")
10475 )
10476 }
10477 )
10478 ] })
10479 })
10480 });
10481 return element;
10482 });
10483
10484 // packages/dataviews/build-module/dataviews/index.mjs
10485 var import_element82 = __toESM(require_element(), 1);
10486 var import_compose13 = __toESM(require_compose(), 1);
10487
10488 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10489 var import_element26 = __toESM(require_element(), 1);
10490
10491 // packages/dataviews/build-module/constants.mjs
10492 var import_i18n2 = __toESM(require_i18n(), 1);
10493 var OPERATOR_IS_ANY = "isAny";
10494 var OPERATOR_IS_NONE = "isNone";
10495 var OPERATOR_IS_ALL = "isAll";
10496 var OPERATOR_IS_NOT_ALL = "isNotAll";
10497 var OPERATOR_BETWEEN = "between";
10498 var OPERATOR_IN_THE_PAST = "inThePast";
10499 var OPERATOR_OVER = "over";
10500 var OPERATOR_IS = "is";
10501 var OPERATOR_IS_NOT = "isNot";
10502 var OPERATOR_LESS_THAN = "lessThan";
10503 var OPERATOR_GREATER_THAN = "greaterThan";
10504 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10505 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10506 var OPERATOR_BEFORE = "before";
10507 var OPERATOR_AFTER = "after";
10508 var OPERATOR_BEFORE_INC = "beforeInc";
10509 var OPERATOR_AFTER_INC = "afterInc";
10510 var OPERATOR_CONTAINS = "contains";
10511 var OPERATOR_NOT_CONTAINS = "notContains";
10512 var OPERATOR_STARTS_WITH = "startsWith";
10513 var OPERATOR_ON = "on";
10514 var OPERATOR_NOT_ON = "notOn";
10515 var SORTING_DIRECTIONS = ["asc", "desc"];
10516 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10517 var sortValues = { asc: "ascending", desc: "descending" };
10518 var sortLabels = {
10519 asc: (0, import_i18n2.__)("Sort ascending"),
10520 desc: (0, import_i18n2.__)("Sort descending")
10521 };
10522 var sortIcons = {
10523 asc: arrow_up_default,
10524 desc: arrow_down_default
10525 };
10526 var LAYOUT_TABLE = "table";
10527 var LAYOUT_GRID = "grid";
10528 var LAYOUT_LIST = "list";
10529 var LAYOUT_ACTIVITY = "activity";
10530 var LAYOUT_PICKER_GRID = "pickerGrid";
10531 var LAYOUT_PICKER_TABLE = "pickerTable";
10532 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10533
10534 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10535 var DataViewsContext = (0, import_element26.createContext)({
10536 view: { type: LAYOUT_TABLE },
10537 onChangeView: () => {
10538 },
10539 fields: [],
10540 data: [],
10541 paginationInfo: {
10542 totalItems: 0,
10543 totalPages: 0
10544 },
10545 selection: [],
10546 onChangeSelection: () => {
10547 },
10548 setOpenedFilter: () => {
10549 },
10550 openedFilter: null,
10551 getItemId: (item) => item.id,
10552 isItemClickable: () => true,
10553 renderItemLink: void 0,
10554 containerWidth: 0,
10555 containerRef: (0, import_element26.createRef)(),
10556 resizeObserverRef: () => {
10557 },
10558 defaultLayouts: { list: {}, grid: {}, table: {} },
10559 filters: [],
10560 isShowingFilter: false,
10561 setIsShowingFilter: () => {
10562 },
10563 hasInitiallyLoaded: false,
10564 config: {
10565 perPageSizes: []
10566 },
10567 intersectionObserver: null
10568 });
10569 DataViewsContext.displayName = "DataViewsContext";
10570 var dataviews_context_default = DataViewsContext;
10571
10572 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10573 var import_i18n23 = __toESM(require_i18n(), 1);
10574
10575 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10576 var import_i18n10 = __toESM(require_i18n(), 1);
10577 var import_components6 = __toESM(require_components(), 1);
10578 var import_element34 = __toESM(require_element(), 1);
10579 var import_keycodes = __toESM(require_keycodes(), 1);
10580
10581 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10582 var import_components = __toESM(require_components(), 1);
10583 var import_i18n3 = __toESM(require_i18n(), 1);
10584 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10585 function DataViewsSelectionCheckbox({
10586 selection,
10587 onChangeSelection,
10588 item,
10589 getItemId,
10590 titleField,
10591 disabled: disabled2,
10592 ...extraProps
10593 }) {
10594 const id = getItemId(item);
10595 const isInSelectionArray = selection.includes(id);
10596 const checked = !disabled2 && isInSelectionArray;
10597 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10598 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10599 import_components.CheckboxControl,
10600 {
10601 className: "dataviews-selection-checkbox",
10602 "aria-label": selectionLabel,
10603 "aria-disabled": disabled2,
10604 checked,
10605 onChange: () => {
10606 if (disabled2) {
10607 return;
10608 }
10609 onChangeSelection(
10610 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10611 );
10612 },
10613 ...extraProps
10614 }
10615 );
10616 }
10617
10618 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10619 var import_components2 = __toESM(require_components(), 1);
10620 var import_i18n4 = __toESM(require_i18n(), 1);
10621 var import_element27 = __toESM(require_element(), 1);
10622 var import_data = __toESM(require_data(), 1);
10623 var import_compose = __toESM(require_compose(), 1);
10624
10625 // packages/dataviews/build-module/lock-unlock.mjs
10626 var import_private_apis2 = __toESM(require_private_apis(), 1);
10627 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10628 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10629 "@wordpress/dataviews"
10630 );
10631
10632 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10633 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10634 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10635 function ButtonTrigger({
10636 action,
10637 onClick,
10638 items,
10639 variant
10640 }) {
10641 const label = typeof action.label === "string" ? action.label : action.label(items);
10642 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10643 import_components2.Button,
10644 {
10645 disabled: !!action.disabled,
10646 accessibleWhenDisabled: true,
10647 size: "compact",
10648 variant,
10649 onClick,
10650 children: label
10651 }
10652 );
10653 }
10654 function MenuItemTrigger({
10655 action,
10656 onClick,
10657 items
10658 }) {
10659 const label = typeof action.label === "string" ? action.label : action.label(items);
10660 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.ItemLabel, { children: label }) });
10661 }
10662 function ActionModal({
10663 action,
10664 items,
10665 closeModal
10666 }) {
10667 const label = typeof action.label === "string" ? action.label : action.label(items);
10668 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10669 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10670 import_components2.Modal,
10671 {
10672 title: modalHeader || label,
10673 __experimentalHideHeader: !!action.hideModalHeader,
10674 onRequestClose: closeModal,
10675 focusOnMount: action.modalFocusOnMount ?? true,
10676 size: action.modalSize || "medium",
10677 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10678 action.id
10679 )}`,
10680 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(action.RenderModal, { items, closeModal })
10681 }
10682 );
10683 }
10684 function ActionsMenuGroup({
10685 actions,
10686 item,
10687 registry,
10688 setActiveModalAction
10689 }) {
10690 const { primaryActions, regularActions } = (0, import_element27.useMemo)(() => {
10691 return actions.reduce(
10692 (acc, action) => {
10693 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10694 return acc;
10695 },
10696 {
10697 primaryActions: [],
10698 regularActions: []
10699 }
10700 );
10701 }, [actions]);
10702 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10703 MenuItemTrigger,
10704 {
10705 action,
10706 onClick: () => {
10707 if ("RenderModal" in action) {
10708 setActiveModalAction(action);
10709 return;
10710 }
10711 action.callback([item], { registry });
10712 },
10713 items: [item]
10714 },
10715 action.id
10716 ));
10717 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu.Group, { children: [
10718 renderActionGroup(primaryActions),
10719 renderActionGroup(regularActions)
10720 ] });
10721 }
10722 function ItemActions({
10723 item,
10724 actions,
10725 isCompact
10726 }) {
10727 const registry = (0, import_data.useRegistry)();
10728 const { primaryActions, eligibleActions } = (0, import_element27.useMemo)(() => {
10729 const _eligibleActions = actions.filter(
10730 (action) => !action.isEligible || action.isEligible(item)
10731 );
10732 const _primaryActions = _eligibleActions.filter(
10733 (action) => action.isPrimary
10734 );
10735 return {
10736 primaryActions: _primaryActions,
10737 eligibleActions: _eligibleActions
10738 };
10739 }, [actions, item]);
10740 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10741 if (isCompact) {
10742 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10743 CompactItemActions,
10744 {
10745 item,
10746 actions: eligibleActions,
10747 isSmall: true,
10748 registry
10749 }
10750 );
10751 }
10752 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
10753 Stack,
10754 {
10755 direction: "row",
10756 justify: "flex-end",
10757 className: "dataviews-item-actions",
10758 style: {
10759 flexShrink: 0,
10760 width: "auto"
10761 },
10762 children: [
10763 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10764 PrimaryActions,
10765 {
10766 item,
10767 actions: primaryActions,
10768 registry
10769 }
10770 ),
10771 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10772 // there if there are any actions at all.
10773 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10774 CompactItemActions,
10775 {
10776 item,
10777 actions: eligibleActions,
10778 registry
10779 }
10780 )
10781 ]
10782 }
10783 );
10784 }
10785 function CompactItemActions({
10786 item,
10787 actions,
10788 isSmall,
10789 registry
10790 }) {
10791 const [activeModalAction, setActiveModalAction] = (0, import_element27.useState)(
10792 null
10793 );
10794 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10795 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Menu, { placement: "bottom-end", children: [
10796 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10797 Menu.TriggerButton,
10798 {
10799 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10800 import_components2.Button,
10801 {
10802 size: isSmall ? "small" : "compact",
10803 icon: more_vertical_default,
10804 label: (0, import_i18n4.__)("Actions"),
10805 accessibleWhenDisabled: true,
10806 disabled: !actions.length,
10807 className: "dataviews-all-actions-button"
10808 }
10809 )
10810 }
10811 ),
10812 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10813 ActionsMenuGroup,
10814 {
10815 actions,
10816 item,
10817 registry,
10818 setActiveModalAction
10819 }
10820 ) })
10821 ] }),
10822 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10823 ActionModal,
10824 {
10825 action: activeModalAction,
10826 items: [item],
10827 closeModal: () => setActiveModalAction(null)
10828 }
10829 )
10830 ] });
10831 }
10832 function PrimaryActions({
10833 item,
10834 actions,
10835 registry,
10836 buttonVariant
10837 }) {
10838 const [activeModalAction, setActiveModalAction] = (0, import_element27.useState)(null);
10839 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10840 if (isMobileViewport) {
10841 return null;
10842 }
10843 if (!Array.isArray(actions) || actions.length === 0) {
10844 return null;
10845 }
10846 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10847 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10848 ButtonTrigger,
10849 {
10850 action,
10851 onClick: () => {
10852 if ("RenderModal" in action) {
10853 setActiveModalAction(action);
10854 return;
10855 }
10856 action.callback([item], { registry });
10857 },
10858 items: [item],
10859 variant: buttonVariant
10860 },
10861 action.id
10862 )),
10863 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10864 ActionModal,
10865 {
10866 action: activeModalAction,
10867 items: [item],
10868 closeModal: () => setActiveModalAction(null)
10869 }
10870 )
10871 ] });
10872 }
10873
10874 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10875 var import_components3 = __toESM(require_components(), 1);
10876 var import_i18n6 = __toESM(require_i18n(), 1);
10877 var import_element28 = __toESM(require_element(), 1);
10878 var import_data2 = __toESM(require_data(), 1);
10879 var import_compose2 = __toESM(require_compose(), 1);
10880
10881 // packages/dataviews/build-module/utils/get-footer-message.mjs
10882 var import_i18n5 = __toESM(require_i18n(), 1);
10883 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10884 if (selectionCount > 0) {
10885 return (0, import_i18n5.sprintf)(
10886 /* translators: %d: number of items. */
10887 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10888 selectionCount
10889 );
10890 }
10891 if (onlyTotalCount || totalItems <= itemsCount) {
10892 return (0, import_i18n5.sprintf)(
10893 /* translators: %d: number of items. */
10894 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10895 totalItems
10896 );
10897 }
10898 return (0, import_i18n5.sprintf)(
10899 /* translators: %1$d: number of items. %2$d: total number of items. */
10900 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10901 itemsCount,
10902 totalItems
10903 );
10904 }
10905
10906 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10907 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
10908 function ActionWithModal({
10909 action,
10910 items,
10911 ActionTriggerComponent
10912 }) {
10913 const [isModalOpen, setIsModalOpen] = (0, import_element28.useState)(false);
10914 const actionTriggerProps = {
10915 action,
10916 onClick: () => {
10917 setIsModalOpen(true);
10918 },
10919 items
10920 };
10921 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
10922 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10923 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10924 ActionModal,
10925 {
10926 action,
10927 items,
10928 closeModal: () => setIsModalOpen(false)
10929 }
10930 )
10931 ] });
10932 }
10933 function useHasAPossibleBulkAction(actions, item) {
10934 return (0, import_element28.useMemo)(() => {
10935 return actions.some((action) => {
10936 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10937 });
10938 }, [actions, item]);
10939 }
10940 function useSomeItemHasAPossibleBulkAction(actions, data) {
10941 return (0, import_element28.useMemo)(() => {
10942 return data.some((item) => {
10943 return actions.some((action) => {
10944 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10945 });
10946 });
10947 }, [actions, data]);
10948 }
10949 function BulkSelectionCheckbox({
10950 selection,
10951 onChangeSelection,
10952 data,
10953 actions,
10954 getItemId,
10955 disableSelectAll = false
10956 }) {
10957 const selectableItems = (0, import_element28.useMemo)(() => {
10958 return data.filter((item) => {
10959 return actions.some(
10960 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10961 );
10962 });
10963 }, [data, actions]);
10964 const selectedItems = data.filter(
10965 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10966 );
10967 const hasSelection = selection.length > 0;
10968 const areAllSelected = selectedItems.length === selectableItems.length;
10969 if (disableSelectAll) {
10970 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10971 import_components3.CheckboxControl,
10972 {
10973 className: "dataviews-view-table-selection-checkbox",
10974 checked: hasSelection,
10975 disabled: !hasSelection,
10976 onChange: () => {
10977 onChangeSelection([]);
10978 },
10979 "aria-label": (0, import_i18n6.__)("Deselect all")
10980 }
10981 );
10982 }
10983 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
10984 import_components3.CheckboxControl,
10985 {
10986 className: "dataviews-view-table-selection-checkbox",
10987 checked: areAllSelected,
10988 indeterminate: !areAllSelected && !!selectedItems.length,
10989 onChange: () => {
10990 if (areAllSelected) {
10991 onChangeSelection([]);
10992 } else {
10993 onChangeSelection(
10994 selectableItems.map((item) => getItemId(item))
10995 );
10996 }
10997 },
10998 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
10999 }
11000 );
11001 }
11002 function ActionTrigger({
11003 action,
11004 onClick,
11005 isBusy,
11006 items
11007 }) {
11008 const label = typeof action.label === "string" ? action.label : action.label(items);
11009 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11010 if (isMobile) {
11011 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11012 import_components3.Button,
11013 {
11014 disabled: isBusy,
11015 accessibleWhenDisabled: true,
11016 label,
11017 icon: action.icon,
11018 size: "compact",
11019 onClick,
11020 isBusy
11021 }
11022 );
11023 }
11024 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11025 import_components3.Button,
11026 {
11027 disabled: isBusy,
11028 accessibleWhenDisabled: true,
11029 size: "compact",
11030 onClick,
11031 isBusy,
11032 children: label
11033 }
11034 );
11035 }
11036 var EMPTY_ARRAY2 = [];
11037 function ActionButton({
11038 action,
11039 selectedItems,
11040 actionInProgress,
11041 setActionInProgress
11042 }) {
11043 const registry = (0, import_data2.useRegistry)();
11044 const selectedEligibleItems = (0, import_element28.useMemo)(() => {
11045 return selectedItems.filter((item) => {
11046 return !action.isEligible || action.isEligible(item);
11047 });
11048 }, [action, selectedItems]);
11049 if ("RenderModal" in action) {
11050 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11051 ActionWithModal,
11052 {
11053 action,
11054 items: selectedEligibleItems,
11055 ActionTriggerComponent: ActionTrigger
11056 },
11057 action.id
11058 );
11059 }
11060 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11061 ActionTrigger,
11062 {
11063 action,
11064 onClick: async () => {
11065 setActionInProgress(action.id);
11066 await action.callback(selectedItems, {
11067 registry
11068 });
11069 setActionInProgress(null);
11070 },
11071 items: selectedEligibleItems,
11072 isBusy: actionInProgress === action.id
11073 },
11074 action.id
11075 );
11076 }
11077 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
11078 const message2 = getFooterMessage(
11079 selection.length,
11080 data.length,
11081 paginationInfo.totalItems,
11082 isInfiniteScroll
11083 );
11084 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11085 Stack,
11086 {
11087 direction: "row",
11088 className: "dataviews-bulk-actions-footer__container",
11089 gap: "md",
11090 align: "center",
11091 children: [
11092 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11093 BulkSelectionCheckbox,
11094 {
11095 selection,
11096 onChangeSelection,
11097 data,
11098 actions,
11099 getItemId,
11100 disableSelectAll: isInfiniteScroll
11101 }
11102 ),
11103 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
11104 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11105 Stack,
11106 {
11107 direction: "row",
11108 className: "dataviews-bulk-actions-footer__action-buttons",
11109 gap: "xs",
11110 children: [
11111 actionsToShow.map((action) => {
11112 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11113 ActionButton,
11114 {
11115 action,
11116 selectedItems,
11117 actionInProgress,
11118 setActionInProgress
11119 },
11120 action.id
11121 );
11122 }),
11123 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11124 import_components3.Button,
11125 {
11126 icon: close_small_default,
11127 showTooltip: true,
11128 tooltipPosition: "top",
11129 size: "compact",
11130 label: (0, import_i18n6.__)("Cancel"),
11131 disabled: !!actionInProgress,
11132 accessibleWhenDisabled: false,
11133 onClick: () => {
11134 onChangeSelection(EMPTY_ARRAY2);
11135 }
11136 }
11137 )
11138 ]
11139 }
11140 )
11141 ]
11142 }
11143 );
11144 }
11145 function FooterContent({
11146 selection,
11147 actions,
11148 onChangeSelection,
11149 data,
11150 getItemId,
11151 isInfiniteScroll,
11152 paginationInfo
11153 }) {
11154 const [actionInProgress, setActionInProgress] = (0, import_element28.useState)(
11155 null
11156 );
11157 const footerContentRef = (0, import_element28.useRef)(void 0);
11158 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11159 const bulkActions = (0, import_element28.useMemo)(
11160 () => actions.filter((action) => action.supportsBulk),
11161 [actions]
11162 );
11163 const selectableItems = (0, import_element28.useMemo)(() => {
11164 return data.filter((item) => {
11165 return bulkActions.some(
11166 (action) => !action.isEligible || action.isEligible(item)
11167 );
11168 });
11169 }, [data, bulkActions]);
11170 const selectedItems = (0, import_element28.useMemo)(() => {
11171 return data.filter(
11172 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11173 );
11174 }, [selection, data, getItemId, selectableItems]);
11175 const actionsToShow = (0, import_element28.useMemo)(
11176 () => actions.filter((action) => {
11177 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11178 (item) => !action.isEligible || action.isEligible(item)
11179 );
11180 }),
11181 [actions, selectedItems, isMobile]
11182 );
11183 if (!actionInProgress) {
11184 if (footerContentRef.current) {
11185 footerContentRef.current = void 0;
11186 }
11187 return renderFooterContent(
11188 data,
11189 actions,
11190 getItemId,
11191 isInfiniteScroll,
11192 selection,
11193 actionsToShow,
11194 selectedItems,
11195 actionInProgress,
11196 setActionInProgress,
11197 onChangeSelection,
11198 paginationInfo
11199 );
11200 } else if (!footerContentRef.current) {
11201 footerContentRef.current = renderFooterContent(
11202 data,
11203 actions,
11204 getItemId,
11205 isInfiniteScroll,
11206 selection,
11207 actionsToShow,
11208 selectedItems,
11209 actionInProgress,
11210 setActionInProgress,
11211 onChangeSelection,
11212 paginationInfo
11213 );
11214 }
11215 return footerContentRef.current;
11216 }
11217 function BulkActionsFooter() {
11218 const {
11219 data,
11220 selection,
11221 actions = EMPTY_ARRAY2,
11222 onChangeSelection,
11223 getItemId,
11224 paginationInfo,
11225 view
11226 } = (0, import_element28.useContext)(dataviews_context_default);
11227 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11228 FooterContent,
11229 {
11230 selection,
11231 onChangeSelection,
11232 data,
11233 actions,
11234 getItemId,
11235 isInfiniteScroll: !!view.infiniteScrollEnabled,
11236 paginationInfo
11237 }
11238 );
11239 }
11240
11241 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11242 var import_i18n7 = __toESM(require_i18n(), 1);
11243 var import_components4 = __toESM(require_components(), 1);
11244 var import_element29 = __toESM(require_element(), 1);
11245
11246 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11247 function getHideableFields(view, fields) {
11248 const togglableFields = [
11249 view?.titleField,
11250 view?.mediaField,
11251 view?.descriptionField
11252 ].filter(Boolean);
11253 return fields.filter(
11254 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11255 );
11256 }
11257
11258 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11259 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11260 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11261 function WithMenuSeparators({ children }) {
11262 return import_element29.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_element29.Fragment, { children: [
11263 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Separator, {}),
11264 child
11265 ] }, i2));
11266 }
11267 var _HeaderMenu = (0, import_element29.forwardRef)(function HeaderMenu({
11268 fieldId,
11269 view,
11270 fields,
11271 onChangeView,
11272 onHide,
11273 setOpenedFilter,
11274 canMove = true,
11275 canInsertLeft = true,
11276 canInsertRight = true
11277 }, ref) {
11278 const visibleFieldIds = view.fields ?? [];
11279 const index2 = visibleFieldIds?.indexOf(fieldId);
11280 const isSorted = view.sort?.field === fieldId;
11281 let isHidable = false;
11282 let isSortable = false;
11283 let canAddFilter = false;
11284 let operators = [];
11285 const field = fields.find((f2) => f2.id === fieldId);
11286 const { setIsShowingFilter } = (0, import_element29.useContext)(dataviews_context_default);
11287 if (!field) {
11288 return null;
11289 }
11290 isHidable = field.enableHiding !== false;
11291 isSortable = field.enableSorting !== false;
11292 const header = field.header;
11293 operators = !!field.filterBy && field.filterBy?.operators || [];
11294 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11295 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11296 return header;
11297 }
11298 const hiddenFields = getHideableFields(view, fields).filter(
11299 (f2) => !visibleFieldIds.includes(f2.id)
11300 );
11301 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11302 const isRtl = (0, import_i18n7.isRTL)();
11303 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11304 /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
11305 Menu2.TriggerButton,
11306 {
11307 render: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11308 import_components4.Button,
11309 {
11310 size: "compact",
11311 className: "dataviews-view-table-header-button",
11312 ref,
11313 variant: "tertiary"
11314 }
11315 ),
11316 children: [
11317 header,
11318 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11319 ]
11320 }
11321 ),
11322 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(WithMenuSeparators, { children: [
11323 isSortable && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11324 (direction) => {
11325 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11326 const value = `${fieldId}-${direction}`;
11327 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11328 Menu2.RadioItem,
11329 {
11330 name: "view-table-sorting",
11331 value,
11332 checked: isChecked,
11333 onChange: () => {
11334 onChangeView({
11335 ...view,
11336 sort: {
11337 field: fieldId,
11338 direction
11339 },
11340 showLevels: false
11341 });
11342 },
11343 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11344 },
11345 value
11346 );
11347 }
11348 ) }),
11349 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11350 Menu2.Item,
11351 {
11352 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: funnel_default }),
11353 onClick: () => {
11354 setOpenedFilter(fieldId);
11355 setIsShowingFilter(true);
11356 onChangeView({
11357 ...view,
11358 page: 1,
11359 filters: [
11360 ...view.filters || [],
11361 {
11362 field: fieldId,
11363 value: void 0,
11364 operator: operators[0]
11365 }
11366 ]
11367 });
11368 },
11369 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11370 }
11371 ) }),
11372 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2.Group, { children: [
11373 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11374 Menu2.Item,
11375 {
11376 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11377 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11378 onClick: () => {
11379 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11380 const newFields = [
11381 ...visibleFieldIds
11382 ];
11383 newFields.splice(index2, 1);
11384 newFields.splice(
11385 targetIndex,
11386 0,
11387 fieldId
11388 );
11389 onChangeView({
11390 ...view,
11391 fields: newFields
11392 });
11393 },
11394 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11395 }
11396 ),
11397 canMove && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11398 Menu2.Item,
11399 {
11400 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11401 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11402 onClick: () => {
11403 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11404 const newFields = [
11405 ...visibleFieldIds
11406 ];
11407 newFields.splice(index2, 1);
11408 newFields.splice(
11409 targetIndex,
11410 0,
11411 fieldId
11412 );
11413 onChangeView({
11414 ...view,
11415 fields: newFields
11416 });
11417 },
11418 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11419 }
11420 ),
11421 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11422 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11423 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11424 const insertIndex = isRtl ? index2 + 1 : index2;
11425 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11426 Menu2.Item,
11427 {
11428 onClick: () => {
11429 onChangeView({
11430 ...view,
11431 fields: [
11432 ...visibleFieldIds.slice(
11433 0,
11434 insertIndex
11435 ),
11436 hiddenField.id,
11437 ...visibleFieldIds.slice(
11438 insertIndex
11439 )
11440 ]
11441 });
11442 },
11443 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11444 },
11445 hiddenField.id
11446 );
11447 }) })
11448 ] }),
11449 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(Menu2, { children: [
11450 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11451 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11452 const insertIndex = isRtl ? index2 : index2 + 1;
11453 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11454 Menu2.Item,
11455 {
11456 onClick: () => {
11457 onChangeView({
11458 ...view,
11459 fields: [
11460 ...visibleFieldIds.slice(
11461 0,
11462 insertIndex
11463 ),
11464 hiddenField.id,
11465 ...visibleFieldIds.slice(
11466 insertIndex
11467 )
11468 ]
11469 });
11470 },
11471 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11472 },
11473 hiddenField.id
11474 );
11475 }) })
11476 ] }),
11477 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
11478 Menu2.Item,
11479 {
11480 prefix: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components4.Icon, { icon: unseen_default }),
11481 onClick: () => {
11482 onHide(field);
11483 onChangeView({
11484 ...view,
11485 fields: visibleFieldIds.filter(
11486 (id) => id !== fieldId
11487 )
11488 });
11489 },
11490 children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11491 }
11492 )
11493 ] })
11494 ] }) })
11495 ] });
11496 });
11497 var ColumnHeaderMenu = _HeaderMenu;
11498 var column_header_menu_default = ColumnHeaderMenu;
11499
11500 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11501 var import_element30 = __toESM(require_element(), 1);
11502 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11503 function getClickableItemProps({
11504 item,
11505 isItemClickable,
11506 onClickItem,
11507 className
11508 }) {
11509 if (!isItemClickable(item) || !onClickItem) {
11510 return { className };
11511 }
11512 return {
11513 className: className ? `${className} ${className}--clickable` : void 0,
11514 role: "button",
11515 tabIndex: 0,
11516 onClick: (event) => {
11517 event.stopPropagation();
11518 onClickItem(item);
11519 },
11520 onKeyDown: (event) => {
11521 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11522 event.stopPropagation();
11523 onClickItem(item);
11524 }
11525 }
11526 };
11527 }
11528 function ItemClickWrapper({
11529 item,
11530 isItemClickable,
11531 onClickItem,
11532 renderItemLink,
11533 className,
11534 children,
11535 ...extraProps
11536 }) {
11537 if (!isItemClickable(item)) {
11538 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className, ...extraProps, children });
11539 }
11540 if (renderItemLink) {
11541 const renderedElement = renderItemLink({
11542 item,
11543 className: `${className} ${className}--clickable`,
11544 ...extraProps,
11545 children
11546 });
11547 return (0, import_element30.cloneElement)(renderedElement, {
11548 onClick: (event) => {
11549 event.stopPropagation();
11550 if (renderedElement.props.onClick) {
11551 renderedElement.props.onClick(event);
11552 }
11553 },
11554 onKeyDown: (event) => {
11555 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11556 event.stopPropagation();
11557 if (renderedElement.props.onKeyDown) {
11558 renderedElement.props.onKeyDown(event);
11559 }
11560 }
11561 }
11562 });
11563 }
11564 const clickProps = getClickableItemProps({
11565 item,
11566 isItemClickable,
11567 onClickItem,
11568 className
11569 });
11570 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { ...clickProps, ...extraProps, children });
11571 }
11572
11573 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11574 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11575 function ColumnPrimary({
11576 item,
11577 level,
11578 titleField,
11579 mediaField,
11580 descriptionField,
11581 onClickItem,
11582 renderItemLink,
11583 isItemClickable
11584 }) {
11585 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11586 mediaField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11587 ItemClickWrapper,
11588 {
11589 item,
11590 isItemClickable,
11591 onClickItem,
11592 renderItemLink,
11593 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11594 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11595 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11596 mediaField.render,
11597 {
11598 item,
11599 field: mediaField,
11600 config: { sizes: "32px" }
11601 }
11602 )
11603 }
11604 ),
11605 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11606 Stack,
11607 {
11608 direction: "column",
11609 align: "flex-start",
11610 className: "dataviews-view-table__primary-column-content",
11611 children: [
11612 titleField && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
11613 ItemClickWrapper,
11614 {
11615 item,
11616 isItemClickable,
11617 onClickItem,
11618 renderItemLink,
11619 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11620 children: [
11621 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("span", { className: "dataviews-view-table__level", children: [
11622 Array(level).fill("\u2014").join(" "),
11623 "\xA0"
11624 ] }),
11625 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField })
11626 ]
11627 }
11628 ),
11629 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11630 descriptionField.render,
11631 {
11632 item,
11633 field: descriptionField
11634 }
11635 )
11636 ]
11637 }
11638 )
11639 ] });
11640 }
11641 var column_primary_default = ColumnPrimary;
11642
11643 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11644 var import_element31 = __toESM(require_element(), 1);
11645 var import_i18n8 = __toESM(require_i18n(), 1);
11646 var isScrolledToEnd = (element) => {
11647 if ((0, import_i18n8.isRTL)()) {
11648 const scrollLeft = Math.abs(element.scrollLeft);
11649 return scrollLeft <= 1;
11650 }
11651 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11652 };
11653 function useScrollState({
11654 scrollContainerRef,
11655 enabledHorizontal = false
11656 }) {
11657 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element31.useState)(false);
11658 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element31.useState)(false);
11659 const handleScroll = (0, import_element31.useCallback)(() => {
11660 const scrollContainer = scrollContainerRef.current;
11661 if (!scrollContainer) {
11662 return;
11663 }
11664 if (enabledHorizontal) {
11665 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11666 }
11667 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11668 }, [scrollContainerRef, enabledHorizontal]);
11669 (0, import_element31.useEffect)(() => {
11670 if (typeof window === "undefined" || !scrollContainerRef.current) {
11671 return () => {
11672 };
11673 }
11674 const scrollContainer = scrollContainerRef.current;
11675 handleScroll();
11676 scrollContainer.addEventListener("scroll", handleScroll);
11677 window.addEventListener("resize", handleScroll);
11678 return () => {
11679 scrollContainer.removeEventListener("scroll", handleScroll);
11680 window.removeEventListener("resize", handleScroll);
11681 };
11682 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11683 return { isHorizontalScrollEnd, isVerticallyScrolled };
11684 }
11685
11686 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11687 function getDataByGroup(data, groupByField) {
11688 return data.reduce((groups, item) => {
11689 const groupName = groupByField.getValue({ item });
11690 if (!groups.has(groupName)) {
11691 groups.set(groupName, []);
11692 }
11693 groups.get(groupName)?.push(item);
11694 return groups;
11695 }, /* @__PURE__ */ new Map());
11696 }
11697
11698 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11699 var import_components5 = __toESM(require_components(), 1);
11700 var import_i18n9 = __toESM(require_i18n(), 1);
11701 var import_element32 = __toESM(require_element(), 1);
11702 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11703 function FieldItem({
11704 field,
11705 isVisible: isVisible2,
11706 onToggleVisibility
11707 }) {
11708 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: [
11709 /* @__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 }) }),
11710 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11711 ] }) });
11712 }
11713 function isDefined(item) {
11714 return !!item;
11715 }
11716 function PropertiesSection({
11717 showLabel = true
11718 }) {
11719 const { view, fields, onChangeView } = (0, import_element32.useContext)(dataviews_context_default);
11720 const regularFields = getHideableFields(view, fields);
11721 if (!regularFields?.length) {
11722 return null;
11723 }
11724 const titleField = fields.find((f2) => f2.id === view.titleField);
11725 const previewField = fields.find((f2) => f2.id === view.mediaField);
11726 const descriptionField = fields.find(
11727 (f2) => f2.id === view.descriptionField
11728 );
11729 const lockedFields = [
11730 {
11731 field: titleField,
11732 isVisibleFlag: "showTitle"
11733 },
11734 {
11735 field: previewField,
11736 isVisibleFlag: "showMedia"
11737 },
11738 {
11739 field: descriptionField,
11740 isVisibleFlag: "showDescription"
11741 }
11742 ].filter(({ field }) => isDefined(field));
11743 const visibleFieldIds = view.fields ?? [];
11744 const visibleRegularFieldsCount = regularFields.filter(
11745 (f2) => visibleFieldIds.includes(f2.id)
11746 ).length;
11747 const visibleLockedFields = lockedFields.filter(
11748 ({ isVisibleFlag }) => (
11749 // @ts-expect-error
11750 view[isVisibleFlag] ?? true
11751 )
11752 );
11753 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11754 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11755 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11756 showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11757 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11758 Stack,
11759 {
11760 direction: "column",
11761 className: "dataviews-view-config__properties",
11762 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11763 lockedFields.map(({ field, isVisibleFlag }) => {
11764 const isVisible2 = view[isVisibleFlag] ?? true;
11765 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11766 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11767 FieldItem,
11768 {
11769 field: fieldToRender,
11770 isVisible: isVisible2,
11771 onToggleVisibility: () => {
11772 onChangeView({
11773 ...view,
11774 [isVisibleFlag]: !isVisible2
11775 });
11776 }
11777 },
11778 field.id
11779 );
11780 }),
11781 regularFields.map((field) => {
11782 const isVisible2 = visibleFieldIds.includes(field.id);
11783 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11784 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11785 FieldItem,
11786 {
11787 field: fieldToRender,
11788 isVisible: isVisible2,
11789 onToggleVisibility: () => {
11790 onChangeView({
11791 ...view,
11792 fields: isVisible2 ? visibleFieldIds.filter(
11793 (fieldId) => fieldId !== field.id
11794 ) : [...visibleFieldIds, field.id]
11795 });
11796 }
11797 },
11798 field.id
11799 );
11800 })
11801 ] })
11802 }
11803 )
11804 ] });
11805 }
11806
11807 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11808 var import_element33 = __toESM(require_element(), 1);
11809 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11810 const [showLoader, setShowLoader] = (0, import_element33.useState)(false);
11811 (0, import_element33.useEffect)(() => {
11812 if (!isLoading) {
11813 return;
11814 }
11815 const timeout = setTimeout(() => {
11816 setShowLoader(true);
11817 }, options.delay);
11818 return () => {
11819 clearTimeout(timeout);
11820 setShowLoader(false);
11821 };
11822 }, [isLoading, options.delay]);
11823 return showLoader;
11824 }
11825
11826 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11827 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
11828 function getEffectiveAlign(explicitAlign, fieldType) {
11829 if (explicitAlign) {
11830 return explicitAlign;
11831 }
11832 if (fieldType === "integer" || fieldType === "number") {
11833 return "end";
11834 }
11835 return void 0;
11836 }
11837 function TableColumnField({
11838 item,
11839 fields,
11840 column,
11841 align
11842 }) {
11843 const field = fields.find((f2) => f2.id === column);
11844 if (!field) {
11845 return null;
11846 }
11847 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11848 "dataviews-view-table__cell-align-end": align === "end",
11849 "dataviews-view-table__cell-align-center": align === "center"
11850 });
11851 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(field.render, { item, field }) });
11852 }
11853 function TableRow({
11854 hasBulkActions,
11855 item,
11856 level,
11857 actions,
11858 fields,
11859 id,
11860 view,
11861 titleField,
11862 mediaField,
11863 descriptionField,
11864 selection,
11865 getItemId,
11866 isItemClickable,
11867 onClickItem,
11868 renderItemLink,
11869 onChangeSelection,
11870 isActionsColumnSticky,
11871 posinset
11872 }) {
11873 const { paginationInfo } = (0, import_element34.useContext)(dataviews_context_default);
11874 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11875 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11876 const {
11877 showTitle = true,
11878 showMedia = true,
11879 showDescription = true,
11880 infiniteScrollEnabled
11881 } = view;
11882 const isTouchDeviceRef = (0, import_element34.useRef)(false);
11883 const columns = view.fields ?? [];
11884 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11885 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
11886 "tr",
11887 {
11888 className: clsx_default("dataviews-view-table__row", {
11889 "is-selected": hasPossibleBulkAction && isSelected2,
11890 "has-bulk-actions": hasPossibleBulkAction
11891 }),
11892 onTouchStart: () => {
11893 isTouchDeviceRef.current = true;
11894 },
11895 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11896 "aria-posinset": posinset,
11897 role: infiniteScrollEnabled ? "article" : void 0,
11898 onMouseDown: (event) => {
11899 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11900 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11901 event?.preventDefault();
11902 }
11903 },
11904 onClick: (event) => {
11905 if (!hasPossibleBulkAction) {
11906 return;
11907 }
11908 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11909 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11910 onChangeSelection(
11911 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11912 );
11913 }
11914 },
11915 children: [
11916 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)(
11917 DataViewsSelectionCheckbox,
11918 {
11919 item,
11920 selection,
11921 onChangeSelection,
11922 getItemId,
11923 titleField,
11924 disabled: !hasPossibleBulkAction
11925 }
11926 ) }) }),
11927 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11928 column_primary_default,
11929 {
11930 item,
11931 level,
11932 titleField: showTitle ? titleField : void 0,
11933 mediaField: showMedia ? mediaField : void 0,
11934 descriptionField: showDescription ? descriptionField : void 0,
11935 isItemClickable,
11936 onClickItem,
11937 renderItemLink
11938 }
11939 ) }),
11940 columns.map((column) => {
11941 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11942 const field = fields.find((f2) => f2.id === column);
11943 const effectiveAlign = getEffectiveAlign(align, field?.type);
11944 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11945 "td",
11946 {
11947 style: {
11948 width,
11949 maxWidth,
11950 minWidth
11951 },
11952 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11953 TableColumnField,
11954 {
11955 fields,
11956 item,
11957 column,
11958 align: effectiveAlign
11959 }
11960 )
11961 },
11962 column
11963 );
11964 }),
11965 !!actions?.length && // Disable reason: we are not making the element interactive,
11966 // but preventing any click events from bubbling up to the
11967 // table row. This allows us to add a click handler to the row
11968 // itself (to toggle row selection) without erroneously
11969 // intercepting click events from ItemActions.
11970 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
11971 "td",
11972 {
11973 className: clsx_default("dataviews-view-table__actions-column", {
11974 "dataviews-view-table__actions-column--sticky": true,
11975 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11976 }),
11977 onClick: (e2) => e2.stopPropagation(),
11978 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ItemActions, { item, actions })
11979 }
11980 )
11981 ]
11982 }
11983 );
11984 }
11985 function ViewTable({
11986 actions,
11987 data,
11988 fields,
11989 getItemId,
11990 getItemLevel,
11991 isLoading = false,
11992 onChangeView,
11993 onChangeSelection,
11994 selection,
11995 setOpenedFilter,
11996 onClickItem,
11997 isItemClickable,
11998 renderItemLink,
11999 view,
12000 className,
12001 empty
12002 }) {
12003 const { containerRef } = (0, import_element34.useContext)(dataviews_context_default);
12004 const isDelayedLoading = useDelayedLoading(isLoading);
12005 const headerMenuRefs = (0, import_element34.useRef)(/* @__PURE__ */ new Map());
12006 const headerMenuToFocusRef = (0, import_element34.useRef)(void 0);
12007 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element34.useState)();
12008 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element34.useState)(null);
12009 (0, import_element34.useEffect)(() => {
12010 if (headerMenuToFocusRef.current) {
12011 headerMenuToFocusRef.current.focus();
12012 headerMenuToFocusRef.current = void 0;
12013 }
12014 });
12015 const tableNoticeId = (0, import_element34.useId)();
12016 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12017 scrollContainerRef: containerRef,
12018 enabledHorizontal: !!actions?.length
12019 });
12020 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12021 if (nextHeaderMenuToFocus) {
12022 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12023 setNextHeaderMenuToFocus(void 0);
12024 return;
12025 }
12026 const onHide = (field) => {
12027 const hidden = headerMenuRefs.current.get(field.id);
12028 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12029 setNextHeaderMenuToFocus(fallback?.node);
12030 };
12031 const handleHeaderContextMenu = (event) => {
12032 event.preventDefault();
12033 event.stopPropagation();
12034 const virtualAnchor = {
12035 getBoundingClientRect: () => ({
12036 x: event.clientX,
12037 y: event.clientY,
12038 top: event.clientY,
12039 left: event.clientX,
12040 right: event.clientX,
12041 bottom: event.clientY,
12042 width: 0,
12043 height: 0,
12044 toJSON: () => ({})
12045 })
12046 };
12047 window.requestAnimationFrame(() => {
12048 setContextMenuAnchor(virtualAnchor);
12049 });
12050 };
12051 const hasData = !!data?.length;
12052 const titleField = fields.find((field) => field.id === view.titleField);
12053 const mediaField = fields.find((field) => field.id === view.mediaField);
12054 const descriptionField = fields.find(
12055 (field) => field.id === view.descriptionField
12056 );
12057 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12058 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12059 const { showTitle = true, showMedia = true, showDescription = true } = view;
12060 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
12061 const columns = view.fields ?? [];
12062 const headerMenuRef = (column, index2) => (node) => {
12063 if (node) {
12064 headerMenuRefs.current.set(column, {
12065 node,
12066 fallback: columns[index2 > 0 ? index2 - 1 : 1]
12067 });
12068 } else {
12069 headerMenuRefs.current.delete(column);
12070 }
12071 };
12072 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12073 const isRtl = (0, import_i18n10.isRTL)();
12074 if (!hasData) {
12075 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12076 "div",
12077 {
12078 className: clsx_default("dataviews-no-results", {
12079 "is-refreshing": isDelayedLoading
12080 }),
12081 id: tableNoticeId,
12082 children: empty
12083 }
12084 );
12085 }
12086 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
12087 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
12088 "table",
12089 {
12090 className: clsx_default("dataviews-view-table", className, {
12091 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12092 view.layout.density
12093 ),
12094 "has-bulk-actions": hasBulkActions,
12095 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12096 }),
12097 "aria-busy": isLoading,
12098 "aria-describedby": tableNoticeId,
12099 role: isInfiniteScroll ? "feed" : void 0,
12100 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12101 children: [
12102 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("colgroup", { children: [
12103 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12104 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12105 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12106 "col",
12107 {
12108 className: clsx_default(
12109 `dataviews-view-table__col-${column}`,
12110 {
12111 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12112 }
12113 )
12114 },
12115 `col-${column}`
12116 )),
12117 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("col", { className: "dataviews-view-table__col-actions" })
12118 ] }),
12119 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12120 import_components6.Popover,
12121 {
12122 anchor: contextMenuAnchor,
12123 onClose: () => setContextMenuAnchor(null),
12124 placement: "bottom-start",
12125 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(PropertiesSection, { showLabel: false })
12126 }
12127 ),
12128 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12129 "thead",
12130 {
12131 className: clsx_default({
12132 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12133 }),
12134 onContextMenu: handleHeaderContextMenu,
12135 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12136 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12137 "th",
12138 {
12139 className: "dataviews-view-table__checkbox-column",
12140 scope: "col",
12141 onContextMenu: handleHeaderContextMenu,
12142 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12143 BulkSelectionCheckbox,
12144 {
12145 selection,
12146 onChangeSelection,
12147 data,
12148 actions,
12149 getItemId
12150 }
12151 )
12152 }
12153 ),
12154 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12155 column_header_menu_default,
12156 {
12157 ref: headerMenuRef(
12158 titleField.id,
12159 0
12160 ),
12161 fieldId: titleField.id,
12162 view,
12163 fields,
12164 onChangeView,
12165 onHide,
12166 setOpenedFilter,
12167 canMove: false,
12168 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12169 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12170 }
12171 ) }),
12172 columns.map((column, index2) => {
12173 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12174 const field = fields.find(
12175 (f2) => f2.id === column
12176 );
12177 const effectiveAlign = getEffectiveAlign(
12178 align,
12179 field?.type
12180 );
12181 const canInsertOrMove = view.layout?.enableMoving ?? true;
12182 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12183 "th",
12184 {
12185 style: {
12186 width,
12187 maxWidth,
12188 minWidth,
12189 textAlign: effectiveAlign
12190 },
12191 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12192 scope: "col",
12193 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12194 column_header_menu_default,
12195 {
12196 ref: headerMenuRef(column, index2),
12197 fieldId: column,
12198 view,
12199 fields,
12200 onChangeView,
12201 onHide,
12202 setOpenedFilter,
12203 canMove: canInsertOrMove,
12204 canInsertLeft: canInsertOrMove,
12205 canInsertRight: canInsertOrMove
12206 }
12207 )
12208 },
12209 column
12210 );
12211 }),
12212 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12213 "th",
12214 {
12215 className: clsx_default(
12216 "dataviews-view-table__actions-column",
12217 {
12218 "dataviews-view-table__actions-column--sticky": true,
12219 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12220 }
12221 ),
12222 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12223 }
12224 )
12225 ] })
12226 }
12227 ),
12228 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12229 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("tbody", { children: [
12230 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12231 "td",
12232 {
12233 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12234 className: "dataviews-view-table__group-header-cell",
12235 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12236 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12237 (0, import_i18n10.__)("%1$s: %2$s"),
12238 groupField.label,
12239 groupName
12240 )
12241 }
12242 ) }),
12243 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12244 TableRow,
12245 {
12246 item,
12247 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12248 hasBulkActions,
12249 actions,
12250 fields,
12251 id: getItemId(item) || index2.toString(),
12252 view,
12253 titleField,
12254 mediaField,
12255 descriptionField,
12256 selection,
12257 getItemId,
12258 onChangeSelection,
12259 onClickItem,
12260 renderItemLink,
12261 isItemClickable,
12262 isActionsColumnSticky: !isHorizontalScrollEnd
12263 },
12264 getItemId(item)
12265 ))
12266 ] }, `group-${groupName}`)
12267 ) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
12268 TableRow,
12269 {
12270 item,
12271 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12272 hasBulkActions,
12273 actions,
12274 fields,
12275 id: getItemId(item) || index2.toString(),
12276 view,
12277 titleField,
12278 mediaField,
12279 descriptionField,
12280 selection,
12281 getItemId,
12282 onChangeSelection,
12283 onClickItem,
12284 renderItemLink,
12285 isItemClickable,
12286 isActionsColumnSticky: !isHorizontalScrollEnd,
12287 posinset: isInfiniteScroll ? index2 + 1 : void 0
12288 },
12289 getItemId(item)
12290 )) })
12291 ]
12292 }
12293 ),
12294 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, {}) }) })
12295 ] });
12296 }
12297 var table_default = ViewTable;
12298
12299 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12300 var import_components9 = __toESM(require_components(), 1);
12301 var import_i18n13 = __toESM(require_i18n(), 1);
12302
12303 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12304 var import_components8 = __toESM(require_components(), 1);
12305 var import_i18n12 = __toESM(require_i18n(), 1);
12306 var import_compose3 = __toESM(require_compose(), 1);
12307 var import_keycodes2 = __toESM(require_keycodes(), 1);
12308 var import_element38 = __toESM(require_element(), 1);
12309
12310 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12311 var import_components7 = __toESM(require_components(), 1);
12312 var import_i18n11 = __toESM(require_i18n(), 1);
12313 var import_element35 = __toESM(require_element(), 1);
12314 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12315 var imageSizes = [
12316 {
12317 value: 120,
12318 breakpoint: 1
12319 },
12320 {
12321 value: 170,
12322 breakpoint: 1
12323 },
12324 {
12325 value: 230,
12326 breakpoint: 1
12327 },
12328 {
12329 value: 290,
12330 breakpoint: 1112
12331 // at minimum image width, 4 images display at this container size
12332 },
12333 {
12334 value: 350,
12335 breakpoint: 1636
12336 // at minimum image width, 6 images display at this container size
12337 },
12338 {
12339 value: 430,
12340 breakpoint: 588
12341 // at minimum image width, 2 images display at this container size
12342 }
12343 ];
12344 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12345 function useGridColumns() {
12346 const context = (0, import_element35.useContext)(dataviews_context_default);
12347 const view = context.view;
12348 return (0, import_element35.useMemo)(() => {
12349 const containerWidth = context.containerWidth;
12350 const gap = 32;
12351 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12352 const columns = Math.floor(
12353 (containerWidth + gap) / (previewSize + gap)
12354 );
12355 return Math.max(1, columns);
12356 }, [context.containerWidth, view.layout?.previewSize]);
12357 }
12358
12359 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12360 var import_element36 = __toESM(require_element(), 1);
12361 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12362 var GridItems = (0, import_element36.forwardRef)(({ className, previewSize, ...props }, ref) => {
12363 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12364 "div",
12365 {
12366 ref,
12367 className: clsx_default("dataviews-view-grid-items", className),
12368 style: {
12369 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12370 },
12371 ...props
12372 }
12373 );
12374 });
12375
12376 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12377 var import_element37 = __toESM(require_element(), 1);
12378 function useIntersectionObserver(elementRef, posinset) {
12379 const { intersectionObserver } = (0, import_element37.useContext)(dataviews_context_default);
12380 (0, import_element37.useEffect)(() => {
12381 const element = elementRef.current;
12382 if (!element || posinset === void 0 || !intersectionObserver) {
12383 return;
12384 }
12385 intersectionObserver.observe(element);
12386 return () => {
12387 intersectionObserver.unobserve(element);
12388 };
12389 }, [elementRef, intersectionObserver, posinset]);
12390 }
12391 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12392 const hasData = !!data?.length;
12393 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12394 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12395 }
12396
12397 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12398 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12399 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12400 function chunk(array, size4) {
12401 const chunks = [];
12402 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12403 chunks.push(array.slice(i2, i2 + size4));
12404 }
12405 return chunks;
12406 }
12407 var GridItem = (0, import_element38.forwardRef)(
12408 function GridItem2({
12409 view,
12410 selection,
12411 onChangeSelection,
12412 onClickItem,
12413 isItemClickable,
12414 renderItemLink,
12415 getItemId,
12416 item,
12417 actions,
12418 mediaField,
12419 titleField,
12420 descriptionField,
12421 regularFields,
12422 badgeFields,
12423 hasBulkActions,
12424 config,
12425 posinset,
12426 setsize,
12427 ...props
12428 }, forwardedRef) {
12429 const {
12430 showTitle = true,
12431 showMedia = true,
12432 showDescription = true
12433 } = view;
12434 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12435 const id = getItemId(item);
12436 const elementRef = (0, import_element38.useRef)(null);
12437 const setRefs = (0, import_element38.useCallback)(
12438 (node) => {
12439 elementRef.current = node;
12440 if (typeof forwardedRef === "function") {
12441 forwardedRef(node);
12442 } else if (forwardedRef) {
12443 forwardedRef.current = node;
12444 }
12445 },
12446 [forwardedRef]
12447 );
12448 useIntersectionObserver(elementRef, posinset);
12449 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12450 const isSelected2 = selection.includes(id);
12451 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12452 const rendersMediaField = showMedia && mediaField?.render;
12453 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12454 mediaField.render,
12455 {
12456 item,
12457 field: mediaField,
12458 config
12459 }
12460 ) : mediaPlaceholder;
12461 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
12462 let mediaA11yProps;
12463 let titleA11yProps;
12464 if (isItemClickable(item) && onClickItem) {
12465 if (renderedTitleField) {
12466 mediaA11yProps = {
12467 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12468 };
12469 titleA11yProps = {
12470 id: `dataviews-view-grid__title-field-${instanceId}`
12471 };
12472 } else {
12473 mediaA11yProps = {
12474 "aria-label": (0, import_i18n12.__)("Navigate to item")
12475 };
12476 }
12477 }
12478 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12479 Stack,
12480 {
12481 direction: "column",
12482 ...props,
12483 ref: setRefs,
12484 "aria-setsize": setsize,
12485 "aria-posinset": posinset,
12486 className: clsx_default(
12487 props.className,
12488 "dataviews-view-grid__row__gridcell",
12489 "dataviews-view-grid__card",
12490 {
12491 "is-selected": hasBulkAction && isSelected2
12492 }
12493 ),
12494 onClickCapture: (event) => {
12495 props.onClickCapture?.(event);
12496 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12497 event.stopPropagation();
12498 event.preventDefault();
12499 if (!hasBulkAction) {
12500 return;
12501 }
12502 onChangeSelection(
12503 isSelected2 ? selection.filter(
12504 (itemId) => id !== itemId
12505 ) : [...selection, id]
12506 );
12507 }
12508 },
12509 children: [
12510 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12511 ItemClickWrapper,
12512 {
12513 item,
12514 isItemClickable,
12515 onClickItem,
12516 renderItemLink,
12517 className: clsx_default("dataviews-view-grid__media", {
12518 "dataviews-view-grid__media--placeholder": !rendersMediaField
12519 }),
12520 ...mediaA11yProps,
12521 children: renderedMediaField
12522 }
12523 ),
12524 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12525 DataViewsSelectionCheckbox,
12526 {
12527 item,
12528 selection,
12529 onChangeSelection,
12530 getItemId,
12531 titleField,
12532 disabled: !hasBulkAction
12533 }
12534 ),
12535 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12536 ItemActions,
12537 {
12538 item,
12539 actions,
12540 isCompact: true
12541 }
12542 ) }),
12543 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12544 ItemClickWrapper,
12545 {
12546 item,
12547 isItemClickable,
12548 onClickItem,
12549 renderItemLink,
12550 className: "dataviews-view-grid__title-field dataviews-title-field",
12551 ...titleA11yProps,
12552 title: titleField?.getValueFormatted({
12553 item,
12554 field: titleField
12555 }) || void 0,
12556 children: renderedTitleField
12557 }
12558 ) }),
12559 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12560 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12561 descriptionField.render,
12562 {
12563 item,
12564 field: descriptionField
12565 }
12566 ),
12567 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12568 Stack,
12569 {
12570 direction: "row",
12571 className: "dataviews-view-grid__badge-fields",
12572 gap: "sm",
12573 wrap: "wrap",
12574 align: "top",
12575 justify: "flex-start",
12576 children: badgeFields.map((field) => {
12577 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12578 WCBadge,
12579 {
12580 className: "dataviews-view-grid__field-value",
12581 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12582 field.render,
12583 {
12584 item,
12585 field
12586 }
12587 )
12588 },
12589 field.id
12590 );
12591 })
12592 }
12593 ),
12594 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12595 Stack,
12596 {
12597 direction: "column",
12598 className: "dataviews-view-grid__fields",
12599 gap: "xs",
12600 children: regularFields.map((field) => {
12601 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12602 import_components8.Flex,
12603 {
12604 className: "dataviews-view-grid__field",
12605 gap: 1,
12606 justify: "flex-start",
12607 expanded: true,
12608 style: { height: "auto" },
12609 direction: "row",
12610 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
12611 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(tooltip_exports.Root, { children: [
12612 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12613 tooltip_exports.Trigger,
12614 {
12615 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12616 }
12617 ),
12618 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(tooltip_exports.Popup, { children: field.label })
12619 ] }),
12620 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12621 import_components8.FlexItem,
12622 {
12623 className: "dataviews-view-grid__field-value",
12624 style: { maxHeight: "none" },
12625 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12626 field.render,
12627 {
12628 item,
12629 field
12630 }
12631 )
12632 }
12633 )
12634 ] })
12635 },
12636 field.id
12637 );
12638 })
12639 }
12640 )
12641 ] })
12642 ]
12643 }
12644 );
12645 }
12646 );
12647 function CompositeGrid({
12648 data,
12649 isInfiniteScroll,
12650 className,
12651 inert,
12652 isLoading,
12653 view,
12654 fields,
12655 selection,
12656 onChangeSelection,
12657 onClickItem,
12658 isItemClickable,
12659 renderItemLink,
12660 getItemId,
12661 actions
12662 }) {
12663 const { paginationInfo, resizeObserverRef } = (0, import_element38.useContext)(dataviews_context_default);
12664 const gridColumns = useGridColumns();
12665 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12666 const titleField = fields.find(
12667 (field) => field.id === view?.titleField
12668 );
12669 const mediaField = fields.find(
12670 (field) => field.id === view?.mediaField
12671 );
12672 const descriptionField = fields.find(
12673 (field) => field.id === view?.descriptionField
12674 );
12675 const otherFields = view.fields ?? [];
12676 const { regularFields, badgeFields } = otherFields.reduce(
12677 (accumulator, fieldId) => {
12678 const field = fields.find((f2) => f2.id === fieldId);
12679 if (!field) {
12680 return accumulator;
12681 }
12682 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12683 accumulator[key].push(field);
12684 return accumulator;
12685 },
12686 { regularFields: [], badgeFields: [] }
12687 );
12688 const size4 = "900px";
12689 const totalRows = Math.ceil(data.length / gridColumns);
12690 const placeholdersNeeded = usePlaceholdersNeeded(
12691 data,
12692 isInfiniteScroll,
12693 gridColumns
12694 );
12695 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12696 // Render infinite scroll layout (no rows, feed semantics)
12697 children: [
12698 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12699 import_components8.Composite,
12700 {
12701 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12702 GridItems,
12703 {
12704 className: clsx_default(
12705 "dataviews-view-grid-infinite-scroll",
12706 className,
12707 {
12708 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12709 "compact",
12710 "comfortable"
12711 ].includes(view.layout.density)
12712 }
12713 ),
12714 previewSize: view.layout?.previewSize,
12715 "aria-busy": isLoading,
12716 ref: resizeObserverRef
12717 }
12718 ),
12719 role: "feed",
12720 focusWrap: true,
12721 inert,
12722 children: [
12723 Array.from({ length: placeholdersNeeded }).map(
12724 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12725 import_components8.Composite.Item,
12726 {
12727 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12728 Stack,
12729 {
12730 ...props,
12731 direction: "column",
12732 role: "article",
12733 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12734 }
12735 ),
12736 "aria-hidden": true,
12737 tabIndex: -1
12738 },
12739 `placeholder-${index2}`
12740 )
12741 ),
12742 data.map((item) => {
12743 const itemId = getItemId(item);
12744 const stablePosition = item.position;
12745 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12746 import_components8.Composite.Item,
12747 {
12748 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12749 GridItem,
12750 {
12751 ...props,
12752 id: itemId,
12753 role: "article",
12754 view,
12755 selection,
12756 onChangeSelection,
12757 onClickItem,
12758 isItemClickable,
12759 renderItemLink,
12760 getItemId,
12761 item,
12762 actions,
12763 mediaField,
12764 titleField,
12765 descriptionField,
12766 regularFields,
12767 badgeFields,
12768 hasBulkActions,
12769 posinset: stablePosition,
12770 setsize: paginationInfo.totalItems,
12771 config: {
12772 sizes: size4
12773 }
12774 }
12775 )
12776 },
12777 itemId
12778 );
12779 })
12780 ]
12781 }
12782 ),
12783 // Render standard grid layout (with rows, grid semantics)
12784 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12785 import_components8.Composite,
12786 {
12787 role: "grid",
12788 className: clsx_default("dataviews-view-grid", className, {
12789 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12790 view.layout.density
12791 )
12792 }),
12793 focusWrap: true,
12794 "aria-busy": isLoading,
12795 "aria-rowcount": totalRows,
12796 ref: resizeObserverRef,
12797 inert,
12798 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12799 import_components8.Composite.Row,
12800 {
12801 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12802 "div",
12803 {
12804 role: "row",
12805 "aria-rowindex": i2 + 1,
12806 "aria-label": (0, import_i18n12.sprintf)(
12807 /* translators: %d: The row number in the grid */
12808 (0, import_i18n12.__)("Row %d"),
12809 i2 + 1
12810 ),
12811 className: "dataviews-view-grid__row",
12812 style: {
12813 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12814 }
12815 }
12816 ),
12817 children: row.map((item) => {
12818 const itemId = getItemId(item);
12819 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12820 import_components8.Composite.Item,
12821 {
12822 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12823 GridItem,
12824 {
12825 ...props,
12826 id: itemId,
12827 role: "gridcell",
12828 view,
12829 selection,
12830 onChangeSelection,
12831 onClickItem,
12832 isItemClickable,
12833 renderItemLink,
12834 getItemId,
12835 item,
12836 actions,
12837 mediaField,
12838 titleField,
12839 descriptionField,
12840 regularFields,
12841 badgeFields,
12842 hasBulkActions,
12843 config: {
12844 sizes: size4
12845 }
12846 }
12847 )
12848 },
12849 itemId
12850 );
12851 })
12852 },
12853 i2
12854 ))
12855 }
12856 )
12857 ]
12858 });
12859 }
12860
12861 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12862 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12863 function ViewGrid({
12864 actions,
12865 data,
12866 fields,
12867 getItemId,
12868 isLoading,
12869 onChangeSelection,
12870 onClickItem,
12871 isItemClickable,
12872 renderItemLink,
12873 selection,
12874 view,
12875 className,
12876 empty
12877 }) {
12878 const isDelayedLoading = useDelayedLoading(!!isLoading);
12879 const hasData = !!data?.length;
12880 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12881 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12882 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12883 if (!hasData) {
12884 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12885 "div",
12886 {
12887 className: clsx_default("dataviews-no-results", {
12888 "is-refreshing": isDelayedLoading
12889 }),
12890 children: empty
12891 }
12892 );
12893 }
12894 const gridProps = {
12895 className: clsx_default(className, {
12896 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12897 }),
12898 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12899 isLoading,
12900 view,
12901 fields,
12902 selection,
12903 onChangeSelection,
12904 onClickItem,
12905 isItemClickable,
12906 renderItemLink,
12907 getItemId,
12908 actions
12909 };
12910 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, {
12911 // Render multiple groups.
12912 children: [
12913 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12914 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
12915 Stack,
12916 {
12917 direction: "column",
12918 gap: "sm",
12919 children: [
12920 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12921 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12922 (0, import_i18n13.__)("%1$s: %2$s"),
12923 groupField.label,
12924 groupName
12925 ) }),
12926 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12927 CompositeGrid,
12928 {
12929 ...gridProps,
12930 data: groupItems,
12931 isInfiniteScroll: false
12932 }
12933 )
12934 ]
12935 },
12936 groupName
12937 )
12938 ) }),
12939 // Render a single grid with all data.
12940 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
12941 CompositeGrid,
12942 {
12943 ...gridProps,
12944 data,
12945 isInfiniteScroll: !!isInfiniteScroll
12946 }
12947 ),
12948 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components9.Spinner, {}) })
12949 ]
12950 });
12951 }
12952 var grid_default = ViewGrid;
12953
12954 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12955 var import_compose4 = __toESM(require_compose(), 1);
12956 var import_components10 = __toESM(require_components(), 1);
12957 var import_element39 = __toESM(require_element(), 1);
12958 var import_i18n14 = __toESM(require_i18n(), 1);
12959 var import_data3 = __toESM(require_data(), 1);
12960 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
12961 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12962 function generateItemWrapperCompositeId(idPrefix) {
12963 return `${idPrefix}-item-wrapper`;
12964 }
12965 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12966 return `${idPrefix}-primary-action-${primaryActionId}`;
12967 }
12968 function generateDropdownTriggerCompositeId(idPrefix) {
12969 return `${idPrefix}-dropdown`;
12970 }
12971 function PrimaryActionGridCell({
12972 idPrefix,
12973 primaryAction,
12974 item
12975 }) {
12976 const registry = (0, import_data3.useRegistry)();
12977 const [isModalOpen, setIsModalOpen] = (0, import_element39.useState)(false);
12978 const compositeItemId = generatePrimaryActionCompositeId(
12979 idPrefix,
12980 primaryAction.id
12981 );
12982 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12983 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12984 import_components10.Composite.Item,
12985 {
12986 id: compositeItemId,
12987 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12988 import_components10.Button,
12989 {
12990 disabled: !!primaryAction.disabled,
12991 accessibleWhenDisabled: true,
12992 text: label,
12993 size: "small",
12994 onClick: () => setIsModalOpen(true)
12995 }
12996 ),
12997 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
12998 ActionModal,
12999 {
13000 action: primaryAction,
13001 items: [item],
13002 closeModal: () => setIsModalOpen(false)
13003 }
13004 )
13005 }
13006 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13007 import_components10.Composite.Item,
13008 {
13009 id: compositeItemId,
13010 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13011 import_components10.Button,
13012 {
13013 disabled: !!primaryAction.disabled,
13014 accessibleWhenDisabled: true,
13015 size: "small",
13016 onClick: () => {
13017 primaryAction.callback([item], { registry });
13018 },
13019 children: label
13020 }
13021 )
13022 }
13023 ) }, primaryAction.id);
13024 }
13025 function ListItem({
13026 view,
13027 actions,
13028 idPrefix,
13029 isSelected: isSelected2,
13030 item,
13031 titleField,
13032 mediaField,
13033 descriptionField,
13034 onSelect,
13035 otherFields,
13036 onDropdownTriggerKeyDown,
13037 posinset
13038 }) {
13039 const {
13040 showTitle = true,
13041 showMedia = true,
13042 showDescription = true,
13043 infiniteScrollEnabled
13044 } = view;
13045 const itemRef = (0, import_element39.useRef)(null);
13046 const labelId = `${idPrefix}-label`;
13047 const descriptionId = `${idPrefix}-description`;
13048 const registry = (0, import_data3.useRegistry)();
13049 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
13050 const [activeModalAction, setActiveModalAction] = (0, import_element39.useState)(
13051 null
13052 );
13053 const handleHover = ({ type }) => {
13054 const isHover = type === "mouseenter";
13055 setIsHovered(isHover);
13056 };
13057 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
13058 (0, import_element39.useEffect)(() => {
13059 if (isSelected2) {
13060 itemRef.current?.scrollIntoView({
13061 behavior: "auto",
13062 block: "nearest",
13063 inline: "nearest"
13064 });
13065 }
13066 }, [isSelected2]);
13067 const { primaryAction, eligibleActions } = (0, import_element39.useMemo)(() => {
13068 const _eligibleActions = actions.filter(
13069 (action) => !action.isEligible || action.isEligible(item)
13070 );
13071 const _primaryActions = _eligibleActions.filter(
13072 (action) => action.isPrimary
13073 );
13074 return {
13075 primaryAction: _primaryActions[0],
13076 eligibleActions: _eligibleActions
13077 };
13078 }, [actions, item]);
13079 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13080 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)(
13081 mediaField.render,
13082 {
13083 item,
13084 field: mediaField,
13085 config: { sizes: "52px" }
13086 }
13087 ) }) : null;
13088 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
13089 const renderDescription = showDescription && descriptionField?.render;
13090 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13091 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13092 Stack,
13093 {
13094 direction: "row",
13095 gap: "md",
13096 className: "dataviews-view-list__item-actions",
13097 children: [
13098 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13099 PrimaryActionGridCell,
13100 {
13101 idPrefix,
13102 primaryAction,
13103 item
13104 }
13105 ),
13106 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { role: "gridcell", children: [
13107 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Menu3, { placement: "bottom-end", children: [
13108 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13109 Menu3.TriggerButton,
13110 {
13111 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13112 import_components10.Composite.Item,
13113 {
13114 id: generateDropdownTriggerCompositeId(
13115 idPrefix
13116 ),
13117 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13118 import_components10.Button,
13119 {
13120 size: "small",
13121 icon: more_vertical_default,
13122 label: (0, import_i18n14.__)("Actions"),
13123 accessibleWhenDisabled: true,
13124 disabled: !actions.length,
13125 onKeyDown: onDropdownTriggerKeyDown
13126 }
13127 )
13128 }
13129 )
13130 }
13131 ),
13132 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13133 ActionsMenuGroup,
13134 {
13135 actions: eligibleActions,
13136 item,
13137 registry,
13138 setActiveModalAction
13139 }
13140 ) })
13141 ] }),
13142 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13143 ActionModal,
13144 {
13145 action: activeModalAction,
13146 items: [item],
13147 closeModal: () => setActiveModalAction(null)
13148 }
13149 )
13150 ] })
13151 ]
13152 }
13153 );
13154 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13155 import_components10.Composite.Row,
13156 {
13157 ref: itemRef,
13158 render: (
13159 /* aria-posinset breaks Composite.Row if passed to it directly. */
13160 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13161 "div",
13162 {
13163 "aria-posinset": posinset,
13164 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13165 }
13166 )
13167 ),
13168 role: infiniteScrollEnabled ? "article" : "row",
13169 className: clsx_default({
13170 "is-selected": isSelected2,
13171 "is-hovered": isHovered
13172 }),
13173 onMouseEnter: handleHover,
13174 onMouseLeave: handleHover,
13175 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13176 Stack,
13177 {
13178 direction: "row",
13179 className: "dataviews-view-list__item-wrapper",
13180 children: [
13181 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13182 import_components10.Composite.Item,
13183 {
13184 id: generateItemWrapperCompositeId(idPrefix),
13185 "aria-pressed": isSelected2,
13186 "aria-labelledby": labelId,
13187 "aria-describedby": descriptionId,
13188 className: "dataviews-view-list__item",
13189 onClick: () => onSelect(item)
13190 }
13191 ) }),
13192 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13193 Stack,
13194 {
13195 direction: "row",
13196 gap: "md",
13197 justify: "start",
13198 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13199 style: { flex: 1, minWidth: 0 },
13200 children: [
13201 renderedMediaField,
13202 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13203 Stack,
13204 {
13205 direction: "column",
13206 gap: "xs",
13207 className: "dataviews-view-list__field-wrapper",
13208 children: [
13209 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", align: "center", children: [
13210 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13211 "div",
13212 {
13213 className: "dataviews-title-field dataviews-view-list__title-field",
13214 id: labelId,
13215 children: renderedTitleField
13216 }
13217 ),
13218 usedActions
13219 ] }),
13220 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13221 descriptionField.render,
13222 {
13223 item,
13224 field: descriptionField
13225 }
13226 ) }),
13227 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13228 "div",
13229 {
13230 className: "dataviews-view-list__fields",
13231 id: descriptionId,
13232 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13233 "div",
13234 {
13235 className: "dataviews-view-list__field",
13236 children: [
13237 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13238 VisuallyHidden,
13239 {
13240 className: "dataviews-view-list__field-label",
13241 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
13242 children: field.label
13243 }
13244 ),
13245 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13246 field.render,
13247 {
13248 item,
13249 field
13250 }
13251 ) })
13252 ]
13253 },
13254 field.id
13255 ))
13256 }
13257 )
13258 ]
13259 }
13260 )
13261 ]
13262 }
13263 )
13264 ]
13265 }
13266 )
13267 }
13268 );
13269 }
13270 function isDefined2(item) {
13271 return !!item;
13272 }
13273 function ViewList(props) {
13274 const {
13275 actions,
13276 data,
13277 fields,
13278 getItemId,
13279 isLoading,
13280 onChangeSelection,
13281 selection,
13282 view,
13283 className,
13284 empty
13285 } = props;
13286 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13287 const isDelayedLoading = useDelayedLoading(!!isLoading);
13288 const selectedItem = data?.findLast(
13289 (item) => selection.includes(getItemId(item))
13290 );
13291 const titleField = fields.find((field) => field.id === view.titleField);
13292 const mediaField = fields.find((field) => field.id === view.mediaField);
13293 const descriptionField = fields.find(
13294 (field) => field.id === view.descriptionField
13295 );
13296 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13297 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13298 const generateCompositeItemIdPrefix = (0, import_element39.useCallback)(
13299 (item) => `${baseId}-${getItemId(item)}`,
13300 [baseId, getItemId]
13301 );
13302 const isActiveCompositeItem = (0, import_element39.useCallback)(
13303 (item, idToCheck) => {
13304 return idToCheck.startsWith(
13305 generateCompositeItemIdPrefix(item)
13306 );
13307 },
13308 [generateCompositeItemIdPrefix]
13309 );
13310 const [activeCompositeId, setActiveCompositeId] = (0, import_element39.useState)(void 0);
13311 const compositeRef = (0, import_element39.useRef)(null);
13312 (0, import_element39.useEffect)(() => {
13313 if (selectedItem) {
13314 setActiveCompositeId(
13315 generateItemWrapperCompositeId(
13316 generateCompositeItemIdPrefix(selectedItem)
13317 )
13318 );
13319 }
13320 }, [selectedItem, generateCompositeItemIdPrefix]);
13321 const activeItemIndex = data.findIndex(
13322 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13323 );
13324 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13325 const isActiveIdInList = activeItemIndex !== -1;
13326 const selectCompositeItem = (0, import_element39.useCallback)(
13327 (targetIndex, generateCompositeId) => {
13328 const clampedIndex = Math.min(
13329 data.length - 1,
13330 Math.max(0, targetIndex)
13331 );
13332 if (!data[clampedIndex]) {
13333 return;
13334 }
13335 const itemIdPrefix = generateCompositeItemIdPrefix(
13336 data[clampedIndex]
13337 );
13338 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13339 setActiveCompositeId(targetCompositeItemId);
13340 if (compositeRef.current?.contains(
13341 compositeRef.current.ownerDocument.activeElement
13342 )) {
13343 document.getElementById(targetCompositeItemId)?.focus();
13344 }
13345 },
13346 [data, generateCompositeItemIdPrefix]
13347 );
13348 (0, import_element39.useEffect)(() => {
13349 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13350 if (!isActiveIdInList && wasActiveIdInList) {
13351 selectCompositeItem(
13352 previousActiveItemIndex,
13353 generateItemWrapperCompositeId
13354 );
13355 }
13356 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13357 const onDropdownTriggerKeyDown = (0, import_element39.useCallback)(
13358 (event) => {
13359 if (event.key === "ArrowDown") {
13360 event.preventDefault();
13361 selectCompositeItem(
13362 activeItemIndex + 1,
13363 generateDropdownTriggerCompositeId
13364 );
13365 }
13366 if (event.key === "ArrowUp") {
13367 event.preventDefault();
13368 selectCompositeItem(
13369 activeItemIndex - 1,
13370 generateDropdownTriggerCompositeId
13371 );
13372 }
13373 },
13374 [selectCompositeItem, activeItemIndex]
13375 );
13376 const hasData = !!data?.length;
13377 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13378 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13379 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13380 if (!hasData) {
13381 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13382 "div",
13383 {
13384 className: clsx_default("dataviews-no-results", {
13385 "is-refreshing": isDelayedLoading
13386 }),
13387 children: empty
13388 }
13389 );
13390 }
13391 if (hasData && groupField && dataByGroup) {
13392 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13393 import_components10.Composite,
13394 {
13395 ref: compositeRef,
13396 id: `${baseId}`,
13397 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13398 className: "dataviews-view-list__group",
13399 role: "grid",
13400 activeId: activeCompositeId,
13401 setActiveId: setActiveCompositeId,
13402 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13403 Stack,
13404 {
13405 direction: "column",
13406 gap: "lg",
13407 className: clsx_default("dataviews-view-list", className),
13408 children: Array.from(dataByGroup.entries()).map(
13409 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13410 Stack,
13411 {
13412 direction: "column",
13413 gap: "sm",
13414 children: [
13415 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13416 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13417 (0, import_i18n14.__)("%1$s: %2$s"),
13418 groupField.label,
13419 groupName
13420 ) }),
13421 groupItems.map((item) => {
13422 const id = generateCompositeItemIdPrefix(item);
13423 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13424 ListItem,
13425 {
13426 view,
13427 idPrefix: id,
13428 actions,
13429 item,
13430 isSelected: item === selectedItem,
13431 onSelect,
13432 mediaField,
13433 titleField,
13434 descriptionField,
13435 otherFields,
13436 onDropdownTriggerKeyDown
13437 },
13438 id
13439 );
13440 })
13441 ]
13442 },
13443 groupName
13444 )
13445 )
13446 }
13447 )
13448 }
13449 );
13450 }
13451 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
13452 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13453 import_components10.Composite,
13454 {
13455 ref: compositeRef,
13456 id: baseId,
13457 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
13458 className: clsx_default("dataviews-view-list", className, {
13459 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13460 view.layout.density
13461 ),
13462 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13463 }),
13464 role: view.infiniteScrollEnabled ? "feed" : "grid",
13465 activeId: activeCompositeId,
13466 setActiveId: setActiveCompositeId,
13467 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13468 children: data.map((item, index2) => {
13469 const id = generateCompositeItemIdPrefix(item);
13470 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13471 ListItem,
13472 {
13473 view,
13474 idPrefix: id,
13475 actions,
13476 item,
13477 isSelected: item === selectedItem,
13478 onSelect,
13479 mediaField,
13480 titleField,
13481 descriptionField,
13482 otherFields,
13483 onDropdownTriggerKeyDown,
13484 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13485 },
13486 id
13487 );
13488 })
13489 }
13490 ),
13491 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components10.Spinner, {}) })
13492 ] });
13493 }
13494
13495 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13496 var import_components11 = __toESM(require_components(), 1);
13497
13498 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13499 var import_i18n15 = __toESM(require_i18n(), 1);
13500 var import_element40 = __toESM(require_element(), 1);
13501 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13502 function ActivityGroup({
13503 groupName,
13504 groupData,
13505 groupField,
13506 showLabel = true,
13507 children
13508 }) {
13509 const groupHeader = showLabel ? (0, import_element40.createInterpolateElement)(
13510 // translators: %s: The label of the field e.g. "Status".
13511 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13512 {
13513 groupName: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13514 groupField.render,
13515 {
13516 item: groupData[0],
13517 field: groupField
13518 }
13519 )
13520 }
13521 ) : /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(groupField.render, { item: groupData[0], field: groupField });
13522 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13523 Stack,
13524 {
13525 direction: "column",
13526 className: "dataviews-view-activity__group",
13527 children: [
13528 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13529 children
13530 ]
13531 },
13532 groupName
13533 );
13534 }
13535
13536 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13537 var import_element41 = __toESM(require_element(), 1);
13538 var import_data4 = __toESM(require_data(), 1);
13539 var import_compose5 = __toESM(require_compose(), 1);
13540 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13541 function ActivityItem(props) {
13542 const {
13543 view,
13544 actions,
13545 item,
13546 titleField,
13547 mediaField,
13548 descriptionField,
13549 otherFields,
13550 posinset,
13551 onClickItem,
13552 renderItemLink,
13553 isItemClickable
13554 } = props;
13555 const {
13556 showTitle = true,
13557 showMedia = true,
13558 showDescription = true,
13559 infiniteScrollEnabled
13560 } = view;
13561 const itemRef = (0, import_element41.useRef)(null);
13562 const registry = (0, import_data4.useRegistry)();
13563 const { paginationInfo } = (0, import_element41.useContext)(dataviews_context_default);
13564 const { primaryActions, eligibleActions } = (0, import_element41.useMemo)(() => {
13565 const _eligibleActions = actions.filter(
13566 (action) => !action.isEligible || action.isEligible(item)
13567 );
13568 const _primaryActions = _eligibleActions.filter(
13569 (action) => action.isPrimary
13570 );
13571 return {
13572 primaryActions: _primaryActions,
13573 eligibleActions: _eligibleActions
13574 };
13575 }, [actions, item]);
13576 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13577 const density = view.layout?.density ?? "balanced";
13578 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13579 mediaField.render,
13580 {
13581 item,
13582 field: mediaField,
13583 config: {
13584 sizes: density === "comfortable" ? "32px" : "24px"
13585 }
13586 }
13587 ) : null;
13588 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13589 "span",
13590 {
13591 className: "dataviews-view-activity__item-bullet",
13592 "aria-hidden": "true"
13593 }
13594 ) });
13595 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(titleField.render, { item, field: titleField }) : null;
13596 const verticalGap = (0, import_element41.useMemo)(() => {
13597 switch (density) {
13598 case "comfortable":
13599 return "md";
13600 default:
13601 return "sm";
13602 }
13603 }, [density]);
13604 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13605 "div",
13606 {
13607 ref: itemRef,
13608 role: infiniteScrollEnabled ? "article" : void 0,
13609 "aria-posinset": posinset,
13610 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13611 className: clsx_default(
13612 "dataviews-view-activity__item",
13613 density === "compact" && "is-compact",
13614 density === "balanced" && "is-balanced",
13615 density === "comfortable" && "is-comfortable"
13616 ),
13617 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13618 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13619 Stack,
13620 {
13621 direction: "column",
13622 gap: "xs",
13623 align: "center",
13624 className: "dataviews-view-activity__item-type",
13625 children: renderedMediaField
13626 }
13627 ),
13628 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13629 Stack,
13630 {
13631 direction: "column",
13632 gap: verticalGap,
13633 align: "flex-start",
13634 className: "dataviews-view-activity__item-content",
13635 children: [
13636 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13637 ItemClickWrapper,
13638 {
13639 item,
13640 isItemClickable,
13641 onClickItem,
13642 renderItemLink,
13643 className: "dataviews-view-activity__item-title",
13644 children: renderedTitleField
13645 }
13646 ),
13647 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13648 descriptionField.render,
13649 {
13650 item,
13651 field: descriptionField
13652 }
13653 ) }),
13654 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
13655 "div",
13656 {
13657 className: "dataviews-view-activity__item-field",
13658 children: [
13659 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13660 VisuallyHidden,
13661 {
13662 className: "dataviews-view-activity__item-field-label",
13663 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", {}),
13664 children: field.label
13665 }
13666 ),
13667 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13668 field.render,
13669 {
13670 item,
13671 field
13672 }
13673 ) })
13674 ]
13675 },
13676 field.id
13677 )) }),
13678 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13679 PrimaryActions,
13680 {
13681 item,
13682 actions: primaryActions,
13683 registry,
13684 buttonVariant: "secondary"
13685 }
13686 )
13687 ]
13688 }
13689 ),
13690 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13691 // there if there are any actions at all.
13692 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13693 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13694 ItemActions,
13695 {
13696 item,
13697 actions: eligibleActions,
13698 isCompact: true
13699 }
13700 ) })
13701 ] })
13702 }
13703 );
13704 }
13705 var activity_item_default = ActivityItem;
13706
13707 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13708 var import_react10 = __toESM(require_react(), 1);
13709 function isDefined3(item) {
13710 return !!item;
13711 }
13712 function ActivityItems(props) {
13713 const { data, fields, getItemId, view } = props;
13714 const titleField = fields.find((field) => field.id === view.titleField);
13715 const mediaField = fields.find((field) => field.id === view.mediaField);
13716 const descriptionField = fields.find(
13717 (field) => field.id === view.descriptionField
13718 );
13719 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13720 return data.map((item, index2) => {
13721 return /* @__PURE__ */ (0, import_react10.createElement)(
13722 activity_item_default,
13723 {
13724 ...props,
13725 key: getItemId(item),
13726 item,
13727 mediaField,
13728 titleField,
13729 descriptionField,
13730 otherFields,
13731 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13732 }
13733 );
13734 });
13735 }
13736
13737 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13738 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13739 function ViewActivity(props) {
13740 const { empty, data, fields, isLoading, view, className } = props;
13741 const isDelayedLoading = useDelayedLoading(!!isLoading);
13742 const hasData = !!data?.length;
13743 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13744 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13745 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13746 if (!hasData) {
13747 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13748 "div",
13749 {
13750 className: clsx_default("dataviews-no-results", {
13751 "is-refreshing": isDelayedLoading
13752 }),
13753 children: empty
13754 }
13755 );
13756 }
13757 const isInert = !isInfiniteScroll && !!isLoading;
13758 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13759 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13760 });
13761 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13762 if (hasData && groupField && dataByGroup) {
13763 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13764 Stack,
13765 {
13766 direction: "column",
13767 gap: "sm",
13768 className: wrapperClassName,
13769 inert: isInert ? "true" : void 0,
13770 children: groupedEntries.map(
13771 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13772 ActivityGroup,
13773 {
13774 groupName,
13775 groupData,
13776 groupField,
13777 showLabel: view.groupBy?.showLabel !== false,
13778 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13779 ActivityItems,
13780 {
13781 ...props,
13782 data: groupData
13783 }
13784 )
13785 },
13786 groupName
13787 )
13788 )
13789 }
13790 );
13791 }
13792 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
13793 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13794 "div",
13795 {
13796 className: wrapperClassName,
13797 role: view.infiniteScrollEnabled ? "feed" : void 0,
13798 inert: isInert ? "true" : void 0,
13799 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ActivityItems, { ...props })
13800 }
13801 ),
13802 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components11.Spinner, {}) })
13803 ] });
13804 }
13805
13806 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13807 var import_components14 = __toESM(require_components(), 1);
13808 var import_i18n18 = __toESM(require_i18n(), 1);
13809 var import_compose6 = __toESM(require_compose(), 1);
13810 var import_element44 = __toESM(require_element(), 1);
13811
13812 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13813 var import_components13 = __toESM(require_components(), 1);
13814 var import_data5 = __toESM(require_data(), 1);
13815 var import_element43 = __toESM(require_element(), 1);
13816 var import_i18n17 = __toESM(require_i18n(), 1);
13817
13818 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13819 var import_components12 = __toESM(require_components(), 1);
13820 var import_element42 = __toESM(require_element(), 1);
13821 var import_i18n16 = __toESM(require_i18n(), 1);
13822 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13823 function DataViewsPagination() {
13824 const {
13825 view,
13826 onChangeView,
13827 paginationInfo: { totalItems = 0, totalPages }
13828 } = (0, import_element42.useContext)(dataviews_context_default);
13829 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13830 return null;
13831 }
13832 const currentPage = view.page ?? 1;
13833 const pageSelectOptions = Array.from(Array(totalPages)).map(
13834 (_, i2) => {
13835 const page = i2 + 1;
13836 return {
13837 value: page.toString(),
13838 label: page.toString(),
13839 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13840 // translators: 1: current page number. 2: total number of pages.
13841 (0, import_i18n16.__)("Page %1$d of %2$d"),
13842 currentPage,
13843 totalPages
13844 ) : page.toString()
13845 };
13846 }
13847 );
13848 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
13849 Stack,
13850 {
13851 direction: "row",
13852 className: "dataviews-pagination",
13853 justify: "end",
13854 align: "center",
13855 gap: "xl",
13856 children: [
13857 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13858 Stack,
13859 {
13860 direction: "row",
13861 justify: "flex-start",
13862 align: "center",
13863 gap: "xs",
13864 className: "dataviews-pagination__page-select",
13865 children: (0, import_element42.createInterpolateElement)(
13866 (0, import_i18n16.sprintf)(
13867 // translators: 1: Current page number, 2: Total number of pages.
13868 (0, import_i18n16._x)(
13869 "<div>Page</div>%1$s<div>of %2$d</div>",
13870 "paging"
13871 ),
13872 "<CurrentPage />",
13873 totalPages
13874 ),
13875 {
13876 div: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { "aria-hidden": true }),
13877 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13878 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13879 import_components12.SelectControl,
13880 {
13881 "aria-label": (0, import_i18n16.__)("Current page"),
13882 value: currentPage.toString(),
13883 options: pageSelectOptions,
13884 onChange: (newValue) => {
13885 onChangeView({
13886 ...view,
13887 page: +newValue
13888 });
13889 },
13890 size: "small",
13891 variant: "minimal"
13892 }
13893 )
13894 }
13895 )
13896 }
13897 ),
13898 /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13899 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13900 import_components12.Button,
13901 {
13902 onClick: () => onChangeView({
13903 ...view,
13904 page: currentPage - 1
13905 }),
13906 disabled: currentPage === 1,
13907 accessibleWhenDisabled: true,
13908 label: (0, import_i18n16.__)("Previous page"),
13909 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13910 showTooltip: true,
13911 size: "compact",
13912 tooltipPosition: "top"
13913 }
13914 ),
13915 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13916 import_components12.Button,
13917 {
13918 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13919 disabled: currentPage >= totalPages,
13920 accessibleWhenDisabled: true,
13921 label: (0, import_i18n16.__)("Next page"),
13922 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13923 showTooltip: true,
13924 size: "compact",
13925 tooltipPosition: "top"
13926 }
13927 )
13928 ] })
13929 ]
13930 }
13931 );
13932 }
13933 var dataviews_pagination_default = (0, import_element42.memo)(DataViewsPagination);
13934
13935 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13936 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13937 function useIsMultiselectPicker(actions) {
13938 return (0, import_element43.useMemo)(() => {
13939 return actions?.every((action) => action.supportsBulk);
13940 }, [actions]);
13941 }
13942
13943 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13944 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13945 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13946 function GridItem3({
13947 view,
13948 multiselect,
13949 selection,
13950 onChangeSelection,
13951 getItemId,
13952 item,
13953 mediaField,
13954 titleField,
13955 descriptionField,
13956 regularFields,
13957 badgeFields,
13958 config,
13959 posinset,
13960 setsize
13961 }) {
13962 const { showTitle = true, showMedia = true, showDescription = true } = view;
13963 const id = getItemId(item);
13964 const elementRef = (0, import_element44.useRef)(null);
13965 const isSelected2 = selection.includes(id);
13966 useIntersectionObserver(elementRef, posinset);
13967 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13968 mediaField.render,
13969 {
13970 item,
13971 field: mediaField,
13972 config
13973 }
13974 ) : null;
13975 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(titleField.render, { item, field: titleField }) : null;
13976 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
13977 import_components14.Composite.Item,
13978 {
13979 ref: elementRef,
13980 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
13981 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Stack, { direction: "column", children, ...props }),
13982 role: "option",
13983 "aria-posinset": posinset,
13984 "aria-setsize": setsize,
13985 className: clsx_default("dataviews-view-picker-grid__card", {
13986 "is-selected": isSelected2
13987 }),
13988 "aria-selected": isSelected2,
13989 onClick: () => {
13990 if (isSelected2) {
13991 onChangeSelection(
13992 selection.filter((itemId) => id !== itemId)
13993 );
13994 } else {
13995 const newSelection = multiselect ? [...selection, id] : [id];
13996 onChangeSelection(newSelection);
13997 }
13998 },
13999 children: [
14000 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14001 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14002 DataViewsSelectionCheckbox,
14003 {
14004 item,
14005 selection,
14006 onChangeSelection,
14007 getItemId,
14008 titleField,
14009 disabled: false,
14010 "aria-hidden": true,
14011 tabIndex: -1
14012 }
14013 ),
14014 showTitle && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14015 Stack,
14016 {
14017 direction: "row",
14018 justify: "space-between",
14019 className: "dataviews-view-picker-grid__title-actions",
14020 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14021 }
14022 ),
14023 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14024 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14025 descriptionField.render,
14026 {
14027 item,
14028 field: descriptionField
14029 }
14030 ),
14031 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14032 Stack,
14033 {
14034 direction: "row",
14035 className: "dataviews-view-picker-grid__badge-fields",
14036 gap: "sm",
14037 wrap: "wrap",
14038 align: "top",
14039 justify: "flex-start",
14040 children: badgeFields.map((field) => {
14041 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14042 WCBadge2,
14043 {
14044 className: "dataviews-view-picker-grid__field-value",
14045 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14046 field.render,
14047 {
14048 item,
14049 field
14050 }
14051 )
14052 },
14053 field.id
14054 );
14055 })
14056 }
14057 ),
14058 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14059 Stack,
14060 {
14061 direction: "column",
14062 className: "dataviews-view-picker-grid__fields",
14063 gap: "xs",
14064 children: regularFields.map((field) => {
14065 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14066 import_components14.Flex,
14067 {
14068 className: "dataviews-view-picker-grid__field",
14069 gap: 1,
14070 justify: "flex-start",
14071 expanded: true,
14072 style: { height: "auto" },
14073 direction: "row",
14074 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14075 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14076 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14077 import_components14.FlexItem,
14078 {
14079 className: "dataviews-view-picker-grid__field-value",
14080 style: { maxHeight: "none" },
14081 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14082 field.render,
14083 {
14084 item,
14085 field
14086 }
14087 )
14088 }
14089 )
14090 ] })
14091 },
14092 field.id
14093 );
14094 })
14095 }
14096 )
14097 ] })
14098 ]
14099 },
14100 id
14101 );
14102 }
14103 function GridGroup({
14104 groupName,
14105 groupField,
14106 showLabel = true,
14107 children
14108 }) {
14109 const headerId = (0, import_compose6.useInstanceId)(
14110 GridGroup,
14111 "dataviews-view-picker-grid-group__header"
14112 );
14113 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14114 Stack,
14115 {
14116 direction: "column",
14117 gap: "sm",
14118 role: "group",
14119 "aria-labelledby": headerId,
14120 children: [
14121 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14122 "h3",
14123 {
14124 className: "dataviews-view-picker-grid-group__header",
14125 id: headerId,
14126 children: showLabel ? (0, import_i18n18.sprintf)(
14127 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14128 (0, import_i18n18.__)("%1$s: %2$s"),
14129 groupField.label,
14130 groupName
14131 ) : groupName
14132 }
14133 ),
14134 children
14135 ]
14136 },
14137 groupName
14138 );
14139 }
14140 function ViewPickerGrid({
14141 actions,
14142 data,
14143 fields,
14144 getItemId,
14145 isLoading,
14146 onChangeSelection,
14147 selection,
14148 view,
14149 className,
14150 empty
14151 }) {
14152 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element44.useContext)(dataviews_context_default);
14153 const titleField = fields.find(
14154 (field) => field.id === view?.titleField
14155 );
14156 const mediaField = fields.find(
14157 (field) => field.id === view?.mediaField
14158 );
14159 const descriptionField = fields.find(
14160 (field) => field.id === view?.descriptionField
14161 );
14162 const otherFields = view.fields ?? [];
14163 const { regularFields, badgeFields } = otherFields.reduce(
14164 (accumulator, fieldId) => {
14165 const field = fields.find((f2) => f2.id === fieldId);
14166 if (!field) {
14167 return accumulator;
14168 }
14169 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14170 accumulator[key].push(field);
14171 return accumulator;
14172 },
14173 { regularFields: [], badgeFields: [] }
14174 );
14175 const hasData = !!data?.length;
14176 const usedPreviewSize = view.layout?.previewSize;
14177 const isMultiselect = useIsMultiselectPicker(actions);
14178 const size4 = "900px";
14179 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14180 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14181 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14182 const currentPage = view?.page ?? 1;
14183 const perPage = view?.perPage ?? 0;
14184 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14185 const gridColumns = useGridColumns();
14186 const placeholdersNeeded = usePlaceholdersNeeded(
14187 data,
14188 isInfiniteScroll,
14189 gridColumns
14190 );
14191 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, {
14192 // Render multiple groups.
14193 children: [
14194 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14195 import_components14.Composite,
14196 {
14197 virtualFocus: true,
14198 orientation: "horizontal",
14199 role: "listbox",
14200 "aria-multiselectable": isMultiselect,
14201 className: clsx_default(
14202 "dataviews-view-picker-grid",
14203 className,
14204 {
14205 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14206 view.layout.density
14207 )
14208 }
14209 ),
14210 "aria-label": itemListLabel,
14211 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14212 Stack,
14213 {
14214 direction: "column",
14215 gap: "lg",
14216 children,
14217 ...props
14218 }
14219 ),
14220 children: Array.from(dataByGroup.entries()).map(
14221 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14222 GridGroup,
14223 {
14224 groupName,
14225 groupField,
14226 showLabel: view.groupBy?.showLabel !== false,
14227 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14228 GridItems,
14229 {
14230 previewSize: usedPreviewSize,
14231 style: {
14232 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14233 },
14234 "aria-busy": isLoading,
14235 ref: resizeObserverRef,
14236 children: groupItems.map((item) => {
14237 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14238 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14239 GridItem3,
14240 {
14241 view,
14242 multiselect: isMultiselect,
14243 selection,
14244 onChangeSelection,
14245 getItemId,
14246 item,
14247 mediaField,
14248 titleField,
14249 descriptionField,
14250 regularFields,
14251 badgeFields,
14252 config: {
14253 sizes: size4
14254 },
14255 posinset: posInSet,
14256 setsize: setSize
14257 },
14258 getItemId(item)
14259 );
14260 })
14261 }
14262 )
14263 },
14264 groupName
14265 )
14266 )
14267 }
14268 ),
14269 // Render a single grid with all data.
14270 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14271 import_components14.Composite,
14272 {
14273 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14274 GridItems,
14275 {
14276 className: clsx_default(
14277 "dataviews-view-picker-grid",
14278 className,
14279 {
14280 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14281 "compact",
14282 "comfortable"
14283 ].includes(view.layout.density)
14284 }
14285 ),
14286 previewSize: usedPreviewSize,
14287 "aria-busy": isLoading,
14288 ref: resizeObserverRef
14289 }
14290 ),
14291 virtualFocus: true,
14292 orientation: "horizontal",
14293 role: "listbox",
14294 "aria-multiselectable": isMultiselect,
14295 "aria-label": itemListLabel,
14296 children: [
14297 Array.from({ length: placeholdersNeeded }).map(
14298 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14299 import_components14.Composite.Item,
14300 {
14301 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14302 Stack,
14303 {
14304 direction: "column",
14305 children,
14306 ...props
14307 }
14308 ),
14309 role: "option",
14310 "aria-hidden": true,
14311 tabIndex: -1,
14312 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14313 },
14314 `placeholder-${index2}`
14315 )
14316 ),
14317 data.map((item) => {
14318 const posinset = item.position;
14319 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14320 GridItem3,
14321 {
14322 view,
14323 multiselect: isMultiselect,
14324 selection,
14325 onChangeSelection,
14326 getItemId,
14327 item,
14328 mediaField,
14329 titleField,
14330 descriptionField,
14331 regularFields,
14332 badgeFields,
14333 config: {
14334 sizes: size4
14335 },
14336 posinset,
14337 setsize: setSize
14338 },
14339 getItemId(item)
14340 );
14341 })
14342 ]
14343 }
14344 ),
14345 // Render empty state.
14346 !hasData && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14347 "div",
14348 {
14349 className: clsx_default({
14350 "dataviews-loading": isLoading,
14351 "dataviews-no-results": !isLoading
14352 }),
14353 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) }) : empty
14354 }
14355 ),
14356 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components14.Spinner, {}) })
14357 ]
14358 });
14359 }
14360 var picker_grid_default = ViewPickerGrid;
14361
14362 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14363 var import_i18n19 = __toESM(require_i18n(), 1);
14364 var import_components15 = __toESM(require_components(), 1);
14365 var import_element45 = __toESM(require_element(), 1);
14366 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14367 function TableColumnField2({
14368 item,
14369 fields,
14370 column,
14371 align
14372 }) {
14373 const field = fields.find((f2) => f2.id === column);
14374 if (!field) {
14375 return null;
14376 }
14377 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14378 "dataviews-view-table__cell-align-end": align === "end",
14379 "dataviews-view-table__cell-align-center": align === "center"
14380 });
14381 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(field.render, { item, field }) });
14382 }
14383 function TableRow2({
14384 item,
14385 fields,
14386 id,
14387 view,
14388 titleField,
14389 mediaField,
14390 descriptionField,
14391 selection,
14392 getItemId,
14393 onChangeSelection,
14394 multiselect,
14395 posinset
14396 }) {
14397 const { paginationInfo } = (0, import_element45.useContext)(dataviews_context_default);
14398 const isSelected2 = selection.includes(id);
14399 const [isHovered, setIsHovered] = (0, import_element45.useState)(false);
14400 const elementRef = (0, import_element45.useRef)(null);
14401 useIntersectionObserver(elementRef, posinset);
14402 const {
14403 showTitle = true,
14404 showMedia = true,
14405 showDescription = true,
14406 infiniteScrollEnabled
14407 } = view;
14408 const handleMouseEnter = () => {
14409 setIsHovered(true);
14410 };
14411 const handleMouseLeave = () => {
14412 setIsHovered(false);
14413 };
14414 const columns = view.fields ?? [];
14415 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14416 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14417 import_components15.Composite.Item,
14418 {
14419 ref: elementRef,
14420 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14421 "tr",
14422 {
14423 className: clsx_default("dataviews-view-table__row", {
14424 "is-selected": isSelected2,
14425 "is-hovered": isHovered
14426 }),
14427 onMouseEnter: handleMouseEnter,
14428 onMouseLeave: handleMouseLeave,
14429 children,
14430 ...props
14431 }
14432 ),
14433 "aria-selected": isSelected2,
14434 "aria-setsize": paginationInfo.totalItems || void 0,
14435 "aria-posinset": posinset,
14436 role: infiniteScrollEnabled ? "article" : "option",
14437 onMouseDown: (event) => {
14438 if (event.button !== 0) {
14439 return;
14440 }
14441 event.currentTarget.parentElement?.focus({
14442 preventScroll: true
14443 });
14444 },
14445 onClick: () => {
14446 if (isSelected2) {
14447 onChangeSelection(
14448 selection.filter((itemId) => id !== itemId)
14449 );
14450 } else {
14451 const newSelection = multiselect ? [...selection, id] : [id];
14452 onChangeSelection(newSelection);
14453 }
14454 },
14455 children: [
14456 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14457 "td",
14458 {
14459 className: "dataviews-view-table__checkbox-column",
14460 role: "presentation",
14461 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14462 DataViewsSelectionCheckbox,
14463 {
14464 item,
14465 selection,
14466 onChangeSelection,
14467 getItemId,
14468 titleField,
14469 disabled: false,
14470 "aria-hidden": true,
14471 tabIndex: -1
14472 }
14473 ) })
14474 }
14475 ),
14476 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14477 "td",
14478 {
14479 role: "presentation",
14480 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14481 column_primary_default,
14482 {
14483 item,
14484 titleField: showTitle ? titleField : void 0,
14485 mediaField: showMedia ? mediaField : void 0,
14486 descriptionField: showDescription ? descriptionField : void 0,
14487 isItemClickable: () => false
14488 }
14489 )
14490 }
14491 ),
14492 columns.map((column) => {
14493 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14494 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14495 "td",
14496 {
14497 style: {
14498 width,
14499 maxWidth,
14500 minWidth
14501 },
14502 role: "presentation",
14503 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14504 TableColumnField2,
14505 {
14506 fields,
14507 item,
14508 column,
14509 align
14510 }
14511 )
14512 },
14513 column
14514 );
14515 })
14516 ]
14517 },
14518 id
14519 );
14520 }
14521 function ViewPickerTable({
14522 actions,
14523 data,
14524 fields,
14525 getItemId,
14526 isLoading = false,
14527 onChangeView,
14528 onChangeSelection,
14529 selection,
14530 setOpenedFilter,
14531 view,
14532 className,
14533 empty
14534 }) {
14535 const headerMenuRefs = (0, import_element45.useRef)(/* @__PURE__ */ new Map());
14536 const headerMenuToFocusRef = (0, import_element45.useRef)(void 0);
14537 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element45.useState)();
14538 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14539 (0, import_element45.useEffect)(() => {
14540 if (headerMenuToFocusRef.current) {
14541 headerMenuToFocusRef.current.focus();
14542 headerMenuToFocusRef.current = void 0;
14543 }
14544 });
14545 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14546 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14547 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14548 const tableNoticeId = (0, import_element45.useId)();
14549 if (nextHeaderMenuToFocus) {
14550 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14551 setNextHeaderMenuToFocus(void 0);
14552 return;
14553 }
14554 const onHide = (field) => {
14555 const hidden = headerMenuRefs.current.get(field.id);
14556 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14557 setNextHeaderMenuToFocus(fallback?.node);
14558 };
14559 const hasData = !!data?.length;
14560 const titleField = fields.find((field) => field.id === view.titleField);
14561 const mediaField = fields.find((field) => field.id === view.mediaField);
14562 const descriptionField = fields.find(
14563 (field) => field.id === view.descriptionField
14564 );
14565 const { showTitle = true, showMedia = true, showDescription = true } = view;
14566 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14567 const columns = view.fields ?? [];
14568 const headerMenuRef = (column, index2) => (node) => {
14569 if (node) {
14570 headerMenuRefs.current.set(column, {
14571 node,
14572 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14573 });
14574 } else {
14575 headerMenuRefs.current.delete(column);
14576 }
14577 };
14578 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
14579 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14580 "table",
14581 {
14582 className: clsx_default(
14583 "dataviews-view-table",
14584 "dataviews-view-picker-table",
14585 className,
14586 {
14587 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14588 view.layout.density
14589 )
14590 }
14591 ),
14592 "aria-busy": isLoading,
14593 "aria-describedby": tableNoticeId,
14594 role: isInfiniteScroll ? "feed" : "listbox",
14595 children: [
14596 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14597 "tr",
14598 {
14599 className: "dataviews-view-table__row",
14600 role: "presentation",
14601 children: [
14602 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14603 BulkSelectionCheckbox,
14604 {
14605 selection,
14606 onChangeSelection,
14607 data,
14608 actions,
14609 getItemId,
14610 disableSelectAll: isInfiniteScroll
14611 }
14612 ) }),
14613 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14614 column_header_menu_default,
14615 {
14616 ref: headerMenuRef(
14617 titleField.id,
14618 0
14619 ),
14620 fieldId: titleField.id,
14621 view,
14622 fields,
14623 onChangeView,
14624 onHide,
14625 setOpenedFilter,
14626 canMove: false
14627 }
14628 ) }),
14629 columns.map((column, index2) => {
14630 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14631 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14632 "th",
14633 {
14634 style: {
14635 width,
14636 maxWidth,
14637 minWidth,
14638 textAlign: align
14639 },
14640 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14641 scope: "col",
14642 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14643 column_header_menu_default,
14644 {
14645 ref: headerMenuRef(column, index2),
14646 fieldId: column,
14647 view,
14648 fields,
14649 onChangeView,
14650 onHide,
14651 setOpenedFilter,
14652 canMove: view.layout?.enableMoving ?? true
14653 }
14654 )
14655 },
14656 column
14657 );
14658 })
14659 ]
14660 }
14661 ) }),
14662 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14663 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14664 import_components15.Composite,
14665 {
14666 virtualFocus: true,
14667 orientation: "vertical",
14668 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "group" }),
14669 children: [
14670 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14671 "tr",
14672 {
14673 className: "dataviews-view-table__group-header-row",
14674 role: "presentation",
14675 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14676 "td",
14677 {
14678 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14679 className: "dataviews-view-table__group-header-cell",
14680 role: "presentation",
14681 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14682 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14683 (0, import_i18n19.__)("%1$s: %2$s"),
14684 groupField.label,
14685 groupName
14686 )
14687 }
14688 )
14689 }
14690 ),
14691 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14692 TableRow2,
14693 {
14694 item,
14695 fields,
14696 id: getItemId(item) || index2.toString(),
14697 view,
14698 titleField,
14699 mediaField,
14700 descriptionField,
14701 selection,
14702 getItemId,
14703 onChangeSelection,
14704 multiselect: isMultiselect
14705 },
14706 getItemId(item)
14707 ))
14708 ]
14709 },
14710 `group-${groupName}`
14711 )
14712 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14713 import_components15.Composite,
14714 {
14715 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { role: "presentation" }),
14716 virtualFocus: true,
14717 orientation: "vertical",
14718 children: hasData && data.map((item, index2) => {
14719 const itemId = getItemId(item);
14720 const posinset = item.position;
14721 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14722 TableRow2,
14723 {
14724 item,
14725 fields,
14726 id: itemId || index2.toString(),
14727 view,
14728 titleField,
14729 mediaField,
14730 descriptionField,
14731 selection,
14732 getItemId,
14733 onChangeSelection,
14734 multiselect: isMultiselect,
14735 posinset
14736 },
14737 itemId
14738 );
14739 })
14740 }
14741 )
14742 ]
14743 }
14744 ),
14745 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14746 "div",
14747 {
14748 className: clsx_default({
14749 "dataviews-loading": isLoading,
14750 "dataviews-no-results": !hasData && !isLoading
14751 }),
14752 id: tableNoticeId,
14753 children: [
14754 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) }) : empty),
14755 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components15.Spinner, {}) })
14756 ]
14757 }
14758 )
14759 ] });
14760 }
14761 var picker_table_default = ViewPickerTable;
14762
14763 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14764 var import_components16 = __toESM(require_components(), 1);
14765 var import_element46 = __toESM(require_element(), 1);
14766 var import_compose7 = __toESM(require_compose(), 1);
14767 var import_i18n20 = __toESM(require_i18n(), 1);
14768 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
14769 function isDefined4(item) {
14770 return !!item;
14771 }
14772 function PickerActivityItem({
14773 view,
14774 multiselect,
14775 selection,
14776 onChangeSelection,
14777 getItemId,
14778 item,
14779 titleField,
14780 mediaField,
14781 descriptionField,
14782 otherFields,
14783 posinset,
14784 setsize
14785 }) {
14786 const elementRef = (0, import_element46.useRef)(null);
14787 useIntersectionObserver(elementRef, posinset);
14788 const { showTitle = true, showMedia = true, showDescription = true } = view;
14789 const id = getItemId(item);
14790 const isSelected2 = selection.includes(id);
14791 const density = view.layout?.density ?? "balanced";
14792 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14793 mediaField.render,
14794 {
14795 item,
14796 field: mediaField,
14797 config: {
14798 sizes: density === "comfortable" ? "32px" : "24px"
14799 }
14800 }
14801 ) : null;
14802 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14803 "span",
14804 {
14805 className: "dataviews-view-picker-activity__item-bullet",
14806 "aria-hidden": "true"
14807 }
14808 ) });
14809 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(titleField.render, { item, field: titleField }) : null;
14810 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14811 const verticalGap = (0, import_element46.useMemo)(() => {
14812 switch (density) {
14813 case "comfortable":
14814 return "md";
14815 default:
14816 return "sm";
14817 }
14818 }, [density]);
14819 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14820 import_components16.Composite.Item,
14821 {
14822 ref: elementRef,
14823 role: "option",
14824 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14825 "aria-posinset": posinset,
14826 "aria-setsize": setsize,
14827 "aria-selected": isSelected2,
14828 className: clsx_default(
14829 "dataviews-view-picker-activity__item",
14830 density === "compact" && "is-compact",
14831 density === "balanced" && "is-balanced",
14832 density === "comfortable" && "is-comfortable",
14833 isSelected2 && "is-selected"
14834 ),
14835 onClick: () => {
14836 if (isSelected2) {
14837 onChangeSelection(
14838 selection.filter((itemId) => id !== itemId)
14839 );
14840 } else {
14841 const newSelection = multiselect ? [...selection, id] : [id];
14842 onChangeSelection(newSelection);
14843 }
14844 },
14845 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", {}),
14846 children: /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14847 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14848 Stack,
14849 {
14850 direction: "column",
14851 gap: "xs",
14852 align: "center",
14853 className: "dataviews-view-picker-activity__item-type",
14854 children: renderedMediaField
14855 }
14856 ),
14857 /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14858 Stack,
14859 {
14860 direction: "column",
14861 gap: verticalGap,
14862 align: "flex-start",
14863 className: "dataviews-view-picker-activity__item-content",
14864 children: [
14865 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14866 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14867 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14868 "div",
14869 {
14870 className: "dataviews-view-picker-activity__item-field",
14871 children: [
14872 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14873 VisuallyHidden,
14874 {
14875 render: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", {}),
14876 className: "dataviews-view-picker-activity__item-field-label",
14877 children: field.label
14878 }
14879 ),
14880 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14881 field.render,
14882 {
14883 item,
14884 field
14885 }
14886 ) })
14887 ]
14888 },
14889 field.id
14890 )) })
14891 ]
14892 }
14893 )
14894 ] })
14895 }
14896 );
14897 }
14898 function PickerActivityGroup({
14899 groupName,
14900 groupField,
14901 showLabel = true,
14902 children
14903 }) {
14904 const headerId = (0, import_compose7.useInstanceId)(
14905 PickerActivityGroup,
14906 "dataviews-view-picker-activity-group__header"
14907 );
14908 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
14909 Stack,
14910 {
14911 direction: "column",
14912 role: "group",
14913 "aria-labelledby": headerId,
14914 className: "dataviews-view-picker-activity-group",
14915 children: [
14916 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14917 "h3",
14918 {
14919 className: "dataviews-view-picker-activity-group__header",
14920 id: headerId,
14921 children: showLabel ? (0, import_i18n20.sprintf)(
14922 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14923 (0, import_i18n20.__)("%1$s: %2$s"),
14924 groupField.label,
14925 groupName
14926 ) : groupName
14927 }
14928 ),
14929 children
14930 ]
14931 }
14932 );
14933 }
14934 function ViewPickerActivity({
14935 data,
14936 fields,
14937 getItemId,
14938 isLoading,
14939 onChangeSelection,
14940 selection,
14941 view,
14942 actions,
14943 className,
14944 empty
14945 }) {
14946 const { itemListLabel, paginationInfo } = (0, import_element46.useContext)(dataviews_context_default);
14947 const isMultiselect = useIsMultiselectPicker(actions);
14948 const titleField = fields.find(
14949 (field) => field.id === view?.titleField
14950 );
14951 const mediaField = fields.find(
14952 (field) => field.id === view?.mediaField
14953 );
14954 const descriptionField = fields.find(
14955 (field) => field.id === view?.descriptionField
14956 );
14957 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
14958 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14959 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14960 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14961 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14962 const hasData = !!data?.length;
14963 const isGrouped = !!(groupField && dataByGroup);
14964 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14965 PickerActivityItem,
14966 {
14967 view,
14968 multiselect: isMultiselect,
14969 selection,
14970 onChangeSelection,
14971 getItemId,
14972 item,
14973 titleField,
14974 mediaField,
14975 descriptionField,
14976 otherFields,
14977 posinset: item.position,
14978 setsize
14979 },
14980 getItemId(item)
14981 );
14982 if (!hasData) {
14983 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14984 "div",
14985 {
14986 className: clsx_default({
14987 "dataviews-loading": isLoading,
14988 "dataviews-no-results": !isLoading
14989 }),
14990 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) }) : empty
14991 }
14992 );
14993 }
14994 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
14995 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
14996 import_components16.Composite,
14997 {
14998 virtualFocus: true,
14999 orientation: "vertical",
15000 role: "listbox",
15001 "aria-multiselectable": isMultiselect,
15002 "aria-label": itemListLabel,
15003 "aria-busy": isLoading,
15004 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15005 className: clsx_default(
15006 "dataviews-view-picker-activity",
15007 className
15008 ),
15009 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15010 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15011 PickerActivityGroup,
15012 {
15013 groupName,
15014 groupField,
15015 showLabel: view.groupBy?.showLabel !== false,
15016 children: groupItems.map(renderItem)
15017 },
15018 groupName
15019 )
15020 ) : data.map(renderItem)
15021 }
15022 ),
15023 isLoading && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_components16.Spinner, {}) })
15024 ] });
15025 }
15026
15027 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15028 var import_components17 = __toESM(require_components(), 1);
15029 var import_i18n21 = __toESM(require_i18n(), 1);
15030 var import_element47 = __toESM(require_element(), 1);
15031 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15032 function DensityPicker() {
15033 const context = (0, import_element47.useContext)(dataviews_context_default);
15034 const view = context.view;
15035 return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
15036 import_components17.__experimentalToggleGroupControl,
15037 {
15038 size: "__unstable-large",
15039 label: (0, import_i18n21.__)("Density"),
15040 value: view.layout?.density || "balanced",
15041 onChange: (value) => {
15042 context.onChangeView({
15043 ...view,
15044 layout: {
15045 ...view.layout,
15046 density: value
15047 }
15048 });
15049 },
15050 isBlock: true,
15051 children: [
15052 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15053 import_components17.__experimentalToggleGroupControlOption,
15054 {
15055 value: "comfortable",
15056 label: (0, import_i18n21._x)(
15057 "Comfortable",
15058 "Density option for DataView layout"
15059 )
15060 },
15061 "comfortable"
15062 ),
15063 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15064 import_components17.__experimentalToggleGroupControlOption,
15065 {
15066 value: "balanced",
15067 label: (0, import_i18n21._x)("Balanced", "Density option for DataView layout")
15068 },
15069 "balanced"
15070 ),
15071 /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15072 import_components17.__experimentalToggleGroupControlOption,
15073 {
15074 value: "compact",
15075 label: (0, import_i18n21._x)("Compact", "Density option for DataView layout")
15076 },
15077 "compact"
15078 )
15079 ]
15080 }
15081 );
15082 }
15083
15084 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15085 var import_components18 = __toESM(require_components(), 1);
15086 var import_i18n22 = __toESM(require_i18n(), 1);
15087 var import_element48 = __toESM(require_element(), 1);
15088 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15089 var imageSizes2 = [
15090 {
15091 value: 120,
15092 breakpoint: 1
15093 },
15094 {
15095 value: 170,
15096 breakpoint: 1
15097 },
15098 {
15099 value: 230,
15100 breakpoint: 1
15101 },
15102 {
15103 value: 290,
15104 breakpoint: 1112
15105 // at minimum image width, 4 images display at this container size
15106 },
15107 {
15108 value: 350,
15109 breakpoint: 1636
15110 // at minimum image width, 6 images display at this container size
15111 },
15112 {
15113 value: 430,
15114 breakpoint: 588
15115 // at minimum image width, 2 images display at this container size
15116 }
15117 ];
15118 function PreviewSizePicker() {
15119 const context = (0, import_element48.useContext)(dataviews_context_default);
15120 const view = context.view;
15121 const breakValues = imageSizes2.filter((size4) => {
15122 return context.containerWidth >= size4.breakpoint;
15123 });
15124 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15125 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15126 const marks = breakValues.map((size4, index2) => {
15127 return {
15128 value: index2
15129 };
15130 });
15131 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
15132 import_components18.RangeControl,
15133 {
15134 __next40pxDefaultSize: true,
15135 showTooltip: false,
15136 label: (0, import_i18n22.__)("Preview size"),
15137 value: previewSizeToUse,
15138 min: 0,
15139 max: breakValues.length - 1,
15140 withInputField: false,
15141 onChange: (value = 0) => {
15142 context.onChangeView({
15143 ...view,
15144 layout: {
15145 ...view.layout,
15146 previewSize: breakValues[value].value
15147 }
15148 });
15149 },
15150 step: 1,
15151 marks
15152 }
15153 );
15154 }
15155
15156 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15157 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15158 function GridConfigOptions() {
15159 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(import_jsx_runtime71.Fragment, { children: [
15160 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(DensityPicker, {}),
15161 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(PreviewSizePicker, {})
15162 ] });
15163 }
15164
15165 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15166 var VIEW_LAYOUTS = [
15167 {
15168 type: LAYOUT_TABLE,
15169 label: (0, import_i18n23.__)("Table"),
15170 component: table_default,
15171 icon: block_table_default,
15172 viewConfigOptions: DensityPicker
15173 },
15174 {
15175 type: LAYOUT_GRID,
15176 label: (0, import_i18n23.__)("Grid"),
15177 component: grid_default,
15178 icon: category_default,
15179 viewConfigOptions: GridConfigOptions
15180 },
15181 {
15182 type: LAYOUT_LIST,
15183 label: (0, import_i18n23.__)("List"),
15184 component: ViewList,
15185 icon: (0, import_i18n23.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15186 viewConfigOptions: DensityPicker
15187 },
15188 {
15189 type: LAYOUT_ACTIVITY,
15190 label: (0, import_i18n23.__)("Activity"),
15191 component: ViewActivity,
15192 icon: scheduled_default,
15193 viewConfigOptions: DensityPicker
15194 },
15195 {
15196 type: LAYOUT_PICKER_GRID,
15197 label: (0, import_i18n23.__)("Grid"),
15198 component: picker_grid_default,
15199 icon: category_default,
15200 viewConfigOptions: GridConfigOptions,
15201 isPicker: true
15202 },
15203 {
15204 type: LAYOUT_PICKER_TABLE,
15205 label: (0, import_i18n23.__)("Table"),
15206 component: picker_table_default,
15207 icon: block_table_default,
15208 viewConfigOptions: DensityPicker,
15209 isPicker: true
15210 },
15211 {
15212 type: LAYOUT_PICKER_ACTIVITY,
15213 label: (0, import_i18n23.__)("Activity"),
15214 component: ViewPickerActivity,
15215 icon: scheduled_default,
15216 viewConfigOptions: DensityPicker,
15217 isPicker: true
15218 }
15219 ];
15220
15221 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15222 var import_element56 = __toESM(require_element(), 1);
15223
15224 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15225 var import_components21 = __toESM(require_components(), 1);
15226 var import_i18n26 = __toESM(require_i18n(), 1);
15227 var import_element53 = __toESM(require_element(), 1);
15228
15229 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
15230 function noop4(..._) {
15231 }
15232 function applyState(argument, currentValue) {
15233 if (isUpdater(argument)) {
15234 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
15235 return argument(value);
15236 }
15237 return argument;
15238 }
15239 function isUpdater(argument) {
15240 return typeof argument === "function";
15241 }
15242 function isLazyValue(value) {
15243 return typeof value === "function";
15244 }
15245 function hasOwnProperty(object, prop) {
15246 if (typeof Object.hasOwn === "function") {
15247 return Object.hasOwn(object, prop);
15248 }
15249 return Object.prototype.hasOwnProperty.call(object, prop);
15250 }
15251 function chain(...fns) {
15252 return (...args) => {
15253 for (const fn of fns) {
15254 if (typeof fn === "function") {
15255 fn(...args);
15256 }
15257 }
15258 };
15259 }
15260 function normalizeString(str) {
15261 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15262 }
15263 function omit(object, keys) {
15264 const result = { ...object };
15265 for (const key of keys) {
15266 if (hasOwnProperty(result, key)) {
15267 delete result[key];
15268 }
15269 }
15270 return result;
15271 }
15272 function pick(object, paths) {
15273 const result = {};
15274 for (const key of paths) {
15275 if (hasOwnProperty(object, key)) {
15276 result[key] = object[key];
15277 }
15278 }
15279 return result;
15280 }
15281 function identity(value) {
15282 return value;
15283 }
15284 function invariant(condition, message2) {
15285 if (condition) return;
15286 if (typeof message2 !== "string") throw new Error("Invariant failed");
15287 throw new Error(message2);
15288 }
15289 function getKeys(obj) {
15290 return Object.keys(obj);
15291 }
15292 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15293 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15294 if (result == null) return false;
15295 return !result;
15296 }
15297 function disabledFromProps(props) {
15298 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15299 }
15300 function removeUndefinedValues(obj) {
15301 const result = {};
15302 for (const key in obj) {
15303 if (obj[key] !== void 0) {
15304 result[key] = obj[key];
15305 }
15306 }
15307 return result;
15308 }
15309 function defaultValue(...values) {
15310 for (const value of values) {
15311 if (value !== void 0) return value;
15312 }
15313 return void 0;
15314 }
15315
15316 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
15317 var import_react11 = __toESM(require_react(), 1);
15318 function setRef(ref, value) {
15319 if (typeof ref === "function") {
15320 ref(value);
15321 } else if (ref) {
15322 ref.current = value;
15323 }
15324 }
15325 function isValidElementWithRef(element) {
15326 if (!element) return false;
15327 if (!(0, import_react11.isValidElement)(element)) return false;
15328 if ("ref" in element.props) return true;
15329 if ("ref" in element) return true;
15330 return false;
15331 }
15332 function getRefProperty(element) {
15333 if (!isValidElementWithRef(element)) return null;
15334 const props = { ...element.props };
15335 return props.ref || element.ref;
15336 }
15337 function mergeProps2(base, overrides) {
15338 const props = { ...base };
15339 for (const key in overrides) {
15340 if (!hasOwnProperty(overrides, key)) continue;
15341 if (key === "className") {
15342 const prop = "className";
15343 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
15344 continue;
15345 }
15346 if (key === "style") {
15347 const prop = "style";
15348 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
15349 continue;
15350 }
15351 const overrideValue = overrides[key];
15352 if (typeof overrideValue === "function" && key.startsWith("on")) {
15353 const baseValue = base[key];
15354 if (typeof baseValue === "function") {
15355 props[key] = (...args) => {
15356 overrideValue(...args);
15357 baseValue(...args);
15358 };
15359 continue;
15360 }
15361 }
15362 props[key] = overrideValue;
15363 }
15364 return props;
15365 }
15366
15367 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
15368 var canUseDOM = checkIsBrowser();
15369 function checkIsBrowser() {
15370 var _a;
15371 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
15372 }
15373 function getDocument(node) {
15374 if (!node) return document;
15375 if ("self" in node) return node.document;
15376 return node.ownerDocument || document;
15377 }
15378 function getActiveElement(node, activeDescendant = false) {
15379 var _a;
15380 const { activeElement: activeElement2 } = getDocument(node);
15381 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
15382 return null;
15383 }
15384 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
15385 return getActiveElement(
15386 activeElement2.contentDocument.body,
15387 activeDescendant
15388 );
15389 }
15390 if (activeDescendant) {
15391 const id = activeElement2.getAttribute("aria-activedescendant");
15392 if (id) {
15393 const element = getDocument(activeElement2).getElementById(id);
15394 if (element) {
15395 return element;
15396 }
15397 }
15398 }
15399 return activeElement2;
15400 }
15401 function contains2(parent, child) {
15402 return parent === child || parent.contains(child);
15403 }
15404 function isFrame(element) {
15405 return element.tagName === "IFRAME";
15406 }
15407 function isButton(element) {
15408 const tagName = element.tagName.toLowerCase();
15409 if (tagName === "button") return true;
15410 if (tagName === "input" && element.type) {
15411 return buttonInputTypes.indexOf(element.type) !== -1;
15412 }
15413 return false;
15414 }
15415 var buttonInputTypes = [
15416 "button",
15417 "color",
15418 "file",
15419 "image",
15420 "reset",
15421 "submit"
15422 ];
15423 function isVisible(element) {
15424 if (typeof element.checkVisibility === "function") {
15425 return element.checkVisibility();
15426 }
15427 const htmlElement = element;
15428 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15429 }
15430 function isTextField(element) {
15431 try {
15432 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15433 const isTextArea = element.tagName === "TEXTAREA";
15434 return isTextInput || isTextArea || false;
15435 } catch (_error) {
15436 return false;
15437 }
15438 }
15439 function isTextbox(element) {
15440 return element.isContentEditable || isTextField(element);
15441 }
15442 function getTextboxValue(element) {
15443 if (isTextField(element)) {
15444 return element.value;
15445 }
15446 if (element.isContentEditable) {
15447 const range = getDocument(element).createRange();
15448 range.selectNodeContents(element);
15449 return range.toString();
15450 }
15451 return "";
15452 }
15453 function getTextboxSelection(element) {
15454 let start = 0;
15455 let end = 0;
15456 if (isTextField(element)) {
15457 start = element.selectionStart || 0;
15458 end = element.selectionEnd || 0;
15459 } else if (element.isContentEditable) {
15460 const selection = getDocument(element).getSelection();
15461 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15462 const range = selection.getRangeAt(0);
15463 const nextRange = range.cloneRange();
15464 nextRange.selectNodeContents(element);
15465 nextRange.setEnd(range.startContainer, range.startOffset);
15466 start = nextRange.toString().length;
15467 nextRange.setEnd(range.endContainer, range.endOffset);
15468 end = nextRange.toString().length;
15469 }
15470 }
15471 return { start, end };
15472 }
15473 function getPopupRole(element, fallback) {
15474 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
15475 const role = element == null ? void 0 : element.getAttribute("role");
15476 if (role && allowedPopupRoles.indexOf(role) !== -1) {
15477 return role;
15478 }
15479 return fallback;
15480 }
15481 function getScrollingElement(element) {
15482 if (!element) return null;
15483 const isScrollableOverflow = (overflow) => {
15484 if (overflow === "auto") return true;
15485 if (overflow === "scroll") return true;
15486 return false;
15487 };
15488 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15489 const { overflowY } = getComputedStyle(element);
15490 if (isScrollableOverflow(overflowY)) return element;
15491 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15492 const { overflowX } = getComputedStyle(element);
15493 if (isScrollableOverflow(overflowX)) return element;
15494 }
15495 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15496 }
15497 function setSelectionRange(element, ...args) {
15498 if (/text|search|password|tel|url/i.test(element.type)) {
15499 element.setSelectionRange(...args);
15500 }
15501 }
15502 function sortBasedOnDOMPosition(items, getElement) {
15503 const pairs = items.map((item, index2) => [index2, item]);
15504 let isOrderDifferent = false;
15505 pairs.sort(([indexA, a2], [indexB, b2]) => {
15506 const elementA = getElement(a2);
15507 const elementB = getElement(b2);
15508 if (elementA === elementB) return 0;
15509 if (!elementA || !elementB) return 0;
15510 if (isElementPreceding(elementA, elementB)) {
15511 if (indexA > indexB) {
15512 isOrderDifferent = true;
15513 }
15514 return -1;
15515 }
15516 if (indexA < indexB) {
15517 isOrderDifferent = true;
15518 }
15519 return 1;
15520 });
15521 if (isOrderDifferent) {
15522 return pairs.map(([_, item]) => item);
15523 }
15524 return items;
15525 }
15526 function isElementPreceding(a2, b2) {
15527 return Boolean(
15528 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
15529 );
15530 }
15531
15532 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
15533 function isTouchDevice() {
15534 return canUseDOM && !!navigator.maxTouchPoints;
15535 }
15536 function isApple() {
15537 if (!canUseDOM) return false;
15538 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15539 }
15540 function isSafari2() {
15541 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15542 }
15543 function isFirefox2() {
15544 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15545 }
15546
15547 // node_modules/@ariakit/core/esm/utils/events.js
15548 function isPortalEvent(event) {
15549 return Boolean(
15550 event.currentTarget && !contains2(event.currentTarget, event.target)
15551 );
15552 }
15553 function isSelfTarget(event) {
15554 return event.target === event.currentTarget;
15555 }
15556 function isOpeningInNewTab(event) {
15557 const element = event.currentTarget;
15558 if (!element) return false;
15559 const isAppleDevice = isApple();
15560 if (isAppleDevice && !event.metaKey) return false;
15561 if (!isAppleDevice && !event.ctrlKey) return false;
15562 const tagName = element.tagName.toLowerCase();
15563 if (tagName === "a") return true;
15564 if (tagName === "button" && element.type === "submit") return true;
15565 if (tagName === "input" && element.type === "submit") return true;
15566 return false;
15567 }
15568 function isDownloading(event) {
15569 const element = event.currentTarget;
15570 if (!element) return false;
15571 const tagName = element.tagName.toLowerCase();
15572 if (!event.altKey) return false;
15573 if (tagName === "a") return true;
15574 if (tagName === "button" && element.type === "submit") return true;
15575 if (tagName === "input" && element.type === "submit") return true;
15576 return false;
15577 }
15578 function fireBlurEvent(element, eventInit) {
15579 const event = new FocusEvent("blur", eventInit);
15580 const defaultAllowed = element.dispatchEvent(event);
15581 const bubbleInit = { ...eventInit, bubbles: true };
15582 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15583 return defaultAllowed;
15584 }
15585 function fireKeyboardEvent(element, type, eventInit) {
15586 const event = new KeyboardEvent(type, eventInit);
15587 return element.dispatchEvent(event);
15588 }
15589 function fireClickEvent(element, eventInit) {
15590 const event = new MouseEvent("click", eventInit);
15591 return element.dispatchEvent(event);
15592 }
15593 function isFocusEventOutside(event, container) {
15594 const containerElement = container || event.currentTarget;
15595 const relatedTarget = event.relatedTarget;
15596 return !relatedTarget || !contains2(containerElement, relatedTarget);
15597 }
15598 function queueBeforeEvent(element, type, callback, timeout) {
15599 const createTimer = (callback2) => {
15600 if (timeout) {
15601 const timerId2 = setTimeout(callback2, timeout);
15602 return () => clearTimeout(timerId2);
15603 }
15604 const timerId = requestAnimationFrame(callback2);
15605 return () => cancelAnimationFrame(timerId);
15606 };
15607 const cancelTimer = createTimer(() => {
15608 element.removeEventListener(type, callSync, true);
15609 callback();
15610 });
15611 const callSync = () => {
15612 cancelTimer();
15613 callback();
15614 };
15615 element.addEventListener(type, callSync, { once: true, capture: true });
15616 return cancelTimer;
15617 }
15618 function addGlobalEventListener(type, listener, options, scope = window) {
15619 const children = [];
15620 try {
15621 scope.document.addEventListener(type, listener, options);
15622 for (const frame of Array.from(scope.frames)) {
15623 children.push(addGlobalEventListener(type, listener, options, frame));
15624 }
15625 } catch (e2) {
15626 }
15627 const removeEventListener = () => {
15628 try {
15629 scope.document.removeEventListener(type, listener, options);
15630 } catch (e2) {
15631 }
15632 for (const remove of children) {
15633 remove();
15634 }
15635 };
15636 return removeEventListener;
15637 }
15638
15639 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15640 var React47 = __toESM(require_react(), 1);
15641 var import_react12 = __toESM(require_react(), 1);
15642 var _React = { ...React47 };
15643 var useReactId = _React.useId;
15644 var useReactDeferredValue = _React.useDeferredValue;
15645 var useReactInsertionEffect = _React.useInsertionEffect;
15646 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15647 function useInitialValue(value) {
15648 const [initialValue] = (0, import_react12.useState)(value);
15649 return initialValue;
15650 }
15651 function useLiveRef(value) {
15652 const ref = (0, import_react12.useRef)(value);
15653 useSafeLayoutEffect(() => {
15654 ref.current = value;
15655 });
15656 return ref;
15657 }
15658 function useEvent(callback) {
15659 const ref = (0, import_react12.useRef)(() => {
15660 throw new Error("Cannot call an event handler while rendering.");
15661 });
15662 if (useReactInsertionEffect) {
15663 useReactInsertionEffect(() => {
15664 ref.current = callback;
15665 });
15666 } else {
15667 ref.current = callback;
15668 }
15669 return (0, import_react12.useCallback)((...args) => {
15670 var _a;
15671 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15672 }, []);
15673 }
15674 function useTransactionState(callback) {
15675 const [state, setState] = (0, import_react12.useState)(null);
15676 useSafeLayoutEffect(() => {
15677 if (state == null) return;
15678 if (!callback) return;
15679 let prevState = null;
15680 callback((prev) => {
15681 prevState = prev;
15682 return state;
15683 });
15684 return () => {
15685 callback(prevState);
15686 };
15687 }, [state, callback]);
15688 return [state, setState];
15689 }
15690 function useMergeRefs(...refs) {
15691 return (0, import_react12.useMemo)(() => {
15692 if (!refs.some(Boolean)) return;
15693 return (value) => {
15694 for (const ref of refs) {
15695 setRef(ref, value);
15696 }
15697 };
15698 }, refs);
15699 }
15700 function useId4(defaultId) {
15701 if (useReactId) {
15702 const reactId = useReactId();
15703 if (defaultId) return defaultId;
15704 return reactId;
15705 }
15706 const [id, setId] = (0, import_react12.useState)(defaultId);
15707 useSafeLayoutEffect(() => {
15708 if (defaultId || id) return;
15709 const random = Math.random().toString(36).slice(2, 8);
15710 setId(`id-${random}`);
15711 }, [defaultId, id]);
15712 return defaultId || id;
15713 }
15714 function useTagName(refOrElement, type) {
15715 const stringOrUndefined = (type2) => {
15716 if (typeof type2 !== "string") return;
15717 return type2;
15718 };
15719 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15720 useSafeLayoutEffect(() => {
15721 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15722 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15723 }, [refOrElement, type]);
15724 return tagName;
15725 }
15726 function useAttribute(refOrElement, attributeName, defaultValue2) {
15727 const initialValue = useInitialValue(defaultValue2);
15728 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15729 (0, import_react12.useEffect)(() => {
15730 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15731 if (!element) return;
15732 const callback = () => {
15733 const value = element.getAttribute(attributeName);
15734 setAttribute(value == null ? initialValue : value);
15735 };
15736 const observer = new MutationObserver(callback);
15737 observer.observe(element, { attributeFilter: [attributeName] });
15738 callback();
15739 return () => observer.disconnect();
15740 }, [refOrElement, attributeName, initialValue]);
15741 return attribute;
15742 }
15743 function useUpdateEffect(effect, deps) {
15744 const mounted = (0, import_react12.useRef)(false);
15745 (0, import_react12.useEffect)(() => {
15746 if (mounted.current) {
15747 return effect();
15748 }
15749 mounted.current = true;
15750 }, deps);
15751 (0, import_react12.useEffect)(
15752 () => () => {
15753 mounted.current = false;
15754 },
15755 []
15756 );
15757 }
15758 function useUpdateLayoutEffect(effect, deps) {
15759 const mounted = (0, import_react12.useRef)(false);
15760 useSafeLayoutEffect(() => {
15761 if (mounted.current) {
15762 return effect();
15763 }
15764 mounted.current = true;
15765 }, deps);
15766 useSafeLayoutEffect(
15767 () => () => {
15768 mounted.current = false;
15769 },
15770 []
15771 );
15772 }
15773 function useForceUpdate() {
15774 return (0, import_react12.useReducer)(() => [], []);
15775 }
15776 function useBooleanEvent(booleanOrCallback) {
15777 return useEvent(
15778 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15779 );
15780 }
15781 function useWrapElement(props, callback, deps = []) {
15782 const wrapElement = (0, import_react12.useCallback)(
15783 (element) => {
15784 if (props.wrapElement) {
15785 element = props.wrapElement(element);
15786 }
15787 return callback(element);
15788 },
15789 [...deps, props.wrapElement]
15790 );
15791 return { ...props, wrapElement };
15792 }
15793 function useMetadataProps(props, key, value) {
15794 const parent = props.onLoadedMetadataCapture;
15795 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15796 return Object.assign(() => {
15797 }, { ...parent, [key]: value });
15798 }, [parent, key, value]);
15799 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15800 }
15801 var hasInstalledGlobalEventListeners = false;
15802 function useIsMouseMoving() {
15803 (0, import_react12.useEffect)(() => {
15804 if (hasInstalledGlobalEventListeners) return;
15805 addGlobalEventListener("mousemove", setMouseMoving, true);
15806 addGlobalEventListener("mousedown", resetMouseMoving, true);
15807 addGlobalEventListener("mouseup", resetMouseMoving, true);
15808 addGlobalEventListener("keydown", resetMouseMoving, true);
15809 addGlobalEventListener("scroll", resetMouseMoving, true);
15810 hasInstalledGlobalEventListeners = true;
15811 }, []);
15812 const isMouseMoving = useEvent(() => mouseMoving);
15813 return isMouseMoving;
15814 }
15815 var mouseMoving = false;
15816 var previousScreenX = 0;
15817 var previousScreenY = 0;
15818 function hasMouseMovement(event) {
15819 const movementX = event.movementX || event.screenX - previousScreenX;
15820 const movementY = event.movementY || event.screenY - previousScreenY;
15821 previousScreenX = event.screenX;
15822 previousScreenY = event.screenY;
15823 return movementX || movementY || false;
15824 }
15825 function setMouseMoving(event) {
15826 if (!hasMouseMovement(event)) return;
15827 mouseMoving = true;
15828 }
15829 function resetMouseMoving() {
15830 mouseMoving = false;
15831 }
15832
15833 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15834 var React48 = __toESM(require_react(), 1);
15835 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
15836 function forwardRef29(render4) {
15837 const Role = React48.forwardRef(
15838 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15839 (props, ref) => render4({ ...props, ref })
15840 );
15841 Role.displayName = render4.displayName || render4.name;
15842 return Role;
15843 }
15844 function memo22(Component, propsAreEqual) {
15845 return React48.memo(Component, propsAreEqual);
15846 }
15847 function createElement3(Type, props) {
15848 const { wrapElement, render: render4, ...rest } = props;
15849 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15850 let element;
15851 if (React48.isValidElement(render4)) {
15852 const renderProps = {
15853 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15854 ...render4.props,
15855 ref: mergedRef
15856 };
15857 element = React48.cloneElement(render4, mergeProps2(rest, renderProps));
15858 } else if (render4) {
15859 element = render4(rest);
15860 } else {
15861 element = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Type, { ...rest });
15862 }
15863 if (wrapElement) {
15864 return wrapElement(element);
15865 }
15866 return element;
15867 }
15868 function createHook(useProps) {
15869 const useRole = (props = {}) => {
15870 return useProps(props);
15871 };
15872 useRole.displayName = useProps.name;
15873 return useRole;
15874 }
15875 function createStoreContext(providers = [], scopedProviders = []) {
15876 const context = React48.createContext(void 0);
15877 const scopedContext = React48.createContext(void 0);
15878 const useContext210 = () => React48.useContext(context);
15879 const useScopedContext = (onlyScoped = false) => {
15880 const scoped = React48.useContext(scopedContext);
15881 const store = useContext210();
15882 if (onlyScoped) return scoped;
15883 return scoped || store;
15884 };
15885 const useProviderContext = () => {
15886 const scoped = React48.useContext(scopedContext);
15887 const store = useContext210();
15888 if (scoped && scoped === store) return;
15889 return store;
15890 };
15891 const ContextProvider = (props) => {
15892 return providers.reduceRight(
15893 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, { ...props, children }),
15894 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(context.Provider, { ...props })
15895 );
15896 };
15897 const ScopedContextProvider = (props) => {
15898 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15899 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Provider2, { ...props, children }),
15900 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(scopedContext.Provider, { ...props })
15901 ) });
15902 };
15903 return {
15904 context,
15905 scopedContext,
15906 useContext: useContext210,
15907 useScopedContext,
15908 useProviderContext,
15909 ContextProvider,
15910 ScopedContextProvider
15911 };
15912 }
15913
15914 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15915 var ctx = createStoreContext();
15916 var useCollectionContext = ctx.useContext;
15917 var useCollectionScopedContext = ctx.useScopedContext;
15918 var useCollectionProviderContext = ctx.useProviderContext;
15919 var CollectionContextProvider = ctx.ContextProvider;
15920 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15921
15922 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15923 var import_react13 = __toESM(require_react(), 1);
15924 var ctx2 = createStoreContext(
15925 [CollectionContextProvider],
15926 [CollectionScopedContextProvider]
15927 );
15928 var useCompositeContext = ctx2.useContext;
15929 var useCompositeScopedContext = ctx2.useScopedContext;
15930 var useCompositeProviderContext = ctx2.useProviderContext;
15931 var CompositeContextProvider = ctx2.ContextProvider;
15932 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15933 var CompositeItemContext = (0, import_react13.createContext)(
15934 void 0
15935 );
15936 var CompositeRowContext = (0, import_react13.createContext)(
15937 void 0
15938 );
15939
15940 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15941 function findFirstEnabledItem(items, excludeId) {
15942 return items.find((item) => {
15943 if (excludeId) {
15944 return !item.disabled && item.id !== excludeId;
15945 }
15946 return !item.disabled;
15947 });
15948 }
15949 function getEnabledItem(store, id) {
15950 if (!id) return null;
15951 return store.item(id) || null;
15952 }
15953 function groupItemsByRows(items) {
15954 const rows = [];
15955 for (const item of items) {
15956 const row = rows.find((currentRow) => {
15957 var _a;
15958 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15959 });
15960 if (row) {
15961 row.push(item);
15962 } else {
15963 rows.push([item]);
15964 }
15965 }
15966 return rows;
15967 }
15968 function selectTextField(element, collapseToEnd = false) {
15969 if (isTextField(element)) {
15970 element.setSelectionRange(
15971 collapseToEnd ? element.value.length : 0,
15972 element.value.length
15973 );
15974 } else if (element.isContentEditable) {
15975 const selection = getDocument(element).getSelection();
15976 selection == null ? void 0 : selection.selectAllChildren(element);
15977 if (collapseToEnd) {
15978 selection == null ? void 0 : selection.collapseToEnd();
15979 }
15980 }
15981 }
15982 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15983 function focusSilently(element) {
15984 element[FOCUS_SILENTLY] = true;
15985 element.focus({ preventScroll: true });
15986 }
15987 function silentlyFocused(element) {
15988 const isSilentlyFocused = element[FOCUS_SILENTLY];
15989 delete element[FOCUS_SILENTLY];
15990 return isSilentlyFocused;
15991 }
15992 function isItem(store, element, exclude) {
15993 if (!element) return false;
15994 if (element === exclude) return false;
15995 const item = store.item(element.id);
15996 if (!item) return false;
15997 if (exclude && item.element === exclude) return false;
15998 return true;
15999 }
16000
16001 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
16002 var import_react14 = __toESM(require_react(), 1);
16003 var TagName = "div";
16004 var useCollectionItem = createHook(
16005 function useCollectionItem2({
16006 store,
16007 shouldRegisterItem = true,
16008 getItem = identity,
16009 // @ts-expect-error This prop may come from a collection renderer.
16010 element,
16011 ...props
16012 }) {
16013 const context = useCollectionContext();
16014 store = store || context;
16015 const id = useId4(props.id);
16016 const ref = (0, import_react14.useRef)(element);
16017 (0, import_react14.useEffect)(() => {
16018 const element2 = ref.current;
16019 if (!id) return;
16020 if (!element2) return;
16021 if (!shouldRegisterItem) return;
16022 const item = getItem({ id, element: element2 });
16023 return store == null ? void 0 : store.renderItem(item);
16024 }, [id, shouldRegisterItem, getItem, store]);
16025 props = {
16026 ...props,
16027 ref: useMergeRefs(ref, props.ref)
16028 };
16029 return removeUndefinedValues(props);
16030 }
16031 );
16032 var CollectionItem = forwardRef29(function CollectionItem2(props) {
16033 const htmlProps = useCollectionItem(props);
16034 return createElement3(TagName, htmlProps);
16035 });
16036
16037 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
16038 var import_react15 = __toESM(require_react(), 1);
16039 var FocusableContext = (0, import_react15.createContext)(true);
16040
16041 // node_modules/@ariakit/core/esm/utils/focus.js
16042 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'])";
16043 function isFocusable(element) {
16044 if (!element.matches(selector)) return false;
16045 if (!isVisible(element)) return false;
16046 if (element.closest("[inert]")) return false;
16047 return true;
16048 }
16049 function getClosestFocusable(element) {
16050 while (element && !isFocusable(element)) {
16051 element = element.closest(selector);
16052 }
16053 return element || null;
16054 }
16055 function hasFocus(element) {
16056 const activeElement2 = getActiveElement(element);
16057 if (!activeElement2) return false;
16058 if (activeElement2 === element) return true;
16059 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
16060 if (!activeDescendant) return false;
16061 return activeDescendant === element.id;
16062 }
16063 function hasFocusWithin(element) {
16064 const activeElement2 = getActiveElement(element);
16065 if (!activeElement2) return false;
16066 if (contains2(element, activeElement2)) return true;
16067 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
16068 if (!activeDescendant) return false;
16069 if (!("id" in element)) return false;
16070 if (activeDescendant === element.id) return true;
16071 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
16072 }
16073 function focusIfNeeded(element) {
16074 if (!hasFocusWithin(element) && isFocusable(element)) {
16075 element.focus();
16076 }
16077 }
16078 function focusIntoView(element, options) {
16079 if (!("scrollIntoView" in element)) {
16080 element.focus();
16081 } else {
16082 element.focus({ preventScroll: true });
16083 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
16084 }
16085 }
16086
16087 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
16088 var import_react16 = __toESM(require_react(), 1);
16089 var TagName2 = "div";
16090 var isSafariBrowser = isSafari2();
16091 var alwaysFocusVisibleInputTypes = [
16092 "text",
16093 "search",
16094 "url",
16095 "tel",
16096 "email",
16097 "password",
16098 "number",
16099 "date",
16100 "month",
16101 "week",
16102 "time",
16103 "datetime",
16104 "datetime-local"
16105 ];
16106 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
16107 function markSafariFocusAncestor(element, value) {
16108 if (!element) return;
16109 element[safariFocusAncestorSymbol] = value;
16110 }
16111 function isAlwaysFocusVisible(element) {
16112 const { tagName, readOnly, type } = element;
16113 if (tagName === "TEXTAREA" && !readOnly) return true;
16114 if (tagName === "SELECT" && !readOnly) return true;
16115 if (tagName === "INPUT" && !readOnly) {
16116 return alwaysFocusVisibleInputTypes.includes(type);
16117 }
16118 if (element.isContentEditable) return true;
16119 const role = element.getAttribute("role");
16120 if (role === "combobox" && element.dataset.name) {
16121 return true;
16122 }
16123 return false;
16124 }
16125 function getLabels(element) {
16126 if ("labels" in element) {
16127 return element.labels;
16128 }
16129 return null;
16130 }
16131 function isNativeCheckboxOrRadio(element) {
16132 const tagName = element.tagName.toLowerCase();
16133 if (tagName === "input" && element.type) {
16134 return element.type === "radio" || element.type === "checkbox";
16135 }
16136 return false;
16137 }
16138 function isNativeTabbable(tagName) {
16139 if (!tagName) return true;
16140 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
16141 }
16142 function supportsDisabledAttribute(tagName) {
16143 if (!tagName) return true;
16144 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
16145 }
16146 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
16147 if (!focusable2) {
16148 return tabIndexProp;
16149 }
16150 if (trulyDisabled) {
16151 if (nativeTabbable && !supportsDisabled) {
16152 return -1;
16153 }
16154 return;
16155 }
16156 if (nativeTabbable) {
16157 return tabIndexProp;
16158 }
16159 return tabIndexProp || 0;
16160 }
16161 function useDisableEvent(onEvent, disabled2) {
16162 return useEvent((event) => {
16163 onEvent == null ? void 0 : onEvent(event);
16164 if (event.defaultPrevented) return;
16165 if (disabled2) {
16166 event.stopPropagation();
16167 event.preventDefault();
16168 }
16169 });
16170 }
16171 var hasInstalledGlobalEventListeners2 = false;
16172 var isKeyboardModality = true;
16173 function onGlobalMouseDown(event) {
16174 const target = event.target;
16175 if (target && "hasAttribute" in target) {
16176 if (!target.hasAttribute("data-focus-visible")) {
16177 isKeyboardModality = false;
16178 }
16179 }
16180 }
16181 function onGlobalKeyDown(event) {
16182 if (event.metaKey) return;
16183 if (event.ctrlKey) return;
16184 if (event.altKey) return;
16185 isKeyboardModality = true;
16186 }
16187 var useFocusable = createHook(
16188 function useFocusable2({
16189 focusable: focusable2 = true,
16190 accessibleWhenDisabled,
16191 autoFocus,
16192 onFocusVisible,
16193 ...props
16194 }) {
16195 const ref = (0, import_react16.useRef)(null);
16196 (0, import_react16.useEffect)(() => {
16197 if (!focusable2) return;
16198 if (hasInstalledGlobalEventListeners2) return;
16199 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16200 addGlobalEventListener("keydown", onGlobalKeyDown, true);
16201 hasInstalledGlobalEventListeners2 = true;
16202 }, [focusable2]);
16203 if (isSafariBrowser) {
16204 (0, import_react16.useEffect)(() => {
16205 if (!focusable2) return;
16206 const element = ref.current;
16207 if (!element) return;
16208 if (!isNativeCheckboxOrRadio(element)) return;
16209 const labels = getLabels(element);
16210 if (!labels) return;
16211 const onMouseUp = () => queueMicrotask(() => element.focus());
16212 for (const label of labels) {
16213 label.addEventListener("mouseup", onMouseUp);
16214 }
16215 return () => {
16216 for (const label of labels) {
16217 label.removeEventListener("mouseup", onMouseUp);
16218 }
16219 };
16220 }, [focusable2]);
16221 }
16222 const disabled2 = focusable2 && disabledFromProps(props);
16223 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
16224 const [focusVisible, setFocusVisible] = (0, import_react16.useState)(false);
16225 (0, import_react16.useEffect)(() => {
16226 if (!focusable2) return;
16227 if (trulyDisabled && focusVisible) {
16228 setFocusVisible(false);
16229 }
16230 }, [focusable2, trulyDisabled, focusVisible]);
16231 (0, import_react16.useEffect)(() => {
16232 if (!focusable2) return;
16233 if (!focusVisible) return;
16234 const element = ref.current;
16235 if (!element) return;
16236 if (typeof IntersectionObserver === "undefined") return;
16237 const observer = new IntersectionObserver(() => {
16238 if (!isFocusable(element)) {
16239 setFocusVisible(false);
16240 }
16241 });
16242 observer.observe(element);
16243 return () => observer.disconnect();
16244 }, [focusable2, focusVisible]);
16245 const onKeyPressCapture = useDisableEvent(
16246 props.onKeyPressCapture,
16247 disabled2
16248 );
16249 const onMouseDownCapture = useDisableEvent(
16250 props.onMouseDownCapture,
16251 disabled2
16252 );
16253 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16254 const onMouseDownProp = props.onMouseDown;
16255 const onMouseDown = useEvent((event) => {
16256 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
16257 if (event.defaultPrevented) return;
16258 if (!focusable2) return;
16259 const element = event.currentTarget;
16260 if (!isSafariBrowser) return;
16261 if (isPortalEvent(event)) return;
16262 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
16263 let receivedFocus = false;
16264 const onFocus = () => {
16265 receivedFocus = true;
16266 };
16267 const options = { capture: true, once: true };
16268 element.addEventListener("focusin", onFocus, options);
16269 const focusableContainer = getClosestFocusable(element.parentElement);
16270 markSafariFocusAncestor(focusableContainer, true);
16271 queueBeforeEvent(element, "mouseup", () => {
16272 element.removeEventListener("focusin", onFocus, true);
16273 markSafariFocusAncestor(focusableContainer, false);
16274 if (receivedFocus) return;
16275 focusIfNeeded(element);
16276 });
16277 });
16278 const handleFocusVisible = (event, currentTarget) => {
16279 if (currentTarget) {
16280 event.currentTarget = currentTarget;
16281 }
16282 if (!focusable2) return;
16283 const element = event.currentTarget;
16284 if (!element) return;
16285 if (!hasFocus(element)) return;
16286 onFocusVisible == null ? void 0 : onFocusVisible(event);
16287 if (event.defaultPrevented) return;
16288 element.dataset.focusVisible = "true";
16289 setFocusVisible(true);
16290 };
16291 const onKeyDownCaptureProp = props.onKeyDownCapture;
16292 const onKeyDownCapture = useEvent((event) => {
16293 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
16294 if (event.defaultPrevented) return;
16295 if (!focusable2) return;
16296 if (focusVisible) return;
16297 if (event.metaKey) return;
16298 if (event.altKey) return;
16299 if (event.ctrlKey) return;
16300 if (!isSelfTarget(event)) return;
16301 const element = event.currentTarget;
16302 const applyFocusVisible = () => handleFocusVisible(event, element);
16303 queueBeforeEvent(element, "focusout", applyFocusVisible);
16304 });
16305 const onFocusCaptureProp = props.onFocusCapture;
16306 const onFocusCapture = useEvent((event) => {
16307 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16308 if (event.defaultPrevented) return;
16309 if (!focusable2) return;
16310 if (!isSelfTarget(event)) {
16311 setFocusVisible(false);
16312 return;
16313 }
16314 const element = event.currentTarget;
16315 const applyFocusVisible = () => handleFocusVisible(event, element);
16316 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
16317 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16318 } else {
16319 setFocusVisible(false);
16320 }
16321 });
16322 const onBlurProp = props.onBlur;
16323 const onBlur = useEvent((event) => {
16324 onBlurProp == null ? void 0 : onBlurProp(event);
16325 if (!focusable2) return;
16326 if (!isFocusEventOutside(event)) return;
16327 event.currentTarget.removeAttribute("data-focus-visible");
16328 setFocusVisible(false);
16329 });
16330 const autoFocusOnShow = (0, import_react16.useContext)(FocusableContext);
16331 const autoFocusRef = useEvent((element) => {
16332 if (!focusable2) return;
16333 if (!autoFocus) return;
16334 if (!element) return;
16335 if (!autoFocusOnShow) return;
16336 queueMicrotask(() => {
16337 if (hasFocus(element)) return;
16338 if (!isFocusable(element)) return;
16339 element.focus();
16340 });
16341 });
16342 const tagName = useTagName(ref);
16343 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16344 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16345 const styleProp = props.style;
16346 const style = (0, import_react16.useMemo)(() => {
16347 if (trulyDisabled) {
16348 return { pointerEvents: "none", ...styleProp };
16349 }
16350 return styleProp;
16351 }, [trulyDisabled, styleProp]);
16352 props = {
16353 "data-focus-visible": focusable2 && focusVisible || void 0,
16354 "data-autofocus": autoFocus || void 0,
16355 "aria-disabled": disabled2 || void 0,
16356 ...props,
16357 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16358 style,
16359 tabIndex: getTabIndex2(
16360 focusable2,
16361 trulyDisabled,
16362 nativeTabbable,
16363 supportsDisabled,
16364 props.tabIndex
16365 ),
16366 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16367 // TODO: Test Focusable contentEditable.
16368 contentEditable: disabled2 ? void 0 : props.contentEditable,
16369 onKeyPressCapture,
16370 onClickCapture,
16371 onMouseDownCapture,
16372 onMouseDown,
16373 onKeyDownCapture,
16374 onFocusCapture,
16375 onBlur
16376 };
16377 return removeUndefinedValues(props);
16378 }
16379 );
16380 var Focusable = forwardRef29(function Focusable2(props) {
16381 const htmlProps = useFocusable(props);
16382 return createElement3(TagName2, htmlProps);
16383 });
16384
16385 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
16386 var import_react17 = __toESM(require_react(), 1);
16387 var TagName3 = "button";
16388 function isNativeClick(event) {
16389 if (!event.isTrusted) return false;
16390 const element = event.currentTarget;
16391 if (event.key === "Enter") {
16392 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16393 }
16394 if (event.key === " ") {
16395 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16396 }
16397 return false;
16398 }
16399 var symbol = /* @__PURE__ */ Symbol("command");
16400 var useCommand = createHook(
16401 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16402 const ref = (0, import_react17.useRef)(null);
16403 const [isNativeButton, setIsNativeButton] = (0, import_react17.useState)(false);
16404 (0, import_react17.useEffect)(() => {
16405 if (!ref.current) return;
16406 setIsNativeButton(isButton(ref.current));
16407 }, []);
16408 const [active, setActive] = (0, import_react17.useState)(false);
16409 const activeRef = (0, import_react17.useRef)(false);
16410 const disabled2 = disabledFromProps(props);
16411 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16412 const onKeyDownProp = props.onKeyDown;
16413 const onKeyDown = useEvent((event) => {
16414 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16415 const element = event.currentTarget;
16416 if (event.defaultPrevented) return;
16417 if (isDuplicate) return;
16418 if (disabled2) return;
16419 if (!isSelfTarget(event)) return;
16420 if (isTextField(element)) return;
16421 if (element.isContentEditable) return;
16422 const isEnter = clickOnEnter && event.key === "Enter";
16423 const isSpace = clickOnSpace && event.key === " ";
16424 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16425 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16426 if (shouldPreventEnter || shouldPreventSpace) {
16427 event.preventDefault();
16428 return;
16429 }
16430 if (isEnter || isSpace) {
16431 const nativeClick = isNativeClick(event);
16432 if (isEnter) {
16433 if (!nativeClick) {
16434 event.preventDefault();
16435 const { view, ...eventInit } = event;
16436 const click = () => fireClickEvent(element, eventInit);
16437 if (isFirefox2()) {
16438 queueBeforeEvent(element, "keyup", click);
16439 } else {
16440 queueMicrotask(click);
16441 }
16442 }
16443 } else if (isSpace) {
16444 activeRef.current = true;
16445 if (!nativeClick) {
16446 event.preventDefault();
16447 setActive(true);
16448 }
16449 }
16450 }
16451 });
16452 const onKeyUpProp = props.onKeyUp;
16453 const onKeyUp = useEvent((event) => {
16454 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
16455 if (event.defaultPrevented) return;
16456 if (isDuplicate) return;
16457 if (disabled2) return;
16458 if (event.metaKey) return;
16459 const isSpace = clickOnSpace && event.key === " ";
16460 if (activeRef.current && isSpace) {
16461 activeRef.current = false;
16462 if (!isNativeClick(event)) {
16463 event.preventDefault();
16464 setActive(false);
16465 const element = event.currentTarget;
16466 const { view, ...eventInit } = event;
16467 queueMicrotask(() => fireClickEvent(element, eventInit));
16468 }
16469 }
16470 });
16471 props = {
16472 "data-active": active || void 0,
16473 type: isNativeButton ? "button" : void 0,
16474 ...metadataProps,
16475 ...props,
16476 ref: useMergeRefs(ref, props.ref),
16477 onKeyDown,
16478 onKeyUp
16479 };
16480 props = useFocusable(props);
16481 return props;
16482 }
16483 );
16484 var Command = forwardRef29(function Command2(props) {
16485 const htmlProps = useCommand(props);
16486 return createElement3(TagName3, htmlProps);
16487 });
16488
16489 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
16490 function getInternal(store, key) {
16491 const internals = store.__unstableInternals;
16492 invariant(internals, "Invalid store");
16493 return internals[key];
16494 }
16495 function createStore(initialState, ...stores) {
16496 let state = initialState;
16497 let prevStateBatch = state;
16498 let lastUpdate = /* @__PURE__ */ Symbol();
16499 let destroy = noop4;
16500 const instances = /* @__PURE__ */ new Set();
16501 const updatedKeys = /* @__PURE__ */ new Set();
16502 const setups = /* @__PURE__ */ new Set();
16503 const listeners = /* @__PURE__ */ new Set();
16504 const batchListeners = /* @__PURE__ */ new Set();
16505 const disposables = /* @__PURE__ */ new WeakMap();
16506 const listenerKeys = /* @__PURE__ */ new WeakMap();
16507 const storeSetup = (callback) => {
16508 setups.add(callback);
16509 return () => setups.delete(callback);
16510 };
16511 const storeInit = () => {
16512 const initialized = instances.size;
16513 const instance = /* @__PURE__ */ Symbol();
16514 instances.add(instance);
16515 const maybeDestroy = () => {
16516 instances.delete(instance);
16517 if (instances.size) return;
16518 destroy();
16519 };
16520 if (initialized) return maybeDestroy;
16521 const desyncs = getKeys(state).map(
16522 (key) => chain(
16523 ...stores.map((store) => {
16524 var _a;
16525 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
16526 if (!storeState) return;
16527 if (!hasOwnProperty(storeState, key)) return;
16528 return sync(store, [key], (state2) => {
16529 setState(
16530 key,
16531 state2[key],
16532 // @ts-expect-error - Not public API. This is just to prevent
16533 // infinite loops.
16534 true
16535 );
16536 });
16537 })
16538 )
16539 );
16540 const teardowns = [];
16541 for (const setup2 of setups) {
16542 teardowns.push(setup2());
16543 }
16544 const cleanups = stores.map(init);
16545 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16546 return maybeDestroy;
16547 };
16548 const sub = (keys, listener, set2 = listeners) => {
16549 set2.add(listener);
16550 listenerKeys.set(listener, keys);
16551 return () => {
16552 var _a;
16553 (_a = disposables.get(listener)) == null ? void 0 : _a();
16554 disposables.delete(listener);
16555 listenerKeys.delete(listener);
16556 set2.delete(listener);
16557 };
16558 };
16559 const storeSubscribe = (keys, listener) => sub(keys, listener);
16560 const storeSync = (keys, listener) => {
16561 disposables.set(listener, listener(state, state));
16562 return sub(keys, listener);
16563 };
16564 const storeBatch = (keys, listener) => {
16565 disposables.set(listener, listener(state, prevStateBatch));
16566 return sub(keys, listener, batchListeners);
16567 };
16568 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16569 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16570 const getState = () => state;
16571 const setState = (key, value, fromStores = false) => {
16572 var _a;
16573 if (!hasOwnProperty(state, key)) return;
16574 const nextValue = applyState(value, state[key]);
16575 if (nextValue === state[key]) return;
16576 if (!fromStores) {
16577 for (const store of stores) {
16578 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
16579 }
16580 }
16581 const prevState = state;
16582 state = { ...state, [key]: nextValue };
16583 const thisUpdate = /* @__PURE__ */ Symbol();
16584 lastUpdate = thisUpdate;
16585 updatedKeys.add(key);
16586 const run = (listener, prev, uKeys) => {
16587 var _a2;
16588 const keys = listenerKeys.get(listener);
16589 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
16590 if (!keys || keys.some(updated)) {
16591 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
16592 disposables.set(listener, listener(state, prev));
16593 }
16594 };
16595 for (const listener of listeners) {
16596 run(listener, prevState);
16597 }
16598 queueMicrotask(() => {
16599 if (lastUpdate !== thisUpdate) return;
16600 const snapshot = state;
16601 for (const listener of batchListeners) {
16602 run(listener, prevStateBatch, updatedKeys);
16603 }
16604 prevStateBatch = snapshot;
16605 updatedKeys.clear();
16606 });
16607 };
16608 const finalStore = {
16609 getState,
16610 setState,
16611 __unstableInternals: {
16612 setup: storeSetup,
16613 init: storeInit,
16614 subscribe: storeSubscribe,
16615 sync: storeSync,
16616 batch: storeBatch,
16617 pick: storePick,
16618 omit: storeOmit
16619 }
16620 };
16621 return finalStore;
16622 }
16623 function setup(store, ...args) {
16624 if (!store) return;
16625 return getInternal(store, "setup")(...args);
16626 }
16627 function init(store, ...args) {
16628 if (!store) return;
16629 return getInternal(store, "init")(...args);
16630 }
16631 function subscribe(store, ...args) {
16632 if (!store) return;
16633 return getInternal(store, "subscribe")(...args);
16634 }
16635 function sync(store, ...args) {
16636 if (!store) return;
16637 return getInternal(store, "sync")(...args);
16638 }
16639 function batch(store, ...args) {
16640 if (!store) return;
16641 return getInternal(store, "batch")(...args);
16642 }
16643 function omit2(store, ...args) {
16644 if (!store) return;
16645 return getInternal(store, "omit")(...args);
16646 }
16647 function pick2(store, ...args) {
16648 if (!store) return;
16649 return getInternal(store, "pick")(...args);
16650 }
16651 function mergeStore(...stores) {
16652 var _a;
16653 const initialState = {};
16654 for (const store2 of stores) {
16655 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16656 if (nextState) {
16657 Object.assign(initialState, nextState);
16658 }
16659 }
16660 const store = createStore(initialState, ...stores);
16661 return Object.assign({}, ...stores, store);
16662 }
16663 function throwOnConflictingProps(props, store) {
16664 if (false) return;
16665 if (!store) return;
16666 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16667 var _a;
16668 const stateKey = key.replace("default", "");
16669 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16670 });
16671 if (!defaultKeys.length) return;
16672 const storeState = store.getState();
16673 const conflictingProps = defaultKeys.filter(
16674 (key) => hasOwnProperty(storeState, key)
16675 );
16676 if (!conflictingProps.length) return;
16677 throw new Error(
16678 `Passing a store prop in conjunction with a default state is not supported.
16679
16680 const store = useSelectStore();
16681 <SelectProvider store={store} defaultValue="Apple" />
16682 ^ ^
16683
16684 Instead, pass the default state to the topmost store:
16685
16686 const store = useSelectStore({ defaultValue: "Apple" });
16687 <SelectProvider store={store} />
16688
16689 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16690
16691 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16692 `
16693 );
16694 }
16695
16696 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16697 var React49 = __toESM(require_react(), 1);
16698 var import_shim2 = __toESM(require_shim(), 1);
16699 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16700 var noopSubscribe = () => () => {
16701 };
16702 function useStoreState(store, keyOrSelector = identity) {
16703 const storeSubscribe = React49.useCallback(
16704 (callback) => {
16705 if (!store) return noopSubscribe();
16706 return subscribe(store, null, callback);
16707 },
16708 [store]
16709 );
16710 const getSnapshot = () => {
16711 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16712 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16713 const state = store == null ? void 0 : store.getState();
16714 if (selector2) return selector2(state);
16715 if (!state) return;
16716 if (!key) return;
16717 if (!hasOwnProperty(state, key)) return;
16718 return state[key];
16719 };
16720 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16721 }
16722 function useStoreStateObject(store, object) {
16723 const objRef = React49.useRef(
16724 {}
16725 );
16726 const storeSubscribe = React49.useCallback(
16727 (callback) => {
16728 if (!store) return noopSubscribe();
16729 return subscribe(store, null, callback);
16730 },
16731 [store]
16732 );
16733 const getSnapshot = () => {
16734 const state = store == null ? void 0 : store.getState();
16735 let updated = false;
16736 const obj = objRef.current;
16737 for (const prop in object) {
16738 const keyOrSelector = object[prop];
16739 if (typeof keyOrSelector === "function") {
16740 const value = keyOrSelector(state);
16741 if (value !== obj[prop]) {
16742 obj[prop] = value;
16743 updated = true;
16744 }
16745 }
16746 if (typeof keyOrSelector === "string") {
16747 if (!state) continue;
16748 if (!hasOwnProperty(state, keyOrSelector)) continue;
16749 const value = state[keyOrSelector];
16750 if (value !== obj[prop]) {
16751 obj[prop] = value;
16752 updated = true;
16753 }
16754 }
16755 }
16756 if (updated) {
16757 objRef.current = { ...obj };
16758 }
16759 return objRef.current;
16760 };
16761 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16762 }
16763 function useStoreProps(store, props, key, setKey) {
16764 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16765 const setValue = setKey ? props[setKey] : void 0;
16766 const propsRef = useLiveRef({ value, setValue });
16767 useSafeLayoutEffect(() => {
16768 return sync(store, [key], (state, prev) => {
16769 const { value: value2, setValue: setValue2 } = propsRef.current;
16770 if (!setValue2) return;
16771 if (state[key] === prev[key]) return;
16772 if (state[key] === value2) return;
16773 setValue2(state[key]);
16774 });
16775 }, [store, key]);
16776 useSafeLayoutEffect(() => {
16777 if (value === void 0) return;
16778 store.setState(key, value);
16779 return batch(store, [key], () => {
16780 if (value === void 0) return;
16781 store.setState(key, value);
16782 });
16783 });
16784 }
16785 function useStore2(createStore2, props) {
16786 const [store, setStore] = React49.useState(() => createStore2(props));
16787 useSafeLayoutEffect(() => init(store), [store]);
16788 const useState210 = React49.useCallback(
16789 (keyOrSelector) => useStoreState(store, keyOrSelector),
16790 [store]
16791 );
16792 const memoizedStore = React49.useMemo(
16793 () => ({ ...store, useState: useState210 }),
16794 [store, useState210]
16795 );
16796 const updateStore = useEvent(() => {
16797 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16798 });
16799 return [memoizedStore, updateStore];
16800 }
16801
16802 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16803 var import_react18 = __toESM(require_react(), 1);
16804 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
16805 var TagName4 = "button";
16806 function isEditableElement(element) {
16807 if (isTextbox(element)) return true;
16808 return element.tagName === "INPUT" && !isButton(element);
16809 }
16810 function getNextPageOffset(scrollingElement, pageUp = false) {
16811 const height = scrollingElement.clientHeight;
16812 const { top } = scrollingElement.getBoundingClientRect();
16813 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16814 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16815 if (scrollingElement.tagName === "HTML") {
16816 return pageOffset + scrollingElement.scrollTop;
16817 }
16818 return pageOffset;
16819 }
16820 function getItemOffset(itemElement, pageUp = false) {
16821 const { top } = itemElement.getBoundingClientRect();
16822 if (pageUp) {
16823 return top + itemElement.clientHeight;
16824 }
16825 return top;
16826 }
16827 function findNextPageItemId(element, store, next, pageUp = false) {
16828 var _a;
16829 if (!store) return;
16830 if (!next) return;
16831 const { renderedItems } = store.getState();
16832 const scrollingElement = getScrollingElement(element);
16833 if (!scrollingElement) return;
16834 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16835 let id;
16836 let prevDifference;
16837 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16838 const previousId = id;
16839 id = next(i2);
16840 if (!id) break;
16841 if (id === previousId) continue;
16842 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16843 if (!itemElement) continue;
16844 const itemOffset = getItemOffset(itemElement, pageUp);
16845 const difference = itemOffset - nextPageOffset;
16846 const absDifference = Math.abs(difference);
16847 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16848 if (prevDifference !== void 0 && prevDifference < absDifference) {
16849 id = previousId;
16850 }
16851 break;
16852 }
16853 prevDifference = absDifference;
16854 }
16855 return id;
16856 }
16857 function targetIsAnotherItem(event, store) {
16858 if (isSelfTarget(event)) return false;
16859 return isItem(store, event.target);
16860 }
16861 var useCompositeItem = createHook(
16862 function useCompositeItem2({
16863 store,
16864 rowId: rowIdProp,
16865 preventScrollOnKeyDown = false,
16866 moveOnKeyPress = true,
16867 tabbable: tabbable2 = false,
16868 getItem: getItemProp,
16869 "aria-setsize": ariaSetSizeProp,
16870 "aria-posinset": ariaPosInSetProp,
16871 ...props
16872 }) {
16873 const context = useCompositeContext();
16874 store = store || context;
16875 const id = useId4(props.id);
16876 const ref = (0, import_react18.useRef)(null);
16877 const row = (0, import_react18.useContext)(CompositeRowContext);
16878 const disabled2 = disabledFromProps(props);
16879 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16880 const {
16881 rowId,
16882 baseElement,
16883 isActiveItem,
16884 ariaSetSize,
16885 ariaPosInSet,
16886 isTabbable
16887 } = useStoreStateObject(store, {
16888 rowId(state) {
16889 if (rowIdProp) return rowIdProp;
16890 if (!state) return;
16891 if (!(row == null ? void 0 : row.baseElement)) return;
16892 if (row.baseElement !== state.baseElement) return;
16893 return row.id;
16894 },
16895 baseElement(state) {
16896 return (state == null ? void 0 : state.baseElement) || void 0;
16897 },
16898 isActiveItem(state) {
16899 return !!state && state.activeId === id;
16900 },
16901 ariaSetSize(state) {
16902 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16903 if (!state) return;
16904 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16905 if (row.baseElement !== state.baseElement) return;
16906 return row.ariaSetSize;
16907 },
16908 ariaPosInSet(state) {
16909 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16910 if (!state) return;
16911 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16912 if (row.baseElement !== state.baseElement) return;
16913 const itemsInRow = state.renderedItems.filter(
16914 (item) => item.rowId === rowId
16915 );
16916 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16917 },
16918 isTabbable(state) {
16919 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16920 if (state.virtualFocus) return false;
16921 if (tabbable2) return true;
16922 if (state.activeId === null) return false;
16923 const item = store == null ? void 0 : store.item(state.activeId);
16924 if (item == null ? void 0 : item.disabled) return true;
16925 if (!(item == null ? void 0 : item.element)) return true;
16926 return state.activeId === id;
16927 }
16928 });
16929 const getItem = (0, import_react18.useCallback)(
16930 (item) => {
16931 var _a;
16932 const nextItem = {
16933 ...item,
16934 id: id || item.id,
16935 rowId,
16936 disabled: !!trulyDisabled,
16937 children: (_a = item.element) == null ? void 0 : _a.textContent
16938 };
16939 if (getItemProp) {
16940 return getItemProp(nextItem);
16941 }
16942 return nextItem;
16943 },
16944 [id, rowId, trulyDisabled, getItemProp]
16945 );
16946 const onFocusProp = props.onFocus;
16947 const hasFocusedComposite = (0, import_react18.useRef)(false);
16948 const onFocus = useEvent((event) => {
16949 onFocusProp == null ? void 0 : onFocusProp(event);
16950 if (event.defaultPrevented) return;
16951 if (isPortalEvent(event)) return;
16952 if (!id) return;
16953 if (!store) return;
16954 if (targetIsAnotherItem(event, store)) return;
16955 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16956 store.setActiveId(id);
16957 if (isTextbox(event.currentTarget)) {
16958 selectTextField(event.currentTarget);
16959 }
16960 if (!virtualFocus) return;
16961 if (!isSelfTarget(event)) return;
16962 if (isEditableElement(event.currentTarget)) return;
16963 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16964 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16965 event.currentTarget.scrollIntoView({
16966 block: "nearest",
16967 inline: "nearest"
16968 });
16969 }
16970 hasFocusedComposite.current = true;
16971 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16972 if (fromComposite) {
16973 focusSilently(baseElement2);
16974 } else {
16975 baseElement2.focus();
16976 }
16977 });
16978 const onBlurCaptureProp = props.onBlurCapture;
16979 const onBlurCapture = useEvent((event) => {
16980 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16981 if (event.defaultPrevented) return;
16982 const state = store == null ? void 0 : store.getState();
16983 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16984 hasFocusedComposite.current = false;
16985 event.preventDefault();
16986 event.stopPropagation();
16987 }
16988 });
16989 const onKeyDownProp = props.onKeyDown;
16990 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16991 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16992 const onKeyDown = useEvent((event) => {
16993 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16994 if (event.defaultPrevented) return;
16995 if (!isSelfTarget(event)) return;
16996 if (!store) return;
16997 const { currentTarget } = event;
16998 const state = store.getState();
16999 const item = store.item(id);
17000 const isGrid2 = !!(item == null ? void 0 : item.rowId);
17001 const isVertical = state.orientation !== "horizontal";
17002 const isHorizontal = state.orientation !== "vertical";
17003 const canHomeEnd = () => {
17004 if (isGrid2) return true;
17005 if (isHorizontal) return true;
17006 if (!state.baseElement) return true;
17007 if (!isTextField(state.baseElement)) return true;
17008 return false;
17009 };
17010 const keyMap = {
17011 ArrowUp: (isGrid2 || isVertical) && store.up,
17012 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17013 ArrowDown: (isGrid2 || isVertical) && store.down,
17014 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17015 Home: () => {
17016 if (!canHomeEnd()) return;
17017 if (!isGrid2 || event.ctrlKey) {
17018 return store == null ? void 0 : store.first();
17019 }
17020 return store == null ? void 0 : store.previous(-1);
17021 },
17022 End: () => {
17023 if (!canHomeEnd()) return;
17024 if (!isGrid2 || event.ctrlKey) {
17025 return store == null ? void 0 : store.last();
17026 }
17027 return store == null ? void 0 : store.next(-1);
17028 },
17029 PageUp: () => {
17030 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
17031 },
17032 PageDown: () => {
17033 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
17034 }
17035 };
17036 const action = keyMap[event.key];
17037 if (action) {
17038 if (isTextbox(currentTarget)) {
17039 const selection = getTextboxSelection(currentTarget);
17040 const isLeft = isHorizontal && event.key === "ArrowLeft";
17041 const isRight = isHorizontal && event.key === "ArrowRight";
17042 const isUp = isVertical && event.key === "ArrowUp";
17043 const isDown = isVertical && event.key === "ArrowDown";
17044 if (isRight || isDown) {
17045 const { length: valueLength } = getTextboxValue(currentTarget);
17046 if (selection.end !== valueLength) return;
17047 } else if ((isLeft || isUp) && selection.start !== 0) return;
17048 }
17049 const nextId = action();
17050 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17051 if (!moveOnKeyPressProp(event)) return;
17052 event.preventDefault();
17053 store.move(nextId);
17054 }
17055 }
17056 });
17057 const providerValue = (0, import_react18.useMemo)(
17058 () => ({ id, baseElement }),
17059 [id, baseElement]
17060 );
17061 props = useWrapElement(
17062 props,
17063 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
17064 [providerValue]
17065 );
17066 props = {
17067 id,
17068 "data-active-item": isActiveItem || void 0,
17069 ...props,
17070 ref: useMergeRefs(ref, props.ref),
17071 tabIndex: isTabbable ? props.tabIndex : -1,
17072 onFocus,
17073 onBlurCapture,
17074 onKeyDown
17075 };
17076 props = useCommand(props);
17077 props = useCollectionItem({
17078 store,
17079 ...props,
17080 getItem,
17081 shouldRegisterItem: id ? props.shouldRegisterItem : false
17082 });
17083 return removeUndefinedValues({
17084 ...props,
17085 "aria-setsize": ariaSetSize,
17086 "aria-posinset": ariaPosInSet
17087 });
17088 }
17089 );
17090 var CompositeItem = memo22(
17091 forwardRef29(function CompositeItem2(props) {
17092 const htmlProps = useCompositeItem(props);
17093 return createElement3(TagName4, htmlProps);
17094 })
17095 );
17096
17097 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
17098 function toArray(arg) {
17099 if (Array.isArray(arg)) {
17100 return arg;
17101 }
17102 return typeof arg !== "undefined" ? [arg] : [];
17103 }
17104 function flatten2DArray(array) {
17105 const flattened = [];
17106 for (const row of array) {
17107 flattened.push(...row);
17108 }
17109 return flattened;
17110 }
17111 function reverseArray(array) {
17112 return array.slice().reverse();
17113 }
17114
17115 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
17116 var import_react19 = __toESM(require_react(), 1);
17117 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17118 var TagName5 = "div";
17119 function isGrid(items) {
17120 return items.some((item) => !!item.rowId);
17121 }
17122 function isPrintableKey(event) {
17123 const target = event.target;
17124 if (target && !isTextField(target)) return false;
17125 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17126 }
17127 function isModifierKey(event) {
17128 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17129 }
17130 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17131 return useEvent((event) => {
17132 var _a;
17133 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
17134 if (event.defaultPrevented) return;
17135 if (event.isPropagationStopped()) return;
17136 if (!isSelfTarget(event)) return;
17137 if (isModifierKey(event)) return;
17138 if (isPrintableKey(event)) return;
17139 const state = store.getState();
17140 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
17141 if (!activeElement2) return;
17142 const { view, ...eventInit } = event;
17143 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
17144 if (activeElement2 !== previousElement) {
17145 activeElement2.focus();
17146 }
17147 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
17148 event.preventDefault();
17149 }
17150 if (event.currentTarget.contains(activeElement2)) {
17151 event.stopPropagation();
17152 }
17153 });
17154 }
17155 function findFirstEnabledItemInTheLastRow(items) {
17156 return findFirstEnabledItem(
17157 flatten2DArray(reverseArray(groupItemsByRows(items)))
17158 );
17159 }
17160 function useScheduleFocus(store) {
17161 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
17162 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
17163 const activeItem = store.useState(
17164 (state) => getEnabledItem(store, state.activeId)
17165 );
17166 (0, import_react19.useEffect)(() => {
17167 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
17168 if (!scheduled) return;
17169 if (!activeElement2) return;
17170 setScheduled(false);
17171 activeElement2.focus({ preventScroll: true });
17172 }, [activeItem, scheduled]);
17173 return schedule;
17174 }
17175 var useComposite = createHook(
17176 function useComposite2({
17177 store,
17178 composite = true,
17179 focusOnMove = composite,
17180 moveOnKeyPress = true,
17181 ...props
17182 }) {
17183 const context = useCompositeProviderContext();
17184 store = store || context;
17185 invariant(
17186 store,
17187 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
17188 );
17189 const ref = (0, import_react19.useRef)(null);
17190 const previousElementRef = (0, import_react19.useRef)(null);
17191 const scheduleFocus = useScheduleFocus(store);
17192 const moves = store.useState("moves");
17193 const [, setBaseElement] = useTransactionState(
17194 composite ? store.setBaseElement : null
17195 );
17196 (0, import_react19.useEffect)(() => {
17197 var _a;
17198 if (!store) return;
17199 if (!moves) return;
17200 if (!composite) return;
17201 if (!focusOnMove) return;
17202 const { activeId: activeId2 } = store.getState();
17203 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
17204 if (!itemElement) return;
17205 focusIntoView(itemElement);
17206 }, [store, moves, composite, focusOnMove]);
17207 useSafeLayoutEffect(() => {
17208 if (!store) return;
17209 if (!moves) return;
17210 if (!composite) return;
17211 const { baseElement, activeId: activeId2 } = store.getState();
17212 const isSelfAcive = activeId2 === null;
17213 if (!isSelfAcive) return;
17214 if (!baseElement) return;
17215 const previousElement = previousElementRef.current;
17216 previousElementRef.current = null;
17217 if (previousElement) {
17218 fireBlurEvent(previousElement, { relatedTarget: baseElement });
17219 }
17220 if (!hasFocus(baseElement)) {
17221 baseElement.focus();
17222 }
17223 }, [store, moves, composite]);
17224 const activeId = store.useState("activeId");
17225 const virtualFocus = store.useState("virtualFocus");
17226 useSafeLayoutEffect(() => {
17227 var _a;
17228 if (!store) return;
17229 if (!composite) return;
17230 if (!virtualFocus) return;
17231 const previousElement = previousElementRef.current;
17232 previousElementRef.current = null;
17233 if (!previousElement) return;
17234 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
17235 const relatedTarget = activeElement2 || getActiveElement(previousElement);
17236 if (relatedTarget === previousElement) return;
17237 fireBlurEvent(previousElement, { relatedTarget });
17238 }, [store, activeId, virtualFocus, composite]);
17239 const onKeyDownCapture = useKeyboardEventProxy(
17240 store,
17241 props.onKeyDownCapture,
17242 previousElementRef
17243 );
17244 const onKeyUpCapture = useKeyboardEventProxy(
17245 store,
17246 props.onKeyUpCapture,
17247 previousElementRef
17248 );
17249 const onFocusCaptureProp = props.onFocusCapture;
17250 const onFocusCapture = useEvent((event) => {
17251 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
17252 if (event.defaultPrevented) return;
17253 if (!store) return;
17254 const { virtualFocus: virtualFocus2 } = store.getState();
17255 if (!virtualFocus2) return;
17256 const previousActiveElement = event.relatedTarget;
17257 const isSilentlyFocused = silentlyFocused(event.currentTarget);
17258 if (isSelfTarget(event) && isSilentlyFocused) {
17259 event.stopPropagation();
17260 previousElementRef.current = previousActiveElement;
17261 }
17262 });
17263 const onFocusProp = props.onFocus;
17264 const onFocus = useEvent((event) => {
17265 onFocusProp == null ? void 0 : onFocusProp(event);
17266 if (event.defaultPrevented) return;
17267 if (!composite) return;
17268 if (!store) return;
17269 const { relatedTarget } = event;
17270 const { virtualFocus: virtualFocus2 } = store.getState();
17271 if (virtualFocus2) {
17272 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
17273 queueMicrotask(scheduleFocus);
17274 }
17275 } else if (isSelfTarget(event)) {
17276 store.setActiveId(null);
17277 }
17278 });
17279 const onBlurCaptureProp = props.onBlurCapture;
17280 const onBlurCapture = useEvent((event) => {
17281 var _a;
17282 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
17283 if (event.defaultPrevented) return;
17284 if (!store) return;
17285 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
17286 if (!virtualFocus2) return;
17287 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
17288 const nextActiveElement = event.relatedTarget;
17289 const nextActiveElementIsItem = isItem(store, nextActiveElement);
17290 const previousElement = previousElementRef.current;
17291 previousElementRef.current = null;
17292 if (isSelfTarget(event) && nextActiveElementIsItem) {
17293 if (nextActiveElement === activeElement2) {
17294 if (previousElement && previousElement !== nextActiveElement) {
17295 fireBlurEvent(previousElement, event);
17296 }
17297 } else if (activeElement2) {
17298 fireBlurEvent(activeElement2, event);
17299 } else if (previousElement) {
17300 fireBlurEvent(previousElement, event);
17301 }
17302 event.stopPropagation();
17303 } else {
17304 const targetIsItem = isItem(store, event.target);
17305 if (!targetIsItem && activeElement2) {
17306 fireBlurEvent(activeElement2, event);
17307 }
17308 }
17309 });
17310 const onKeyDownProp = props.onKeyDown;
17311 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17312 const onKeyDown = useEvent((event) => {
17313 var _a;
17314 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17315 if (event.nativeEvent.isComposing) return;
17316 if (event.defaultPrevented) return;
17317 if (!store) return;
17318 if (!isSelfTarget(event)) return;
17319 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
17320 const activeItem = getEnabledItem(store, activeId2);
17321 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
17322 const isVertical = orientation !== "horizontal";
17323 const isHorizontal = orientation !== "vertical";
17324 const grid = isGrid(renderedItems);
17325 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
17326 if (isHorizontalKey && isTextField(event.currentTarget)) return;
17327 const up = () => {
17328 if (grid) {
17329 const item = findFirstEnabledItemInTheLastRow(renderedItems);
17330 return item == null ? void 0 : item.id;
17331 }
17332 return store == null ? void 0 : store.last();
17333 };
17334 const keyMap = {
17335 ArrowUp: (grid || isVertical) && up,
17336 ArrowRight: (grid || isHorizontal) && store.first,
17337 ArrowDown: (grid || isVertical) && store.first,
17338 ArrowLeft: (grid || isHorizontal) && store.last,
17339 Home: store.first,
17340 End: store.last,
17341 PageUp: store.first,
17342 PageDown: store.last
17343 };
17344 const action = keyMap[event.key];
17345 if (action) {
17346 const id = action();
17347 if (id !== void 0) {
17348 if (!moveOnKeyPressProp(event)) return;
17349 event.preventDefault();
17350 store.move(id);
17351 }
17352 }
17353 });
17354 props = useWrapElement(
17355 props,
17356 (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(CompositeContextProvider, { value: store, children: element }),
17357 [store]
17358 );
17359 const activeDescendant = store.useState((state) => {
17360 var _a;
17361 if (!store) return;
17362 if (!composite) return;
17363 if (!state.virtualFocus) return;
17364 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
17365 });
17366 props = {
17367 "aria-activedescendant": activeDescendant,
17368 ...props,
17369 ref: useMergeRefs(ref, setBaseElement, props.ref),
17370 onKeyDownCapture,
17371 onKeyUpCapture,
17372 onFocusCapture,
17373 onFocus,
17374 onBlurCapture,
17375 onKeyDown
17376 };
17377 const focusable2 = store.useState(
17378 (state) => composite && (state.virtualFocus || state.activeId === null)
17379 );
17380 props = useFocusable({ focusable: focusable2, ...props });
17381 return props;
17382 }
17383 );
17384 var Composite6 = forwardRef29(function Composite22(props) {
17385 const htmlProps = useComposite(props);
17386 return createElement3(TagName5, htmlProps);
17387 });
17388
17389 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
17390 var ctx3 = createStoreContext();
17391 var useDisclosureContext = ctx3.useContext;
17392 var useDisclosureScopedContext = ctx3.useScopedContext;
17393 var useDisclosureProviderContext = ctx3.useProviderContext;
17394 var DisclosureContextProvider = ctx3.ContextProvider;
17395 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17396
17397 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
17398 var import_react20 = __toESM(require_react(), 1);
17399 var ctx4 = createStoreContext(
17400 [DisclosureContextProvider],
17401 [DisclosureScopedContextProvider]
17402 );
17403 var useDialogContext = ctx4.useContext;
17404 var useDialogScopedContext = ctx4.useScopedContext;
17405 var useDialogProviderContext = ctx4.useProviderContext;
17406 var DialogContextProvider = ctx4.ContextProvider;
17407 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17408 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
17409 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
17410
17411 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
17412 var import_react21 = __toESM(require_react(), 1);
17413 var import_react_dom4 = __toESM(require_react_dom(), 1);
17414 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
17415 var TagName6 = "div";
17416 function afterTimeout(timeoutMs, cb) {
17417 const timeoutId = setTimeout(cb, timeoutMs);
17418 return () => clearTimeout(timeoutId);
17419 }
17420 function afterPaint2(cb) {
17421 let raf = requestAnimationFrame(() => {
17422 raf = requestAnimationFrame(cb);
17423 });
17424 return () => cancelAnimationFrame(raf);
17425 }
17426 function parseCSSTime(...times) {
17427 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17428 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17429 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17430 if (currentTime > longestTime) return currentTime;
17431 return longestTime;
17432 }, 0);
17433 }
17434 function isHidden(mounted, hidden, alwaysVisible) {
17435 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17436 }
17437 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17438 const context = useDisclosureProviderContext();
17439 store = store || context;
17440 invariant(
17441 store,
17442 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
17443 );
17444 const ref = (0, import_react21.useRef)(null);
17445 const id = useId4(props.id);
17446 const [transition, setTransition] = (0, import_react21.useState)(null);
17447 const open = store.useState("open");
17448 const mounted = store.useState("mounted");
17449 const animated = store.useState("animated");
17450 const contentElement = store.useState("contentElement");
17451 const otherElement = useStoreState(store.disclosure, "contentElement");
17452 useSafeLayoutEffect(() => {
17453 if (!ref.current) return;
17454 store == null ? void 0 : store.setContentElement(ref.current);
17455 }, [store]);
17456 useSafeLayoutEffect(() => {
17457 let previousAnimated;
17458 store == null ? void 0 : store.setState("animated", (animated2) => {
17459 previousAnimated = animated2;
17460 return true;
17461 });
17462 return () => {
17463 if (previousAnimated === void 0) return;
17464 store == null ? void 0 : store.setState("animated", previousAnimated);
17465 };
17466 }, [store]);
17467 useSafeLayoutEffect(() => {
17468 if (!animated) return;
17469 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
17470 setTransition(null);
17471 return;
17472 }
17473 return afterPaint2(() => {
17474 setTransition(open ? "enter" : mounted ? "leave" : null);
17475 });
17476 }, [animated, contentElement, open, mounted]);
17477 useSafeLayoutEffect(() => {
17478 if (!store) return;
17479 if (!animated) return;
17480 if (!transition) return;
17481 if (!contentElement) return;
17482 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
17483 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17484 if (transition === "leave" && open) return;
17485 if (transition === "enter" && !open) return;
17486 if (typeof animated === "number") {
17487 const timeout2 = animated;
17488 return afterTimeout(timeout2, stopAnimationSync);
17489 }
17490 const {
17491 transitionDuration,
17492 animationDuration,
17493 transitionDelay,
17494 animationDelay
17495 } = getComputedStyle(contentElement);
17496 const {
17497 transitionDuration: transitionDuration2 = "0",
17498 animationDuration: animationDuration2 = "0",
17499 transitionDelay: transitionDelay2 = "0",
17500 animationDelay: animationDelay2 = "0"
17501 } = otherElement ? getComputedStyle(otherElement) : {};
17502 const delay = parseCSSTime(
17503 transitionDelay,
17504 animationDelay,
17505 transitionDelay2,
17506 animationDelay2
17507 );
17508 const duration = parseCSSTime(
17509 transitionDuration,
17510 animationDuration,
17511 transitionDuration2,
17512 animationDuration2
17513 );
17514 const timeout = delay + duration;
17515 if (!timeout) {
17516 if (transition === "enter") {
17517 store.setState("animated", false);
17518 }
17519 stopAnimation();
17520 return;
17521 }
17522 const frameRate = 1e3 / 60;
17523 const maxTimeout = Math.max(timeout - frameRate, 0);
17524 return afterTimeout(maxTimeout, stopAnimationSync);
17525 }, [store, animated, contentElement, otherElement, open, transition]);
17526 props = useWrapElement(
17527 props,
17528 (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DialogScopedContextProvider, { value: store, children: element }),
17529 [store]
17530 );
17531 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17532 const styleProp = props.style;
17533 const style = (0, import_react21.useMemo)(() => {
17534 if (hidden) {
17535 return { ...styleProp, display: "none" };
17536 }
17537 return styleProp;
17538 }, [hidden, styleProp]);
17539 props = {
17540 id,
17541 "data-open": open || void 0,
17542 "data-enter": transition === "enter" || void 0,
17543 "data-leave": transition === "leave" || void 0,
17544 hidden,
17545 ...props,
17546 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17547 style
17548 };
17549 return removeUndefinedValues(props);
17550 });
17551 var DisclosureContentImpl = forwardRef29(function DisclosureContentImpl2(props) {
17552 const htmlProps = useDisclosureContent(props);
17553 return createElement3(TagName6, htmlProps);
17554 });
17555 var DisclosureContent = forwardRef29(function DisclosureContent2({
17556 unmountOnHide,
17557 ...props
17558 }) {
17559 const context = useDisclosureProviderContext();
17560 const store = props.store || context;
17561 const mounted = useStoreState(
17562 store,
17563 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
17564 );
17565 if (mounted === false) return null;
17566 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(DisclosureContentImpl, { ...props });
17567 });
17568
17569 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
17570 function createDisclosureStore(props = {}) {
17571 const store = mergeStore(
17572 props.store,
17573 omit2(props.disclosure, ["contentElement", "disclosureElement"])
17574 );
17575 throwOnConflictingProps(props, store);
17576 const syncState = store == null ? void 0 : store.getState();
17577 const open = defaultValue(
17578 props.open,
17579 syncState == null ? void 0 : syncState.open,
17580 props.defaultOpen,
17581 false
17582 );
17583 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
17584 const initialState = {
17585 open,
17586 animated,
17587 animating: !!animated && open,
17588 mounted: open,
17589 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
17590 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
17591 };
17592 const disclosure = createStore(initialState, store);
17593 setup(
17594 disclosure,
17595 () => sync(disclosure, ["animated", "animating"], (state) => {
17596 if (state.animated) return;
17597 disclosure.setState("animating", false);
17598 })
17599 );
17600 setup(
17601 disclosure,
17602 () => subscribe(disclosure, ["open"], () => {
17603 if (!disclosure.getState().animated) return;
17604 disclosure.setState("animating", true);
17605 })
17606 );
17607 setup(
17608 disclosure,
17609 () => sync(disclosure, ["open", "animating"], (state) => {
17610 disclosure.setState("mounted", state.open || state.animating);
17611 })
17612 );
17613 return {
17614 ...disclosure,
17615 disclosure: props.disclosure,
17616 setOpen: (value) => disclosure.setState("open", value),
17617 show: () => disclosure.setState("open", true),
17618 hide: () => disclosure.setState("open", false),
17619 toggle: () => disclosure.setState("open", (open2) => !open2),
17620 stopAnimation: () => disclosure.setState("animating", false),
17621 setContentElement: (value) => disclosure.setState("contentElement", value),
17622 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17623 };
17624 }
17625
17626 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17627 function useDisclosureStoreProps(store, update2, props) {
17628 useUpdateEffect(update2, [props.store, props.disclosure]);
17629 useStoreProps(store, props, "open", "setOpen");
17630 useStoreProps(store, props, "mounted", "setMounted");
17631 useStoreProps(store, props, "animated");
17632 return Object.assign(store, { disclosure: props.disclosure });
17633 }
17634
17635 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17636 var ctx5 = createStoreContext(
17637 [DialogContextProvider],
17638 [DialogScopedContextProvider]
17639 );
17640 var usePopoverContext = ctx5.useContext;
17641 var usePopoverScopedContext = ctx5.useScopedContext;
17642 var usePopoverProviderContext = ctx5.useProviderContext;
17643 var PopoverContextProvider = ctx5.ContextProvider;
17644 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17645
17646 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17647 function getCommonParent(items) {
17648 var _a;
17649 const firstItem = items.find((item) => !!item.element);
17650 const lastItem = [...items].reverse().find((item) => !!item.element);
17651 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17652 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17653 const parent = parentElement;
17654 if (lastItem && parent.contains(lastItem.element)) {
17655 return parentElement;
17656 }
17657 parentElement = parentElement.parentElement;
17658 }
17659 return getDocument(parentElement).body;
17660 }
17661 function getPrivateStore(store) {
17662 return store == null ? void 0 : store.__unstablePrivateStore;
17663 }
17664 function createCollectionStore(props = {}) {
17665 var _a;
17666 throwOnConflictingProps(props, props.store);
17667 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17668 const items = defaultValue(
17669 props.items,
17670 syncState == null ? void 0 : syncState.items,
17671 props.defaultItems,
17672 []
17673 );
17674 const itemsMap = new Map(items.map((item) => [item.id, item]));
17675 const initialState = {
17676 items,
17677 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17678 };
17679 const syncPrivateStore = getPrivateStore(props.store);
17680 const privateStore = createStore(
17681 { items, renderedItems: initialState.renderedItems },
17682 syncPrivateStore
17683 );
17684 const collection = createStore(initialState, props.store);
17685 const sortItems = (renderedItems) => {
17686 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17687 privateStore.setState("renderedItems", sortedItems);
17688 collection.setState("renderedItems", sortedItems);
17689 };
17690 setup(collection, () => init(privateStore));
17691 setup(privateStore, () => {
17692 return batch(privateStore, ["items"], (state) => {
17693 collection.setState("items", state.items);
17694 });
17695 });
17696 setup(privateStore, () => {
17697 return batch(privateStore, ["renderedItems"], (state) => {
17698 let firstRun = true;
17699 let raf = requestAnimationFrame(() => {
17700 const { renderedItems } = collection.getState();
17701 if (state.renderedItems === renderedItems) return;
17702 sortItems(state.renderedItems);
17703 });
17704 if (typeof IntersectionObserver !== "function") {
17705 return () => cancelAnimationFrame(raf);
17706 }
17707 const ioCallback = () => {
17708 if (firstRun) {
17709 firstRun = false;
17710 return;
17711 }
17712 cancelAnimationFrame(raf);
17713 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17714 };
17715 const root = getCommonParent(state.renderedItems);
17716 const observer = new IntersectionObserver(ioCallback, { root });
17717 for (const item of state.renderedItems) {
17718 if (!item.element) continue;
17719 observer.observe(item.element);
17720 }
17721 return () => {
17722 cancelAnimationFrame(raf);
17723 observer.disconnect();
17724 };
17725 });
17726 });
17727 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17728 let prevItem;
17729 setItems((items2) => {
17730 const index2 = items2.findIndex(({ id }) => id === item.id);
17731 const nextItems = items2.slice();
17732 if (index2 !== -1) {
17733 prevItem = items2[index2];
17734 const nextItem = { ...prevItem, ...item };
17735 nextItems[index2] = nextItem;
17736 itemsMap.set(item.id, nextItem);
17737 } else {
17738 nextItems.push(item);
17739 itemsMap.set(item.id, item);
17740 }
17741 return nextItems;
17742 });
17743 const unmergeItem = () => {
17744 setItems((items2) => {
17745 if (!prevItem) {
17746 if (canDeleteFromMap) {
17747 itemsMap.delete(item.id);
17748 }
17749 return items2.filter(({ id }) => id !== item.id);
17750 }
17751 const index2 = items2.findIndex(({ id }) => id === item.id);
17752 if (index2 === -1) return items2;
17753 const nextItems = items2.slice();
17754 nextItems[index2] = prevItem;
17755 itemsMap.set(item.id, prevItem);
17756 return nextItems;
17757 });
17758 };
17759 return unmergeItem;
17760 };
17761 const registerItem = (item) => mergeItem(
17762 item,
17763 (getItems) => privateStore.setState("items", getItems),
17764 true
17765 );
17766 return {
17767 ...collection,
17768 registerItem,
17769 renderItem: (item) => chain(
17770 registerItem(item),
17771 mergeItem(
17772 item,
17773 (getItems) => privateStore.setState("renderedItems", getItems)
17774 )
17775 ),
17776 item: (id) => {
17777 if (!id) return null;
17778 let item = itemsMap.get(id);
17779 if (!item) {
17780 const { items: items2 } = privateStore.getState();
17781 item = items2.find((item2) => item2.id === id);
17782 if (item) {
17783 itemsMap.set(id, item);
17784 }
17785 }
17786 return item || null;
17787 },
17788 // @ts-expect-error Internal
17789 __unstablePrivateStore: privateStore
17790 };
17791 }
17792
17793 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17794 function useCollectionStoreProps(store, update2, props) {
17795 useUpdateEffect(update2, [props.store]);
17796 useStoreProps(store, props, "items", "setItems");
17797 return store;
17798 }
17799
17800 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17801 var NULL_ITEM = { id: null };
17802 function findFirstEnabledItem2(items, excludeId) {
17803 return items.find((item) => {
17804 if (excludeId) {
17805 return !item.disabled && item.id !== excludeId;
17806 }
17807 return !item.disabled;
17808 });
17809 }
17810 function getEnabledItems(items, excludeId) {
17811 return items.filter((item) => {
17812 if (excludeId) {
17813 return !item.disabled && item.id !== excludeId;
17814 }
17815 return !item.disabled;
17816 });
17817 }
17818 function getItemsInRow(items, rowId) {
17819 return items.filter((item) => item.rowId === rowId);
17820 }
17821 function flipItems(items, activeId, shouldInsertNullItem = false) {
17822 const index2 = items.findIndex((item) => item.id === activeId);
17823 return [
17824 ...items.slice(index2 + 1),
17825 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17826 ...items.slice(0, index2)
17827 ];
17828 }
17829 function groupItemsByRows2(items) {
17830 const rows = [];
17831 for (const item of items) {
17832 const row = rows.find((currentRow) => {
17833 var _a;
17834 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17835 });
17836 if (row) {
17837 row.push(item);
17838 } else {
17839 rows.push([item]);
17840 }
17841 }
17842 return rows;
17843 }
17844 function getMaxRowLength(array) {
17845 let maxLength = 0;
17846 for (const { length } of array) {
17847 if (length > maxLength) {
17848 maxLength = length;
17849 }
17850 }
17851 return maxLength;
17852 }
17853 function createEmptyItem(rowId) {
17854 return {
17855 id: "__EMPTY_ITEM__",
17856 disabled: true,
17857 rowId
17858 };
17859 }
17860 function normalizeRows(rows, activeId, focusShift) {
17861 const maxLength = getMaxRowLength(rows);
17862 for (const row of rows) {
17863 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17864 const item = row[i2];
17865 if (!item || focusShift && item.disabled) {
17866 const isFirst = i2 === 0;
17867 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17868 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17869 }
17870 }
17871 }
17872 return rows;
17873 }
17874 function verticalizeItems(items) {
17875 const rows = groupItemsByRows2(items);
17876 const maxLength = getMaxRowLength(rows);
17877 const verticalized = [];
17878 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17879 for (const row of rows) {
17880 const item = row[i2];
17881 if (item) {
17882 verticalized.push({
17883 ...item,
17884 // If there's no rowId, it means that it's not a grid composite, but
17885 // a single row instead. So, instead of verticalizing it, that is,
17886 // assigning a different rowId based on the column index, we keep it
17887 // undefined so they will be part of the same row. This is useful
17888 // when using up/down on one-dimensional composites.
17889 rowId: item.rowId ? `${i2}` : void 0
17890 });
17891 }
17892 }
17893 }
17894 return verticalized;
17895 }
17896 function createCompositeStore(props = {}) {
17897 var _a;
17898 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17899 const collection = createCollectionStore(props);
17900 const activeId = defaultValue(
17901 props.activeId,
17902 syncState == null ? void 0 : syncState.activeId,
17903 props.defaultActiveId
17904 );
17905 const initialState = {
17906 ...collection.getState(),
17907 id: defaultValue(
17908 props.id,
17909 syncState == null ? void 0 : syncState.id,
17910 `id-${Math.random().toString(36).slice(2, 8)}`
17911 ),
17912 activeId,
17913 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17914 includesBaseElement: defaultValue(
17915 props.includesBaseElement,
17916 syncState == null ? void 0 : syncState.includesBaseElement,
17917 activeId === null
17918 ),
17919 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17920 orientation: defaultValue(
17921 props.orientation,
17922 syncState == null ? void 0 : syncState.orientation,
17923 "both"
17924 ),
17925 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17926 virtualFocus: defaultValue(
17927 props.virtualFocus,
17928 syncState == null ? void 0 : syncState.virtualFocus,
17929 false
17930 ),
17931 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17932 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17933 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17934 };
17935 const composite = createStore(initialState, collection, props.store);
17936 setup(
17937 composite,
17938 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17939 composite.setState("activeId", (activeId2) => {
17940 var _a2;
17941 if (activeId2 !== void 0) return activeId2;
17942 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17943 });
17944 })
17945 );
17946 const getNextId = (direction = "next", options = {}) => {
17947 var _a2, _b;
17948 const defaultState = composite.getState();
17949 const {
17950 skip = 0,
17951 activeId: activeId2 = defaultState.activeId,
17952 focusShift = defaultState.focusShift,
17953 focusLoop = defaultState.focusLoop,
17954 focusWrap = defaultState.focusWrap,
17955 includesBaseElement = defaultState.includesBaseElement,
17956 renderedItems = defaultState.renderedItems,
17957 rtl = defaultState.rtl
17958 } = options;
17959 const isVerticalDirection = direction === "up" || direction === "down";
17960 const isNextDirection = direction === "next" || direction === "down";
17961 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17962 const canShift = focusShift && !skip;
17963 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17964 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17965 );
17966 items = canReverse ? reverseArray(items) : items;
17967 items = isVerticalDirection ? verticalizeItems(items) : items;
17968 if (activeId2 == null) {
17969 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17970 }
17971 const activeItem = items.find((item) => item.id === activeId2);
17972 if (!activeItem) {
17973 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17974 }
17975 const isGrid2 = items.some((item) => item.rowId);
17976 const activeIndex = items.indexOf(activeItem);
17977 const nextItems = items.slice(activeIndex + 1);
17978 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17979 if (skip) {
17980 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17981 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17982 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17983 return nextItem2 == null ? void 0 : nextItem2.id;
17984 }
17985 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17986 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17987 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17988 if (canLoop) {
17989 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17990 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17991 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17992 return nextItem2 == null ? void 0 : nextItem2.id;
17993 }
17994 if (canWrap) {
17995 const nextItem2 = findFirstEnabledItem2(
17996 // We can use nextItems, which contains all the next items, including
17997 // items from other rows, to wrap between rows. However, if there is a
17998 // null item (the composite container), we'll only use the next items in
17999 // the row. So moving next from the last item will focus on the
18000 // composite container. On grid composites, horizontal navigation never
18001 // focuses on the composite container, only vertical.
18002 hasNullItem ? nextItemsInRow : nextItems,
18003 activeId2
18004 );
18005 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
18006 return nextId;
18007 }
18008 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
18009 if (!nextItem && hasNullItem) {
18010 return null;
18011 }
18012 return nextItem == null ? void 0 : nextItem.id;
18013 };
18014 return {
18015 ...collection,
18016 ...composite,
18017 setBaseElement: (element) => composite.setState("baseElement", element),
18018 setActiveId: (id) => composite.setState("activeId", id),
18019 move: (id) => {
18020 if (id === void 0) return;
18021 composite.setState("activeId", id);
18022 composite.setState("moves", (moves) => moves + 1);
18023 },
18024 first: () => {
18025 var _a2;
18026 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
18027 },
18028 last: () => {
18029 var _a2;
18030 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
18031 },
18032 next: (options) => {
18033 if (options !== void 0 && typeof options === "number") {
18034 options = { skip: options };
18035 }
18036 return getNextId("next", options);
18037 },
18038 previous: (options) => {
18039 if (options !== void 0 && typeof options === "number") {
18040 options = { skip: options };
18041 }
18042 return getNextId("previous", options);
18043 },
18044 down: (options) => {
18045 if (options !== void 0 && typeof options === "number") {
18046 options = { skip: options };
18047 }
18048 return getNextId("down", options);
18049 },
18050 up: (options) => {
18051 if (options !== void 0 && typeof options === "number") {
18052 options = { skip: options };
18053 }
18054 return getNextId("up", options);
18055 }
18056 };
18057 }
18058
18059 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
18060 function useCompositeStoreOptions(props) {
18061 const id = useId4(props.id);
18062 return { id, ...props };
18063 }
18064 function useCompositeStoreProps(store, update2, props) {
18065 store = useCollectionStoreProps(store, update2, props);
18066 useStoreProps(store, props, "activeId", "setActiveId");
18067 useStoreProps(store, props, "includesBaseElement");
18068 useStoreProps(store, props, "virtualFocus");
18069 useStoreProps(store, props, "orientation");
18070 useStoreProps(store, props, "rtl");
18071 useStoreProps(store, props, "focusLoop");
18072 useStoreProps(store, props, "focusWrap");
18073 useStoreProps(store, props, "focusShift");
18074 return store;
18075 }
18076
18077 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
18078 var import_react22 = __toESM(require_react(), 1);
18079 var ComboboxListRoleContext = (0, import_react22.createContext)(
18080 void 0
18081 );
18082 var ctx6 = createStoreContext(
18083 [PopoverContextProvider, CompositeContextProvider],
18084 [PopoverScopedContextProvider, CompositeScopedContextProvider]
18085 );
18086 var useComboboxContext = ctx6.useContext;
18087 var useComboboxScopedContext = ctx6.useScopedContext;
18088 var useComboboxProviderContext = ctx6.useProviderContext;
18089 var ComboboxContextProvider = ctx6.ContextProvider;
18090 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
18091 var ComboboxItemValueContext = (0, import_react22.createContext)(
18092 void 0
18093 );
18094 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
18095
18096 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
18097 function createDialogStore(props = {}) {
18098 return createDisclosureStore(props);
18099 }
18100
18101 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
18102 function useDialogStoreProps(store, update2, props) {
18103 return useDisclosureStoreProps(store, update2, props);
18104 }
18105
18106 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
18107 function createPopoverStore({
18108 popover: otherPopover,
18109 ...props
18110 } = {}) {
18111 const store = mergeStore(
18112 props.store,
18113 omit2(otherPopover, [
18114 "arrowElement",
18115 "anchorElement",
18116 "contentElement",
18117 "popoverElement",
18118 "disclosureElement"
18119 ])
18120 );
18121 throwOnConflictingProps(props, store);
18122 const syncState = store == null ? void 0 : store.getState();
18123 const dialog = createDialogStore({ ...props, store });
18124 const placement = defaultValue(
18125 props.placement,
18126 syncState == null ? void 0 : syncState.placement,
18127 "bottom"
18128 );
18129 const initialState = {
18130 ...dialog.getState(),
18131 placement,
18132 currentPlacement: placement,
18133 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
18134 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
18135 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
18136 rendered: /* @__PURE__ */ Symbol("rendered")
18137 };
18138 const popover = createStore(initialState, dialog, store);
18139 return {
18140 ...dialog,
18141 ...popover,
18142 setAnchorElement: (element) => popover.setState("anchorElement", element),
18143 setPopoverElement: (element) => popover.setState("popoverElement", element),
18144 setArrowElement: (element) => popover.setState("arrowElement", element),
18145 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18146 };
18147 }
18148
18149 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
18150 function usePopoverStoreProps(store, update2, props) {
18151 useUpdateEffect(update2, [props.popover]);
18152 useStoreProps(store, props, "placement");
18153 return useDialogStoreProps(store, update2, props);
18154 }
18155
18156 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
18157 var TagName7 = "div";
18158 var usePopoverAnchor = createHook(
18159 function usePopoverAnchor2({ store, ...props }) {
18160 const context = usePopoverProviderContext();
18161 store = store || context;
18162 props = {
18163 ...props,
18164 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
18165 };
18166 return props;
18167 }
18168 );
18169 var PopoverAnchor = forwardRef29(function PopoverAnchor2(props) {
18170 const htmlProps = usePopoverAnchor(props);
18171 return createElement3(TagName7, htmlProps);
18172 });
18173
18174 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
18175 var import_react23 = __toESM(require_react(), 1);
18176 var TagName8 = "div";
18177 function getMouseDestination(event) {
18178 const relatedTarget = event.relatedTarget;
18179 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
18180 return relatedTarget;
18181 }
18182 return null;
18183 }
18184 function hoveringInside(event) {
18185 const nextElement = getMouseDestination(event);
18186 if (!nextElement) return false;
18187 return contains2(event.currentTarget, nextElement);
18188 }
18189 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18190 function movingToAnotherItem(event) {
18191 let dest = getMouseDestination(event);
18192 if (!dest) return false;
18193 do {
18194 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18195 dest = dest.parentElement;
18196 } while (dest);
18197 return false;
18198 }
18199 var useCompositeHover = createHook(
18200 function useCompositeHover2({
18201 store,
18202 focusOnHover = true,
18203 blurOnHoverEnd = !!focusOnHover,
18204 ...props
18205 }) {
18206 const context = useCompositeContext();
18207 store = store || context;
18208 invariant(
18209 store,
18210 "CompositeHover must be wrapped in a Composite component."
18211 );
18212 const isMouseMoving = useIsMouseMoving();
18213 const onMouseMoveProp = props.onMouseMove;
18214 const focusOnHoverProp = useBooleanEvent(focusOnHover);
18215 const onMouseMove = useEvent((event) => {
18216 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
18217 if (event.defaultPrevented) return;
18218 if (!isMouseMoving()) return;
18219 if (!focusOnHoverProp(event)) return;
18220 if (!hasFocusWithin(event.currentTarget)) {
18221 const baseElement = store == null ? void 0 : store.getState().baseElement;
18222 if (baseElement && !hasFocus(baseElement)) {
18223 baseElement.focus();
18224 }
18225 }
18226 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
18227 });
18228 const onMouseLeaveProp = props.onMouseLeave;
18229 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18230 const onMouseLeave = useEvent((event) => {
18231 var _a;
18232 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
18233 if (event.defaultPrevented) return;
18234 if (!isMouseMoving()) return;
18235 if (hoveringInside(event)) return;
18236 if (movingToAnotherItem(event)) return;
18237 if (!focusOnHoverProp(event)) return;
18238 if (!blurOnHoverEndProp(event)) return;
18239 store == null ? void 0 : store.setActiveId(null);
18240 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
18241 });
18242 const ref = (0, import_react23.useCallback)((element) => {
18243 if (!element) return;
18244 element[symbol2] = true;
18245 }, []);
18246 props = {
18247 ...props,
18248 ref: useMergeRefs(ref, props.ref),
18249 onMouseMove,
18250 onMouseLeave
18251 };
18252 return removeUndefinedValues(props);
18253 }
18254 );
18255 var CompositeHover = memo22(
18256 forwardRef29(function CompositeHover2(props) {
18257 const htmlProps = useCompositeHover(props);
18258 return createElement3(TagName8, htmlProps);
18259 })
18260 );
18261
18262 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
18263 var import_react24 = __toESM(require_react(), 1);
18264 var TagName9 = "input";
18265 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18266 if (!autoSelect) return false;
18267 const firstItem = items.find((item) => !item.disabled && item.value);
18268 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
18269 }
18270 function hasCompletionString(value, activeValue) {
18271 if (!activeValue) return false;
18272 if (value == null) return false;
18273 value = normalizeString(value);
18274 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
18275 }
18276 function isInputEvent(event) {
18277 return event.type === "input";
18278 }
18279 function isAriaAutoCompleteValue(value) {
18280 return value === "inline" || value === "list" || value === "both" || value === "none";
18281 }
18282 function getDefaultAutoSelectId(items) {
18283 const item = items.find((item2) => {
18284 var _a;
18285 if (item2.disabled) return false;
18286 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
18287 });
18288 return item == null ? void 0 : item.id;
18289 }
18290 var useCombobox = createHook(
18291 function useCombobox2({
18292 store,
18293 focusable: focusable2 = true,
18294 autoSelect: autoSelectProp = false,
18295 getAutoSelectId,
18296 setValueOnChange,
18297 showMinLength = 0,
18298 showOnChange,
18299 showOnMouseDown,
18300 showOnClick = showOnMouseDown,
18301 showOnKeyDown,
18302 showOnKeyPress = showOnKeyDown,
18303 blurActiveItemOnClick,
18304 setValueOnClick = true,
18305 moveOnKeyPress = true,
18306 autoComplete = "list",
18307 ...props
18308 }) {
18309 const context = useComboboxProviderContext();
18310 store = store || context;
18311 invariant(
18312 store,
18313 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
18314 );
18315 const ref = (0, import_react24.useRef)(null);
18316 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18317 const canAutoSelectRef = (0, import_react24.useRef)(false);
18318 const composingRef = (0, import_react24.useRef)(false);
18319 const autoSelect = store.useState(
18320 (state) => state.virtualFocus && autoSelectProp
18321 );
18322 const inline4 = autoComplete === "inline" || autoComplete === "both";
18323 const [canInline, setCanInline] = (0, import_react24.useState)(inline4);
18324 useUpdateLayoutEffect(() => {
18325 if (!inline4) return;
18326 setCanInline(true);
18327 }, [inline4]);
18328 const storeValue = store.useState("value");
18329 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
18330 (0, import_react24.useEffect)(() => {
18331 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18332 prevSelectedValueRef.current = prev.selectedValue;
18333 });
18334 }, []);
18335 const inlineActiveValue = store.useState((state) => {
18336 var _a;
18337 if (!inline4) return;
18338 if (!canInline) return;
18339 if (state.activeValue && Array.isArray(state.selectedValue)) {
18340 if (state.selectedValue.includes(state.activeValue)) return;
18341 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
18342 }
18343 return state.activeValue;
18344 });
18345 const items = store.useState("renderedItems");
18346 const open = store.useState("open");
18347 const contentElement = store.useState("contentElement");
18348 const value = (0, import_react24.useMemo)(() => {
18349 if (!inline4) return storeValue;
18350 if (!canInline) return storeValue;
18351 const firstItemAutoSelected = isFirstItemAutoSelected(
18352 items,
18353 inlineActiveValue,
18354 autoSelect
18355 );
18356 if (firstItemAutoSelected) {
18357 if (hasCompletionString(storeValue, inlineActiveValue)) {
18358 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
18359 return storeValue + slice;
18360 }
18361 return storeValue;
18362 }
18363 return inlineActiveValue || storeValue;
18364 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
18365 (0, import_react24.useEffect)(() => {
18366 const element = ref.current;
18367 if (!element) return;
18368 const onCompositeItemMove = () => setCanInline(true);
18369 element.addEventListener("combobox-item-move", onCompositeItemMove);
18370 return () => {
18371 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18372 };
18373 }, []);
18374 (0, import_react24.useEffect)(() => {
18375 if (!inline4) return;
18376 if (!canInline) return;
18377 if (!inlineActiveValue) return;
18378 const firstItemAutoSelected = isFirstItemAutoSelected(
18379 items,
18380 inlineActiveValue,
18381 autoSelect
18382 );
18383 if (!firstItemAutoSelected) return;
18384 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18385 let cleanup = noop4;
18386 queueMicrotask(() => {
18387 const element = ref.current;
18388 if (!element) return;
18389 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18390 const nextStart = storeValue.length;
18391 const nextEnd = inlineActiveValue.length;
18392 setSelectionRange(element, nextStart, nextEnd);
18393 cleanup = () => {
18394 if (!hasFocus(element)) return;
18395 const { start, end } = getTextboxSelection(element);
18396 if (start !== nextStart) return;
18397 if (end !== nextEnd) return;
18398 setSelectionRange(element, prevStart, prevEnd);
18399 };
18400 });
18401 return () => cleanup();
18402 }, [
18403 valueUpdated,
18404 inline4,
18405 canInline,
18406 inlineActiveValue,
18407 items,
18408 autoSelect,
18409 storeValue
18410 ]);
18411 const scrollingElementRef = (0, import_react24.useRef)(null);
18412 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18413 const autoSelectIdRef = (0, import_react24.useRef)(null);
18414 (0, import_react24.useEffect)(() => {
18415 if (!open) return;
18416 if (!contentElement) return;
18417 const scrollingElement = getScrollingElement(contentElement);
18418 if (!scrollingElement) return;
18419 scrollingElementRef.current = scrollingElement;
18420 const onUserScroll = () => {
18421 canAutoSelectRef.current = false;
18422 };
18423 const onScroll = () => {
18424 if (!store) return;
18425 if (!canAutoSelectRef.current) return;
18426 const { activeId } = store.getState();
18427 if (activeId === null) return;
18428 if (activeId === autoSelectIdRef.current) return;
18429 canAutoSelectRef.current = false;
18430 };
18431 const options = { passive: true, capture: true };
18432 scrollingElement.addEventListener("wheel", onUserScroll, options);
18433 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18434 scrollingElement.addEventListener("scroll", onScroll, options);
18435 return () => {
18436 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18437 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18438 scrollingElement.removeEventListener("scroll", onScroll, true);
18439 };
18440 }, [open, contentElement, store]);
18441 useSafeLayoutEffect(() => {
18442 if (!storeValue) return;
18443 if (composingRef.current) return;
18444 canAutoSelectRef.current = true;
18445 }, [storeValue]);
18446 useSafeLayoutEffect(() => {
18447 if (autoSelect !== "always" && open) return;
18448 canAutoSelectRef.current = open;
18449 }, [autoSelect, open]);
18450 const resetValueOnSelect = store.useState("resetValueOnSelect");
18451 useUpdateEffect(() => {
18452 var _a, _b;
18453 const canAutoSelect = canAutoSelectRef.current;
18454 if (!store) return;
18455 if (!open) return;
18456 if (!canAutoSelect && !resetValueOnSelect) return;
18457 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18458 if (baseElement && !hasFocus(baseElement)) return;
18459 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
18460 const observer = new MutationObserver(forceValueUpdate);
18461 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18462 return () => observer.disconnect();
18463 }
18464 if (autoSelect && canAutoSelect) {
18465 const userAutoSelectId = getAutoSelectIdProp(items);
18466 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
18467 autoSelectIdRef.current = autoSelectId;
18468 store.move(autoSelectId != null ? autoSelectId : null);
18469 } else {
18470 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
18471 if (element && "scrollIntoView" in element) {
18472 element.scrollIntoView({ block: "nearest", inline: "nearest" });
18473 }
18474 }
18475 return;
18476 }, [
18477 store,
18478 open,
18479 valueUpdated,
18480 storeValue,
18481 autoSelect,
18482 resetValueOnSelect,
18483 getAutoSelectIdProp,
18484 items
18485 ]);
18486 (0, import_react24.useEffect)(() => {
18487 if (!inline4) return;
18488 const combobox = ref.current;
18489 if (!combobox) return;
18490 const elements = [combobox, contentElement].filter(
18491 (value2) => !!value2
18492 );
18493 const onBlur2 = (event) => {
18494 if (elements.every((el) => isFocusEventOutside(event, el))) {
18495 store == null ? void 0 : store.setValue(value);
18496 }
18497 };
18498 for (const element of elements) {
18499 element.addEventListener("focusout", onBlur2);
18500 }
18501 return () => {
18502 for (const element of elements) {
18503 element.removeEventListener("focusout", onBlur2);
18504 }
18505 };
18506 }, [inline4, contentElement, store, value]);
18507 const canShow = (event) => {
18508 const currentTarget = event.currentTarget;
18509 return currentTarget.value.length >= showMinLength;
18510 };
18511 const onChangeProp = props.onChange;
18512 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
18513 const setValueOnChangeProp = useBooleanEvent(
18514 // If the combobox is combined with tags, the value will be set by the tag
18515 // input component.
18516 setValueOnChange != null ? setValueOnChange : !store.tag
18517 );
18518 const onChange = useEvent((event) => {
18519 onChangeProp == null ? void 0 : onChangeProp(event);
18520 if (event.defaultPrevented) return;
18521 if (!store) return;
18522 const currentTarget = event.currentTarget;
18523 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18524 const nativeEvent = event.nativeEvent;
18525 canAutoSelectRef.current = true;
18526 if (isInputEvent(nativeEvent)) {
18527 if (nativeEvent.isComposing) {
18528 canAutoSelectRef.current = false;
18529 composingRef.current = true;
18530 }
18531 if (inline4) {
18532 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18533 const caretAtEnd = selectionStart === value2.length;
18534 setCanInline(textInserted && caretAtEnd);
18535 }
18536 }
18537 if (setValueOnChangeProp(event)) {
18538 const isSameValue = value2 === store.getState().value;
18539 store.setValue(value2);
18540 queueMicrotask(() => {
18541 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18542 });
18543 if (inline4 && autoSelect && isSameValue) {
18544 forceValueUpdate();
18545 }
18546 }
18547 if (showOnChangeProp(event)) {
18548 store.show();
18549 }
18550 if (!autoSelect || !canAutoSelectRef.current) {
18551 store.setActiveId(null);
18552 }
18553 });
18554 const onCompositionEndProp = props.onCompositionEnd;
18555 const onCompositionEnd = useEvent((event) => {
18556 canAutoSelectRef.current = true;
18557 composingRef.current = false;
18558 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
18559 if (event.defaultPrevented) return;
18560 if (!autoSelect) return;
18561 forceValueUpdate();
18562 });
18563 const onMouseDownProp = props.onMouseDown;
18564 const blurActiveItemOnClickProp = useBooleanEvent(
18565 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
18566 );
18567 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18568 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
18569 const onMouseDown = useEvent((event) => {
18570 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18571 if (event.defaultPrevented) return;
18572 if (event.button) return;
18573 if (event.ctrlKey) return;
18574 if (!store) return;
18575 if (blurActiveItemOnClickProp(event)) {
18576 store.setActiveId(null);
18577 }
18578 if (setValueOnClickProp(event)) {
18579 store.setValue(value);
18580 }
18581 if (showOnClickProp(event)) {
18582 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18583 }
18584 });
18585 const onKeyDownProp = props.onKeyDown;
18586 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
18587 const onKeyDown = useEvent((event) => {
18588 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18589 if (!event.repeat) {
18590 canAutoSelectRef.current = false;
18591 }
18592 if (event.defaultPrevented) return;
18593 if (event.ctrlKey) return;
18594 if (event.altKey) return;
18595 if (event.shiftKey) return;
18596 if (event.metaKey) return;
18597 if (!store) return;
18598 const { open: open2 } = store.getState();
18599 if (open2) return;
18600 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18601 if (showOnKeyPressProp(event)) {
18602 event.preventDefault();
18603 store.show();
18604 }
18605 }
18606 });
18607 const onBlurProp = props.onBlur;
18608 const onBlur = useEvent((event) => {
18609 canAutoSelectRef.current = false;
18610 onBlurProp == null ? void 0 : onBlurProp(event);
18611 if (event.defaultPrevented) return;
18612 });
18613 const id = useId4(props.id);
18614 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18615 const isActiveItem = store.useState((state) => state.activeId === null);
18616 props = {
18617 id,
18618 role: "combobox",
18619 "aria-autocomplete": ariaAutoComplete,
18620 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18621 "aria-expanded": open,
18622 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18623 "data-active-item": isActiveItem || void 0,
18624 value,
18625 ...props,
18626 ref: useMergeRefs(ref, props.ref),
18627 onChange,
18628 onCompositionEnd,
18629 onMouseDown,
18630 onKeyDown,
18631 onBlur
18632 };
18633 props = useComposite({
18634 store,
18635 focusable: focusable2,
18636 ...props,
18637 // Enable inline autocomplete when the user moves from the combobox input
18638 // to an item.
18639 moveOnKeyPress: (event) => {
18640 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18641 if (inline4) setCanInline(true);
18642 return true;
18643 }
18644 });
18645 props = usePopoverAnchor({ store, ...props });
18646 return { autoComplete: "off", ...props };
18647 }
18648 );
18649 var Combobox = forwardRef29(function Combobox2(props) {
18650 const htmlProps = useCombobox(props);
18651 return createElement3(TagName9, htmlProps);
18652 });
18653
18654 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18655 var import_react25 = __toESM(require_react(), 1);
18656 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18657 var TagName10 = "div";
18658 function isSelected(storeValue, itemValue) {
18659 if (itemValue == null) return;
18660 if (storeValue == null) return false;
18661 if (Array.isArray(storeValue)) {
18662 return storeValue.includes(itemValue);
18663 }
18664 return storeValue === itemValue;
18665 }
18666 function getItemRole(popupRole) {
18667 var _a;
18668 const itemRoleByPopupRole = {
18669 menu: "menuitem",
18670 listbox: "option",
18671 tree: "treeitem"
18672 };
18673 const key = popupRole;
18674 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18675 }
18676 var useComboboxItem = createHook(
18677 function useComboboxItem2({
18678 store,
18679 value,
18680 hideOnClick,
18681 setValueOnClick,
18682 selectValueOnClick = true,
18683 resetValueOnSelect,
18684 focusOnHover = false,
18685 moveOnKeyPress = true,
18686 getItem: getItemProp,
18687 ...props
18688 }) {
18689 var _a;
18690 const context = useComboboxScopedContext();
18691 store = store || context;
18692 invariant(
18693 store,
18694 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18695 );
18696 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18697 resetValueOnSelectState: "resetValueOnSelect",
18698 multiSelectable(state) {
18699 return Array.isArray(state.selectedValue);
18700 },
18701 selected(state) {
18702 return isSelected(state.selectedValue, value);
18703 }
18704 });
18705 const getItem = (0, import_react25.useCallback)(
18706 (item) => {
18707 const nextItem = { ...item, value };
18708 if (getItemProp) {
18709 return getItemProp(nextItem);
18710 }
18711 return nextItem;
18712 },
18713 [value, getItemProp]
18714 );
18715 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18716 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18717 const onClickProp = props.onClick;
18718 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18719 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18720 const resetValueOnSelectProp = useBooleanEvent(
18721 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18722 );
18723 const hideOnClickProp = useBooleanEvent(hideOnClick);
18724 const onClick = useEvent((event) => {
18725 onClickProp == null ? void 0 : onClickProp(event);
18726 if (event.defaultPrevented) return;
18727 if (isDownloading(event)) return;
18728 if (isOpeningInNewTab(event)) return;
18729 if (value != null) {
18730 if (selectValueOnClickProp(event)) {
18731 if (resetValueOnSelectProp(event)) {
18732 store == null ? void 0 : store.resetValue();
18733 }
18734 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18735 if (!Array.isArray(prevValue)) return value;
18736 if (prevValue.includes(value)) {
18737 return prevValue.filter((v2) => v2 !== value);
18738 }
18739 return [...prevValue, value];
18740 });
18741 }
18742 if (setValueOnClickProp(event)) {
18743 store == null ? void 0 : store.setValue(value);
18744 }
18745 }
18746 if (hideOnClickProp(event)) {
18747 store == null ? void 0 : store.hide();
18748 }
18749 });
18750 const onKeyDownProp = props.onKeyDown;
18751 const onKeyDown = useEvent((event) => {
18752 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18753 if (event.defaultPrevented) return;
18754 const baseElement = store == null ? void 0 : store.getState().baseElement;
18755 if (!baseElement) return;
18756 if (hasFocus(baseElement)) return;
18757 const printable = event.key.length === 1;
18758 if (printable || event.key === "Backspace" || event.key === "Delete") {
18759 queueMicrotask(() => baseElement.focus());
18760 if (isTextField(baseElement)) {
18761 store == null ? void 0 : store.setValue(baseElement.value);
18762 }
18763 }
18764 });
18765 if (multiSelectable && selected != null) {
18766 props = {
18767 "aria-selected": selected,
18768 ...props
18769 };
18770 }
18771 props = useWrapElement(
18772 props,
18773 (element) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
18774 [value, selected]
18775 );
18776 const popupRole = (0, import_react25.useContext)(ComboboxListRoleContext);
18777 props = {
18778 role: getItemRole(popupRole),
18779 children: value,
18780 ...props,
18781 onClick,
18782 onKeyDown
18783 };
18784 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18785 props = useCompositeItem({
18786 store,
18787 ...props,
18788 getItem,
18789 // Dispatch a custom event on the combobox input when moving to an item
18790 // with the keyboard so the Combobox component can enable inline
18791 // autocompletion.
18792 moveOnKeyPress: (event) => {
18793 if (!moveOnKeyPressProp(event)) return false;
18794 const moveEvent = new Event("combobox-item-move");
18795 const baseElement = store == null ? void 0 : store.getState().baseElement;
18796 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18797 return true;
18798 }
18799 });
18800 props = useCompositeHover({ store, focusOnHover, ...props });
18801 return props;
18802 }
18803 );
18804 var ComboboxItem = memo22(
18805 forwardRef29(function ComboboxItem2(props) {
18806 const htmlProps = useComboboxItem(props);
18807 return createElement3(TagName10, htmlProps);
18808 })
18809 );
18810
18811 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18812 var import_react26 = __toESM(require_react(), 1);
18813 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18814 var TagName11 = "span";
18815 function normalizeValue(value) {
18816 return normalizeString(value).toLowerCase();
18817 }
18818 function getOffsets(string, values) {
18819 const offsets = [];
18820 for (const value of values) {
18821 let pos = 0;
18822 const length = value.length;
18823 while (string.indexOf(value, pos) !== -1) {
18824 const index2 = string.indexOf(value, pos);
18825 if (index2 !== -1) {
18826 offsets.push([index2, length]);
18827 }
18828 pos = index2 + 1;
18829 }
18830 }
18831 return offsets;
18832 }
18833 function filterOverlappingOffsets(offsets) {
18834 return offsets.filter(([offset4, length], i2, arr) => {
18835 return !arr.some(
18836 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18837 );
18838 });
18839 }
18840 function sortOffsets(offsets) {
18841 return offsets.sort(([a2], [b2]) => a2 - b2);
18842 }
18843 function splitValue(itemValue, userValue) {
18844 if (!itemValue) return itemValue;
18845 if (!userValue) return itemValue;
18846 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18847 const parts = [];
18848 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
18849 "span",
18850 {
18851 "data-autocomplete-value": autocomplete ? "" : void 0,
18852 "data-user-value": autocomplete ? void 0 : "",
18853 children: value
18854 },
18855 parts.length
18856 );
18857 const offsets = sortOffsets(
18858 filterOverlappingOffsets(
18859 // Convert userValues into a set to avoid duplicates
18860 getOffsets(normalizeValue(itemValue), new Set(userValues))
18861 )
18862 );
18863 if (!offsets.length) {
18864 parts.push(span(itemValue, true));
18865 return parts;
18866 }
18867 const [firstOffset] = offsets[0];
18868 const values = [
18869 itemValue.slice(0, firstOffset),
18870 ...offsets.flatMap(([offset4, length], i2) => {
18871 var _a;
18872 const value = itemValue.slice(offset4, offset4 + length);
18873 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18874 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18875 return [value, nextValue];
18876 })
18877 ];
18878 values.forEach((value, i2) => {
18879 if (!value) return;
18880 parts.push(span(value, i2 % 2 === 0));
18881 });
18882 return parts;
18883 }
18884 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18885 const context = useComboboxScopedContext();
18886 store = store || context;
18887 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
18888 const itemValue = value != null ? value : itemContext;
18889 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18890 const children = (0, import_react26.useMemo)(() => {
18891 if (!itemValue) return;
18892 if (!inputValue) return itemValue;
18893 return splitValue(itemValue, inputValue);
18894 }, [itemValue, inputValue]);
18895 props = {
18896 children,
18897 ...props
18898 };
18899 return removeUndefinedValues(props);
18900 });
18901 var ComboboxItemValue = forwardRef29(function ComboboxItemValue2(props) {
18902 const htmlProps = useComboboxItemValue(props);
18903 return createElement3(TagName11, htmlProps);
18904 });
18905
18906 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18907 var TagName12 = "label";
18908 var useComboboxLabel = createHook(
18909 function useComboboxLabel2({ store, ...props }) {
18910 const context = useComboboxProviderContext();
18911 store = store || context;
18912 invariant(
18913 store,
18914 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18915 );
18916 const comboboxId = store.useState((state) => {
18917 var _a;
18918 return (_a = state.baseElement) == null ? void 0 : _a.id;
18919 });
18920 props = {
18921 htmlFor: comboboxId,
18922 ...props
18923 };
18924 return removeUndefinedValues(props);
18925 }
18926 );
18927 var ComboboxLabel = memo22(
18928 forwardRef29(function ComboboxLabel2(props) {
18929 const htmlProps = useComboboxLabel(props);
18930 return createElement3(TagName12, htmlProps);
18931 })
18932 );
18933
18934 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18935 var import_react27 = __toESM(require_react(), 1);
18936 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
18937 var TagName13 = "div";
18938 var useComboboxList = createHook(
18939 function useComboboxList2({ store, alwaysVisible, ...props }) {
18940 const scopedContext = useComboboxScopedContext(true);
18941 const context = useComboboxContext();
18942 store = store || context;
18943 const scopedContextSameStore = !!store && store === scopedContext;
18944 invariant(
18945 store,
18946 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18947 );
18948 const ref = (0, import_react27.useRef)(null);
18949 const id = useId4(props.id);
18950 const mounted = store.useState("mounted");
18951 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18952 const style = hidden ? { ...props.style, display: "none" } : props.style;
18953 const multiSelectable = store.useState(
18954 (state) => Array.isArray(state.selectedValue)
18955 );
18956 const role = useAttribute(ref, "role", props.role);
18957 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18958 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18959 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
18960 const contentElement = store.useState("contentElement");
18961 useSafeLayoutEffect(() => {
18962 if (!mounted) return;
18963 const element = ref.current;
18964 if (!element) return;
18965 if (contentElement !== element) return;
18966 const callback = () => {
18967 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18968 };
18969 const observer = new MutationObserver(callback);
18970 observer.observe(element, {
18971 subtree: true,
18972 childList: true,
18973 attributeFilter: ["role"]
18974 });
18975 callback();
18976 return () => observer.disconnect();
18977 }, [mounted, contentElement]);
18978 if (!hasListboxInside) {
18979 props = {
18980 role: "listbox",
18981 "aria-multiselectable": ariaMultiSelectable,
18982 ...props
18983 };
18984 }
18985 props = useWrapElement(
18986 props,
18987 (element) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18988 [store, role]
18989 );
18990 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18991 props = {
18992 id,
18993 hidden,
18994 ...props,
18995 ref: useMergeRefs(setContentElement, ref, props.ref),
18996 style
18997 };
18998 return removeUndefinedValues(props);
18999 }
19000 );
19001 var ComboboxList = forwardRef29(function ComboboxList2(props) {
19002 const htmlProps = useComboboxList(props);
19003 return createElement3(TagName13, htmlProps);
19004 });
19005
19006 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
19007 var import_react28 = __toESM(require_react(), 1);
19008 var TagValueContext = (0, import_react28.createContext)(null);
19009 var TagRemoveIdContext = (0, import_react28.createContext)(
19010 null
19011 );
19012 var ctx7 = createStoreContext(
19013 [CompositeContextProvider],
19014 [CompositeScopedContextProvider]
19015 );
19016 var useTagContext = ctx7.useContext;
19017 var useTagScopedContext = ctx7.useScopedContext;
19018 var useTagProviderContext = ctx7.useProviderContext;
19019 var TagContextProvider = ctx7.ContextProvider;
19020 var TagScopedContextProvider = ctx7.ScopedContextProvider;
19021
19022 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
19023 var isTouchSafari = isSafari2() && isTouchDevice();
19024 function createComboboxStore({
19025 tag,
19026 ...props
19027 } = {}) {
19028 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
19029 throwOnConflictingProps(props, store);
19030 const tagState = tag == null ? void 0 : tag.getState();
19031 const syncState = store == null ? void 0 : store.getState();
19032 const activeId = defaultValue(
19033 props.activeId,
19034 syncState == null ? void 0 : syncState.activeId,
19035 props.defaultActiveId,
19036 null
19037 );
19038 const composite = createCompositeStore({
19039 ...props,
19040 activeId,
19041 includesBaseElement: defaultValue(
19042 props.includesBaseElement,
19043 syncState == null ? void 0 : syncState.includesBaseElement,
19044 true
19045 ),
19046 orientation: defaultValue(
19047 props.orientation,
19048 syncState == null ? void 0 : syncState.orientation,
19049 "vertical"
19050 ),
19051 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
19052 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
19053 virtualFocus: defaultValue(
19054 props.virtualFocus,
19055 syncState == null ? void 0 : syncState.virtualFocus,
19056 true
19057 )
19058 });
19059 const popover = createPopoverStore({
19060 ...props,
19061 placement: defaultValue(
19062 props.placement,
19063 syncState == null ? void 0 : syncState.placement,
19064 "bottom-start"
19065 )
19066 });
19067 const value = defaultValue(
19068 props.value,
19069 syncState == null ? void 0 : syncState.value,
19070 props.defaultValue,
19071 ""
19072 );
19073 const selectedValue = defaultValue(
19074 props.selectedValue,
19075 syncState == null ? void 0 : syncState.selectedValue,
19076 tagState == null ? void 0 : tagState.values,
19077 props.defaultSelectedValue,
19078 ""
19079 );
19080 const multiSelectable = Array.isArray(selectedValue);
19081 const initialState = {
19082 ...composite.getState(),
19083 ...popover.getState(),
19084 value,
19085 selectedValue,
19086 resetValueOnSelect: defaultValue(
19087 props.resetValueOnSelect,
19088 syncState == null ? void 0 : syncState.resetValueOnSelect,
19089 multiSelectable
19090 ),
19091 resetValueOnHide: defaultValue(
19092 props.resetValueOnHide,
19093 syncState == null ? void 0 : syncState.resetValueOnHide,
19094 multiSelectable && !tag
19095 ),
19096 activeValue: syncState == null ? void 0 : syncState.activeValue
19097 };
19098 const combobox = createStore(initialState, composite, popover, store);
19099 if (isTouchSafari) {
19100 setup(
19101 combobox,
19102 () => sync(combobox, ["virtualFocus"], () => {
19103 combobox.setState("virtualFocus", false);
19104 })
19105 );
19106 }
19107 setup(combobox, () => {
19108 if (!tag) return;
19109 return chain(
19110 sync(combobox, ["selectedValue"], (state) => {
19111 if (!Array.isArray(state.selectedValue)) return;
19112 tag.setValues(state.selectedValue);
19113 }),
19114 sync(tag, ["values"], (state) => {
19115 combobox.setState("selectedValue", state.values);
19116 })
19117 );
19118 });
19119 setup(
19120 combobox,
19121 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
19122 if (!state.resetValueOnHide) return;
19123 if (state.mounted) return;
19124 combobox.setState("value", value);
19125 })
19126 );
19127 setup(
19128 combobox,
19129 () => sync(combobox, ["open"], (state) => {
19130 if (state.open) return;
19131 combobox.setState("activeId", activeId);
19132 combobox.setState("moves", 0);
19133 })
19134 );
19135 setup(
19136 combobox,
19137 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
19138 if (state.moves === prevState.moves) {
19139 combobox.setState("activeValue", void 0);
19140 }
19141 })
19142 );
19143 setup(
19144 combobox,
19145 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
19146 if (state.moves === prev.moves) return;
19147 const { activeId: activeId2 } = combobox.getState();
19148 const activeItem = composite.item(activeId2);
19149 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
19150 })
19151 );
19152 return {
19153 ...popover,
19154 ...composite,
19155 ...combobox,
19156 tag,
19157 setValue: (value2) => combobox.setState("value", value2),
19158 resetValue: () => combobox.setState("value", initialState.value),
19159 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
19160 };
19161 }
19162
19163 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
19164 function useComboboxStoreOptions(props) {
19165 const tag = useTagContext();
19166 props = {
19167 ...props,
19168 tag: props.tag !== void 0 ? props.tag : tag
19169 };
19170 return useCompositeStoreOptions(props);
19171 }
19172 function useComboboxStoreProps(store, update2, props) {
19173 useUpdateEffect(update2, [props.tag]);
19174 useStoreProps(store, props, "value", "setValue");
19175 useStoreProps(store, props, "selectedValue", "setSelectedValue");
19176 useStoreProps(store, props, "resetValueOnHide");
19177 useStoreProps(store, props, "resetValueOnSelect");
19178 return Object.assign(
19179 useCompositeStoreProps(
19180 usePopoverStoreProps(store, update2, props),
19181 update2,
19182 props
19183 ),
19184 { tag: props.tag }
19185 );
19186 }
19187 function useComboboxStore(props = {}) {
19188 props = useComboboxStoreOptions(props);
19189 const [store, update2] = useStore2(createComboboxStore, props);
19190 return useComboboxStoreProps(store, update2, props);
19191 }
19192
19193 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
19194 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19195 function ComboboxProvider(props = {}) {
19196 const store = useComboboxStore(props);
19197 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxContextProvider, { value: store, children: props.children });
19198 }
19199
19200 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19201 var import_remove_accents = __toESM(require_remove_accents(), 1);
19202 var import_compose8 = __toESM(require_compose(), 1);
19203 var import_i18n24 = __toESM(require_i18n(), 1);
19204 var import_element50 = __toESM(require_element(), 1);
19205 var import_components19 = __toESM(require_components(), 1);
19206
19207 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
19208 var EMPTY_ARRAY3 = [];
19209 var getCurrentValue = (filterDefinition, currentFilter) => {
19210 if (filterDefinition.singleSelection) {
19211 return currentFilter?.value;
19212 }
19213 if (Array.isArray(currentFilter?.value)) {
19214 return currentFilter.value;
19215 }
19216 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
19217 return [currentFilter.value];
19218 }
19219 return EMPTY_ARRAY3;
19220 };
19221
19222 // packages/dataviews/build-module/hooks/use-elements.mjs
19223 var import_element49 = __toESM(require_element(), 1);
19224 var EMPTY_ARRAY4 = [];
19225 function useElements({
19226 elements,
19227 getElements
19228 }) {
19229 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
19230 const [records, setRecords] = (0, import_element49.useState)(staticElements);
19231 const [isLoading, setIsLoading] = (0, import_element49.useState)(false);
19232 (0, import_element49.useEffect)(() => {
19233 if (!getElements) {
19234 setRecords(staticElements);
19235 return;
19236 }
19237 let cancelled = false;
19238 setIsLoading(true);
19239 getElements().then((fetchedElements) => {
19240 if (!cancelled) {
19241 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
19242 setRecords(dynamicElements);
19243 }
19244 }).catch(() => {
19245 if (!cancelled) {
19246 setRecords(staticElements);
19247 }
19248 }).finally(() => {
19249 if (!cancelled) {
19250 setIsLoading(false);
19251 }
19252 });
19253 return () => {
19254 cancelled = true;
19255 };
19256 }, [getElements, staticElements]);
19257 return {
19258 elements: records,
19259 isLoading
19260 };
19261 }
19262
19263 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19264 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19265 function normalizeSearchInput(input = "") {
19266 return (0, import_remove_accents.default)(input.trim().toLowerCase());
19267 }
19268 var getNewValue = (filterDefinition, currentFilter, value) => {
19269 if (filterDefinition.singleSelection) {
19270 return value;
19271 }
19272 if (Array.isArray(currentFilter?.value)) {
19273 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
19274 }
19275 return [value];
19276 };
19277 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
19278 return `${prefix}-${filterElementValue}`;
19279 }
19280 var MultiSelectionOption = ({ selected }) => {
19281 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19282 "span",
19283 {
19284 className: clsx_default(
19285 "dataviews-filters__search-widget-listitem-multi-selection",
19286 { "is-selected": selected }
19287 ),
19288 children: selected && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: check_default })
19289 }
19290 );
19291 };
19292 var SingleSelectionOption = ({ selected }) => {
19293 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19294 "span",
19295 {
19296 className: clsx_default(
19297 "dataviews-filters__search-widget-listitem-single-selection",
19298 { "is-selected": selected }
19299 )
19300 }
19301 );
19302 };
19303 function ListBox({ view, filter, onChangeView }) {
19304 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19305 const [activeCompositeId, setActiveCompositeId] = (0, import_element50.useState)(
19306 // When there are one or less operators, the first item is set as active
19307 // (by setting the initial `activeId` to `undefined`).
19308 // With 2 or more operators, the focus is moved on the operators control
19309 // (by setting the initial `activeId` to `null`), meaning that there won't
19310 // be an active item initially. Focus is then managed via the
19311 // `onFocusVisible` callback.
19312 filter.operators?.length === 1 ? void 0 : null
19313 );
19314 const currentFilter = view.filters?.find(
19315 (f2) => f2.field === filter.field
19316 );
19317 const currentValue = getCurrentValue(filter, currentFilter);
19318 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19319 import_components19.Composite,
19320 {
19321 virtualFocus: true,
19322 focusLoop: true,
19323 activeId: activeCompositeId,
19324 setActiveId: setActiveCompositeId,
19325 role: "listbox",
19326 className: "dataviews-filters__search-widget-listbox",
19327 "aria-label": (0, import_i18n24.sprintf)(
19328 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19329 (0, import_i18n24.__)("List of: %1$s"),
19330 filter.name
19331 ),
19332 onFocusVisible: () => {
19333 if (!activeCompositeId && filter.elements.length) {
19334 setActiveCompositeId(
19335 generateFilterElementCompositeItemId(
19336 baseId,
19337 filter.elements[0].value
19338 )
19339 );
19340 }
19341 },
19342 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Composite.Typeahead, {}),
19343 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19344 import_components19.Composite.Hover,
19345 {
19346 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19347 import_components19.Composite.Item,
19348 {
19349 id: generateFilterElementCompositeItemId(
19350 baseId,
19351 element.value
19352 ),
19353 render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19354 "div",
19355 {
19356 "aria-label": element.label,
19357 role: "option",
19358 className: "dataviews-filters__search-widget-listitem"
19359 }
19360 ),
19361 onClick: () => {
19362 const newFilters = currentFilter ? [
19363 ...(view.filters ?? []).map(
19364 (_filter) => {
19365 if (_filter.field === filter.field) {
19366 return {
19367 ..._filter,
19368 operator: currentFilter.operator || filter.operators[0],
19369 value: getNewValue(
19370 filter,
19371 currentFilter,
19372 element.value
19373 )
19374 };
19375 }
19376 return _filter;
19377 }
19378 )
19379 ] : [
19380 ...view.filters ?? [],
19381 {
19382 field: filter.field,
19383 operator: filter.operators[0],
19384 value: getNewValue(
19385 filter,
19386 currentFilter,
19387 element.value
19388 )
19389 }
19390 ];
19391 onChangeView({
19392 ...view,
19393 page: 1,
19394 filters: newFilters
19395 });
19396 }
19397 }
19398 ),
19399 children: [
19400 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19401 SingleSelectionOption,
19402 {
19403 selected: currentValue === element.value
19404 }
19405 ),
19406 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19407 MultiSelectionOption,
19408 {
19409 selected: currentValue.includes(element.value)
19410 }
19411 ),
19412 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19413 "span",
19414 {
19415 className: "dataviews-filters__search-widget-listitem-value",
19416 title: element.label,
19417 children: element.label
19418 }
19419 )
19420 ]
19421 },
19422 element.value
19423 ))
19424 }
19425 );
19426 }
19427 function ComboboxList22({ view, filter, onChangeView }) {
19428 const [searchValue, setSearchValue] = (0, import_element50.useState)("");
19429 const deferredSearchValue = (0, import_element50.useDeferredValue)(searchValue);
19430 const currentFilter = view.filters?.find(
19431 (_filter) => _filter.field === filter.field
19432 );
19433 const currentValue = getCurrentValue(filter, currentFilter);
19434 const matches = (0, import_element50.useMemo)(() => {
19435 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19436 return filter.elements.filter(
19437 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19438 );
19439 }, [filter.elements, deferredSearchValue]);
19440 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19441 ComboboxProvider,
19442 {
19443 selectedValue: currentValue,
19444 setSelectedValue: (value) => {
19445 const newFilters = currentFilter ? [
19446 ...(view.filters ?? []).map((_filter) => {
19447 if (_filter.field === filter.field) {
19448 return {
19449 ..._filter,
19450 operator: currentFilter.operator || filter.operators[0],
19451 value
19452 };
19453 }
19454 return _filter;
19455 })
19456 ] : [
19457 ...view.filters ?? [],
19458 {
19459 field: filter.field,
19460 operator: filter.operators[0],
19461 value
19462 }
19463 ];
19464 onChangeView({
19465 ...view,
19466 page: 1,
19467 filters: newFilters
19468 });
19469 },
19470 setValue: setSearchValue,
19471 children: [
19472 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19473 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ComboboxLabel, {}), children: (0, import_i18n24.__)("Search items") }),
19474 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19475 Combobox,
19476 {
19477 autoSelect: "always",
19478 placeholder: (0, import_i18n24.__)("Search"),
19479 className: "dataviews-filters__search-widget-filter-combobox__input"
19480 }
19481 ),
19482 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Icon, { icon: search_default }) })
19483 ] }),
19484 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19485 ComboboxList,
19486 {
19487 className: "dataviews-filters__search-widget-filter-combobox-list",
19488 alwaysVisible: true,
19489 children: [
19490 matches.map((element) => {
19491 return /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19492 ComboboxItem,
19493 {
19494 resetValueOnSelect: false,
19495 value: element.value,
19496 className: "dataviews-filters__search-widget-listitem",
19497 hideOnClick: false,
19498 setValueOnClick: false,
19499 focusOnHover: true,
19500 children: [
19501 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19502 SingleSelectionOption,
19503 {
19504 selected: currentValue === element.value
19505 }
19506 ),
19507 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19508 MultiSelectionOption,
19509 {
19510 selected: currentValue.includes(
19511 element.value
19512 )
19513 }
19514 ),
19515 /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(
19516 "span",
19517 {
19518 className: "dataviews-filters__search-widget-listitem-value",
19519 title: element.label,
19520 children: [
19521 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19522 ComboboxItemValue,
19523 {
19524 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19525 value: element.label
19526 }
19527 ),
19528 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19529 ]
19530 }
19531 )
19532 ]
19533 },
19534 element.value
19535 );
19536 }),
19537 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n24.__)("No results found") })
19538 ]
19539 }
19540 )
19541 ]
19542 }
19543 );
19544 }
19545 function SearchWidget(props) {
19546 const { elements, isLoading } = useElements({
19547 elements: props.filter.elements,
19548 getElements: props.filter.getElements
19549 });
19550 if (isLoading) {
19551 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components19.Spinner, {}) });
19552 }
19553 if (elements.length === 0) {
19554 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n24.__)("No elements found") });
19555 }
19556 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19557 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19558 }
19559
19560 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19561 var import_es6 = __toESM(require_es6(), 1);
19562 var import_compose9 = __toESM(require_compose(), 1);
19563 var import_element51 = __toESM(require_element(), 1);
19564 var import_components20 = __toESM(require_components(), 1);
19565 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
19566 function InputWidget({
19567 filter,
19568 view,
19569 onChangeView,
19570 fields
19571 }) {
19572 const currentFilter = view.filters?.find(
19573 (f2) => f2.field === filter.field
19574 );
19575 const currentValue = getCurrentValue(filter, currentFilter);
19576 const field = (0, import_element51.useMemo)(() => {
19577 const currentField = fields.find((f2) => f2.id === filter.field);
19578 if (currentField) {
19579 return {
19580 ...currentField,
19581 // Deactivate validation for filters.
19582 isValid: {},
19583 // Filter controls are always enabled.
19584 isDisabled: () => false,
19585 // Filter controls are always visible.
19586 isVisible: () => true,
19587 // Configure getValue/setValue as if Item was a plain object.
19588 getValue: ({ item }) => item[currentField.id],
19589 setValue: ({ value }) => ({
19590 [currentField.id]: value
19591 })
19592 };
19593 }
19594 return currentField;
19595 }, [fields, filter.field]);
19596 const data = (0, import_element51.useMemo)(() => {
19597 return (view.filters ?? []).reduce(
19598 (acc, activeFilter) => {
19599 acc[activeFilter.field] = activeFilter.value;
19600 return acc;
19601 },
19602 {}
19603 );
19604 }, [view.filters]);
19605 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19606 if (!field || !currentFilter) {
19607 return;
19608 }
19609 const nextValue = field.getValue({ item: updatedData });
19610 if ((0, import_es6.default)(nextValue, currentValue)) {
19611 return;
19612 }
19613 onChangeView({
19614 ...view,
19615 filters: (view.filters ?? []).map(
19616 (_filter) => _filter.field === filter.field ? {
19617 ..._filter,
19618 operator: currentFilter.operator || filter.operators[0],
19619 // Consider empty strings as undefined:
19620 //
19621 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19622 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19623 //
19624 // In practice, this means the filter will not be able to find an empty string as the value.
19625 value: nextValue === "" ? void 0 : nextValue
19626 } : _filter
19627 )
19628 });
19629 });
19630 if (!field || !field.Edit || !currentFilter) {
19631 return null;
19632 }
19633 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19634 import_components20.Flex,
19635 {
19636 className: "dataviews-filters__user-input-widget",
19637 gap: 2.5,
19638 direction: "column",
19639 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
19640 field.Edit,
19641 {
19642 hideLabelFromVision: true,
19643 data,
19644 field,
19645 operator: currentFilter.operator,
19646 onChange: handleChange
19647 }
19648 )
19649 }
19650 );
19651 }
19652
19653 // node_modules/date-fns/constants.js
19654 var daysInYear = 365.2425;
19655 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19656 var minTime = -maxTime;
19657 var millisecondsInWeek = 6048e5;
19658 var millisecondsInDay = 864e5;
19659 var secondsInHour = 3600;
19660 var secondsInDay = secondsInHour * 24;
19661 var secondsInWeek = secondsInDay * 7;
19662 var secondsInYear = secondsInDay * daysInYear;
19663 var secondsInMonth = secondsInYear / 12;
19664 var secondsInQuarter = secondsInMonth * 3;
19665 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19666
19667 // node_modules/date-fns/constructFrom.js
19668 function constructFrom(date, value) {
19669 if (typeof date === "function") return date(value);
19670 if (date && typeof date === "object" && constructFromSymbol in date)
19671 return date[constructFromSymbol](value);
19672 if (date instanceof Date) return new date.constructor(value);
19673 return new Date(value);
19674 }
19675
19676 // node_modules/date-fns/toDate.js
19677 function toDate(argument, context) {
19678 return constructFrom(context || argument, argument);
19679 }
19680
19681 // node_modules/date-fns/addDays.js
19682 function addDays(date, amount, options) {
19683 const _date = toDate(date, options?.in);
19684 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19685 if (!amount) return _date;
19686 _date.setDate(_date.getDate() + amount);
19687 return _date;
19688 }
19689
19690 // node_modules/date-fns/addMonths.js
19691 function addMonths(date, amount, options) {
19692 const _date = toDate(date, options?.in);
19693 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19694 if (!amount) {
19695 return _date;
19696 }
19697 const dayOfMonth = _date.getDate();
19698 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19699 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19700 const daysInMonth = endOfDesiredMonth.getDate();
19701 if (dayOfMonth >= daysInMonth) {
19702 return endOfDesiredMonth;
19703 } else {
19704 _date.setFullYear(
19705 endOfDesiredMonth.getFullYear(),
19706 endOfDesiredMonth.getMonth(),
19707 dayOfMonth
19708 );
19709 return _date;
19710 }
19711 }
19712
19713 // node_modules/date-fns/_lib/defaultOptions.js
19714 var defaultOptions = {};
19715 function getDefaultOptions() {
19716 return defaultOptions;
19717 }
19718
19719 // node_modules/date-fns/startOfWeek.js
19720 function startOfWeek(date, options) {
19721 const defaultOptions2 = getDefaultOptions();
19722 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19723 const _date = toDate(date, options?.in);
19724 const day = _date.getDay();
19725 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19726 _date.setDate(_date.getDate() - diff);
19727 _date.setHours(0, 0, 0, 0);
19728 return _date;
19729 }
19730
19731 // node_modules/date-fns/startOfISOWeek.js
19732 function startOfISOWeek(date, options) {
19733 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19734 }
19735
19736 // node_modules/date-fns/getISOWeekYear.js
19737 function getISOWeekYear(date, options) {
19738 const _date = toDate(date, options?.in);
19739 const year = _date.getFullYear();
19740 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19741 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19742 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19743 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19744 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19745 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19746 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19747 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19748 if (_date.getTime() >= startOfNextYear.getTime()) {
19749 return year + 1;
19750 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19751 return year;
19752 } else {
19753 return year - 1;
19754 }
19755 }
19756
19757 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19758 function getTimezoneOffsetInMilliseconds(date) {
19759 const _date = toDate(date);
19760 const utcDate = new Date(
19761 Date.UTC(
19762 _date.getFullYear(),
19763 _date.getMonth(),
19764 _date.getDate(),
19765 _date.getHours(),
19766 _date.getMinutes(),
19767 _date.getSeconds(),
19768 _date.getMilliseconds()
19769 )
19770 );
19771 utcDate.setUTCFullYear(_date.getFullYear());
19772 return +date - +utcDate;
19773 }
19774
19775 // node_modules/date-fns/_lib/normalizeDates.js
19776 function normalizeDates(context, ...dates) {
19777 const normalize = constructFrom.bind(
19778 null,
19779 context || dates.find((date) => typeof date === "object")
19780 );
19781 return dates.map(normalize);
19782 }
19783
19784 // node_modules/date-fns/startOfDay.js
19785 function startOfDay(date, options) {
19786 const _date = toDate(date, options?.in);
19787 _date.setHours(0, 0, 0, 0);
19788 return _date;
19789 }
19790
19791 // node_modules/date-fns/differenceInCalendarDays.js
19792 function differenceInCalendarDays(laterDate, earlierDate, options) {
19793 const [laterDate_, earlierDate_] = normalizeDates(
19794 options?.in,
19795 laterDate,
19796 earlierDate
19797 );
19798 const laterStartOfDay = startOfDay(laterDate_);
19799 const earlierStartOfDay = startOfDay(earlierDate_);
19800 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19801 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19802 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19803 }
19804
19805 // node_modules/date-fns/startOfISOWeekYear.js
19806 function startOfISOWeekYear(date, options) {
19807 const year = getISOWeekYear(date, options);
19808 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19809 fourthOfJanuary.setFullYear(year, 0, 4);
19810 fourthOfJanuary.setHours(0, 0, 0, 0);
19811 return startOfISOWeek(fourthOfJanuary);
19812 }
19813
19814 // node_modules/date-fns/addWeeks.js
19815 function addWeeks(date, amount, options) {
19816 return addDays(date, amount * 7, options);
19817 }
19818
19819 // node_modules/date-fns/addYears.js
19820 function addYears(date, amount, options) {
19821 return addMonths(date, amount * 12, options);
19822 }
19823
19824 // node_modules/date-fns/isDate.js
19825 function isDate(value) {
19826 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19827 }
19828
19829 // node_modules/date-fns/isValid.js
19830 function isValid(date) {
19831 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19832 }
19833
19834 // node_modules/date-fns/startOfMonth.js
19835 function startOfMonth(date, options) {
19836 const _date = toDate(date, options?.in);
19837 _date.setDate(1);
19838 _date.setHours(0, 0, 0, 0);
19839 return _date;
19840 }
19841
19842 // node_modules/date-fns/startOfYear.js
19843 function startOfYear(date, options) {
19844 const date_ = toDate(date, options?.in);
19845 date_.setFullYear(date_.getFullYear(), 0, 1);
19846 date_.setHours(0, 0, 0, 0);
19847 return date_;
19848 }
19849
19850 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19851 var formatDistanceLocale = {
19852 lessThanXSeconds: {
19853 one: "less than a second",
19854 other: "less than {{count}} seconds"
19855 },
19856 xSeconds: {
19857 one: "1 second",
19858 other: "{{count}} seconds"
19859 },
19860 halfAMinute: "half a minute",
19861 lessThanXMinutes: {
19862 one: "less than a minute",
19863 other: "less than {{count}} minutes"
19864 },
19865 xMinutes: {
19866 one: "1 minute",
19867 other: "{{count}} minutes"
19868 },
19869 aboutXHours: {
19870 one: "about 1 hour",
19871 other: "about {{count}} hours"
19872 },
19873 xHours: {
19874 one: "1 hour",
19875 other: "{{count}} hours"
19876 },
19877 xDays: {
19878 one: "1 day",
19879 other: "{{count}} days"
19880 },
19881 aboutXWeeks: {
19882 one: "about 1 week",
19883 other: "about {{count}} weeks"
19884 },
19885 xWeeks: {
19886 one: "1 week",
19887 other: "{{count}} weeks"
19888 },
19889 aboutXMonths: {
19890 one: "about 1 month",
19891 other: "about {{count}} months"
19892 },
19893 xMonths: {
19894 one: "1 month",
19895 other: "{{count}} months"
19896 },
19897 aboutXYears: {
19898 one: "about 1 year",
19899 other: "about {{count}} years"
19900 },
19901 xYears: {
19902 one: "1 year",
19903 other: "{{count}} years"
19904 },
19905 overXYears: {
19906 one: "over 1 year",
19907 other: "over {{count}} years"
19908 },
19909 almostXYears: {
19910 one: "almost 1 year",
19911 other: "almost {{count}} years"
19912 }
19913 };
19914 var formatDistance = (token, count, options) => {
19915 let result;
19916 const tokenValue = formatDistanceLocale[token];
19917 if (typeof tokenValue === "string") {
19918 result = tokenValue;
19919 } else if (count === 1) {
19920 result = tokenValue.one;
19921 } else {
19922 result = tokenValue.other.replace("{{count}}", count.toString());
19923 }
19924 if (options?.addSuffix) {
19925 if (options.comparison && options.comparison > 0) {
19926 return "in " + result;
19927 } else {
19928 return result + " ago";
19929 }
19930 }
19931 return result;
19932 };
19933
19934 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19935 function buildFormatLongFn(args) {
19936 return (options = {}) => {
19937 const width = options.width ? String(options.width) : args.defaultWidth;
19938 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19939 return format6;
19940 };
19941 }
19942
19943 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19944 var dateFormats = {
19945 full: "EEEE, MMMM do, y",
19946 long: "MMMM do, y",
19947 medium: "MMM d, y",
19948 short: "MM/dd/yyyy"
19949 };
19950 var timeFormats = {
19951 full: "h:mm:ss a zzzz",
19952 long: "h:mm:ss a z",
19953 medium: "h:mm:ss a",
19954 short: "h:mm a"
19955 };
19956 var dateTimeFormats = {
19957 full: "{{date}} 'at' {{time}}",
19958 long: "{{date}} 'at' {{time}}",
19959 medium: "{{date}}, {{time}}",
19960 short: "{{date}}, {{time}}"
19961 };
19962 var formatLong = {
19963 date: buildFormatLongFn({
19964 formats: dateFormats,
19965 defaultWidth: "full"
19966 }),
19967 time: buildFormatLongFn({
19968 formats: timeFormats,
19969 defaultWidth: "full"
19970 }),
19971 dateTime: buildFormatLongFn({
19972 formats: dateTimeFormats,
19973 defaultWidth: "full"
19974 })
19975 };
19976
19977 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19978 var formatRelativeLocale = {
19979 lastWeek: "'last' eeee 'at' p",
19980 yesterday: "'yesterday at' p",
19981 today: "'today at' p",
19982 tomorrow: "'tomorrow at' p",
19983 nextWeek: "eeee 'at' p",
19984 other: "P"
19985 };
19986 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19987
19988 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19989 function buildLocalizeFn(args) {
19990 return (value, options) => {
19991 const context = options?.context ? String(options.context) : "standalone";
19992 let valuesArray;
19993 if (context === "formatting" && args.formattingValues) {
19994 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19995 const width = options?.width ? String(options.width) : defaultWidth;
19996 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19997 } else {
19998 const defaultWidth = args.defaultWidth;
19999 const width = options?.width ? String(options.width) : args.defaultWidth;
20000 valuesArray = args.values[width] || args.values[defaultWidth];
20001 }
20002 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
20003 return valuesArray[index2];
20004 };
20005 }
20006
20007 // node_modules/date-fns/locale/en-US/_lib/localize.js
20008 var eraValues = {
20009 narrow: ["B", "A"],
20010 abbreviated: ["BC", "AD"],
20011 wide: ["Before Christ", "Anno Domini"]
20012 };
20013 var quarterValues = {
20014 narrow: ["1", "2", "3", "4"],
20015 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
20016 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
20017 };
20018 var monthValues = {
20019 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
20020 abbreviated: [
20021 "Jan",
20022 "Feb",
20023 "Mar",
20024 "Apr",
20025 "May",
20026 "Jun",
20027 "Jul",
20028 "Aug",
20029 "Sep",
20030 "Oct",
20031 "Nov",
20032 "Dec"
20033 ],
20034 wide: [
20035 "January",
20036 "February",
20037 "March",
20038 "April",
20039 "May",
20040 "June",
20041 "July",
20042 "August",
20043 "September",
20044 "October",
20045 "November",
20046 "December"
20047 ]
20048 };
20049 var dayValues = {
20050 narrow: ["S", "M", "T", "W", "T", "F", "S"],
20051 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
20052 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
20053 wide: [
20054 "Sunday",
20055 "Monday",
20056 "Tuesday",
20057 "Wednesday",
20058 "Thursday",
20059 "Friday",
20060 "Saturday"
20061 ]
20062 };
20063 var dayPeriodValues = {
20064 narrow: {
20065 am: "a",
20066 pm: "p",
20067 midnight: "mi",
20068 noon: "n",
20069 morning: "morning",
20070 afternoon: "afternoon",
20071 evening: "evening",
20072 night: "night"
20073 },
20074 abbreviated: {
20075 am: "AM",
20076 pm: "PM",
20077 midnight: "midnight",
20078 noon: "noon",
20079 morning: "morning",
20080 afternoon: "afternoon",
20081 evening: "evening",
20082 night: "night"
20083 },
20084 wide: {
20085 am: "a.m.",
20086 pm: "p.m.",
20087 midnight: "midnight",
20088 noon: "noon",
20089 morning: "morning",
20090 afternoon: "afternoon",
20091 evening: "evening",
20092 night: "night"
20093 }
20094 };
20095 var formattingDayPeriodValues = {
20096 narrow: {
20097 am: "a",
20098 pm: "p",
20099 midnight: "mi",
20100 noon: "n",
20101 morning: "in the morning",
20102 afternoon: "in the afternoon",
20103 evening: "in the evening",
20104 night: "at night"
20105 },
20106 abbreviated: {
20107 am: "AM",
20108 pm: "PM",
20109 midnight: "midnight",
20110 noon: "noon",
20111 morning: "in the morning",
20112 afternoon: "in the afternoon",
20113 evening: "in the evening",
20114 night: "at night"
20115 },
20116 wide: {
20117 am: "a.m.",
20118 pm: "p.m.",
20119 midnight: "midnight",
20120 noon: "noon",
20121 morning: "in the morning",
20122 afternoon: "in the afternoon",
20123 evening: "in the evening",
20124 night: "at night"
20125 }
20126 };
20127 var ordinalNumber = (dirtyNumber, _options) => {
20128 const number = Number(dirtyNumber);
20129 const rem100 = number % 100;
20130 if (rem100 > 20 || rem100 < 10) {
20131 switch (rem100 % 10) {
20132 case 1:
20133 return number + "st";
20134 case 2:
20135 return number + "nd";
20136 case 3:
20137 return number + "rd";
20138 }
20139 }
20140 return number + "th";
20141 };
20142 var localize = {
20143 ordinalNumber,
20144 era: buildLocalizeFn({
20145 values: eraValues,
20146 defaultWidth: "wide"
20147 }),
20148 quarter: buildLocalizeFn({
20149 values: quarterValues,
20150 defaultWidth: "wide",
20151 argumentCallback: (quarter) => quarter - 1
20152 }),
20153 month: buildLocalizeFn({
20154 values: monthValues,
20155 defaultWidth: "wide"
20156 }),
20157 day: buildLocalizeFn({
20158 values: dayValues,
20159 defaultWidth: "wide"
20160 }),
20161 dayPeriod: buildLocalizeFn({
20162 values: dayPeriodValues,
20163 defaultWidth: "wide",
20164 formattingValues: formattingDayPeriodValues,
20165 defaultFormattingWidth: "wide"
20166 })
20167 };
20168
20169 // node_modules/date-fns/locale/_lib/buildMatchFn.js
20170 function buildMatchFn(args) {
20171 return (string, options = {}) => {
20172 const width = options.width;
20173 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
20174 const matchResult = string.match(matchPattern);
20175 if (!matchResult) {
20176 return null;
20177 }
20178 const matchedString = matchResult[0];
20179 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
20180 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
20181 // [TODO] -- I challenge you to fix the type
20182 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
20183 );
20184 let value;
20185 value = args.valueCallback ? args.valueCallback(key) : key;
20186 value = options.valueCallback ? (
20187 // [TODO] -- I challenge you to fix the type
20188 options.valueCallback(value)
20189 ) : value;
20190 const rest = string.slice(matchedString.length);
20191 return { value, rest };
20192 };
20193 }
20194 function findKey(object, predicate) {
20195 for (const key in object) {
20196 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
20197 return key;
20198 }
20199 }
20200 return void 0;
20201 }
20202 function findIndex(array, predicate) {
20203 for (let key = 0; key < array.length; key++) {
20204 if (predicate(array[key])) {
20205 return key;
20206 }
20207 }
20208 return void 0;
20209 }
20210
20211 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
20212 function buildMatchPatternFn(args) {
20213 return (string, options = {}) => {
20214 const matchResult = string.match(args.matchPattern);
20215 if (!matchResult) return null;
20216 const matchedString = matchResult[0];
20217 const parseResult = string.match(args.parsePattern);
20218 if (!parseResult) return null;
20219 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
20220 value = options.valueCallback ? options.valueCallback(value) : value;
20221 const rest = string.slice(matchedString.length);
20222 return { value, rest };
20223 };
20224 }
20225
20226 // node_modules/date-fns/locale/en-US/_lib/match.js
20227 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
20228 var parseOrdinalNumberPattern = /\d+/i;
20229 var matchEraPatterns = {
20230 narrow: /^(b|a)/i,
20231 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
20232 wide: /^(before christ|before common era|anno domini|common era)/i
20233 };
20234 var parseEraPatterns = {
20235 any: [/^b/i, /^(a|c)/i]
20236 };
20237 var matchQuarterPatterns = {
20238 narrow: /^[1234]/i,
20239 abbreviated: /^q[1234]/i,
20240 wide: /^[1234](th|st|nd|rd)? quarter/i
20241 };
20242 var parseQuarterPatterns = {
20243 any: [/1/i, /2/i, /3/i, /4/i]
20244 };
20245 var matchMonthPatterns = {
20246 narrow: /^[jfmasond]/i,
20247 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
20248 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
20249 };
20250 var parseMonthPatterns = {
20251 narrow: [
20252 /^j/i,
20253 /^f/i,
20254 /^m/i,
20255 /^a/i,
20256 /^m/i,
20257 /^j/i,
20258 /^j/i,
20259 /^a/i,
20260 /^s/i,
20261 /^o/i,
20262 /^n/i,
20263 /^d/i
20264 ],
20265 any: [
20266 /^ja/i,
20267 /^f/i,
20268 /^mar/i,
20269 /^ap/i,
20270 /^may/i,
20271 /^jun/i,
20272 /^jul/i,
20273 /^au/i,
20274 /^s/i,
20275 /^o/i,
20276 /^n/i,
20277 /^d/i
20278 ]
20279 };
20280 var matchDayPatterns = {
20281 narrow: /^[smtwf]/i,
20282 short: /^(su|mo|tu|we|th|fr|sa)/i,
20283 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20284 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20285 };
20286 var parseDayPatterns = {
20287 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20288 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20289 };
20290 var matchDayPeriodPatterns = {
20291 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20292 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20293 };
20294 var parseDayPeriodPatterns = {
20295 any: {
20296 am: /^a/i,
20297 pm: /^p/i,
20298 midnight: /^mi/i,
20299 noon: /^no/i,
20300 morning: /morning/i,
20301 afternoon: /afternoon/i,
20302 evening: /evening/i,
20303 night: /night/i
20304 }
20305 };
20306 var match = {
20307 ordinalNumber: buildMatchPatternFn({
20308 matchPattern: matchOrdinalNumberPattern,
20309 parsePattern: parseOrdinalNumberPattern,
20310 valueCallback: (value) => parseInt(value, 10)
20311 }),
20312 era: buildMatchFn({
20313 matchPatterns: matchEraPatterns,
20314 defaultMatchWidth: "wide",
20315 parsePatterns: parseEraPatterns,
20316 defaultParseWidth: "any"
20317 }),
20318 quarter: buildMatchFn({
20319 matchPatterns: matchQuarterPatterns,
20320 defaultMatchWidth: "wide",
20321 parsePatterns: parseQuarterPatterns,
20322 defaultParseWidth: "any",
20323 valueCallback: (index2) => index2 + 1
20324 }),
20325 month: buildMatchFn({
20326 matchPatterns: matchMonthPatterns,
20327 defaultMatchWidth: "wide",
20328 parsePatterns: parseMonthPatterns,
20329 defaultParseWidth: "any"
20330 }),
20331 day: buildMatchFn({
20332 matchPatterns: matchDayPatterns,
20333 defaultMatchWidth: "wide",
20334 parsePatterns: parseDayPatterns,
20335 defaultParseWidth: "any"
20336 }),
20337 dayPeriod: buildMatchFn({
20338 matchPatterns: matchDayPeriodPatterns,
20339 defaultMatchWidth: "any",
20340 parsePatterns: parseDayPeriodPatterns,
20341 defaultParseWidth: "any"
20342 })
20343 };
20344
20345 // node_modules/date-fns/locale/en-US.js
20346 var enUS = {
20347 code: "en-US",
20348 formatDistance,
20349 formatLong,
20350 formatRelative,
20351 localize,
20352 match,
20353 options: {
20354 weekStartsOn: 0,
20355 firstWeekContainsDate: 1
20356 }
20357 };
20358
20359 // node_modules/date-fns/getDayOfYear.js
20360 function getDayOfYear(date, options) {
20361 const _date = toDate(date, options?.in);
20362 const diff = differenceInCalendarDays(_date, startOfYear(_date));
20363 const dayOfYear = diff + 1;
20364 return dayOfYear;
20365 }
20366
20367 // node_modules/date-fns/getISOWeek.js
20368 function getISOWeek(date, options) {
20369 const _date = toDate(date, options?.in);
20370 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20371 return Math.round(diff / millisecondsInWeek) + 1;
20372 }
20373
20374 // node_modules/date-fns/getWeekYear.js
20375 function getWeekYear(date, options) {
20376 const _date = toDate(date, options?.in);
20377 const year = _date.getFullYear();
20378 const defaultOptions2 = getDefaultOptions();
20379 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20380 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20381 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20382 firstWeekOfNextYear.setHours(0, 0, 0, 0);
20383 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20384 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20385 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20386 firstWeekOfThisYear.setHours(0, 0, 0, 0);
20387 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20388 if (+_date >= +startOfNextYear) {
20389 return year + 1;
20390 } else if (+_date >= +startOfThisYear) {
20391 return year;
20392 } else {
20393 return year - 1;
20394 }
20395 }
20396
20397 // node_modules/date-fns/startOfWeekYear.js
20398 function startOfWeekYear(date, options) {
20399 const defaultOptions2 = getDefaultOptions();
20400 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20401 const year = getWeekYear(date, options);
20402 const firstWeek = constructFrom(options?.in || date, 0);
20403 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20404 firstWeek.setHours(0, 0, 0, 0);
20405 const _date = startOfWeek(firstWeek, options);
20406 return _date;
20407 }
20408
20409 // node_modules/date-fns/getWeek.js
20410 function getWeek(date, options) {
20411 const _date = toDate(date, options?.in);
20412 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20413 return Math.round(diff / millisecondsInWeek) + 1;
20414 }
20415
20416 // node_modules/date-fns/_lib/addLeadingZeros.js
20417 function addLeadingZeros(number, targetLength) {
20418 const sign = number < 0 ? "-" : "";
20419 const output = Math.abs(number).toString().padStart(targetLength, "0");
20420 return sign + output;
20421 }
20422
20423 // node_modules/date-fns/_lib/format/lightFormatters.js
20424 var lightFormatters = {
20425 // Year
20426 y(date, token) {
20427 const signedYear = date.getFullYear();
20428 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20429 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20430 },
20431 // Month
20432 M(date, token) {
20433 const month = date.getMonth();
20434 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20435 },
20436 // Day of the month
20437 d(date, token) {
20438 return addLeadingZeros(date.getDate(), token.length);
20439 },
20440 // AM or PM
20441 a(date, token) {
20442 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20443 switch (token) {
20444 case "a":
20445 case "aa":
20446 return dayPeriodEnumValue.toUpperCase();
20447 case "aaa":
20448 return dayPeriodEnumValue;
20449 case "aaaaa":
20450 return dayPeriodEnumValue[0];
20451 case "aaaa":
20452 default:
20453 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20454 }
20455 },
20456 // Hour [1-12]
20457 h(date, token) {
20458 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20459 },
20460 // Hour [0-23]
20461 H(date, token) {
20462 return addLeadingZeros(date.getHours(), token.length);
20463 },
20464 // Minute
20465 m(date, token) {
20466 return addLeadingZeros(date.getMinutes(), token.length);
20467 },
20468 // Second
20469 s(date, token) {
20470 return addLeadingZeros(date.getSeconds(), token.length);
20471 },
20472 // Fraction of second
20473 S(date, token) {
20474 const numberOfDigits = token.length;
20475 const milliseconds = date.getMilliseconds();
20476 const fractionalSeconds = Math.trunc(
20477 milliseconds * Math.pow(10, numberOfDigits - 3)
20478 );
20479 return addLeadingZeros(fractionalSeconds, token.length);
20480 }
20481 };
20482
20483 // node_modules/date-fns/_lib/format/formatters.js
20484 var dayPeriodEnum = {
20485 am: "am",
20486 pm: "pm",
20487 midnight: "midnight",
20488 noon: "noon",
20489 morning: "morning",
20490 afternoon: "afternoon",
20491 evening: "evening",
20492 night: "night"
20493 };
20494 var formatters = {
20495 // Era
20496 G: function(date, token, localize2) {
20497 const era = date.getFullYear() > 0 ? 1 : 0;
20498 switch (token) {
20499 // AD, BC
20500 case "G":
20501 case "GG":
20502 case "GGG":
20503 return localize2.era(era, { width: "abbreviated" });
20504 // A, B
20505 case "GGGGG":
20506 return localize2.era(era, { width: "narrow" });
20507 // Anno Domini, Before Christ
20508 case "GGGG":
20509 default:
20510 return localize2.era(era, { width: "wide" });
20511 }
20512 },
20513 // Year
20514 y: function(date, token, localize2) {
20515 if (token === "yo") {
20516 const signedYear = date.getFullYear();
20517 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20518 return localize2.ordinalNumber(year, { unit: "year" });
20519 }
20520 return lightFormatters.y(date, token);
20521 },
20522 // Local week-numbering year
20523 Y: function(date, token, localize2, options) {
20524 const signedWeekYear = getWeekYear(date, options);
20525 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20526 if (token === "YY") {
20527 const twoDigitYear = weekYear % 100;
20528 return addLeadingZeros(twoDigitYear, 2);
20529 }
20530 if (token === "Yo") {
20531 return localize2.ordinalNumber(weekYear, { unit: "year" });
20532 }
20533 return addLeadingZeros(weekYear, token.length);
20534 },
20535 // ISO week-numbering year
20536 R: function(date, token) {
20537 const isoWeekYear = getISOWeekYear(date);
20538 return addLeadingZeros(isoWeekYear, token.length);
20539 },
20540 // Extended year. This is a single number designating the year of this calendar system.
20541 // The main difference between `y` and `u` localizers are B.C. years:
20542 // | Year | `y` | `u` |
20543 // |------|-----|-----|
20544 // | AC 1 | 1 | 1 |
20545 // | BC 1 | 1 | 0 |
20546 // | BC 2 | 2 | -1 |
20547 // Also `yy` always returns the last two digits of a year,
20548 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20549 u: function(date, token) {
20550 const year = date.getFullYear();
20551 return addLeadingZeros(year, token.length);
20552 },
20553 // Quarter
20554 Q: function(date, token, localize2) {
20555 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20556 switch (token) {
20557 // 1, 2, 3, 4
20558 case "Q":
20559 return String(quarter);
20560 // 01, 02, 03, 04
20561 case "QQ":
20562 return addLeadingZeros(quarter, 2);
20563 // 1st, 2nd, 3rd, 4th
20564 case "Qo":
20565 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20566 // Q1, Q2, Q3, Q4
20567 case "QQQ":
20568 return localize2.quarter(quarter, {
20569 width: "abbreviated",
20570 context: "formatting"
20571 });
20572 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20573 case "QQQQQ":
20574 return localize2.quarter(quarter, {
20575 width: "narrow",
20576 context: "formatting"
20577 });
20578 // 1st quarter, 2nd quarter, ...
20579 case "QQQQ":
20580 default:
20581 return localize2.quarter(quarter, {
20582 width: "wide",
20583 context: "formatting"
20584 });
20585 }
20586 },
20587 // Stand-alone quarter
20588 q: function(date, token, localize2) {
20589 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20590 switch (token) {
20591 // 1, 2, 3, 4
20592 case "q":
20593 return String(quarter);
20594 // 01, 02, 03, 04
20595 case "qq":
20596 return addLeadingZeros(quarter, 2);
20597 // 1st, 2nd, 3rd, 4th
20598 case "qo":
20599 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20600 // Q1, Q2, Q3, Q4
20601 case "qqq":
20602 return localize2.quarter(quarter, {
20603 width: "abbreviated",
20604 context: "standalone"
20605 });
20606 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20607 case "qqqqq":
20608 return localize2.quarter(quarter, {
20609 width: "narrow",
20610 context: "standalone"
20611 });
20612 // 1st quarter, 2nd quarter, ...
20613 case "qqqq":
20614 default:
20615 return localize2.quarter(quarter, {
20616 width: "wide",
20617 context: "standalone"
20618 });
20619 }
20620 },
20621 // Month
20622 M: function(date, token, localize2) {
20623 const month = date.getMonth();
20624 switch (token) {
20625 case "M":
20626 case "MM":
20627 return lightFormatters.M(date, token);
20628 // 1st, 2nd, ..., 12th
20629 case "Mo":
20630 return localize2.ordinalNumber(month + 1, { unit: "month" });
20631 // Jan, Feb, ..., Dec
20632 case "MMM":
20633 return localize2.month(month, {
20634 width: "abbreviated",
20635 context: "formatting"
20636 });
20637 // J, F, ..., D
20638 case "MMMMM":
20639 return localize2.month(month, {
20640 width: "narrow",
20641 context: "formatting"
20642 });
20643 // January, February, ..., December
20644 case "MMMM":
20645 default:
20646 return localize2.month(month, { width: "wide", context: "formatting" });
20647 }
20648 },
20649 // Stand-alone month
20650 L: function(date, token, localize2) {
20651 const month = date.getMonth();
20652 switch (token) {
20653 // 1, 2, ..., 12
20654 case "L":
20655 return String(month + 1);
20656 // 01, 02, ..., 12
20657 case "LL":
20658 return addLeadingZeros(month + 1, 2);
20659 // 1st, 2nd, ..., 12th
20660 case "Lo":
20661 return localize2.ordinalNumber(month + 1, { unit: "month" });
20662 // Jan, Feb, ..., Dec
20663 case "LLL":
20664 return localize2.month(month, {
20665 width: "abbreviated",
20666 context: "standalone"
20667 });
20668 // J, F, ..., D
20669 case "LLLLL":
20670 return localize2.month(month, {
20671 width: "narrow",
20672 context: "standalone"
20673 });
20674 // January, February, ..., December
20675 case "LLLL":
20676 default:
20677 return localize2.month(month, { width: "wide", context: "standalone" });
20678 }
20679 },
20680 // Local week of year
20681 w: function(date, token, localize2, options) {
20682 const week = getWeek(date, options);
20683 if (token === "wo") {
20684 return localize2.ordinalNumber(week, { unit: "week" });
20685 }
20686 return addLeadingZeros(week, token.length);
20687 },
20688 // ISO week of year
20689 I: function(date, token, localize2) {
20690 const isoWeek = getISOWeek(date);
20691 if (token === "Io") {
20692 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20693 }
20694 return addLeadingZeros(isoWeek, token.length);
20695 },
20696 // Day of the month
20697 d: function(date, token, localize2) {
20698 if (token === "do") {
20699 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20700 }
20701 return lightFormatters.d(date, token);
20702 },
20703 // Day of year
20704 D: function(date, token, localize2) {
20705 const dayOfYear = getDayOfYear(date);
20706 if (token === "Do") {
20707 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20708 }
20709 return addLeadingZeros(dayOfYear, token.length);
20710 },
20711 // Day of week
20712 E: function(date, token, localize2) {
20713 const dayOfWeek = date.getDay();
20714 switch (token) {
20715 // Tue
20716 case "E":
20717 case "EE":
20718 case "EEE":
20719 return localize2.day(dayOfWeek, {
20720 width: "abbreviated",
20721 context: "formatting"
20722 });
20723 // T
20724 case "EEEEE":
20725 return localize2.day(dayOfWeek, {
20726 width: "narrow",
20727 context: "formatting"
20728 });
20729 // Tu
20730 case "EEEEEE":
20731 return localize2.day(dayOfWeek, {
20732 width: "short",
20733 context: "formatting"
20734 });
20735 // Tuesday
20736 case "EEEE":
20737 default:
20738 return localize2.day(dayOfWeek, {
20739 width: "wide",
20740 context: "formatting"
20741 });
20742 }
20743 },
20744 // Local day of week
20745 e: function(date, token, localize2, options) {
20746 const dayOfWeek = date.getDay();
20747 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20748 switch (token) {
20749 // Numerical value (Nth day of week with current locale or weekStartsOn)
20750 case "e":
20751 return String(localDayOfWeek);
20752 // Padded numerical value
20753 case "ee":
20754 return addLeadingZeros(localDayOfWeek, 2);
20755 // 1st, 2nd, ..., 7th
20756 case "eo":
20757 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20758 case "eee":
20759 return localize2.day(dayOfWeek, {
20760 width: "abbreviated",
20761 context: "formatting"
20762 });
20763 // T
20764 case "eeeee":
20765 return localize2.day(dayOfWeek, {
20766 width: "narrow",
20767 context: "formatting"
20768 });
20769 // Tu
20770 case "eeeeee":
20771 return localize2.day(dayOfWeek, {
20772 width: "short",
20773 context: "formatting"
20774 });
20775 // Tuesday
20776 case "eeee":
20777 default:
20778 return localize2.day(dayOfWeek, {
20779 width: "wide",
20780 context: "formatting"
20781 });
20782 }
20783 },
20784 // Stand-alone local day of week
20785 c: function(date, token, localize2, options) {
20786 const dayOfWeek = date.getDay();
20787 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20788 switch (token) {
20789 // Numerical value (same as in `e`)
20790 case "c":
20791 return String(localDayOfWeek);
20792 // Padded numerical value
20793 case "cc":
20794 return addLeadingZeros(localDayOfWeek, token.length);
20795 // 1st, 2nd, ..., 7th
20796 case "co":
20797 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20798 case "ccc":
20799 return localize2.day(dayOfWeek, {
20800 width: "abbreviated",
20801 context: "standalone"
20802 });
20803 // T
20804 case "ccccc":
20805 return localize2.day(dayOfWeek, {
20806 width: "narrow",
20807 context: "standalone"
20808 });
20809 // Tu
20810 case "cccccc":
20811 return localize2.day(dayOfWeek, {
20812 width: "short",
20813 context: "standalone"
20814 });
20815 // Tuesday
20816 case "cccc":
20817 default:
20818 return localize2.day(dayOfWeek, {
20819 width: "wide",
20820 context: "standalone"
20821 });
20822 }
20823 },
20824 // ISO day of week
20825 i: function(date, token, localize2) {
20826 const dayOfWeek = date.getDay();
20827 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20828 switch (token) {
20829 // 2
20830 case "i":
20831 return String(isoDayOfWeek);
20832 // 02
20833 case "ii":
20834 return addLeadingZeros(isoDayOfWeek, token.length);
20835 // 2nd
20836 case "io":
20837 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20838 // Tue
20839 case "iii":
20840 return localize2.day(dayOfWeek, {
20841 width: "abbreviated",
20842 context: "formatting"
20843 });
20844 // T
20845 case "iiiii":
20846 return localize2.day(dayOfWeek, {
20847 width: "narrow",
20848 context: "formatting"
20849 });
20850 // Tu
20851 case "iiiiii":
20852 return localize2.day(dayOfWeek, {
20853 width: "short",
20854 context: "formatting"
20855 });
20856 // Tuesday
20857 case "iiii":
20858 default:
20859 return localize2.day(dayOfWeek, {
20860 width: "wide",
20861 context: "formatting"
20862 });
20863 }
20864 },
20865 // AM or PM
20866 a: function(date, token, localize2) {
20867 const hours = date.getHours();
20868 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20869 switch (token) {
20870 case "a":
20871 case "aa":
20872 return localize2.dayPeriod(dayPeriodEnumValue, {
20873 width: "abbreviated",
20874 context: "formatting"
20875 });
20876 case "aaa":
20877 return localize2.dayPeriod(dayPeriodEnumValue, {
20878 width: "abbreviated",
20879 context: "formatting"
20880 }).toLowerCase();
20881 case "aaaaa":
20882 return localize2.dayPeriod(dayPeriodEnumValue, {
20883 width: "narrow",
20884 context: "formatting"
20885 });
20886 case "aaaa":
20887 default:
20888 return localize2.dayPeriod(dayPeriodEnumValue, {
20889 width: "wide",
20890 context: "formatting"
20891 });
20892 }
20893 },
20894 // AM, PM, midnight, noon
20895 b: function(date, token, localize2) {
20896 const hours = date.getHours();
20897 let dayPeriodEnumValue;
20898 if (hours === 12) {
20899 dayPeriodEnumValue = dayPeriodEnum.noon;
20900 } else if (hours === 0) {
20901 dayPeriodEnumValue = dayPeriodEnum.midnight;
20902 } else {
20903 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20904 }
20905 switch (token) {
20906 case "b":
20907 case "bb":
20908 return localize2.dayPeriod(dayPeriodEnumValue, {
20909 width: "abbreviated",
20910 context: "formatting"
20911 });
20912 case "bbb":
20913 return localize2.dayPeriod(dayPeriodEnumValue, {
20914 width: "abbreviated",
20915 context: "formatting"
20916 }).toLowerCase();
20917 case "bbbbb":
20918 return localize2.dayPeriod(dayPeriodEnumValue, {
20919 width: "narrow",
20920 context: "formatting"
20921 });
20922 case "bbbb":
20923 default:
20924 return localize2.dayPeriod(dayPeriodEnumValue, {
20925 width: "wide",
20926 context: "formatting"
20927 });
20928 }
20929 },
20930 // in the morning, in the afternoon, in the evening, at night
20931 B: function(date, token, localize2) {
20932 const hours = date.getHours();
20933 let dayPeriodEnumValue;
20934 if (hours >= 17) {
20935 dayPeriodEnumValue = dayPeriodEnum.evening;
20936 } else if (hours >= 12) {
20937 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20938 } else if (hours >= 4) {
20939 dayPeriodEnumValue = dayPeriodEnum.morning;
20940 } else {
20941 dayPeriodEnumValue = dayPeriodEnum.night;
20942 }
20943 switch (token) {
20944 case "B":
20945 case "BB":
20946 case "BBB":
20947 return localize2.dayPeriod(dayPeriodEnumValue, {
20948 width: "abbreviated",
20949 context: "formatting"
20950 });
20951 case "BBBBB":
20952 return localize2.dayPeriod(dayPeriodEnumValue, {
20953 width: "narrow",
20954 context: "formatting"
20955 });
20956 case "BBBB":
20957 default:
20958 return localize2.dayPeriod(dayPeriodEnumValue, {
20959 width: "wide",
20960 context: "formatting"
20961 });
20962 }
20963 },
20964 // Hour [1-12]
20965 h: function(date, token, localize2) {
20966 if (token === "ho") {
20967 let hours = date.getHours() % 12;
20968 if (hours === 0) hours = 12;
20969 return localize2.ordinalNumber(hours, { unit: "hour" });
20970 }
20971 return lightFormatters.h(date, token);
20972 },
20973 // Hour [0-23]
20974 H: function(date, token, localize2) {
20975 if (token === "Ho") {
20976 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20977 }
20978 return lightFormatters.H(date, token);
20979 },
20980 // Hour [0-11]
20981 K: function(date, token, localize2) {
20982 const hours = date.getHours() % 12;
20983 if (token === "Ko") {
20984 return localize2.ordinalNumber(hours, { unit: "hour" });
20985 }
20986 return addLeadingZeros(hours, token.length);
20987 },
20988 // Hour [1-24]
20989 k: function(date, token, localize2) {
20990 let hours = date.getHours();
20991 if (hours === 0) hours = 24;
20992 if (token === "ko") {
20993 return localize2.ordinalNumber(hours, { unit: "hour" });
20994 }
20995 return addLeadingZeros(hours, token.length);
20996 },
20997 // Minute
20998 m: function(date, token, localize2) {
20999 if (token === "mo") {
21000 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
21001 }
21002 return lightFormatters.m(date, token);
21003 },
21004 // Second
21005 s: function(date, token, localize2) {
21006 if (token === "so") {
21007 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
21008 }
21009 return lightFormatters.s(date, token);
21010 },
21011 // Fraction of second
21012 S: function(date, token) {
21013 return lightFormatters.S(date, token);
21014 },
21015 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
21016 X: function(date, token, _localize) {
21017 const timezoneOffset = date.getTimezoneOffset();
21018 if (timezoneOffset === 0) {
21019 return "Z";
21020 }
21021 switch (token) {
21022 // Hours and optional minutes
21023 case "X":
21024 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21025 // Hours, minutes and optional seconds without `:` delimiter
21026 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21027 // so this token always has the same output as `XX`
21028 case "XXXX":
21029 case "XX":
21030 return formatTimezone(timezoneOffset);
21031 // Hours, minutes and optional seconds with `:` delimiter
21032 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21033 // so this token always has the same output as `XXX`
21034 case "XXXXX":
21035 case "XXX":
21036 // Hours and minutes with `:` delimiter
21037 default:
21038 return formatTimezone(timezoneOffset, ":");
21039 }
21040 },
21041 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
21042 x: function(date, token, _localize) {
21043 const timezoneOffset = date.getTimezoneOffset();
21044 switch (token) {
21045 // Hours and optional minutes
21046 case "x":
21047 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21048 // Hours, minutes and optional seconds without `:` delimiter
21049 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21050 // so this token always has the same output as `xx`
21051 case "xxxx":
21052 case "xx":
21053 return formatTimezone(timezoneOffset);
21054 // Hours, minutes and optional seconds with `:` delimiter
21055 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21056 // so this token always has the same output as `xxx`
21057 case "xxxxx":
21058 case "xxx":
21059 // Hours and minutes with `:` delimiter
21060 default:
21061 return formatTimezone(timezoneOffset, ":");
21062 }
21063 },
21064 // Timezone (GMT)
21065 O: function(date, token, _localize) {
21066 const timezoneOffset = date.getTimezoneOffset();
21067 switch (token) {
21068 // Short
21069 case "O":
21070 case "OO":
21071 case "OOO":
21072 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21073 // Long
21074 case "OOOO":
21075 default:
21076 return "GMT" + formatTimezone(timezoneOffset, ":");
21077 }
21078 },
21079 // Timezone (specific non-location)
21080 z: function(date, token, _localize) {
21081 const timezoneOffset = date.getTimezoneOffset();
21082 switch (token) {
21083 // Short
21084 case "z":
21085 case "zz":
21086 case "zzz":
21087 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21088 // Long
21089 case "zzzz":
21090 default:
21091 return "GMT" + formatTimezone(timezoneOffset, ":");
21092 }
21093 },
21094 // Seconds timestamp
21095 t: function(date, token, _localize) {
21096 const timestamp = Math.trunc(+date / 1e3);
21097 return addLeadingZeros(timestamp, token.length);
21098 },
21099 // Milliseconds timestamp
21100 T: function(date, token, _localize) {
21101 return addLeadingZeros(+date, token.length);
21102 }
21103 };
21104 function formatTimezoneShort(offset4, delimiter = "") {
21105 const sign = offset4 > 0 ? "-" : "+";
21106 const absOffset = Math.abs(offset4);
21107 const hours = Math.trunc(absOffset / 60);
21108 const minutes = absOffset % 60;
21109 if (minutes === 0) {
21110 return sign + String(hours);
21111 }
21112 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
21113 }
21114 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
21115 if (offset4 % 60 === 0) {
21116 const sign = offset4 > 0 ? "-" : "+";
21117 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
21118 }
21119 return formatTimezone(offset4, delimiter);
21120 }
21121 function formatTimezone(offset4, delimiter = "") {
21122 const sign = offset4 > 0 ? "-" : "+";
21123 const absOffset = Math.abs(offset4);
21124 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
21125 const minutes = addLeadingZeros(absOffset % 60, 2);
21126 return sign + hours + delimiter + minutes;
21127 }
21128
21129 // node_modules/date-fns/_lib/format/longFormatters.js
21130 var dateLongFormatter = (pattern, formatLong2) => {
21131 switch (pattern) {
21132 case "P":
21133 return formatLong2.date({ width: "short" });
21134 case "PP":
21135 return formatLong2.date({ width: "medium" });
21136 case "PPP":
21137 return formatLong2.date({ width: "long" });
21138 case "PPPP":
21139 default:
21140 return formatLong2.date({ width: "full" });
21141 }
21142 };
21143 var timeLongFormatter = (pattern, formatLong2) => {
21144 switch (pattern) {
21145 case "p":
21146 return formatLong2.time({ width: "short" });
21147 case "pp":
21148 return formatLong2.time({ width: "medium" });
21149 case "ppp":
21150 return formatLong2.time({ width: "long" });
21151 case "pppp":
21152 default:
21153 return formatLong2.time({ width: "full" });
21154 }
21155 };
21156 var dateTimeLongFormatter = (pattern, formatLong2) => {
21157 const matchResult = pattern.match(/(P+)(p+)?/) || [];
21158 const datePattern = matchResult[1];
21159 const timePattern = matchResult[2];
21160 if (!timePattern) {
21161 return dateLongFormatter(pattern, formatLong2);
21162 }
21163 let dateTimeFormat;
21164 switch (datePattern) {
21165 case "P":
21166 dateTimeFormat = formatLong2.dateTime({ width: "short" });
21167 break;
21168 case "PP":
21169 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
21170 break;
21171 case "PPP":
21172 dateTimeFormat = formatLong2.dateTime({ width: "long" });
21173 break;
21174 case "PPPP":
21175 default:
21176 dateTimeFormat = formatLong2.dateTime({ width: "full" });
21177 break;
21178 }
21179 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
21180 };
21181 var longFormatters = {
21182 p: timeLongFormatter,
21183 P: dateTimeLongFormatter
21184 };
21185
21186 // node_modules/date-fns/_lib/protectedTokens.js
21187 var dayOfYearTokenRE = /^D+$/;
21188 var weekYearTokenRE = /^Y+$/;
21189 var throwTokens = ["D", "DD", "YY", "YYYY"];
21190 function isProtectedDayOfYearToken(token) {
21191 return dayOfYearTokenRE.test(token);
21192 }
21193 function isProtectedWeekYearToken(token) {
21194 return weekYearTokenRE.test(token);
21195 }
21196 function warnOrThrowProtectedError(token, format6, input) {
21197 const _message = message(token, format6, input);
21198 console.warn(_message);
21199 if (throwTokens.includes(token)) throw new RangeError(_message);
21200 }
21201 function message(token, format6, input) {
21202 const subject = token[0] === "Y" ? "years" : "days of the month";
21203 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`;
21204 }
21205
21206 // node_modules/date-fns/format.js
21207 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
21208 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
21209 var escapedStringRegExp = /^'([^]*?)'?$/;
21210 var doubleQuoteRegExp = /''/g;
21211 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
21212 function format(date, formatStr, options) {
21213 const defaultOptions2 = getDefaultOptions();
21214 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
21215 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
21216 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21217 const originalDate = toDate(date, options?.in);
21218 if (!isValid(originalDate)) {
21219 throw new RangeError("Invalid time value");
21220 }
21221 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
21222 const firstCharacter = substring[0];
21223 if (firstCharacter === "p" || firstCharacter === "P") {
21224 const longFormatter = longFormatters[firstCharacter];
21225 return longFormatter(substring, locale.formatLong);
21226 }
21227 return substring;
21228 }).join("").match(formattingTokensRegExp).map((substring) => {
21229 if (substring === "''") {
21230 return { isToken: false, value: "'" };
21231 }
21232 const firstCharacter = substring[0];
21233 if (firstCharacter === "'") {
21234 return { isToken: false, value: cleanEscapedString(substring) };
21235 }
21236 if (formatters[firstCharacter]) {
21237 return { isToken: true, value: substring };
21238 }
21239 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
21240 throw new RangeError(
21241 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
21242 );
21243 }
21244 return { isToken: false, value: substring };
21245 });
21246 if (locale.localize.preprocessor) {
21247 parts = locale.localize.preprocessor(originalDate, parts);
21248 }
21249 const formatterOptions = {
21250 firstWeekContainsDate,
21251 weekStartsOn,
21252 locale
21253 };
21254 return parts.map((part) => {
21255 if (!part.isToken) return part.value;
21256 const token = part.value;
21257 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
21258 warnOrThrowProtectedError(token, formatStr, String(date));
21259 }
21260 const formatter = formatters[token[0]];
21261 return formatter(originalDate, token, locale.localize, formatterOptions);
21262 }).join("");
21263 }
21264 function cleanEscapedString(input) {
21265 const matched = input.match(escapedStringRegExp);
21266 if (!matched) {
21267 return input;
21268 }
21269 return matched[1].replace(doubleQuoteRegExp, "'");
21270 }
21271
21272 // node_modules/date-fns/subDays.js
21273 function subDays(date, amount, options) {
21274 return addDays(date, -amount, options);
21275 }
21276
21277 // node_modules/date-fns/subMonths.js
21278 function subMonths(date, amount, options) {
21279 return addMonths(date, -amount, options);
21280 }
21281
21282 // node_modules/date-fns/subWeeks.js
21283 function subWeeks(date, amount, options) {
21284 return addWeeks(date, -amount, options);
21285 }
21286
21287 // node_modules/date-fns/subYears.js
21288 function subYears(date, amount, options) {
21289 return addYears(date, -amount, options);
21290 }
21291
21292 // packages/dataviews/build-module/utils/operators.mjs
21293 var import_i18n25 = __toESM(require_i18n(), 1);
21294 var import_element52 = __toESM(require_element(), 1);
21295 var import_date = __toESM(require_date(), 1);
21296 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21297 var filterTextWrappers = {
21298 Name: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21299 Value: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21300 };
21301 function getRelativeDate(value, unit) {
21302 switch (unit) {
21303 case "days":
21304 return subDays(/* @__PURE__ */ new Date(), value);
21305 case "weeks":
21306 return subWeeks(/* @__PURE__ */ new Date(), value);
21307 case "months":
21308 return subMonths(/* @__PURE__ */ new Date(), value);
21309 case "years":
21310 return subYears(/* @__PURE__ */ new Date(), value);
21311 default:
21312 return /* @__PURE__ */ new Date();
21313 }
21314 }
21315 var isNoneOperatorDefinition = {
21316 /* translators: DataViews operator name */
21317 label: (0, import_i18n25.__)("Is none of"),
21318 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21319 (0, import_i18n25.sprintf)(
21320 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21321 (0, import_i18n25.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21322 filter.name,
21323 activeElements.map((element) => element.label).join(", ")
21324 ),
21325 filterTextWrappers
21326 ),
21327 filter: ((item, field, filterValue) => {
21328 if (!filterValue?.length) {
21329 return true;
21330 }
21331 const fieldValue = field.getValue({ item });
21332 if (Array.isArray(fieldValue)) {
21333 return !filterValue.some(
21334 (fv) => fieldValue.includes(fv)
21335 );
21336 } else if (typeof fieldValue === "string") {
21337 return !filterValue.includes(fieldValue);
21338 }
21339 return false;
21340 }),
21341 selection: "multi"
21342 };
21343 var OPERATORS = [
21344 {
21345 name: OPERATOR_IS_ANY,
21346 /* translators: DataViews operator name */
21347 label: (0, import_i18n25.__)("Includes"),
21348 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21349 (0, import_i18n25.sprintf)(
21350 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21351 (0, import_i18n25.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21352 filter.name,
21353 activeElements.map((element) => element.label).join(", ")
21354 ),
21355 filterTextWrappers
21356 ),
21357 filter(item, field, filterValue) {
21358 if (!filterValue?.length) {
21359 return true;
21360 }
21361 const fieldValue = field.getValue({ item });
21362 if (Array.isArray(fieldValue)) {
21363 return filterValue.some(
21364 (fv) => fieldValue.includes(fv)
21365 );
21366 } else if (typeof fieldValue === "string") {
21367 return filterValue.includes(fieldValue);
21368 }
21369 return false;
21370 },
21371 selection: "multi"
21372 },
21373 {
21374 name: OPERATOR_IS_NONE,
21375 ...isNoneOperatorDefinition
21376 },
21377 {
21378 name: OPERATOR_IS_ALL,
21379 /* translators: DataViews operator name */
21380 label: (0, import_i18n25.__)("Includes all"),
21381 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21382 (0, import_i18n25.sprintf)(
21383 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21384 (0, import_i18n25.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21385 filter.name,
21386 activeElements.map((element) => element.label).join(", ")
21387 ),
21388 filterTextWrappers
21389 ),
21390 filter(item, field, filterValue) {
21391 if (!filterValue?.length) {
21392 return true;
21393 }
21394 return filterValue.every((value) => {
21395 return field.getValue({ item })?.includes(value);
21396 });
21397 },
21398 selection: "multi"
21399 },
21400 {
21401 name: OPERATOR_IS_NOT_ALL,
21402 ...isNoneOperatorDefinition
21403 },
21404 {
21405 name: OPERATOR_BETWEEN,
21406 /* translators: DataViews operator name */
21407 label: (0, import_i18n25.__)("Between (inc)"),
21408 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21409 (0, import_i18n25.sprintf)(
21410 /* 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". */
21411 (0, import_i18n25.__)(
21412 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21413 ),
21414 filter.name,
21415 activeElements[0].label[0],
21416 activeElements[0].label[1]
21417 ),
21418 filterTextWrappers
21419 ),
21420 filter(item, field, filterValue) {
21421 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21422 return true;
21423 }
21424 const fieldValue = field.getValue({ item });
21425 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21426 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21427 }
21428 return false;
21429 },
21430 selection: "custom"
21431 },
21432 {
21433 name: OPERATOR_IN_THE_PAST,
21434 /* translators: DataViews operator name */
21435 label: (0, import_i18n25.__)("In the past"),
21436 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21437 (0, import_i18n25.sprintf)(
21438 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21439 (0, import_i18n25.__)(
21440 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21441 ),
21442 filter.name,
21443 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21444 ),
21445 filterTextWrappers
21446 ),
21447 filter(item, field, filterValue) {
21448 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21449 return true;
21450 }
21451 const targetDate = getRelativeDate(
21452 filterValue.value,
21453 filterValue.unit
21454 );
21455 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21456 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21457 },
21458 selection: "custom"
21459 },
21460 {
21461 name: OPERATOR_OVER,
21462 /* translators: DataViews operator name */
21463 label: (0, import_i18n25.__)("Over"),
21464 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21465 (0, import_i18n25.sprintf)(
21466 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21467 (0, import_i18n25.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21468 filter.name,
21469 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21470 ),
21471 filterTextWrappers
21472 ),
21473 filter(item, field, filterValue) {
21474 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21475 return true;
21476 }
21477 const targetDate = getRelativeDate(
21478 filterValue.value,
21479 filterValue.unit
21480 );
21481 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21482 return fieldValue < targetDate;
21483 },
21484 selection: "custom"
21485 },
21486 {
21487 name: OPERATOR_IS,
21488 /* translators: DataViews operator name */
21489 label: (0, import_i18n25.__)("Is"),
21490 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21491 (0, import_i18n25.sprintf)(
21492 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21493 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21494 filter.name,
21495 activeElements[0].label
21496 ),
21497 filterTextWrappers
21498 ),
21499 filter(item, field, filterValue) {
21500 return filterValue === field.getValue({ item }) || filterValue === void 0;
21501 },
21502 selection: "single"
21503 },
21504 {
21505 name: OPERATOR_IS_NOT,
21506 /* translators: DataViews operator name */
21507 label: (0, import_i18n25.__)("Is not"),
21508 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21509 (0, import_i18n25.sprintf)(
21510 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21511 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21512 filter.name,
21513 activeElements[0].label
21514 ),
21515 filterTextWrappers
21516 ),
21517 filter(item, field, filterValue) {
21518 return filterValue !== field.getValue({ item });
21519 },
21520 selection: "single"
21521 },
21522 {
21523 name: OPERATOR_LESS_THAN,
21524 /* translators: DataViews operator name */
21525 label: (0, import_i18n25.__)("Less than"),
21526 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21527 (0, import_i18n25.sprintf)(
21528 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21529 (0, import_i18n25.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21530 filter.name,
21531 activeElements[0].label
21532 ),
21533 filterTextWrappers
21534 ),
21535 filter(item, field, filterValue) {
21536 if (filterValue === void 0) {
21537 return true;
21538 }
21539 const fieldValue = field.getValue({ item });
21540 return fieldValue < filterValue;
21541 },
21542 selection: "single"
21543 },
21544 {
21545 name: OPERATOR_GREATER_THAN,
21546 /* translators: DataViews operator name */
21547 label: (0, import_i18n25.__)("Greater than"),
21548 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21549 (0, import_i18n25.sprintf)(
21550 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21551 (0, import_i18n25.__)(
21552 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21553 ),
21554 filter.name,
21555 activeElements[0].label
21556 ),
21557 filterTextWrappers
21558 ),
21559 filter(item, field, filterValue) {
21560 if (filterValue === void 0) {
21561 return true;
21562 }
21563 const fieldValue = field.getValue({ item });
21564 return fieldValue > filterValue;
21565 },
21566 selection: "single"
21567 },
21568 {
21569 name: OPERATOR_LESS_THAN_OR_EQUAL,
21570 /* translators: DataViews operator name */
21571 label: (0, import_i18n25.__)("Less than or equal"),
21572 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21573 (0, import_i18n25.sprintf)(
21574 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21575 (0, import_i18n25.__)(
21576 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21577 ),
21578 filter.name,
21579 activeElements[0].label
21580 ),
21581 filterTextWrappers
21582 ),
21583 filter(item, field, filterValue) {
21584 if (filterValue === void 0) {
21585 return true;
21586 }
21587 const fieldValue = field.getValue({ item });
21588 return fieldValue <= filterValue;
21589 },
21590 selection: "single"
21591 },
21592 {
21593 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21594 /* translators: DataViews operator name */
21595 label: (0, import_i18n25.__)("Greater than or equal"),
21596 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21597 (0, import_i18n25.sprintf)(
21598 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21599 (0, import_i18n25.__)(
21600 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21601 ),
21602 filter.name,
21603 activeElements[0].label
21604 ),
21605 filterTextWrappers
21606 ),
21607 filter(item, field, filterValue) {
21608 if (filterValue === void 0) {
21609 return true;
21610 }
21611 const fieldValue = field.getValue({ item });
21612 return fieldValue >= filterValue;
21613 },
21614 selection: "single"
21615 },
21616 {
21617 name: OPERATOR_BEFORE,
21618 /* translators: DataViews operator name */
21619 label: (0, import_i18n25.__)("Before"),
21620 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21621 (0, import_i18n25.sprintf)(
21622 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21623 (0, import_i18n25.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21624 filter.name,
21625 activeElements[0].label
21626 ),
21627 filterTextWrappers
21628 ),
21629 filter(item, field, filterValue) {
21630 if (filterValue === void 0) {
21631 return true;
21632 }
21633 const filterDate = (0, import_date.getDate)(filterValue);
21634 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21635 return fieldDate < filterDate;
21636 },
21637 selection: "single"
21638 },
21639 {
21640 name: OPERATOR_AFTER,
21641 /* translators: DataViews operator name */
21642 label: (0, import_i18n25.__)("After"),
21643 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21644 (0, import_i18n25.sprintf)(
21645 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21646 (0, import_i18n25.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21647 filter.name,
21648 activeElements[0].label
21649 ),
21650 filterTextWrappers
21651 ),
21652 filter(item, field, filterValue) {
21653 if (filterValue === void 0) {
21654 return true;
21655 }
21656 const filterDate = (0, import_date.getDate)(filterValue);
21657 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21658 return fieldDate > filterDate;
21659 },
21660 selection: "single"
21661 },
21662 {
21663 name: OPERATOR_BEFORE_INC,
21664 /* translators: DataViews operator name */
21665 label: (0, import_i18n25.__)("Before (inc)"),
21666 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21667 (0, import_i18n25.sprintf)(
21668 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21669 (0, import_i18n25.__)(
21670 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21671 ),
21672 filter.name,
21673 activeElements[0].label
21674 ),
21675 filterTextWrappers
21676 ),
21677 filter(item, field, filterValue) {
21678 if (filterValue === void 0) {
21679 return true;
21680 }
21681 const filterDate = (0, import_date.getDate)(filterValue);
21682 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21683 return fieldDate <= filterDate;
21684 },
21685 selection: "single"
21686 },
21687 {
21688 name: OPERATOR_AFTER_INC,
21689 /* translators: DataViews operator name */
21690 label: (0, import_i18n25.__)("After (inc)"),
21691 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21692 (0, import_i18n25.sprintf)(
21693 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21694 (0, import_i18n25.__)(
21695 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21696 ),
21697 filter.name,
21698 activeElements[0].label
21699 ),
21700 filterTextWrappers
21701 ),
21702 filter(item, field, filterValue) {
21703 if (filterValue === void 0) {
21704 return true;
21705 }
21706 const filterDate = (0, import_date.getDate)(filterValue);
21707 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21708 return fieldDate >= filterDate;
21709 },
21710 selection: "single"
21711 },
21712 {
21713 name: OPERATOR_CONTAINS,
21714 /* translators: DataViews operator name */
21715 label: (0, import_i18n25.__)("Contains"),
21716 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21717 (0, import_i18n25.sprintf)(
21718 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21719 (0, import_i18n25.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21720 filter.name,
21721 activeElements[0].label
21722 ),
21723 filterTextWrappers
21724 ),
21725 filter(item, field, filterValue) {
21726 if (filterValue === void 0) {
21727 return true;
21728 }
21729 const fieldValue = field.getValue({ item });
21730 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21731 },
21732 selection: "single"
21733 },
21734 {
21735 name: OPERATOR_NOT_CONTAINS,
21736 /* translators: DataViews operator name */
21737 label: (0, import_i18n25.__)("Doesn't contain"),
21738 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21739 (0, import_i18n25.sprintf)(
21740 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21741 (0, import_i18n25.__)(
21742 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21743 ),
21744 filter.name,
21745 activeElements[0].label
21746 ),
21747 filterTextWrappers
21748 ),
21749 filter(item, field, filterValue) {
21750 if (filterValue === void 0) {
21751 return true;
21752 }
21753 const fieldValue = field.getValue({ item });
21754 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21755 },
21756 selection: "single"
21757 },
21758 {
21759 name: OPERATOR_STARTS_WITH,
21760 /* translators: DataViews operator name */
21761 label: (0, import_i18n25.__)("Starts with"),
21762 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21763 (0, import_i18n25.sprintf)(
21764 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21765 (0, import_i18n25.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21766 filter.name,
21767 activeElements[0].label
21768 ),
21769 filterTextWrappers
21770 ),
21771 filter(item, field, filterValue) {
21772 if (filterValue === void 0) {
21773 return true;
21774 }
21775 const fieldValue = field.getValue({ item });
21776 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21777 },
21778 selection: "single"
21779 },
21780 {
21781 name: OPERATOR_ON,
21782 /* translators: DataViews operator name */
21783 label: (0, import_i18n25.__)("On"),
21784 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21785 (0, import_i18n25.sprintf)(
21786 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21787 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21788 filter.name,
21789 activeElements[0].label
21790 ),
21791 filterTextWrappers
21792 ),
21793 filter(item, field, filterValue) {
21794 if (filterValue === void 0) {
21795 return true;
21796 }
21797 const filterDate = (0, import_date.getDate)(filterValue);
21798 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21799 return filterDate.getTime() === fieldDate.getTime();
21800 },
21801 selection: "single"
21802 },
21803 {
21804 name: OPERATOR_NOT_ON,
21805 /* translators: DataViews operator name */
21806 label: (0, import_i18n25.__)("Not on"),
21807 filterText: (filter, activeElements) => (0, import_element52.createInterpolateElement)(
21808 (0, import_i18n25.sprintf)(
21809 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21810 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21811 filter.name,
21812 activeElements[0].label
21813 ),
21814 filterTextWrappers
21815 ),
21816 filter(item, field, filterValue) {
21817 if (filterValue === void 0) {
21818 return true;
21819 }
21820 const filterDate = (0, import_date.getDate)(filterValue);
21821 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21822 return filterDate.getTime() !== fieldDate.getTime();
21823 },
21824 selection: "single"
21825 }
21826 ];
21827 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21828 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21829 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21830 (op) => op.name === name
21831 );
21832 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21833
21834 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21835 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21836 var ENTER = "Enter";
21837 var SPACE = " ";
21838 var FilterText = ({
21839 activeElements,
21840 filterInView,
21841 filter
21842 }) => {
21843 if (activeElements === void 0 || activeElements.length === 0) {
21844 return filter.name;
21845 }
21846 const operator = getOperatorByName(filterInView?.operator);
21847 if (operator !== void 0) {
21848 return operator.filterText(filter, activeElements);
21849 }
21850 return (0, import_i18n26.sprintf)(
21851 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21852 (0, import_i18n26.__)("Unknown status for %1$s"),
21853 filter.name
21854 );
21855 };
21856 function OperatorSelector({
21857 filter,
21858 view,
21859 onChangeView
21860 }) {
21861 const operatorOptions = filter.operators?.map((operator) => ({
21862 value: operator,
21863 label: getOperatorByName(operator)?.label || operator
21864 }));
21865 const currentFilter = view.filters?.find(
21866 (_filter) => _filter.field === filter.field
21867 );
21868 const value = currentFilter?.operator || filter.operators[0];
21869 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
21870 Stack,
21871 {
21872 direction: "row",
21873 gap: "sm",
21874 justify: "flex-start",
21875 className: "dataviews-filters__summary-operators-container",
21876 align: "center",
21877 children: [
21878 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21879 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21880 import_components21.SelectControl,
21881 {
21882 className: "dataviews-filters__summary-operators-filter-select",
21883 label: (0, import_i18n26.__)("Conditions"),
21884 value,
21885 options: operatorOptions,
21886 onChange: (newValue) => {
21887 const newOperator = newValue;
21888 const currentOperator = currentFilter?.operator;
21889 const newFilters = currentFilter ? [
21890 ...(view.filters ?? []).map(
21891 (_filter) => {
21892 if (_filter.field === filter.field) {
21893 const currentOpSelectionModel = getOperatorByName(
21894 currentOperator
21895 )?.selection;
21896 const newOpSelectionModel = getOperatorByName(
21897 newOperator
21898 )?.selection;
21899 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21900 currentOpSelectionModel,
21901 newOpSelectionModel
21902 ].includes("custom");
21903 return {
21904 ..._filter,
21905 value: shouldResetValue ? void 0 : _filter.value,
21906 operator: newOperator
21907 };
21908 }
21909 return _filter;
21910 }
21911 )
21912 ] : [
21913 ...view.filters ?? [],
21914 {
21915 field: filter.field,
21916 operator: newOperator,
21917 value: void 0
21918 }
21919 ];
21920 onChangeView({
21921 ...view,
21922 page: 1,
21923 filters: newFilters
21924 });
21925 },
21926 size: "small",
21927 variant: "minimal",
21928 hideLabelFromVision: true
21929 }
21930 )
21931 ]
21932 }
21933 );
21934 }
21935 function Filter({
21936 addFilterRef,
21937 openedFilter,
21938 fields,
21939 ...commonProps
21940 }) {
21941 const toggleRef = (0, import_element53.useRef)(null);
21942 const { filter, view, onChangeView } = commonProps;
21943 const filterInView = view.filters?.find(
21944 (f2) => f2.field === filter.field
21945 );
21946 let activeElements = [];
21947 const field = (0, import_element53.useMemo)(() => {
21948 const currentField = fields.find((f2) => f2.id === filter.field);
21949 if (currentField) {
21950 return {
21951 ...currentField,
21952 // Configure getValue as if Item was a plain object.
21953 // See related input-widget.tsx
21954 getValue: ({ item }) => item[currentField.id]
21955 };
21956 }
21957 return currentField;
21958 }, [fields, filter.field]);
21959 const { elements } = useElements({
21960 elements: filter.elements,
21961 getElements: filter.getElements
21962 });
21963 if (elements.length > 0) {
21964 activeElements = elements.filter((element) => {
21965 if (filter.singleSelection) {
21966 return element.value === filterInView?.value;
21967 }
21968 return filterInView?.value?.includes(element.value);
21969 });
21970 } else if (Array.isArray(filterInView?.value)) {
21971 const label = filterInView.value.map((v2) => {
21972 const formattedValue = field?.getValueFormatted({
21973 item: { [field.id]: v2 },
21974 field
21975 });
21976 return formattedValue || String(v2);
21977 });
21978 activeElements = [
21979 {
21980 value: filterInView.value,
21981 // @ts-ignore
21982 label
21983 }
21984 ];
21985 } else if (typeof filterInView?.value === "object") {
21986 activeElements = [
21987 { value: filterInView.value, label: filterInView.value }
21988 ];
21989 } else if (filterInView?.value !== void 0) {
21990 const label = field !== void 0 ? field.getValueFormatted({
21991 item: { [field.id]: filterInView.value },
21992 field
21993 }) : String(filterInView.value);
21994 activeElements = [
21995 {
21996 value: filterInView.value,
21997 label
21998 }
21999 ];
22000 }
22001 const isPrimary = filter.isPrimary;
22002 const isLocked = filterInView?.isLocked;
22003 const hasValues = !isLocked && filterInView?.value !== void 0;
22004 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
22005 const resetOrRemoveLabel = isPrimary ? (0, import_i18n26.__)("Reset") : (0, import_i18n26.__)("Remove");
22006 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22007 import_components21.Dropdown,
22008 {
22009 defaultOpen: openedFilter === filter.field,
22010 contentClassName: "dataviews-filters__summary-popover",
22011 popoverProps: { placement: "bottom-start", role: "dialog" },
22012 onClose: () => {
22013 toggleRef.current?.focus();
22014 },
22015 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
22016 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22017 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22018 tooltip_exports.Trigger,
22019 {
22020 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22021 "div",
22022 {
22023 className: clsx_default(
22024 "dataviews-filters__summary-chip",
22025 {
22026 "has-reset": canResetOrRemove,
22027 "has-values": hasValues,
22028 "is-not-clickable": isLocked
22029 }
22030 ),
22031 role: "button",
22032 tabIndex: isLocked ? -1 : 0,
22033 onClick: () => {
22034 if (!isLocked) {
22035 onToggle();
22036 }
22037 },
22038 onKeyDown: (event) => {
22039 if (!isLocked && [ENTER, SPACE].includes(
22040 event.key
22041 )) {
22042 onToggle();
22043 event.preventDefault();
22044 }
22045 },
22046 "aria-disabled": isLocked,
22047 "aria-pressed": isOpen,
22048 "aria-expanded": isOpen,
22049 ref: toggleRef,
22050 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22051 FilterText,
22052 {
22053 activeElements,
22054 filterInView,
22055 filter
22056 }
22057 )
22058 }
22059 )
22060 }
22061 ),
22062 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: (0, import_i18n26.sprintf)(
22063 /* translators: 1: Filter name. */
22064 (0, import_i18n26.__)("Filter by: %1$s"),
22065 filter.name.toLowerCase()
22066 ) })
22067 ] }),
22068 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(tooltip_exports.Root, { children: [
22069 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22070 tooltip_exports.Trigger,
22071 {
22072 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22073 "button",
22074 {
22075 className: clsx_default(
22076 "dataviews-filters__summary-chip-remove",
22077 { "has-values": hasValues }
22078 ),
22079 "aria-label": resetOrRemoveLabel,
22080 onClick: () => {
22081 onChangeView({
22082 ...view,
22083 page: 1,
22084 filters: view.filters?.filter(
22085 (_filter) => _filter.field !== filter.field
22086 )
22087 });
22088 if (!isPrimary) {
22089 addFilterRef.current?.focus();
22090 } else {
22091 toggleRef.current?.focus();
22092 }
22093 },
22094 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components21.Icon, { icon: close_small_default })
22095 }
22096 )
22097 }
22098 ),
22099 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
22100 ] })
22101 ] }),
22102 renderContent: () => {
22103 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
22104 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(OperatorSelector, { ...commonProps }),
22105 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22106 SearchWidget,
22107 {
22108 ...commonProps,
22109 filter: {
22110 ...commonProps.filter,
22111 elements
22112 }
22113 }
22114 ) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(InputWidget, { ...commonProps, fields })
22115 ] });
22116 }
22117 }
22118 );
22119 }
22120
22121 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
22122 var import_components22 = __toESM(require_components(), 1);
22123 var import_i18n27 = __toESM(require_i18n(), 1);
22124 var import_element54 = __toESM(require_element(), 1);
22125 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22126 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
22127 function AddFilterMenu({
22128 filters,
22129 view,
22130 onChangeView,
22131 setOpenedFilter,
22132 triggerProps
22133 }) {
22134 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22135 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu4, { children: [
22136 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.TriggerButton, { ...triggerProps }),
22137 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
22138 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22139 Menu4.Item,
22140 {
22141 onClick: () => {
22142 setOpenedFilter(filter.field);
22143 onChangeView({
22144 ...view,
22145 page: 1,
22146 filters: [
22147 ...view.filters || [],
22148 {
22149 field: filter.field,
22150 value: void 0,
22151 operator: filter.operators[0]
22152 }
22153 ]
22154 });
22155 },
22156 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu4.ItemLabel, { children: filter.name })
22157 },
22158 filter.field
22159 );
22160 }) })
22161 ] });
22162 }
22163 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
22164 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
22165 return null;
22166 }
22167 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22168 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22169 AddFilterMenu,
22170 {
22171 triggerProps: {
22172 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22173 import_components22.Button,
22174 {
22175 accessibleWhenDisabled: true,
22176 size: "compact",
22177 className: "dataviews-filters-button",
22178 variant: "tertiary",
22179 disabled: !inactiveFilters.length,
22180 ref
22181 }
22182 ),
22183 children: (0, import_i18n27.__)("Add filter")
22184 },
22185 ...{ filters, view, onChangeView, setOpenedFilter }
22186 }
22187 );
22188 }
22189 var add_filter_default = (0, import_element54.forwardRef)(AddFilter);
22190
22191 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
22192 var import_components23 = __toESM(require_components(), 1);
22193 var import_i18n28 = __toESM(require_i18n(), 1);
22194 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22195 function ResetFilter({
22196 filters,
22197 view,
22198 onChangeView
22199 }) {
22200 const isPrimary = (field) => filters.some(
22201 (_filter) => _filter.field === field && _filter.isPrimary
22202 );
22203 const isDisabled = !view.search && !view.filters?.some(
22204 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
22205 );
22206 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22207 import_components23.Button,
22208 {
22209 disabled: isDisabled,
22210 accessibleWhenDisabled: true,
22211 size: "compact",
22212 variant: "tertiary",
22213 className: "dataviews-filters__reset-button",
22214 onClick: () => {
22215 onChangeView({
22216 ...view,
22217 page: 1,
22218 search: "",
22219 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
22220 });
22221 },
22222 children: (0, import_i18n28.__)("Reset")
22223 }
22224 );
22225 }
22226
22227 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
22228 var import_element55 = __toESM(require_element(), 1);
22229 function useFilters(fields, view) {
22230 return (0, import_element55.useMemo)(() => {
22231 const filters = [];
22232 fields.forEach((field) => {
22233 if (field.filterBy === false || !field.hasElements && !field.Edit) {
22234 return;
22235 }
22236 const operators = field.filterBy.operators;
22237 const isPrimary = !!field.filterBy?.isPrimary;
22238 const isLocked = view.filters?.some(
22239 (f2) => f2.field === field.id && !!f2.isLocked
22240 ) ?? false;
22241 filters.push({
22242 field: field.id,
22243 name: field.label,
22244 elements: field.elements,
22245 getElements: field.getElements,
22246 hasElements: field.hasElements,
22247 singleSelection: operators.some(
22248 (op) => isSingleSelectionOperator(op)
22249 ),
22250 operators,
22251 isVisible: isLocked || isPrimary || !!view.filters?.some(
22252 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
22253 ),
22254 isPrimary,
22255 isLocked
22256 });
22257 });
22258 filters.sort((a2, b2) => {
22259 if (a2.isLocked && !b2.isLocked) {
22260 return -1;
22261 }
22262 if (!a2.isLocked && b2.isLocked) {
22263 return 1;
22264 }
22265 if (a2.isPrimary && !b2.isPrimary) {
22266 return -1;
22267 }
22268 if (!a2.isPrimary && b2.isPrimary) {
22269 return 1;
22270 }
22271 return a2.name.localeCompare(b2.name);
22272 });
22273 return filters;
22274 }, [fields, view]);
22275 }
22276 var use_filters_default = useFilters;
22277
22278 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
22279 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22280 function Filters({ className }) {
22281 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element56.useContext)(dataviews_context_default);
22282 const addFilterRef = (0, import_element56.useRef)(null);
22283 const filters = use_filters_default(fields, view);
22284 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22285 add_filter_default,
22286 {
22287 filters,
22288 view,
22289 onChangeView,
22290 ref: addFilterRef,
22291 setOpenedFilter
22292 },
22293 "add-filter"
22294 );
22295 const visibleFilters = filters.filter((filter) => filter.isVisible);
22296 if (visibleFilters.length === 0) {
22297 return null;
22298 }
22299 const filterComponents = [
22300 ...visibleFilters.map((filter) => {
22301 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22302 Filter,
22303 {
22304 filter,
22305 view,
22306 fields,
22307 onChangeView,
22308 addFilterRef,
22309 openedFilter
22310 },
22311 filter.field
22312 );
22313 }),
22314 addFilter
22315 ];
22316 filterComponents.push(
22317 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22318 ResetFilter,
22319 {
22320 filters,
22321 view,
22322 onChangeView
22323 },
22324 "reset-filters"
22325 )
22326 );
22327 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22328 Stack,
22329 {
22330 direction: "row",
22331 justify: "flex-start",
22332 gap: "sm",
22333 style: { width: "fit-content" },
22334 wrap: "wrap",
22335 className,
22336 children: filterComponents
22337 }
22338 );
22339 }
22340 var filters_default = (0, import_element56.memo)(Filters);
22341
22342 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22343 var import_element57 = __toESM(require_element(), 1);
22344 var import_components24 = __toESM(require_components(), 1);
22345 var import_i18n29 = __toESM(require_i18n(), 1);
22346 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22347 function FiltersToggle() {
22348 const {
22349 filters,
22350 view,
22351 onChangeView,
22352 setOpenedFilter,
22353 isShowingFilter,
22354 setIsShowingFilter
22355 } = (0, import_element57.useContext)(dataviews_context_default);
22356 const buttonRef = (0, import_element57.useRef)(null);
22357 const onChangeViewWithFilterVisibility = (0, import_element57.useCallback)(
22358 (_view) => {
22359 onChangeView(_view);
22360 setIsShowingFilter(true);
22361 },
22362 [onChangeView, setIsShowingFilter]
22363 );
22364 if (filters.length === 0) {
22365 return null;
22366 }
22367 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22368 const addFilterButtonProps = {
22369 label: (0, import_i18n29.__)("Add filter"),
22370 "aria-expanded": false,
22371 isPressed: false
22372 };
22373 const toggleFiltersButtonProps = {
22374 label: (0, import_i18n29._x)("Filter", "verb"),
22375 "aria-expanded": isShowingFilter,
22376 isPressed: isShowingFilter,
22377 onClick: () => {
22378 if (!isShowingFilter) {
22379 setOpenedFilter(null);
22380 }
22381 setIsShowingFilter(!isShowingFilter);
22382 }
22383 };
22384 const hasPrimaryOrLockedFilters = filters.some(
22385 (filter) => filter.isPrimary || filter.isLocked
22386 );
22387 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22388 import_components24.Button,
22389 {
22390 ref: buttonRef,
22391 className: "dataviews-filters__visibility-toggle",
22392 size: "compact",
22393 icon: funnel_default,
22394 disabled: hasPrimaryOrLockedFilters,
22395 accessibleWhenDisabled: true,
22396 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22397 }
22398 );
22399 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22400 AddFilterMenu,
22401 {
22402 filters,
22403 view,
22404 onChangeView: onChangeViewWithFilterVisibility,
22405 setOpenedFilter,
22406 triggerProps: { render: buttonComponent }
22407 }
22408 ) : /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22409 FilterVisibilityToggle,
22410 {
22411 buttonRef,
22412 filtersCount: view.filters?.length,
22413 children: buttonComponent
22414 }
22415 ) });
22416 }
22417 function FilterVisibilityToggle({
22418 buttonRef,
22419 filtersCount,
22420 children
22421 }) {
22422 (0, import_element57.useEffect)(
22423 () => () => {
22424 buttonRef.current?.focus();
22425 },
22426 [buttonRef]
22427 );
22428 return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(import_jsx_runtime87.Fragment, { children: [
22429 children,
22430 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22431 ] });
22432 }
22433 var toggle_default = FiltersToggle;
22434
22435 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22436 var import_element58 = __toESM(require_element(), 1);
22437 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22438 function FiltersToggled(props) {
22439 const { isShowingFilter } = (0, import_element58.useContext)(dataviews_context_default);
22440 if (!isShowingFilter) {
22441 return null;
22442 }
22443 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(filters_default, { ...props });
22444 }
22445 var filters_toggled_default = FiltersToggled;
22446
22447 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22448 var import_element59 = __toESM(require_element(), 1);
22449 var import_components25 = __toESM(require_components(), 1);
22450 var import_i18n30 = __toESM(require_i18n(), 1);
22451 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22452 function DataViewsLayout({ className }) {
22453 const {
22454 actions = [],
22455 data,
22456 fields,
22457 getItemId,
22458 getItemLevel,
22459 hasInitiallyLoaded,
22460 isLoading,
22461 view,
22462 onChangeView,
22463 selection,
22464 onChangeSelection,
22465 setOpenedFilter,
22466 onClickItem,
22467 isItemClickable,
22468 renderItemLink,
22469 defaultLayouts,
22470 containerRef,
22471 empty = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: (0, import_i18n30.__)("No results") })
22472 } = (0, import_element59.useContext)(dataviews_context_default);
22473 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22474 delay: 200
22475 });
22476 if (!hasInitiallyLoaded) {
22477 if (!isDelayedInitialLoading) {
22478 return null;
22479 }
22480 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components25.Spinner, {}) }) });
22481 }
22482 const ViewComponent = VIEW_LAYOUTS.find(
22483 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22484 )?.component;
22485 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22486 ViewComponent,
22487 {
22488 className,
22489 actions,
22490 data,
22491 fields,
22492 getItemId,
22493 getItemLevel,
22494 isLoading,
22495 onChangeView,
22496 onChangeSelection,
22497 selection,
22498 setOpenedFilter,
22499 onClickItem,
22500 renderItemLink,
22501 isItemClickable,
22502 view,
22503 empty
22504 }
22505 ) });
22506 }
22507
22508 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22509 var import_element60 = __toESM(require_element(), 1);
22510 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22511 var EMPTY_ARRAY5 = [];
22512 function DataViewsFooter() {
22513 const {
22514 view,
22515 paginationInfo: { totalItems = 0, totalPages },
22516 data,
22517 actions = EMPTY_ARRAY5,
22518 isLoading,
22519 hasInitiallyLoaded
22520 } = (0, import_element60.useContext)(dataviews_context_default);
22521 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22522 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22523 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22524 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22525 return null;
22526 }
22527 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22528 "div",
22529 {
22530 className: "dataviews-footer",
22531 inert: isRefreshing ? "true" : void 0,
22532 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(
22533 Stack,
22534 {
22535 direction: "row",
22536 justify: "end",
22537 align: "center",
22538 className: clsx_default("dataviews-footer__content", {
22539 "is-refreshing": isDelayedRefreshing
22540 }),
22541 gap: "sm",
22542 children: [
22543 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BulkActionsFooter, {}),
22544 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(dataviews_pagination_default, {})
22545 ]
22546 }
22547 )
22548 }
22549 );
22550 }
22551
22552 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22553 var import_i18n31 = __toESM(require_i18n(), 1);
22554 var import_element61 = __toESM(require_element(), 1);
22555 var import_components26 = __toESM(require_components(), 1);
22556 var import_compose10 = __toESM(require_compose(), 1);
22557 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22558 var DataViewsSearch = (0, import_element61.memo)(function Search({ label }) {
22559 const { view, onChangeView } = (0, import_element61.useContext)(dataviews_context_default);
22560 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22561 view.search
22562 );
22563 (0, import_element61.useEffect)(() => {
22564 if (view.search !== debouncedSearch) {
22565 setSearch(view.search ?? "");
22566 }
22567 }, [view.search, setSearch]);
22568 const onChangeViewRef = (0, import_element61.useRef)(onChangeView);
22569 const viewRef = (0, import_element61.useRef)(view);
22570 (0, import_element61.useEffect)(() => {
22571 onChangeViewRef.current = onChangeView;
22572 viewRef.current = view;
22573 }, [onChangeView, view]);
22574 (0, import_element61.useEffect)(() => {
22575 if (debouncedSearch !== viewRef.current?.search) {
22576 onChangeViewRef.current({
22577 ...viewRef.current,
22578 page: view.page ? 1 : void 0,
22579 startPosition: view.startPosition ? 1 : void 0,
22580 search: debouncedSearch
22581 });
22582 }
22583 }, [debouncedSearch]);
22584 const searchLabel = label || (0, import_i18n31.__)("Search");
22585 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22586 import_components26.SearchControl,
22587 {
22588 className: "dataviews-search",
22589 onChange: setSearch,
22590 value: search,
22591 label: searchLabel,
22592 placeholder: searchLabel,
22593 size: "compact"
22594 }
22595 );
22596 });
22597 var dataviews_search_default = DataViewsSearch;
22598
22599 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22600 var import_components27 = __toESM(require_components(), 1);
22601 var import_i18n32 = __toESM(require_i18n(), 1);
22602 var import_element62 = __toESM(require_element(), 1);
22603 var import_warning = __toESM(require_warning(), 1);
22604 var import_compose11 = __toESM(require_compose(), 1);
22605 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22606 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22607 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22608 className: "dataviews-config__popover",
22609 placement: "bottom-end",
22610 offset: 9
22611 };
22612 function ViewTypeMenu() {
22613 const { view, onChangeView, defaultLayouts } = (0, import_element62.useContext)(dataviews_context_default);
22614 const availableLayouts = Object.keys(defaultLayouts);
22615 if (availableLayouts.length <= 1) {
22616 return null;
22617 }
22618 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22619 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Menu5, { children: [
22620 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22621 Menu5.TriggerButton,
22622 {
22623 render: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22624 import_components27.Button,
22625 {
22626 size: "compact",
22627 icon: activeView?.icon,
22628 label: (0, import_i18n32.__)("Layout")
22629 }
22630 )
22631 }
22632 ),
22633 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22634 const config = VIEW_LAYOUTS.find(
22635 (v2) => v2.type === layout
22636 );
22637 if (!config) {
22638 return null;
22639 }
22640 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22641 Menu5.RadioItem,
22642 {
22643 value: layout,
22644 name: "view-actions-available-view",
22645 checked: layout === view.type,
22646 hideOnClick: true,
22647 onChange: (e2) => {
22648 switch (e2.target.value) {
22649 case "list":
22650 case "grid":
22651 case "table":
22652 case "pickerGrid":
22653 case "pickerTable":
22654 case "pickerActivity":
22655 case "activity":
22656 const viewWithoutLayout = { ...view };
22657 if ("layout" in viewWithoutLayout) {
22658 delete viewWithoutLayout.layout;
22659 }
22660 return onChangeView({
22661 ...viewWithoutLayout,
22662 type: e2.target.value,
22663 ...defaultLayouts[e2.target.value]
22664 });
22665 }
22666 (0, import_warning.default)("Invalid dataview");
22667 },
22668 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Menu5.ItemLabel, { children: config.label })
22669 },
22670 layout
22671 );
22672 }) })
22673 ] });
22674 }
22675 function SortFieldControl() {
22676 const { view, fields, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22677 const orderOptions = (0, import_element62.useMemo)(() => {
22678 const sortableFields = fields.filter(
22679 (field) => field.enableSorting !== false
22680 );
22681 return sortableFields.map((field) => {
22682 return {
22683 label: field.label,
22684 value: field.id
22685 };
22686 });
22687 }, [fields]);
22688 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22689 import_components27.SelectControl,
22690 {
22691 __next40pxDefaultSize: true,
22692 label: (0, import_i18n32.__)("Sort by"),
22693 value: view.sort?.field,
22694 options: orderOptions,
22695 onChange: (value) => {
22696 onChangeView({
22697 ...view,
22698 sort: {
22699 direction: view?.sort?.direction || "desc",
22700 field: value
22701 },
22702 showLevels: false
22703 });
22704 }
22705 }
22706 );
22707 }
22708 function SortDirectionControl() {
22709 const { view, fields, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22710 const sortableFields = fields.filter(
22711 (field) => field.enableSorting !== false
22712 );
22713 if (sortableFields.length === 0) {
22714 return null;
22715 }
22716 let value = view.sort?.direction;
22717 if (!value && view.sort?.field) {
22718 value = "desc";
22719 }
22720 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22721 import_components27.__experimentalToggleGroupControl,
22722 {
22723 className: "dataviews-view-config__sort-direction",
22724 __next40pxDefaultSize: true,
22725 isBlock: true,
22726 label: (0, import_i18n32.__)("Order"),
22727 value,
22728 onChange: (newDirection) => {
22729 if (newDirection === "asc" || newDirection === "desc") {
22730 onChangeView({
22731 ...view,
22732 sort: {
22733 direction: newDirection,
22734 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22735 fields.find(
22736 (field) => field.enableSorting !== false
22737 )?.id || ""
22738 },
22739 showLevels: false
22740 });
22741 return;
22742 }
22743 (0, import_warning.default)("Invalid direction");
22744 },
22745 children: SORTING_DIRECTIONS.map((direction) => {
22746 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22747 import_components27.__experimentalToggleGroupControlOptionIcon,
22748 {
22749 value: direction,
22750 icon: sortIcons[direction],
22751 label: sortLabels[direction]
22752 },
22753 direction
22754 );
22755 })
22756 }
22757 );
22758 }
22759 function ItemsPerPageControl() {
22760 const { view, config, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22761 const { infiniteScrollEnabled } = view;
22762 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22763 return null;
22764 }
22765 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22766 import_components27.__experimentalToggleGroupControl,
22767 {
22768 __next40pxDefaultSize: true,
22769 isBlock: true,
22770 label: (0, import_i18n32.__)("Items per page"),
22771 value: view.perPage || 10,
22772 disabled: !view?.sort?.field,
22773 onChange: (newItemsPerPage) => {
22774 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22775 onChangeView({
22776 ...view,
22777 perPage: newItemsPerPageNumber,
22778 page: 1
22779 });
22780 },
22781 children: config.perPageSizes.map((value) => {
22782 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22783 import_components27.__experimentalToggleGroupControlOption,
22784 {
22785 value,
22786 label: value.toString()
22787 },
22788 value
22789 );
22790 })
22791 }
22792 );
22793 }
22794 function ResetViewButton() {
22795 const { onReset } = (0, import_element62.useContext)(dataviews_context_default);
22796 if (onReset === void 0) {
22797 return null;
22798 }
22799 const isDisabled = onReset === false;
22800 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22801 import_components27.Button,
22802 {
22803 variant: "tertiary",
22804 size: "compact",
22805 disabled: isDisabled,
22806 accessibleWhenDisabled: true,
22807 className: "dataviews-view-config__reset-button",
22808 onClick: () => {
22809 if (typeof onReset === "function") {
22810 onReset();
22811 }
22812 },
22813 children: (0, import_i18n32.__)("Reset view")
22814 }
22815 );
22816 }
22817 function DataviewsViewConfigDropdown() {
22818 const { view, onReset } = (0, import_element62.useContext)(dataviews_context_default);
22819 const popoverId = (0, import_compose11.useInstanceId)(
22820 _DataViewsViewConfig,
22821 "dataviews-view-config-dropdown"
22822 );
22823 const activeLayout = VIEW_LAYOUTS.find(
22824 (layout) => layout.type === view.type
22825 );
22826 const isModified = typeof onReset === "function";
22827 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22828 import_components27.Dropdown,
22829 {
22830 expandOnMobile: true,
22831 popoverProps: {
22832 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22833 id: popoverId
22834 },
22835 renderToggle: ({ onToggle, isOpen }) => {
22836 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22837 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22838 import_components27.Button,
22839 {
22840 size: "compact",
22841 icon: cog_default,
22842 label: (0, import_i18n32._x)(
22843 "View options",
22844 "View is used as a noun"
22845 ),
22846 onClick: onToggle,
22847 "aria-expanded": isOpen ? "true" : "false",
22848 "aria-controls": popoverId
22849 }
22850 ),
22851 isModified && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22852 ] });
22853 },
22854 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22855 import_components27.__experimentalDropdownContentWrapper,
22856 {
22857 paddingSize: "medium",
22858 className: "dataviews-config__popover-content-wrapper",
22859 children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
22860 Stack,
22861 {
22862 direction: "column",
22863 className: "dataviews-view-config",
22864 gap: "xl",
22865 children: [
22866 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
22867 Stack,
22868 {
22869 direction: "row",
22870 justify: "space-between",
22871 align: "center",
22872 className: "dataviews-view-config__header",
22873 children: [
22874 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22875 import_components27.__experimentalHeading,
22876 {
22877 level: 2,
22878 className: "dataviews-settings-section__title",
22879 children: (0, import_i18n32.__)("Appearance")
22880 }
22881 ),
22882 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ResetViewButton, {})
22883 ]
22884 }
22885 ),
22886 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22887 /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
22888 Stack,
22889 {
22890 direction: "row",
22891 gap: "sm",
22892 className: "dataviews-view-config__sort-controls",
22893 children: [
22894 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(SortFieldControl, {}),
22895 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(SortDirectionControl, {})
22896 ]
22897 }
22898 ),
22899 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(activeLayout.viewConfigOptions, {}),
22900 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ItemsPerPageControl, {}),
22901 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(PropertiesSection, {})
22902 ] })
22903 ]
22904 }
22905 )
22906 }
22907 )
22908 }
22909 );
22910 }
22911 function _DataViewsViewConfig() {
22912 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
22913 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ViewTypeMenu, {}),
22914 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DataviewsViewConfigDropdown, {})
22915 ] });
22916 }
22917 var DataViewsViewConfig = (0, import_element62.memo)(_DataViewsViewConfig);
22918 var dataviews_view_config_default = DataViewsViewConfig;
22919
22920 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22921 var import_components28 = __toESM(require_components(), 1);
22922 var import_element63 = __toESM(require_element(), 1);
22923
22924 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22925 function getCustomValidity(isValid2, validity) {
22926 let customValidity;
22927 if (isValid2?.required && validity?.required) {
22928 customValidity = validity?.required?.message ? validity.required : void 0;
22929 } else if (isValid2?.pattern && validity?.pattern) {
22930 customValidity = validity.pattern;
22931 } else if (isValid2?.min && validity?.min) {
22932 customValidity = validity.min;
22933 } else if (isValid2?.max && validity?.max) {
22934 customValidity = validity.max;
22935 } else if (isValid2?.minLength && validity?.minLength) {
22936 customValidity = validity.minLength;
22937 } else if (isValid2?.maxLength && validity?.maxLength) {
22938 customValidity = validity.maxLength;
22939 } else if (isValid2?.elements && validity?.elements) {
22940 customValidity = validity.elements;
22941 } else if (validity?.custom) {
22942 customValidity = validity.custom;
22943 }
22944 return customValidity;
22945 }
22946
22947 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22948 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
22949 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
22950 function Checkbox({
22951 field,
22952 onChange,
22953 data,
22954 hideLabelFromVision,
22955 markWhenOptional,
22956 validity
22957 }) {
22958 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22959 const disabled2 = field.isDisabled({ item: data, field });
22960 const onChangeControl = (0, import_element63.useCallback)(() => {
22961 onChange(
22962 setValue({ item: data, value: !getValue({ item: data }) })
22963 );
22964 }, [data, getValue, onChange, setValue]);
22965 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
22966 ValidatedCheckboxControl,
22967 {
22968 required: !!field.isValid?.required,
22969 markWhenOptional,
22970 customValidity: getCustomValidity(isValid2, validity),
22971 hidden: hideLabelFromVision,
22972 label,
22973 help: description,
22974 checked: getValue({ item: data }),
22975 onChange: onChangeControl,
22976 disabled: disabled2
22977 }
22978 );
22979 }
22980
22981 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22982 var import_components29 = __toESM(require_components(), 1);
22983 var import_element64 = __toESM(require_element(), 1);
22984 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
22985 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
22986 function Combobox3({
22987 data,
22988 field,
22989 onChange,
22990 hideLabelFromVision,
22991 validity
22992 }) {
22993 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22994 const value = getValue({ item: data }) ?? "";
22995 const onChangeControl = (0, import_element64.useCallback)(
22996 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22997 [data, onChange, setValue]
22998 );
22999 const { elements, isLoading } = useElements({
23000 elements: field.elements,
23001 getElements: field.getElements
23002 });
23003 if (isLoading) {
23004 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components29.Spinner, {});
23005 }
23006 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23007 ValidatedComboboxControl,
23008 {
23009 required: !!field.isValid?.required,
23010 customValidity: getCustomValidity(isValid2, validity),
23011 label,
23012 value,
23013 help: description,
23014 placeholder,
23015 options: elements,
23016 onChange: onChangeControl,
23017 hideLabelFromVision,
23018 allowReset: true,
23019 expandOnFocus: true
23020 }
23021 );
23022 }
23023
23024 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23025 var import_components31 = __toESM(require_components(), 1);
23026 var import_element67 = __toESM(require_element(), 1);
23027 var import_i18n34 = __toESM(require_i18n(), 1);
23028 var import_date3 = __toESM(require_date(), 1);
23029
23030 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
23031 var import_components30 = __toESM(require_components(), 1);
23032 var import_element65 = __toESM(require_element(), 1);
23033 var import_i18n33 = __toESM(require_i18n(), 1);
23034 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23035 var TIME_UNITS_OPTIONS = {
23036 [OPERATOR_IN_THE_PAST]: [
23037 { value: "days", label: (0, import_i18n33.__)("Days") },
23038 { value: "weeks", label: (0, import_i18n33.__)("Weeks") },
23039 { value: "months", label: (0, import_i18n33.__)("Months") },
23040 { value: "years", label: (0, import_i18n33.__)("Years") }
23041 ],
23042 [OPERATOR_OVER]: [
23043 { value: "days", label: (0, import_i18n33.__)("Days ago") },
23044 { value: "weeks", label: (0, import_i18n33.__)("Weeks ago") },
23045 { value: "months", label: (0, import_i18n33.__)("Months ago") },
23046 { value: "years", label: (0, import_i18n33.__)("Years ago") }
23047 ]
23048 };
23049 function RelativeDateControl({
23050 className,
23051 data,
23052 field,
23053 onChange,
23054 hideLabelFromVision,
23055 operator
23056 }) {
23057 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
23058 const { id, label, description, getValue, setValue } = field;
23059 const disabled2 = field.isDisabled({ item: data, field });
23060 const fieldValue = getValue({ item: data });
23061 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
23062 const onChangeValue = (0, import_element65.useCallback)(
23063 (newValue) => onChange(
23064 setValue({
23065 item: data,
23066 value: { value: Number(newValue), unit }
23067 })
23068 ),
23069 [onChange, setValue, data, unit]
23070 );
23071 const onChangeUnit = (0, import_element65.useCallback)(
23072 (newUnit) => onChange(
23073 setValue({
23074 item: data,
23075 value: { value: relValue, unit: newUnit }
23076 })
23077 ),
23078 [onChange, setValue, data, relValue]
23079 );
23080 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23081 import_components30.BaseControl,
23082 {
23083 id,
23084 className: clsx_default(className, "dataviews-controls__relative-date"),
23085 label,
23086 hideLabelFromVision,
23087 help: description,
23088 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "row", gap: "sm", children: [
23089 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23090 import_components30.__experimentalNumberControl,
23091 {
23092 __next40pxDefaultSize: true,
23093 className: "dataviews-controls__relative-date-number",
23094 spinControls: "none",
23095 min: 1,
23096 step: 1,
23097 value: relValue,
23098 onChange: onChangeValue,
23099 disabled: disabled2
23100 }
23101 ),
23102 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23103 import_components30.SelectControl,
23104 {
23105 className: "dataviews-controls__relative-date-unit",
23106 __next40pxDefaultSize: true,
23107 label: (0, import_i18n33.__)("Unit"),
23108 value: unit,
23109 options,
23110 onChange: onChangeUnit,
23111 hideLabelFromVision: true,
23112 disabled: disabled2
23113 }
23114 )
23115 ] })
23116 }
23117 );
23118 }
23119
23120 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
23121 var import_element66 = __toESM(require_element(), 1);
23122 function useDisabledDateMatchers(isValid2, parseDateFn) {
23123 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
23124 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
23125 const disabledMatchers = (0, import_element66.useMemo)(() => {
23126 const matchers = [];
23127 if (minConstraint) {
23128 const minDate = parseDateFn(minConstraint);
23129 if (minDate) {
23130 matchers.push({ before: minDate });
23131 }
23132 }
23133 if (maxConstraint) {
23134 const maxDate = parseDateFn(maxConstraint);
23135 if (maxDate) {
23136 matchers.push({ after: maxDate });
23137 }
23138 }
23139 return matchers.length > 0 ? matchers : void 0;
23140 }, [minConstraint, maxConstraint, parseDateFn]);
23141 return { minConstraint, maxConstraint, disabledMatchers };
23142 }
23143
23144 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
23145 var import_date2 = __toESM(require_date(), 1);
23146 function parseDateTime(dateTimeString) {
23147 if (!dateTimeString) {
23148 return null;
23149 }
23150 const parsed = (0, import_date2.getDate)(dateTimeString);
23151 return parsed && isValid(parsed) ? parsed : null;
23152 }
23153
23154 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23155 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23156 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
23157 var formatDateTime = (value) => {
23158 if (!value) {
23159 return "";
23160 }
23161 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
23162 };
23163 function CalendarDateTimeControl({
23164 data,
23165 field,
23166 onChange,
23167 hideLabelFromVision,
23168 markWhenOptional,
23169 validity,
23170 config
23171 }) {
23172 const { compact } = config || {};
23173 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
23174 const disabled2 = field.isDisabled({ item: data, field });
23175 const fieldValue = getValue({ item: data });
23176 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23177 const [calendarMonth, setCalendarMonth] = (0, import_element67.useState)(() => {
23178 const parsedDate = parseDateTime(value);
23179 return parsedDate || /* @__PURE__ */ new Date();
23180 });
23181 const inputControlRef = (0, import_element67.useRef)(null);
23182 const validationTimeoutRef = (0, import_element67.useRef)(void 0);
23183 const previousFocusRef = (0, import_element67.useRef)(null);
23184 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
23185 const onChangeCallback = (0, import_element67.useCallback)(
23186 (newValue) => onChange(setValue({ item: data, value: newValue })),
23187 [data, onChange, setValue]
23188 );
23189 (0, import_element67.useEffect)(() => {
23190 return () => {
23191 if (validationTimeoutRef.current) {
23192 clearTimeout(validationTimeoutRef.current);
23193 }
23194 };
23195 }, []);
23196 const onSelectDate = (0, import_element67.useCallback)(
23197 (newDate) => {
23198 let dateTimeValue;
23199 if (newDate) {
23200 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
23201 let wpTime;
23202 if (value) {
23203 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
23204 } else {
23205 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
23206 }
23207 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
23208 dateTimeValue = finalDateTime.toISOString();
23209 onChangeCallback(dateTimeValue);
23210 if (validationTimeoutRef.current) {
23211 clearTimeout(validationTimeoutRef.current);
23212 }
23213 } else {
23214 onChangeCallback(void 0);
23215 }
23216 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
23217 validationTimeoutRef.current = setTimeout(() => {
23218 if (inputControlRef.current) {
23219 inputControlRef.current.focus();
23220 inputControlRef.current.blur();
23221 onChangeCallback(dateTimeValue);
23222 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
23223 previousFocusRef.current.focus();
23224 }
23225 }
23226 }, 0);
23227 },
23228 [onChangeCallback, value]
23229 );
23230 const handleManualDateTimeChange = (0, import_element67.useCallback)(
23231 (newValue) => {
23232 if (newValue) {
23233 const dateTime = (0, import_date3.getDate)(newValue);
23234 onChangeCallback(dateTime.toISOString());
23235 const parsedDate = parseDateTime(dateTime.toISOString());
23236 if (parsedDate) {
23237 setCalendarMonth(parsedDate);
23238 }
23239 } else {
23240 onChangeCallback(void 0);
23241 }
23242 },
23243 [onChangeCallback]
23244 );
23245 const { format: fieldFormat } = field;
23246 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
23247 const {
23248 timezone: { string: timezoneString }
23249 } = (0, import_date3.getSettings)();
23250 let displayLabel = label;
23251 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
23252 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23253 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
23254 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23255 }
23256 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23257 import_components31.BaseControl,
23258 {
23259 id,
23260 label: displayLabel,
23261 help: description,
23262 hideLabelFromVision,
23263 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23264 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23265 ValidatedInputControl,
23266 {
23267 ref: inputControlRef,
23268 __next40pxDefaultSize: true,
23269 required: !!isValid2?.required,
23270 customValidity: getCustomValidity(isValid2, validity),
23271 type: "datetime-local",
23272 label: (0, import_i18n34.__)("Date time"),
23273 hideLabelFromVision: true,
23274 value: formatDateTime(value),
23275 onChange: handleManualDateTimeChange,
23276 disabled: disabled2,
23277 min: minConstraint ? formatDateTime(minConstraint) : void 0,
23278 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
23279 }
23280 ),
23281 !compact && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23282 DateCalendar,
23283 {
23284 style: { width: "100%" },
23285 selected: value ? parseDateTime(value) || void 0 : void 0,
23286 onSelect: onSelectDate,
23287 month: calendarMonth,
23288 onMonthChange: setCalendarMonth,
23289 timeZone: timezoneString || void 0,
23290 weekStartsOn,
23291 disabled: disabled2 || disabledMatchers
23292 }
23293 )
23294 ] })
23295 }
23296 );
23297 }
23298 function DateTime({
23299 data,
23300 field,
23301 onChange,
23302 hideLabelFromVision,
23303 markWhenOptional,
23304 operator,
23305 validity,
23306 config
23307 }) {
23308 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23309 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23310 RelativeDateControl,
23311 {
23312 className: "dataviews-controls__datetime",
23313 data,
23314 field,
23315 onChange,
23316 hideLabelFromVision,
23317 operator
23318 }
23319 );
23320 }
23321 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23322 CalendarDateTimeControl,
23323 {
23324 data,
23325 field,
23326 onChange,
23327 hideLabelFromVision,
23328 markWhenOptional,
23329 validity,
23330 config
23331 }
23332 );
23333 }
23334
23335 // packages/dataviews/build-module/components/dataform-controls/date.mjs
23336 var import_components32 = __toESM(require_components(), 1);
23337 var import_element68 = __toESM(require_element(), 1);
23338 var import_i18n35 = __toESM(require_i18n(), 1);
23339 var import_date4 = __toESM(require_date(), 1);
23340 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23341 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
23342 var DATE_PRESETS = [
23343 {
23344 id: "today",
23345 label: (0, import_i18n35.__)("Today"),
23346 getValue: () => (0, import_date4.getDate)(null)
23347 },
23348 {
23349 id: "yesterday",
23350 label: (0, import_i18n35.__)("Yesterday"),
23351 getValue: () => {
23352 const today = (0, import_date4.getDate)(null);
23353 return subDays(today, 1);
23354 }
23355 },
23356 {
23357 id: "past-week",
23358 label: (0, import_i18n35.__)("Past week"),
23359 getValue: () => {
23360 const today = (0, import_date4.getDate)(null);
23361 return subDays(today, 7);
23362 }
23363 },
23364 {
23365 id: "past-month",
23366 label: (0, import_i18n35.__)("Past month"),
23367 getValue: () => {
23368 const today = (0, import_date4.getDate)(null);
23369 return subMonths(today, 1);
23370 }
23371 }
23372 ];
23373 var DATE_RANGE_PRESETS = [
23374 {
23375 id: "last-7-days",
23376 label: (0, import_i18n35.__)("Last 7 days"),
23377 getValue: () => {
23378 const today = (0, import_date4.getDate)(null);
23379 return [subDays(today, 7), today];
23380 }
23381 },
23382 {
23383 id: "last-30-days",
23384 label: (0, import_i18n35.__)("Last 30 days"),
23385 getValue: () => {
23386 const today = (0, import_date4.getDate)(null);
23387 return [subDays(today, 30), today];
23388 }
23389 },
23390 {
23391 id: "month-to-date",
23392 label: (0, import_i18n35.__)("Month to date"),
23393 getValue: () => {
23394 const today = (0, import_date4.getDate)(null);
23395 return [startOfMonth(today), today];
23396 }
23397 },
23398 {
23399 id: "last-year",
23400 label: (0, import_i18n35.__)("Last year"),
23401 getValue: () => {
23402 const today = (0, import_date4.getDate)(null);
23403 return [subYears(today, 1), today];
23404 }
23405 },
23406 {
23407 id: "year-to-date",
23408 label: (0, import_i18n35.__)("Year to date"),
23409 getValue: () => {
23410 const today = (0, import_date4.getDate)(null);
23411 return [startOfYear(today), today];
23412 }
23413 }
23414 ];
23415 var parseDate = (dateString) => {
23416 if (!dateString) {
23417 return null;
23418 }
23419 const parsed = (0, import_date4.getDate)(dateString);
23420 return parsed && isValid(parsed) ? parsed : null;
23421 };
23422 var formatDate = (date) => {
23423 if (!date) {
23424 return "";
23425 }
23426 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23427 };
23428 function ValidatedDateControl({
23429 field,
23430 validity,
23431 inputRefs,
23432 isTouched,
23433 setIsTouched,
23434 children
23435 }) {
23436 const { isValid: isValid2 } = field;
23437 const [customValidity, setCustomValidity] = (0, import_element68.useState)(void 0);
23438 const validateRefs = (0, import_element68.useCallback)(() => {
23439 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23440 for (const ref of refs) {
23441 const input = ref.current;
23442 if (input && !input.validity.valid) {
23443 setCustomValidity({
23444 type: "invalid",
23445 message: input.validationMessage
23446 });
23447 return;
23448 }
23449 }
23450 setCustomValidity(void 0);
23451 }, [inputRefs]);
23452 (0, import_element68.useEffect)(() => {
23453 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23454 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23455 for (const ref of refs) {
23456 const input = ref.current;
23457 if (input) {
23458 input.setCustomValidity(
23459 result?.type === "invalid" && result.message ? result.message : ""
23460 );
23461 }
23462 }
23463 }, [inputRefs, isValid2, validity]);
23464 (0, import_element68.useEffect)(() => {
23465 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23466 const handleInvalid = (event) => {
23467 event.preventDefault();
23468 setIsTouched(true);
23469 };
23470 for (const ref of refs) {
23471 ref.current?.addEventListener("invalid", handleInvalid);
23472 }
23473 return () => {
23474 for (const ref of refs) {
23475 ref.current?.removeEventListener("invalid", handleInvalid);
23476 }
23477 };
23478 }, [inputRefs, setIsTouched]);
23479 (0, import_element68.useEffect)(() => {
23480 if (!isTouched) {
23481 return;
23482 }
23483 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23484 if (result) {
23485 setCustomValidity(result);
23486 } else {
23487 validateRefs();
23488 }
23489 }, [isTouched, isValid2, validity, validateRefs]);
23490 const onBlur = (event) => {
23491 if (isTouched) {
23492 return;
23493 }
23494 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23495 setIsTouched(true);
23496 }
23497 };
23498 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { onBlur, children: [
23499 children,
23500 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23501 "p",
23502 {
23503 className: clsx_default(
23504 "components-validated-control__indicator",
23505 customValidity.type === "invalid" ? "is-invalid" : void 0
23506 ),
23507 children: [
23508 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23509 import_components32.Icon,
23510 {
23511 className: "components-validated-control__indicator-icon",
23512 icon: error_default,
23513 size: 16,
23514 fill: "currentColor"
23515 }
23516 ),
23517 customValidity.message
23518 ]
23519 }
23520 ) })
23521 ] });
23522 }
23523 function CalendarDateControl({
23524 data,
23525 field,
23526 onChange,
23527 hideLabelFromVision,
23528 markWhenOptional,
23529 validity
23530 }) {
23531 const {
23532 id,
23533 label,
23534 description,
23535 setValue,
23536 getValue,
23537 isValid: isValid2,
23538 format: fieldFormat
23539 } = field;
23540 const disabled2 = field.isDisabled({ item: data, field });
23541 const [selectedPresetId, setSelectedPresetId] = (0, import_element68.useState)(
23542 null
23543 );
23544 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23545 const fieldValue = getValue({ item: data });
23546 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23547 const [calendarMonth, setCalendarMonth] = (0, import_element68.useState)(() => {
23548 const parsedDate = parseDate(value);
23549 return parsedDate || /* @__PURE__ */ new Date();
23550 });
23551 const [isTouched, setIsTouched] = (0, import_element68.useState)(false);
23552 const validityTargetRef = (0, import_element68.useRef)(null);
23553 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23554 const onChangeCallback = (0, import_element68.useCallback)(
23555 (newValue) => onChange(setValue({ item: data, value: newValue })),
23556 [data, onChange, setValue]
23557 );
23558 const onSelectDate = (0, import_element68.useCallback)(
23559 (newDate) => {
23560 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23561 onChangeCallback(dateValue);
23562 setSelectedPresetId(null);
23563 setIsTouched(true);
23564 },
23565 [onChangeCallback]
23566 );
23567 const handlePresetClick = (0, import_element68.useCallback)(
23568 (preset) => {
23569 const presetDate = preset.getValue();
23570 const dateValue = formatDate(presetDate);
23571 setCalendarMonth(presetDate);
23572 onChangeCallback(dateValue);
23573 setSelectedPresetId(preset.id);
23574 setIsTouched(true);
23575 },
23576 [onChangeCallback]
23577 );
23578 const handleManualDateChange = (0, import_element68.useCallback)(
23579 (newValue) => {
23580 onChangeCallback(newValue);
23581 if (newValue) {
23582 const parsedDate = parseDate(newValue);
23583 if (parsedDate) {
23584 setCalendarMonth(parsedDate);
23585 }
23586 }
23587 setSelectedPresetId(null);
23588 setIsTouched(true);
23589 },
23590 [onChangeCallback]
23591 );
23592 const {
23593 timezone: { string: timezoneString }
23594 } = (0, import_date4.getSettings)();
23595 let displayLabel = label;
23596 if (isValid2?.required && !markWhenOptional) {
23597 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23598 } else if (!isValid2?.required && markWhenOptional) {
23599 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23600 }
23601 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23602 ValidatedDateControl,
23603 {
23604 field,
23605 validity,
23606 inputRefs: validityTargetRef,
23607 isTouched,
23608 setIsTouched,
23609 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23610 import_components32.BaseControl,
23611 {
23612 id,
23613 className: "dataviews-controls__date",
23614 label: displayLabel,
23615 help: description,
23616 hideLabelFromVision,
23617 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23618 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23619 Stack,
23620 {
23621 direction: "row",
23622 gap: "sm",
23623 wrap: "wrap",
23624 justify: "flex-start",
23625 children: [
23626 DATE_PRESETS.map((preset) => {
23627 const isSelected2 = selectedPresetId === preset.id;
23628 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23629 import_components32.Button,
23630 {
23631 className: "dataviews-controls__date-preset",
23632 variant: "tertiary",
23633 isPressed: isSelected2,
23634 size: "small",
23635 disabled: disabled2,
23636 accessibleWhenDisabled: true,
23637 onClick: () => handlePresetClick(preset),
23638 children: preset.label
23639 },
23640 preset.id
23641 );
23642 }),
23643 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23644 import_components32.Button,
23645 {
23646 className: "dataviews-controls__date-preset",
23647 variant: "tertiary",
23648 isPressed: !selectedPresetId,
23649 size: "small",
23650 disabled: !!selectedPresetId || disabled2,
23651 accessibleWhenDisabled: true,
23652 children: (0, import_i18n35.__)("Custom")
23653 }
23654 )
23655 ]
23656 }
23657 ),
23658 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23659 import_components32.__experimentalInputControl,
23660 {
23661 __next40pxDefaultSize: true,
23662 ref: validityTargetRef,
23663 type: "date",
23664 label: (0, import_i18n35.__)("Date"),
23665 hideLabelFromVision: true,
23666 value,
23667 onChange: handleManualDateChange,
23668 required: !!field.isValid?.required,
23669 disabled: disabled2,
23670 min: minConstraint,
23671 max: maxConstraint
23672 }
23673 ),
23674 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23675 DateCalendar2,
23676 {
23677 style: { width: "100%" },
23678 selected: value ? parseDate(value) || void 0 : void 0,
23679 onSelect: onSelectDate,
23680 month: calendarMonth,
23681 onMonthChange: setCalendarMonth,
23682 timeZone: timezoneString || void 0,
23683 weekStartsOn,
23684 disabled: disabled2 || disabledMatchers,
23685 disableNavigation: disabled2
23686 }
23687 )
23688 ] })
23689 }
23690 )
23691 }
23692 );
23693 }
23694 function CalendarDateRangeControl({
23695 data,
23696 field,
23697 onChange,
23698 hideLabelFromVision,
23699 markWhenOptional,
23700 validity
23701 }) {
23702 const {
23703 id,
23704 label,
23705 description,
23706 getValue,
23707 setValue,
23708 isValid: isValid2,
23709 format: fieldFormat
23710 } = field;
23711 const disabled2 = field.isDisabled({ item: data, field });
23712 let value;
23713 const fieldValue = getValue({ item: data });
23714 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23715 value = fieldValue;
23716 }
23717 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23718 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23719 const onChangeCallback = (0, import_element68.useCallback)(
23720 (newValue) => {
23721 onChange(
23722 setValue({
23723 item: data,
23724 value: newValue
23725 })
23726 );
23727 },
23728 [data, onChange, setValue]
23729 );
23730 const [selectedPresetId, setSelectedPresetId] = (0, import_element68.useState)(
23731 null
23732 );
23733 const selectedRange = (0, import_element68.useMemo)(() => {
23734 if (!value) {
23735 return { from: void 0, to: void 0 };
23736 }
23737 const [from, to] = value;
23738 return {
23739 from: parseDate(from) || void 0,
23740 to: parseDate(to) || void 0
23741 };
23742 }, [value]);
23743 const [calendarMonth, setCalendarMonth] = (0, import_element68.useState)(() => {
23744 return selectedRange.from || /* @__PURE__ */ new Date();
23745 });
23746 const [isTouched, setIsTouched] = (0, import_element68.useState)(false);
23747 const fromInputRef = (0, import_element68.useRef)(null);
23748 const toInputRef = (0, import_element68.useRef)(null);
23749 const updateDateRange = (0, import_element68.useCallback)(
23750 (fromDate, toDate2) => {
23751 if (fromDate && toDate2) {
23752 onChangeCallback([
23753 formatDate(fromDate),
23754 formatDate(toDate2)
23755 ]);
23756 } else if (!fromDate && !toDate2) {
23757 onChangeCallback(void 0);
23758 }
23759 },
23760 [onChangeCallback]
23761 );
23762 const onSelectCalendarRange = (0, import_element68.useCallback)(
23763 (newRange) => {
23764 updateDateRange(newRange?.from, newRange?.to);
23765 setSelectedPresetId(null);
23766 setIsTouched(true);
23767 },
23768 [updateDateRange]
23769 );
23770 const handlePresetClick = (0, import_element68.useCallback)(
23771 (preset) => {
23772 const [startDate, endDate] = preset.getValue();
23773 setCalendarMonth(startDate);
23774 updateDateRange(startDate, endDate);
23775 setSelectedPresetId(preset.id);
23776 setIsTouched(true);
23777 },
23778 [updateDateRange]
23779 );
23780 const handleManualDateChange = (0, import_element68.useCallback)(
23781 (fromOrTo, newValue) => {
23782 const [currentFrom, currentTo] = value || [
23783 void 0,
23784 void 0
23785 ];
23786 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23787 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23788 updateDateRange(updatedFrom, updatedTo);
23789 if (newValue) {
23790 const parsedDate = parseDate(newValue);
23791 if (parsedDate) {
23792 setCalendarMonth(parsedDate);
23793 }
23794 }
23795 setSelectedPresetId(null);
23796 setIsTouched(true);
23797 },
23798 [value, updateDateRange]
23799 );
23800 const { timezone } = (0, import_date4.getSettings)();
23801 let displayLabel = label;
23802 if (field.isValid?.required && !markWhenOptional) {
23803 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23804 } else if (!field.isValid?.required && markWhenOptional) {
23805 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23806 }
23807 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23808 ValidatedDateControl,
23809 {
23810 field,
23811 validity,
23812 inputRefs: [fromInputRef, toInputRef],
23813 isTouched,
23814 setIsTouched,
23815 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23816 import_components32.BaseControl,
23817 {
23818 id,
23819 className: "dataviews-controls__date",
23820 label: displayLabel,
23821 help: description,
23822 hideLabelFromVision,
23823 children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23824 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23825 Stack,
23826 {
23827 direction: "row",
23828 gap: "sm",
23829 wrap: "wrap",
23830 justify: "flex-start",
23831 children: [
23832 DATE_RANGE_PRESETS.map((preset) => {
23833 const isSelected2 = selectedPresetId === preset.id;
23834 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23835 import_components32.Button,
23836 {
23837 className: "dataviews-controls__date-preset",
23838 variant: "tertiary",
23839 isPressed: isSelected2,
23840 size: "small",
23841 disabled: disabled2,
23842 accessibleWhenDisabled: true,
23843 onClick: () => handlePresetClick(preset),
23844 children: preset.label
23845 },
23846 preset.id
23847 );
23848 }),
23849 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23850 import_components32.Button,
23851 {
23852 className: "dataviews-controls__date-preset",
23853 variant: "tertiary",
23854 isPressed: !selectedPresetId,
23855 size: "small",
23856 accessibleWhenDisabled: true,
23857 disabled: !!selectedPresetId || disabled2,
23858 children: (0, import_i18n35.__)("Custom")
23859 }
23860 )
23861 ]
23862 }
23863 ),
23864 /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
23865 Stack,
23866 {
23867 direction: "row",
23868 gap: "sm",
23869 justify: "space-between",
23870 className: "dataviews-controls__date-range-inputs",
23871 children: [
23872 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23873 import_components32.__experimentalInputControl,
23874 {
23875 __next40pxDefaultSize: true,
23876 ref: fromInputRef,
23877 type: "date",
23878 label: (0, import_i18n35.__)("From"),
23879 hideLabelFromVision: true,
23880 value: value?.[0],
23881 onChange: (newValue) => handleManualDateChange("from", newValue),
23882 required: !!field.isValid?.required,
23883 disabled: disabled2,
23884 min: minConstraint,
23885 max: maxConstraint
23886 }
23887 ),
23888 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23889 import_components32.__experimentalInputControl,
23890 {
23891 __next40pxDefaultSize: true,
23892 ref: toInputRef,
23893 type: "date",
23894 label: (0, import_i18n35.__)("To"),
23895 hideLabelFromVision: true,
23896 value: value?.[1],
23897 onChange: (newValue) => handleManualDateChange("to", newValue),
23898 required: !!field.isValid?.required,
23899 disabled: disabled2,
23900 min: minConstraint,
23901 max: maxConstraint
23902 }
23903 )
23904 ]
23905 }
23906 ),
23907 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23908 DateRangeCalendar,
23909 {
23910 style: { width: "100%" },
23911 selected: selectedRange,
23912 onSelect: onSelectCalendarRange,
23913 month: calendarMonth,
23914 onMonthChange: setCalendarMonth,
23915 timeZone: timezone.string || void 0,
23916 weekStartsOn,
23917 disabled: disabled2 || disabledMatchers
23918 }
23919 )
23920 ] })
23921 }
23922 )
23923 }
23924 );
23925 }
23926 function DateControl({
23927 data,
23928 field,
23929 onChange,
23930 hideLabelFromVision,
23931 markWhenOptional,
23932 operator,
23933 validity
23934 }) {
23935 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23936 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23937 RelativeDateControl,
23938 {
23939 className: "dataviews-controls__date",
23940 data,
23941 field,
23942 onChange,
23943 hideLabelFromVision,
23944 operator
23945 }
23946 );
23947 }
23948 if (operator === OPERATOR_BETWEEN) {
23949 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23950 CalendarDateRangeControl,
23951 {
23952 data,
23953 field,
23954 onChange,
23955 hideLabelFromVision,
23956 markWhenOptional,
23957 validity
23958 }
23959 );
23960 }
23961 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
23962 CalendarDateControl,
23963 {
23964 data,
23965 field,
23966 onChange,
23967 hideLabelFromVision,
23968 markWhenOptional,
23969 validity
23970 }
23971 );
23972 }
23973
23974 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23975 var import_components33 = __toESM(require_components(), 1);
23976 var import_element69 = __toESM(require_element(), 1);
23977 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23978 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
23979 function Select({
23980 data,
23981 field,
23982 onChange,
23983 hideLabelFromVision,
23984 markWhenOptional,
23985 validity
23986 }) {
23987 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23988 const disabled2 = field.isDisabled({ item: data, field });
23989 const isMultiple = type === "array";
23990 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23991 const onChangeControl = (0, import_element69.useCallback)(
23992 (newValue) => onChange(setValue({ item: data, value: newValue })),
23993 [data, onChange, setValue]
23994 );
23995 const { elements, isLoading } = useElements({
23996 elements: field.elements,
23997 getElements: field.getElements
23998 });
23999 if (isLoading) {
24000 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components33.Spinner, {});
24001 }
24002 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
24003 ValidatedSelectControl,
24004 {
24005 required: !!field.isValid?.required,
24006 markWhenOptional,
24007 customValidity: getCustomValidity(isValid2, validity),
24008 label,
24009 value,
24010 help: description,
24011 options: elements,
24012 onChange: onChangeControl,
24013 __next40pxDefaultSize: true,
24014 hideLabelFromVision,
24015 multiple: isMultiple,
24016 disabled: disabled2
24017 }
24018 );
24019 }
24020
24021 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
24022 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24023 var ELEMENTS_THRESHOLD = 10;
24024 function AdaptiveSelect(props) {
24025 const { field } = props;
24026 const { elements } = useElements({
24027 elements: field.elements,
24028 getElements: field.getElements
24029 });
24030 if (elements.length >= ELEMENTS_THRESHOLD) {
24031 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Combobox3, { ...props });
24032 }
24033 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(Select, { ...props });
24034 }
24035
24036 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24037 var import_components35 = __toESM(require_components(), 1);
24038
24039 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
24040 var import_components34 = __toESM(require_components(), 1);
24041 var import_element70 = __toESM(require_element(), 1);
24042 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24043 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
24044 function ValidatedText({
24045 data,
24046 field,
24047 onChange,
24048 hideLabelFromVision,
24049 markWhenOptional,
24050 type,
24051 prefix,
24052 suffix,
24053 validity
24054 }) {
24055 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24056 const value = getValue({ item: data });
24057 const disabled2 = field.isDisabled({ item: data, field });
24058 const onChangeControl = (0, import_element70.useCallback)(
24059 (newValue) => onChange(
24060 setValue({
24061 item: data,
24062 value: newValue
24063 })
24064 ),
24065 [data, setValue, onChange]
24066 );
24067 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24068 ValidatedInputControl2,
24069 {
24070 required: !!isValid2.required,
24071 markWhenOptional,
24072 customValidity: getCustomValidity(isValid2, validity),
24073 label,
24074 placeholder,
24075 value: value ?? "",
24076 help: description,
24077 onChange: onChangeControl,
24078 hideLabelFromVision,
24079 type,
24080 prefix,
24081 suffix,
24082 disabled: disabled2,
24083 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
24084 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24085 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24086 __next40pxDefaultSize: true
24087 }
24088 );
24089 }
24090
24091 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24092 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24093 function Email({
24094 data,
24095 field,
24096 onChange,
24097 hideLabelFromVision,
24098 markWhenOptional,
24099 validity
24100 }) {
24101 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24102 ValidatedText,
24103 {
24104 ...{
24105 data,
24106 field,
24107 onChange,
24108 hideLabelFromVision,
24109 markWhenOptional,
24110 validity,
24111 type: "email",
24112 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components35.Icon, { icon: envelope_default }) })
24113 }
24114 }
24115 );
24116 }
24117
24118 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
24119 var import_components36 = __toESM(require_components(), 1);
24120 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24121 function Telephone({
24122 data,
24123 field,
24124 onChange,
24125 hideLabelFromVision,
24126 markWhenOptional,
24127 validity
24128 }) {
24129 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24130 ValidatedText,
24131 {
24132 ...{
24133 data,
24134 field,
24135 onChange,
24136 hideLabelFromVision,
24137 markWhenOptional,
24138 validity,
24139 type: "tel",
24140 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components36.Icon, { icon: mobile_default }) })
24141 }
24142 }
24143 );
24144 }
24145
24146 // packages/dataviews/build-module/components/dataform-controls/url.mjs
24147 var import_components37 = __toESM(require_components(), 1);
24148 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24149 function Url({
24150 data,
24151 field,
24152 onChange,
24153 hideLabelFromVision,
24154 markWhenOptional,
24155 validity
24156 }) {
24157 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24158 ValidatedText,
24159 {
24160 ...{
24161 data,
24162 field,
24163 onChange,
24164 hideLabelFromVision,
24165 markWhenOptional,
24166 validity,
24167 type: "url",
24168 prefix: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components37.Icon, { icon: link_default }) })
24169 }
24170 }
24171 );
24172 }
24173
24174 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
24175 var import_components38 = __toESM(require_components(), 1);
24176 var import_element71 = __toESM(require_element(), 1);
24177 var import_i18n36 = __toESM(require_i18n(), 1);
24178 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24179 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
24180 function toNumberOrEmpty(value) {
24181 if (value === "" || value === void 0) {
24182 return "";
24183 }
24184 const number = Number(value);
24185 return Number.isFinite(number) ? number : "";
24186 }
24187 function BetweenControls({
24188 value,
24189 onChange,
24190 hideLabelFromVision,
24191 step
24192 }) {
24193 const [min2 = "", max2 = ""] = value;
24194 const onChangeMin = (0, import_element71.useCallback)(
24195 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
24196 [onChange, max2]
24197 );
24198 const onChangeMax = (0, import_element71.useCallback)(
24199 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
24200 [onChange, min2]
24201 );
24202 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24203 import_components38.BaseControl,
24204 {
24205 help: (0, import_i18n36.__)("The max. value must be greater than the min. value."),
24206 children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
24207 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24208 import_components38.__experimentalNumberControl,
24209 {
24210 label: (0, import_i18n36.__)("Min."),
24211 value: min2,
24212 max: max2 ? Number(max2) - step : void 0,
24213 onChange: onChangeMin,
24214 __next40pxDefaultSize: true,
24215 hideLabelFromVision,
24216 step
24217 }
24218 ),
24219 /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24220 import_components38.__experimentalNumberControl,
24221 {
24222 label: (0, import_i18n36.__)("Max."),
24223 value: max2,
24224 min: min2 ? Number(min2) + step : void 0,
24225 onChange: onChangeMax,
24226 __next40pxDefaultSize: true,
24227 hideLabelFromVision,
24228 step
24229 }
24230 )
24231 ] })
24232 }
24233 );
24234 }
24235 function ValidatedNumber({
24236 data,
24237 field,
24238 onChange,
24239 hideLabelFromVision,
24240 markWhenOptional,
24241 operator,
24242 validity
24243 }) {
24244 const decimals = field.format?.decimals ?? 0;
24245 const step = Math.pow(10, Math.abs(decimals) * -1);
24246 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24247 const value = getValue({ item: data }) ?? "";
24248 const disabled2 = field.isDisabled({ item: data, field });
24249 const onChangeControl = (0, import_element71.useCallback)(
24250 (newValue) => {
24251 onChange(
24252 setValue({
24253 item: data,
24254 // Do not convert an empty string or undefined to a number,
24255 // otherwise there's a mismatch between the UI control (empty)
24256 // and the data relied by onChange (0).
24257 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
24258 })
24259 );
24260 },
24261 [data, onChange, setValue]
24262 );
24263 const onChangeBetweenControls = (0, import_element71.useCallback)(
24264 (newValue) => {
24265 onChange(
24266 setValue({
24267 item: data,
24268 value: newValue
24269 })
24270 );
24271 },
24272 [data, onChange, setValue]
24273 );
24274 if (operator === OPERATOR_BETWEEN) {
24275 let valueBetween = ["", ""];
24276 if (Array.isArray(value) && value.length === 2 && value.every(
24277 (element) => typeof element === "number" || element === ""
24278 )) {
24279 valueBetween = value;
24280 }
24281 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24282 BetweenControls,
24283 {
24284 value: valueBetween,
24285 onChange: onChangeBetweenControls,
24286 hideLabelFromVision,
24287 step
24288 }
24289 );
24290 }
24291 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24292 ValidatedNumberControl,
24293 {
24294 required: !!isValid2.required,
24295 markWhenOptional,
24296 customValidity: getCustomValidity(isValid2, validity),
24297 label,
24298 help: description,
24299 value,
24300 onChange: onChangeControl,
24301 __next40pxDefaultSize: true,
24302 hideLabelFromVision,
24303 step,
24304 min: isValid2.min ? isValid2.min.constraint : void 0,
24305 max: isValid2.max ? isValid2.max.constraint : void 0,
24306 disabled: disabled2
24307 }
24308 );
24309 }
24310
24311 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24312 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24313 function Integer(props) {
24314 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
24315 }
24316
24317 // packages/dataviews/build-module/components/dataform-controls/number.mjs
24318 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24319 function Number2(props) {
24320 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(ValidatedNumber, { ...props });
24321 }
24322
24323 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24324 var import_components39 = __toESM(require_components(), 1);
24325 var import_element72 = __toESM(require_element(), 1);
24326 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24327 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
24328 function Radio({
24329 data,
24330 field,
24331 onChange,
24332 hideLabelFromVision,
24333 markWhenOptional,
24334 validity
24335 }) {
24336 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24337 const disabled2 = field.isDisabled({ item: data, field });
24338 const { elements, isLoading } = useElements({
24339 elements: field.elements,
24340 getElements: field.getElements
24341 });
24342 const value = getValue({ item: data });
24343 const onChangeControl = (0, import_element72.useCallback)(
24344 (newValue) => onChange(setValue({ item: data, value: newValue })),
24345 [data, onChange, setValue]
24346 );
24347 if (isLoading) {
24348 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components39.Spinner, {});
24349 }
24350 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24351 ValidatedRadioControl,
24352 {
24353 required: !!field.isValid?.required,
24354 markWhenOptional,
24355 customValidity: getCustomValidity(isValid2, validity),
24356 label,
24357 help: description,
24358 onChange: onChangeControl,
24359 options: elements,
24360 selected: value,
24361 hideLabelFromVision,
24362 disabled: disabled2
24363 }
24364 );
24365 }
24366
24367 // packages/dataviews/build-module/components/dataform-controls/text.mjs
24368 var import_element73 = __toESM(require_element(), 1);
24369 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24370 function Text3({
24371 data,
24372 field,
24373 onChange,
24374 hideLabelFromVision,
24375 markWhenOptional,
24376 config,
24377 validity
24378 }) {
24379 const { prefix, suffix } = config || {};
24380 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24381 ValidatedText,
24382 {
24383 ...{
24384 data,
24385 field,
24386 onChange,
24387 hideLabelFromVision,
24388 markWhenOptional,
24389 validity,
24390 prefix: prefix ? (0, import_element73.createElement)(prefix) : void 0,
24391 suffix: suffix ? (0, import_element73.createElement)(suffix) : void 0
24392 }
24393 }
24394 );
24395 }
24396
24397 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24398 var import_components40 = __toESM(require_components(), 1);
24399 var import_element74 = __toESM(require_element(), 1);
24400 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24401 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
24402 function Toggle({
24403 field,
24404 onChange,
24405 data,
24406 hideLabelFromVision,
24407 markWhenOptional,
24408 validity
24409 }) {
24410 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24411 const disabled2 = field.isDisabled({ item: data, field });
24412 const onChangeControl = (0, import_element74.useCallback)(() => {
24413 onChange(
24414 setValue({ item: data, value: !getValue({ item: data }) })
24415 );
24416 }, [onChange, setValue, data, getValue]);
24417 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24418 ValidatedToggleControl,
24419 {
24420 required: !!isValid2.required,
24421 markWhenOptional,
24422 customValidity: getCustomValidity(isValid2, validity),
24423 hidden: hideLabelFromVision,
24424 label,
24425 help: description,
24426 checked: getValue({ item: data }),
24427 onChange: onChangeControl,
24428 disabled: disabled2
24429 }
24430 );
24431 }
24432
24433 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24434 var import_components41 = __toESM(require_components(), 1);
24435 var import_element75 = __toESM(require_element(), 1);
24436 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24437 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
24438 function Textarea({
24439 data,
24440 field,
24441 onChange,
24442 hideLabelFromVision,
24443 markWhenOptional,
24444 config,
24445 validity
24446 }) {
24447 const { rows = 4 } = config || {};
24448 const disabled2 = field.isDisabled({ item: data, field });
24449 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24450 const value = field.getValue({ item: data });
24451 const onChangeControl = (0, import_element75.useCallback)(
24452 (newValue) => onChange(setValue({ item: data, value: newValue })),
24453 [data, onChange, setValue]
24454 );
24455 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24456 ValidatedTextareaControl,
24457 {
24458 required: !!isValid2.required,
24459 markWhenOptional,
24460 customValidity: getCustomValidity(isValid2, validity),
24461 label,
24462 placeholder,
24463 value: value ?? "",
24464 help: description,
24465 onChange: onChangeControl,
24466 rows,
24467 disabled: disabled2,
24468 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24469 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24470 __next40pxDefaultSize: true,
24471 hideLabelFromVision
24472 }
24473 );
24474 }
24475
24476 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24477 var import_components42 = __toESM(require_components(), 1);
24478 var import_element76 = __toESM(require_element(), 1);
24479 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24480 var { ValidatedToggleGroupControl } = unlock2(import_components42.privateApis);
24481 function ToggleGroup({
24482 data,
24483 field,
24484 onChange,
24485 hideLabelFromVision,
24486 markWhenOptional,
24487 validity
24488 }) {
24489 const { getValue, setValue, isValid: isValid2 } = field;
24490 const disabled2 = field.isDisabled({ item: data, field });
24491 const value = getValue({ item: data });
24492 const onChangeControl = (0, import_element76.useCallback)(
24493 (newValue) => onChange(setValue({ item: data, value: newValue })),
24494 [data, onChange, setValue]
24495 );
24496 const { elements, isLoading } = useElements({
24497 elements: field.elements,
24498 getElements: field.getElements
24499 });
24500 if (isLoading) {
24501 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components42.Spinner, {});
24502 }
24503 if (elements.length === 0) {
24504 return null;
24505 }
24506 const selectedOption = elements.find((el) => el.value === value);
24507 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24508 ValidatedToggleGroupControl,
24509 {
24510 required: !!field.isValid?.required,
24511 markWhenOptional,
24512 customValidity: getCustomValidity(isValid2, validity),
24513 __next40pxDefaultSize: true,
24514 isBlock: true,
24515 label: field.label,
24516 help: selectedOption?.description || field.description,
24517 onChange: onChangeControl,
24518 value,
24519 hideLabelFromVision,
24520 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24521 import_components42.__experimentalToggleGroupControlOption,
24522 {
24523 label: el.label,
24524 value: el.value,
24525 disabled: disabled2
24526 },
24527 el.value
24528 ))
24529 }
24530 );
24531 }
24532
24533 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24534 var import_components43 = __toESM(require_components(), 1);
24535 var import_element77 = __toESM(require_element(), 1);
24536 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24537 var { ValidatedFormTokenField } = unlock2(import_components43.privateApis);
24538 function ArrayControl({
24539 data,
24540 field,
24541 onChange,
24542 hideLabelFromVision,
24543 markWhenOptional,
24544 validity
24545 }) {
24546 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24547 const value = getValue({ item: data });
24548 const disabled2 = field.isDisabled({ item: data, field });
24549 const { elements, isLoading } = useElements({
24550 elements: field.elements,
24551 getElements: field.getElements
24552 });
24553 const arrayValueAsElements = (0, import_element77.useMemo)(
24554 () => Array.isArray(value) ? value.map((token) => {
24555 const element = elements?.find(
24556 (suggestion) => suggestion.value === token
24557 );
24558 return element || { value: token, label: token };
24559 }) : [],
24560 [value, elements]
24561 );
24562 const onChangeControl = (0, import_element77.useCallback)(
24563 (tokens) => {
24564 const valueTokens = tokens.map((token) => {
24565 if (typeof token === "object" && "value" in token) {
24566 return token.value;
24567 }
24568 return token;
24569 });
24570 onChange(setValue({ item: data, value: valueTokens }));
24571 },
24572 [onChange, setValue, data]
24573 );
24574 if (isLoading) {
24575 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components43.Spinner, {});
24576 }
24577 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24578 ValidatedFormTokenField,
24579 {
24580 required: !!isValid2?.required,
24581 markWhenOptional,
24582 customValidity: getCustomValidity(isValid2, validity),
24583 label: hideLabelFromVision ? void 0 : label,
24584 value: arrayValueAsElements,
24585 onChange: onChangeControl,
24586 placeholder,
24587 suggestions: elements?.map((element) => element.value),
24588 disabled: disabled2,
24589 __experimentalValidateInput: (token) => {
24590 if (field.isValid?.elements && elements) {
24591 return elements.some(
24592 (element) => element.value === token || element.label === token
24593 );
24594 }
24595 return true;
24596 },
24597 __experimentalExpandOnFocus: elements && elements.length > 0,
24598 help: description ?? (field.isValid?.elements ? "" : void 0),
24599 displayTransform: (token) => {
24600 if (typeof token === "object" && "label" in token) {
24601 return token.label;
24602 }
24603 if (typeof token === "string" && elements) {
24604 const element = elements.find(
24605 (el) => el.value === token
24606 );
24607 return element?.label || token;
24608 }
24609 return token;
24610 },
24611 __experimentalRenderItem: ({ item }) => {
24612 if (typeof item === "string" && elements) {
24613 const element = elements.find(
24614 (el) => el.value === item
24615 );
24616 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("span", { children: element?.label || item });
24617 }
24618 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("span", { children: item });
24619 }
24620 }
24621 );
24622 }
24623
24624 // node_modules/colord/index.mjs
24625 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24626 var t = function(r3) {
24627 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24628 };
24629 var n = function(r3, t2, n2) {
24630 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24631 };
24632 var e = function(r3, t2, n2) {
24633 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24634 };
24635 var u = function(r3) {
24636 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24637 };
24638 var a = function(r3) {
24639 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24640 };
24641 var o = function(r3) {
24642 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24643 };
24644 var i = /^#([0-9a-f]{3,8})$/i;
24645 var s = function(r3) {
24646 var t2 = r3.toString(16);
24647 return t2.length < 2 ? "0" + t2 : t2;
24648 };
24649 var h = function(r3) {
24650 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;
24651 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24652 };
24653 var b = function(r3) {
24654 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24655 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24656 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;
24657 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 };
24658 };
24659 var g = function(r3) {
24660 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24661 };
24662 var d = function(r3) {
24663 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24664 };
24665 var f = function(r3) {
24666 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 }));
24667 var t2, n2, e2;
24668 };
24669 var c = function(r3) {
24670 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 };
24671 var t2, n2, e2, u2;
24672 };
24673 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24674 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24675 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24676 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24677 var y = { string: [[function(r3) {
24678 var t2 = i.exec(r3);
24679 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;
24680 }, "hex"], [function(r3) {
24681 var t2 = v.exec(r3) || m.exec(r3);
24682 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;
24683 }, "rgb"], [function(t2) {
24684 var n2 = l.exec(t2) || p.exec(t2);
24685 if (!n2) return null;
24686 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) });
24687 return f(a2);
24688 }, "hsl"]], object: [[function(r3) {
24689 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24690 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24691 }, "rgb"], [function(r3) {
24692 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24693 if (!t(n2) || !t(e2) || !t(u2)) return null;
24694 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24695 return f(i2);
24696 }, "hsl"], [function(r3) {
24697 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24698 if (!t(n2) || !t(a2) || !t(o2)) return null;
24699 var h2 = (function(r4) {
24700 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24701 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24702 return b(h2);
24703 }, "hsv"]] };
24704 var N = function(r3, t2) {
24705 for (var n2 = 0; n2 < t2.length; n2++) {
24706 var e2 = t2[n2][0](r3);
24707 if (e2) return [e2, t2[n2][1]];
24708 }
24709 return [null, void 0];
24710 };
24711 var x = function(r3) {
24712 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24713 };
24714 var M = function(r3, t2) {
24715 var n2 = c(r3);
24716 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24717 };
24718 var H = function(r3) {
24719 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24720 };
24721 var $ = function(r3, t2) {
24722 var n2 = c(r3);
24723 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24724 };
24725 var j = (function() {
24726 function r3(r4) {
24727 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24728 }
24729 return r3.prototype.isValid = function() {
24730 return null !== this.parsed;
24731 }, r3.prototype.brightness = function() {
24732 return n(H(this.rgba), 2);
24733 }, r3.prototype.isDark = function() {
24734 return H(this.rgba) < 0.5;
24735 }, r3.prototype.isLight = function() {
24736 return H(this.rgba) >= 0.5;
24737 }, r3.prototype.toHex = function() {
24738 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;
24739 var r4, t2, e2, u2, a2, i2;
24740 }, r3.prototype.toRgb = function() {
24741 return o(this.rgba);
24742 }, r3.prototype.toRgbString = function() {
24743 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 + ")";
24744 var r4, t2, n2, e2, u2;
24745 }, r3.prototype.toHsl = function() {
24746 return d(c(this.rgba));
24747 }, r3.prototype.toHslString = function() {
24748 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 + "%)";
24749 var r4, t2, n2, e2, u2;
24750 }, r3.prototype.toHsv = function() {
24751 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24752 var r4;
24753 }, r3.prototype.invert = function() {
24754 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24755 var r4;
24756 }, r3.prototype.saturate = function(r4) {
24757 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24758 }, r3.prototype.desaturate = function(r4) {
24759 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24760 }, r3.prototype.grayscale = function() {
24761 return w(M(this.rgba, -1));
24762 }, r3.prototype.lighten = function(r4) {
24763 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24764 }, r3.prototype.darken = function(r4) {
24765 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24766 }, r3.prototype.rotate = function(r4) {
24767 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24768 }, r3.prototype.alpha = function(r4) {
24769 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24770 var t2;
24771 }, r3.prototype.hue = function(r4) {
24772 var t2 = c(this.rgba);
24773 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24774 }, r3.prototype.isEqual = function(r4) {
24775 return this.toHex() === w(r4).toHex();
24776 }, r3;
24777 })();
24778 var w = function(r3) {
24779 return r3 instanceof j ? r3 : new j(r3);
24780 };
24781
24782 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24783 var import_components44 = __toESM(require_components(), 1);
24784 var import_element78 = __toESM(require_element(), 1);
24785 var import_i18n37 = __toESM(require_i18n(), 1);
24786 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24787 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components44.privateApis);
24788 var ColorPickerDropdown = ({
24789 color,
24790 onColorChange,
24791 disabled: disabled2
24792 }) => {
24793 const validColor = color && w(color).isValid() ? color : "#ffffff";
24794 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24795 import_components44.Dropdown,
24796 {
24797 className: "dataviews-controls__color-picker-dropdown",
24798 popoverProps: { resize: false },
24799 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24800 import_components44.Button,
24801 {
24802 onClick: onToggle,
24803 "aria-label": (0, import_i18n37.__)("Open color picker"),
24804 size: "small",
24805 disabled: disabled2,
24806 accessibleWhenDisabled: true,
24807 icon: () => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
24808 }
24809 ),
24810 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24811 import_components44.ColorPicker,
24812 {
24813 color: validColor,
24814 onChange: onColorChange,
24815 enableAlpha: true
24816 }
24817 ) })
24818 }
24819 );
24820 };
24821 function Color({
24822 data,
24823 field,
24824 onChange,
24825 hideLabelFromVision,
24826 markWhenOptional,
24827 validity
24828 }) {
24829 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24830 const disabled2 = field.isDisabled({ item: data, field });
24831 const value = field.getValue({ item: data }) || "";
24832 const handleColorChange = (0, import_element78.useCallback)(
24833 (newColor) => {
24834 onChange(setValue({ item: data, value: newColor }));
24835 },
24836 [data, onChange, setValue]
24837 );
24838 const handleInputChange = (0, import_element78.useCallback)(
24839 (newValue) => {
24840 onChange(setValue({ item: data, value: newValue || "" }));
24841 },
24842 [data, onChange, setValue]
24843 );
24844 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24845 ValidatedInputControl3,
24846 {
24847 required: !!field.isValid?.required,
24848 markWhenOptional,
24849 customValidity: getCustomValidity(isValid2, validity),
24850 label,
24851 placeholder,
24852 value,
24853 help: description,
24854 onChange: handleInputChange,
24855 hideLabelFromVision,
24856 type: "text",
24857 disabled: disabled2,
24858 prefix: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24859 ColorPickerDropdown,
24860 {
24861 color: value,
24862 onColorChange: handleColorChange,
24863 disabled: disabled2
24864 }
24865 ) })
24866 }
24867 );
24868 }
24869
24870 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24871 var import_components45 = __toESM(require_components(), 1);
24872 var import_element79 = __toESM(require_element(), 1);
24873 var import_i18n38 = __toESM(require_i18n(), 1);
24874 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24875 function Password({
24876 data,
24877 field,
24878 onChange,
24879 hideLabelFromVision,
24880 markWhenOptional,
24881 validity
24882 }) {
24883 const [isVisible2, setIsVisible] = (0, import_element79.useState)(false);
24884 const disabled2 = field.isDisabled({ item: data, field });
24885 const toggleVisibility = (0, import_element79.useCallback)(() => {
24886 setIsVisible((prev) => !prev);
24887 }, []);
24888 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
24889 ValidatedText,
24890 {
24891 ...{
24892 data,
24893 field,
24894 onChange,
24895 hideLabelFromVision,
24896 markWhenOptional,
24897 validity,
24898 type: isVisible2 ? "text" : "password",
24899 suffix: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
24900 import_components45.Button,
24901 {
24902 icon: isVisible2 ? unseen_default : seen_default,
24903 onClick: toggleVisibility,
24904 size: "small",
24905 label: isVisible2 ? (0, import_i18n38.__)("Hide password") : (0, import_i18n38.__)("Show password"),
24906 disabled: disabled2,
24907 accessibleWhenDisabled: true
24908 }
24909 ) })
24910 }
24911 }
24912 );
24913 }
24914
24915 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24916 function hasElements(field) {
24917 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24918 }
24919
24920 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24921 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
24922 var FORM_CONTROLS = {
24923 adaptiveSelect: AdaptiveSelect,
24924 array: ArrayControl,
24925 checkbox: Checkbox,
24926 color: Color,
24927 combobox: Combobox3,
24928 datetime: DateTime,
24929 date: DateControl,
24930 email: Email,
24931 telephone: Telephone,
24932 url: Url,
24933 integer: Integer,
24934 number: Number2,
24935 password: Password,
24936 radio: Radio,
24937 select: Select,
24938 text: Text3,
24939 toggle: Toggle,
24940 textarea: Textarea,
24941 toggleGroup: ToggleGroup
24942 };
24943 function isEditConfig(value) {
24944 return value && typeof value === "object" && typeof value.control === "string";
24945 }
24946 function createConfiguredControl(config) {
24947 const { control, ...controlConfig } = config;
24948 const BaseControlType = getControlByType(control);
24949 if (BaseControlType === null) {
24950 return null;
24951 }
24952 return function ConfiguredControl(props) {
24953 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(BaseControlType, { ...props, config: controlConfig });
24954 };
24955 }
24956 function getControl(field, fallback) {
24957 if (typeof field.Edit === "function") {
24958 return field.Edit;
24959 }
24960 if (typeof field.Edit === "string") {
24961 return getControlByType(field.Edit);
24962 }
24963 if (isEditConfig(field.Edit)) {
24964 return createConfiguredControl(field.Edit);
24965 }
24966 if (hasElements(field) && field.type !== "array") {
24967 return getControlByType("adaptiveSelect");
24968 }
24969 if (fallback === null) {
24970 return null;
24971 }
24972 return getControlByType(fallback);
24973 }
24974 function getControlByType(type) {
24975 if (Object.keys(FORM_CONTROLS).includes(type)) {
24976 return FORM_CONTROLS[type];
24977 }
24978 return null;
24979 }
24980
24981 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24982 function getFilterBy(field, defaultOperators, validOperators) {
24983 if (field.filterBy === false) {
24984 return false;
24985 }
24986 const operators = field.filterBy?.operators?.filter(
24987 (op) => validOperators.includes(op)
24988 ) ?? defaultOperators;
24989 if (operators.length === 0) {
24990 return false;
24991 }
24992 return {
24993 isPrimary: !!field.filterBy?.isPrimary,
24994 operators
24995 };
24996 }
24997 var get_filter_by_default = getFilterBy;
24998
24999 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25000 var getValueFromId = (id) => ({ item }) => {
25001 const path = id.split(".");
25002 let value = item;
25003 for (const segment of path) {
25004 if (value.hasOwnProperty(segment)) {
25005 value = value[segment];
25006 } else {
25007 value = void 0;
25008 }
25009 }
25010 return value;
25011 };
25012 var get_value_from_id_default = getValueFromId;
25013
25014 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25015 var setValueFromId = (id) => ({ value }) => {
25016 const path = id.split(".");
25017 const result = {};
25018 let current = result;
25019 for (const segment of path.slice(0, -1)) {
25020 current[segment] = {};
25021 current = current[segment];
25022 }
25023 current[path.at(-1)] = value;
25024 return result;
25025 };
25026 var set_value_from_id_default = setValueFromId;
25027
25028 // packages/dataviews/build-module/field-types/email.mjs
25029 var import_i18n39 = __toESM(require_i18n(), 1);
25030
25031 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25032 function RenderFromElements({
25033 item,
25034 field
25035 }) {
25036 const { elements, isLoading } = useElements({
25037 elements: field.elements,
25038 getElements: field.getElements
25039 });
25040 const value = field.getValue({ item });
25041 if (isLoading) {
25042 return value;
25043 }
25044 if (elements.length === 0) {
25045 return value;
25046 }
25047 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25048 }
25049
25050 // packages/dataviews/build-module/field-types/utils/render-default.mjs
25051 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25052 function render({
25053 item,
25054 field
25055 }) {
25056 if (field.hasElements) {
25057 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(RenderFromElements, { item, field });
25058 }
25059 return field.getValueFormatted({ item, field });
25060 }
25061
25062 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25063 var sort_text_default = (a2, b2, direction) => {
25064 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25065 };
25066
25067 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25068 function isValidRequired(item, field) {
25069 const value = field.getValue({ item });
25070 return ![void 0, "", null].includes(value);
25071 }
25072
25073 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25074 function isValidMinLength(item, field) {
25075 if (typeof field.isValid.minLength?.constraint !== "number") {
25076 return false;
25077 }
25078 const value = field.getValue({ item });
25079 if ([void 0, "", null].includes(value)) {
25080 return true;
25081 }
25082 return String(value).length >= field.isValid.minLength.constraint;
25083 }
25084
25085 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25086 function isValidMaxLength(item, field) {
25087 if (typeof field.isValid.maxLength?.constraint !== "number") {
25088 return false;
25089 }
25090 const value = field.getValue({ item });
25091 if ([void 0, "", null].includes(value)) {
25092 return true;
25093 }
25094 return String(value).length <= field.isValid.maxLength.constraint;
25095 }
25096
25097 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25098 function isValidPattern(item, field) {
25099 if (field.isValid.pattern?.constraint === void 0) {
25100 return true;
25101 }
25102 try {
25103 const regexp = new RegExp(field.isValid.pattern.constraint);
25104 const value = field.getValue({ item });
25105 if ([void 0, "", null].includes(value)) {
25106 return true;
25107 }
25108 return regexp.test(String(value));
25109 } catch {
25110 return false;
25111 }
25112 }
25113
25114 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25115 function isValidElements(item, field) {
25116 const elements = field.elements ?? [];
25117 const validValues = elements.map((el) => el.value);
25118 if (validValues.length === 0) {
25119 return true;
25120 }
25121 const value = field.getValue({ item });
25122 return [].concat(value).every((v2) => validValues.includes(v2));
25123 }
25124
25125 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25126 function getValueFormatted({
25127 item,
25128 field
25129 }) {
25130 return field.getValue({ item });
25131 }
25132 var get_value_formatted_default_default = getValueFormatted;
25133
25134 // packages/dataviews/build-module/field-types/email.mjs
25135 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])?)*$/;
25136 function isValidCustom(item, field) {
25137 const value = field.getValue({ item });
25138 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25139 return (0, import_i18n39.__)("Value must be a valid email address.");
25140 }
25141 return null;
25142 }
25143 var email_default = {
25144 type: "email",
25145 render,
25146 Edit: "email",
25147 sort: sort_text_default,
25148 enableSorting: true,
25149 enableGlobalSearch: false,
25150 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25151 validOperators: [
25152 OPERATOR_IS,
25153 OPERATOR_IS_NOT,
25154 OPERATOR_CONTAINS,
25155 OPERATOR_NOT_CONTAINS,
25156 OPERATOR_STARTS_WITH,
25157 // Multiple selection
25158 OPERATOR_IS_ANY,
25159 OPERATOR_IS_NONE,
25160 OPERATOR_IS_ALL,
25161 OPERATOR_IS_NOT_ALL
25162 ],
25163 format: {},
25164 getValueFormatted: get_value_formatted_default_default,
25165 validate: {
25166 required: isValidRequired,
25167 pattern: isValidPattern,
25168 minLength: isValidMinLength,
25169 maxLength: isValidMaxLength,
25170 elements: isValidElements,
25171 custom: isValidCustom
25172 }
25173 };
25174
25175 // packages/dataviews/build-module/field-types/integer.mjs
25176 var import_i18n40 = __toESM(require_i18n(), 1);
25177
25178 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25179 var sort_number_default = (a2, b2, direction) => {
25180 return direction === "asc" ? a2 - b2 : b2 - a2;
25181 };
25182
25183 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25184 function isValidMin(item, field) {
25185 if (typeof field.isValid.min?.constraint !== "number") {
25186 return false;
25187 }
25188 const value = field.getValue({ item });
25189 if ([void 0, "", null].includes(value)) {
25190 return true;
25191 }
25192 return Number(value) >= field.isValid.min.constraint;
25193 }
25194
25195 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25196 function isValidMax(item, field) {
25197 if (typeof field.isValid.max?.constraint !== "number") {
25198 return false;
25199 }
25200 const value = field.getValue({ item });
25201 if ([void 0, "", null].includes(value)) {
25202 return true;
25203 }
25204 return Number(value) <= field.isValid.max.constraint;
25205 }
25206
25207 // packages/dataviews/build-module/field-types/integer.mjs
25208 var format2 = {
25209 separatorThousand: ","
25210 };
25211 function getValueFormatted2({
25212 item,
25213 field
25214 }) {
25215 let value = field.getValue({ item });
25216 if (value === null || value === void 0) {
25217 return "";
25218 }
25219 value = Number(value);
25220 if (!Number.isFinite(value)) {
25221 return String(value);
25222 }
25223 let formatInteger;
25224 if (field.type !== "integer") {
25225 formatInteger = format2;
25226 } else {
25227 formatInteger = field.format;
25228 }
25229 const { separatorThousand } = formatInteger;
25230 const integerValue = Math.trunc(value);
25231 if (!separatorThousand) {
25232 return String(integerValue);
25233 }
25234 return String(integerValue).replace(
25235 /\B(?=(\d{3})+(?!\d))/g,
25236 separatorThousand
25237 );
25238 }
25239 function isValidCustom2(item, field) {
25240 const value = field.getValue({ item });
25241 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25242 return (0, import_i18n40.__)("Value must be an integer.");
25243 }
25244 return null;
25245 }
25246 var integer_default = {
25247 type: "integer",
25248 render,
25249 Edit: "integer",
25250 sort: sort_number_default,
25251 enableSorting: true,
25252 enableGlobalSearch: false,
25253 defaultOperators: [
25254 OPERATOR_IS,
25255 OPERATOR_IS_NOT,
25256 OPERATOR_LESS_THAN,
25257 OPERATOR_GREATER_THAN,
25258 OPERATOR_LESS_THAN_OR_EQUAL,
25259 OPERATOR_GREATER_THAN_OR_EQUAL,
25260 OPERATOR_BETWEEN
25261 ],
25262 validOperators: [
25263 // Single-selection
25264 OPERATOR_IS,
25265 OPERATOR_IS_NOT,
25266 OPERATOR_LESS_THAN,
25267 OPERATOR_GREATER_THAN,
25268 OPERATOR_LESS_THAN_OR_EQUAL,
25269 OPERATOR_GREATER_THAN_OR_EQUAL,
25270 OPERATOR_BETWEEN,
25271 // Multiple-selection
25272 OPERATOR_IS_ANY,
25273 OPERATOR_IS_NONE,
25274 OPERATOR_IS_ALL,
25275 OPERATOR_IS_NOT_ALL
25276 ],
25277 format: format2,
25278 getValueFormatted: getValueFormatted2,
25279 validate: {
25280 required: isValidRequired,
25281 min: isValidMin,
25282 max: isValidMax,
25283 elements: isValidElements,
25284 custom: isValidCustom2
25285 }
25286 };
25287
25288 // packages/dataviews/build-module/field-types/number.mjs
25289 var import_i18n41 = __toESM(require_i18n(), 1);
25290 var format3 = {
25291 separatorThousand: ",",
25292 separatorDecimal: ".",
25293 decimals: 2
25294 };
25295 function getValueFormatted3({
25296 item,
25297 field
25298 }) {
25299 let value = field.getValue({ item });
25300 if (value === null || value === void 0) {
25301 return "";
25302 }
25303 value = Number(value);
25304 if (!Number.isFinite(value)) {
25305 return String(value);
25306 }
25307 let formatNumber;
25308 if (field.type !== "number") {
25309 formatNumber = format3;
25310 } else {
25311 formatNumber = field.format;
25312 }
25313 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25314 const fixedValue = value.toFixed(decimals);
25315 const [integerPart, decimalPart] = fixedValue.split(".");
25316 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25317 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25318 }
25319 function isEmpty2(value) {
25320 return value === "" || value === void 0 || value === null;
25321 }
25322 function isValidCustom3(item, field) {
25323 const value = field.getValue({ item });
25324 if (!isEmpty2(value) && !Number.isFinite(value)) {
25325 return (0, import_i18n41.__)("Value must be a number.");
25326 }
25327 return null;
25328 }
25329 var number_default = {
25330 type: "number",
25331 render,
25332 Edit: "number",
25333 sort: sort_number_default,
25334 enableSorting: true,
25335 enableGlobalSearch: false,
25336 defaultOperators: [
25337 OPERATOR_IS,
25338 OPERATOR_IS_NOT,
25339 OPERATOR_LESS_THAN,
25340 OPERATOR_GREATER_THAN,
25341 OPERATOR_LESS_THAN_OR_EQUAL,
25342 OPERATOR_GREATER_THAN_OR_EQUAL,
25343 OPERATOR_BETWEEN
25344 ],
25345 validOperators: [
25346 // Single-selection
25347 OPERATOR_IS,
25348 OPERATOR_IS_NOT,
25349 OPERATOR_LESS_THAN,
25350 OPERATOR_GREATER_THAN,
25351 OPERATOR_LESS_THAN_OR_EQUAL,
25352 OPERATOR_GREATER_THAN_OR_EQUAL,
25353 OPERATOR_BETWEEN,
25354 // Multiple-selection
25355 OPERATOR_IS_ANY,
25356 OPERATOR_IS_NONE,
25357 OPERATOR_IS_ALL,
25358 OPERATOR_IS_NOT_ALL
25359 ],
25360 format: format3,
25361 getValueFormatted: getValueFormatted3,
25362 validate: {
25363 required: isValidRequired,
25364 min: isValidMin,
25365 max: isValidMax,
25366 elements: isValidElements,
25367 custom: isValidCustom3
25368 }
25369 };
25370
25371 // packages/dataviews/build-module/field-types/text.mjs
25372 var text_default = {
25373 type: "text",
25374 render,
25375 Edit: "text",
25376 sort: sort_text_default,
25377 enableSorting: true,
25378 enableGlobalSearch: false,
25379 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25380 validOperators: [
25381 // Single selection
25382 OPERATOR_IS,
25383 OPERATOR_IS_NOT,
25384 OPERATOR_CONTAINS,
25385 OPERATOR_NOT_CONTAINS,
25386 OPERATOR_STARTS_WITH,
25387 // Multiple selection
25388 OPERATOR_IS_ANY,
25389 OPERATOR_IS_NONE,
25390 OPERATOR_IS_ALL,
25391 OPERATOR_IS_NOT_ALL
25392 ],
25393 format: {},
25394 getValueFormatted: get_value_formatted_default_default,
25395 validate: {
25396 required: isValidRequired,
25397 pattern: isValidPattern,
25398 minLength: isValidMinLength,
25399 maxLength: isValidMaxLength,
25400 elements: isValidElements
25401 }
25402 };
25403
25404 // packages/dataviews/build-module/field-types/datetime.mjs
25405 var import_date7 = __toESM(require_date(), 1);
25406
25407 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25408 var import_date6 = __toESM(require_date(), 1);
25409 function parseDateLike(value) {
25410 if (!value) {
25411 return null;
25412 }
25413 if (!isValid(new Date(value))) {
25414 return null;
25415 }
25416 const parsed = (0, import_date6.getDate)(value);
25417 return parsed && isValid(parsed) ? parsed : null;
25418 }
25419 function validateDateLikeBoundary(item, field, boundary) {
25420 const constraint = field.isValid[boundary]?.constraint;
25421 if (typeof constraint !== "string") {
25422 return false;
25423 }
25424 const value = field.getValue({ item });
25425 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25426 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25427 return true;
25428 }
25429 const parsedConstraint = parseDateLike(constraint);
25430 const parsedValue = parseDateLike(String(boundaryValue));
25431 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25432 }
25433 function isValidMinDate(item, field) {
25434 return validateDateLikeBoundary(item, field, "min");
25435 }
25436 function isValidMaxDate(item, field) {
25437 return validateDateLikeBoundary(item, field, "max");
25438 }
25439
25440 // packages/dataviews/build-module/field-types/datetime.mjs
25441 var format4 = {
25442 datetime: (0, import_date7.getSettings)().formats.datetime,
25443 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25444 };
25445 function getValueFormatted4({
25446 item,
25447 field
25448 }) {
25449 const value = field.getValue({ item });
25450 if (["", void 0, null].includes(value)) {
25451 return "";
25452 }
25453 let formatDatetime;
25454 if (field.type !== "datetime") {
25455 formatDatetime = format4;
25456 } else {
25457 formatDatetime = field.format;
25458 }
25459 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25460 }
25461 var sort = (a2, b2, direction) => {
25462 const timeA = new Date(a2).getTime();
25463 const timeB = new Date(b2).getTime();
25464 return direction === "asc" ? timeA - timeB : timeB - timeA;
25465 };
25466 var datetime_default = {
25467 type: "datetime",
25468 render,
25469 Edit: "datetime",
25470 sort,
25471 enableSorting: true,
25472 enableGlobalSearch: false,
25473 defaultOperators: [
25474 OPERATOR_ON,
25475 OPERATOR_NOT_ON,
25476 OPERATOR_BEFORE,
25477 OPERATOR_AFTER,
25478 OPERATOR_BEFORE_INC,
25479 OPERATOR_AFTER_INC,
25480 OPERATOR_IN_THE_PAST,
25481 OPERATOR_OVER
25482 ],
25483 validOperators: [
25484 OPERATOR_ON,
25485 OPERATOR_NOT_ON,
25486 OPERATOR_BEFORE,
25487 OPERATOR_AFTER,
25488 OPERATOR_BEFORE_INC,
25489 OPERATOR_AFTER_INC,
25490 OPERATOR_IN_THE_PAST,
25491 OPERATOR_OVER
25492 ],
25493 format: format4,
25494 getValueFormatted: getValueFormatted4,
25495 validate: {
25496 required: isValidRequired,
25497 elements: isValidElements,
25498 min: isValidMinDate,
25499 max: isValidMaxDate
25500 }
25501 };
25502
25503 // packages/dataviews/build-module/field-types/date.mjs
25504 var import_date8 = __toESM(require_date(), 1);
25505 var format5 = {
25506 date: (0, import_date8.getSettings)().formats.date,
25507 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25508 };
25509 function getValueFormatted5({
25510 item,
25511 field
25512 }) {
25513 const value = field.getValue({ item });
25514 if (["", void 0, null].includes(value)) {
25515 return "";
25516 }
25517 let formatDate2;
25518 if (field.type !== "date") {
25519 formatDate2 = format5;
25520 } else {
25521 formatDate2 = field.format;
25522 }
25523 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25524 }
25525 var sort2 = (a2, b2, direction) => {
25526 const timeA = new Date(a2).getTime();
25527 const timeB = new Date(b2).getTime();
25528 return direction === "asc" ? timeA - timeB : timeB - timeA;
25529 };
25530 var date_default = {
25531 type: "date",
25532 render,
25533 Edit: "date",
25534 sort: sort2,
25535 enableSorting: true,
25536 enableGlobalSearch: false,
25537 defaultOperators: [
25538 OPERATOR_ON,
25539 OPERATOR_NOT_ON,
25540 OPERATOR_BEFORE,
25541 OPERATOR_AFTER,
25542 OPERATOR_BEFORE_INC,
25543 OPERATOR_AFTER_INC,
25544 OPERATOR_IN_THE_PAST,
25545 OPERATOR_OVER,
25546 OPERATOR_BETWEEN
25547 ],
25548 validOperators: [
25549 OPERATOR_ON,
25550 OPERATOR_NOT_ON,
25551 OPERATOR_BEFORE,
25552 OPERATOR_AFTER,
25553 OPERATOR_BEFORE_INC,
25554 OPERATOR_AFTER_INC,
25555 OPERATOR_IN_THE_PAST,
25556 OPERATOR_OVER,
25557 OPERATOR_BETWEEN
25558 ],
25559 format: format5,
25560 getValueFormatted: getValueFormatted5,
25561 validate: {
25562 required: isValidRequired,
25563 elements: isValidElements,
25564 min: isValidMinDate,
25565 max: isValidMaxDate
25566 }
25567 };
25568
25569 // packages/dataviews/build-module/field-types/boolean.mjs
25570 var import_i18n42 = __toESM(require_i18n(), 1);
25571
25572 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25573 function isValidRequiredForBool(item, field) {
25574 const value = field.getValue({ item });
25575 return value === true;
25576 }
25577
25578 // packages/dataviews/build-module/field-types/boolean.mjs
25579 function getValueFormatted6({
25580 item,
25581 field
25582 }) {
25583 const value = field.getValue({ item });
25584 if (value === true) {
25585 return (0, import_i18n42.__)("True");
25586 }
25587 if (value === false) {
25588 return (0, import_i18n42.__)("False");
25589 }
25590 return "";
25591 }
25592 function isValidCustom4(item, field) {
25593 const value = field.getValue({ item });
25594 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25595 return (0, import_i18n42.__)("Value must be true, false, or undefined");
25596 }
25597 return null;
25598 }
25599 var sort3 = (a2, b2, direction) => {
25600 const boolA = Boolean(a2);
25601 const boolB = Boolean(b2);
25602 if (boolA === boolB) {
25603 return 0;
25604 }
25605 if (direction === "asc") {
25606 return boolA ? 1 : -1;
25607 }
25608 return boolA ? -1 : 1;
25609 };
25610 var boolean_default = {
25611 type: "boolean",
25612 render,
25613 Edit: "checkbox",
25614 sort: sort3,
25615 validate: {
25616 required: isValidRequiredForBool,
25617 elements: isValidElements,
25618 custom: isValidCustom4
25619 },
25620 enableSorting: true,
25621 enableGlobalSearch: false,
25622 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25623 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25624 format: {},
25625 getValueFormatted: getValueFormatted6
25626 };
25627
25628 // packages/dataviews/build-module/field-types/media.mjs
25629 var media_default = {
25630 type: "media",
25631 render: () => null,
25632 Edit: null,
25633 sort: () => 0,
25634 enableSorting: false,
25635 enableGlobalSearch: false,
25636 defaultOperators: [],
25637 validOperators: [],
25638 format: {},
25639 getValueFormatted: get_value_formatted_default_default,
25640 // cannot validate any constraint, so
25641 // the only available validation for the field author
25642 // would be providing a custom validator.
25643 validate: {}
25644 };
25645
25646 // packages/dataviews/build-module/field-types/array.mjs
25647 var import_i18n43 = __toESM(require_i18n(), 1);
25648
25649 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25650 function isValidRequiredForArray(item, field) {
25651 const value = field.getValue({ item });
25652 return Array.isArray(value) && value.length > 0 && value.every(
25653 (element) => ![void 0, "", null].includes(element)
25654 );
25655 }
25656
25657 // packages/dataviews/build-module/field-types/array.mjs
25658 function getValueFormatted7({
25659 item,
25660 field
25661 }) {
25662 const value = field.getValue({ item });
25663 const arr = Array.isArray(value) ? value : [];
25664 return arr.join(", ");
25665 }
25666 function render2({ item, field }) {
25667 return getValueFormatted7({ item, field });
25668 }
25669 function isValidCustom5(item, field) {
25670 const value = field.getValue({ item });
25671 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25672 return (0, import_i18n43.__)("Value must be an array.");
25673 }
25674 if (!value.every((v2) => typeof v2 === "string")) {
25675 return (0, import_i18n43.__)("Every value must be a string.");
25676 }
25677 return null;
25678 }
25679 var sort4 = (a2, b2, direction) => {
25680 const arrA = Array.isArray(a2) ? a2 : [];
25681 const arrB = Array.isArray(b2) ? b2 : [];
25682 if (arrA.length !== arrB.length) {
25683 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25684 }
25685 const joinedA = arrA.join(",");
25686 const joinedB = arrB.join(",");
25687 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25688 };
25689 var array_default = {
25690 type: "array",
25691 render: render2,
25692 Edit: "array",
25693 sort: sort4,
25694 enableSorting: true,
25695 enableGlobalSearch: false,
25696 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25697 validOperators: [
25698 OPERATOR_IS_ANY,
25699 OPERATOR_IS_NONE,
25700 OPERATOR_IS_ALL,
25701 OPERATOR_IS_NOT_ALL
25702 ],
25703 format: {},
25704 getValueFormatted: getValueFormatted7,
25705 validate: {
25706 required: isValidRequiredForArray,
25707 elements: isValidElements,
25708 custom: isValidCustom5
25709 }
25710 };
25711
25712 // packages/dataviews/build-module/field-types/password.mjs
25713 function getValueFormatted8({
25714 item,
25715 field
25716 }) {
25717 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25718 }
25719 var password_default = {
25720 type: "password",
25721 render,
25722 Edit: "password",
25723 sort: () => 0,
25724 // Passwords should not be sortable for security reasons
25725 enableSorting: false,
25726 enableGlobalSearch: false,
25727 defaultOperators: [],
25728 validOperators: [],
25729 format: {},
25730 getValueFormatted: getValueFormatted8,
25731 validate: {
25732 required: isValidRequired,
25733 pattern: isValidPattern,
25734 minLength: isValidMinLength,
25735 maxLength: isValidMaxLength,
25736 elements: isValidElements
25737 }
25738 };
25739
25740 // packages/dataviews/build-module/field-types/telephone.mjs
25741 var telephone_default = {
25742 type: "telephone",
25743 render,
25744 Edit: "telephone",
25745 sort: sort_text_default,
25746 enableSorting: true,
25747 enableGlobalSearch: false,
25748 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25749 validOperators: [
25750 OPERATOR_IS,
25751 OPERATOR_IS_NOT,
25752 OPERATOR_CONTAINS,
25753 OPERATOR_NOT_CONTAINS,
25754 OPERATOR_STARTS_WITH,
25755 // Multiple selection
25756 OPERATOR_IS_ANY,
25757 OPERATOR_IS_NONE,
25758 OPERATOR_IS_ALL,
25759 OPERATOR_IS_NOT_ALL
25760 ],
25761 format: {},
25762 getValueFormatted: get_value_formatted_default_default,
25763 validate: {
25764 required: isValidRequired,
25765 pattern: isValidPattern,
25766 minLength: isValidMinLength,
25767 maxLength: isValidMaxLength,
25768 elements: isValidElements
25769 }
25770 };
25771
25772 // packages/dataviews/build-module/field-types/color.mjs
25773 var import_i18n44 = __toESM(require_i18n(), 1);
25774 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
25775 function render3({ item, field }) {
25776 if (field.hasElements) {
25777 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(RenderFromElements, { item, field });
25778 }
25779 const value = get_value_formatted_default_default({ item, field });
25780 if (!value || !w(value).isValid()) {
25781 return value;
25782 }
25783 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25784 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
25785 "div",
25786 {
25787 style: {
25788 width: "16px",
25789 height: "16px",
25790 borderRadius: "50%",
25791 backgroundColor: value,
25792 border: "1px solid #ddd",
25793 flexShrink: 0
25794 }
25795 }
25796 ),
25797 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("span", { children: value })
25798 ] });
25799 }
25800 function isValidCustom6(item, field) {
25801 const value = field.getValue({ item });
25802 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25803 return (0, import_i18n44.__)("Value must be a valid color.");
25804 }
25805 return null;
25806 }
25807 var sort5 = (a2, b2, direction) => {
25808 const colorA = w(a2);
25809 const colorB = w(b2);
25810 if (!colorA.isValid() && !colorB.isValid()) {
25811 return 0;
25812 }
25813 if (!colorA.isValid()) {
25814 return direction === "asc" ? 1 : -1;
25815 }
25816 if (!colorB.isValid()) {
25817 return direction === "asc" ? -1 : 1;
25818 }
25819 const hslA = colorA.toHsl();
25820 const hslB = colorB.toHsl();
25821 if (hslA.h !== hslB.h) {
25822 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25823 }
25824 if (hslA.s !== hslB.s) {
25825 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25826 }
25827 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25828 };
25829 var color_default = {
25830 type: "color",
25831 render: render3,
25832 Edit: "color",
25833 sort: sort5,
25834 enableSorting: true,
25835 enableGlobalSearch: false,
25836 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25837 validOperators: [
25838 OPERATOR_IS,
25839 OPERATOR_IS_NOT,
25840 OPERATOR_IS_ANY,
25841 OPERATOR_IS_NONE
25842 ],
25843 format: {},
25844 getValueFormatted: get_value_formatted_default_default,
25845 validate: {
25846 required: isValidRequired,
25847 elements: isValidElements,
25848 custom: isValidCustom6
25849 }
25850 };
25851
25852 // packages/dataviews/build-module/field-types/url.mjs
25853 var url_default = {
25854 type: "url",
25855 render,
25856 Edit: "url",
25857 sort: sort_text_default,
25858 enableSorting: true,
25859 enableGlobalSearch: false,
25860 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25861 validOperators: [
25862 OPERATOR_IS,
25863 OPERATOR_IS_NOT,
25864 OPERATOR_CONTAINS,
25865 OPERATOR_NOT_CONTAINS,
25866 OPERATOR_STARTS_WITH,
25867 // Multiple selection
25868 OPERATOR_IS_ANY,
25869 OPERATOR_IS_NONE,
25870 OPERATOR_IS_ALL,
25871 OPERATOR_IS_NOT_ALL
25872 ],
25873 format: {},
25874 getValueFormatted: get_value_formatted_default_default,
25875 validate: {
25876 required: isValidRequired,
25877 pattern: isValidPattern,
25878 minLength: isValidMinLength,
25879 maxLength: isValidMaxLength,
25880 elements: isValidElements
25881 }
25882 };
25883
25884 // packages/dataviews/build-module/field-types/no-type.mjs
25885 var sort6 = (a2, b2, direction) => {
25886 if (typeof a2 === "number" && typeof b2 === "number") {
25887 return sort_number_default(a2, b2, direction);
25888 }
25889 return sort_text_default(a2, b2, direction);
25890 };
25891 var no_type_default = {
25892 // type: no type for this one
25893 render,
25894 Edit: null,
25895 sort: sort6,
25896 enableSorting: true,
25897 enableGlobalSearch: false,
25898 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25899 validOperators: getAllOperatorNames(),
25900 format: {},
25901 getValueFormatted: get_value_formatted_default_default,
25902 validate: {
25903 required: isValidRequired,
25904 elements: isValidElements
25905 }
25906 };
25907
25908 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25909 function supportsNumericRangeConstraint(type) {
25910 return type === "integer" || type === "number";
25911 }
25912 function supportsDateRangeConstraint(type) {
25913 return type === "date" || type === "datetime";
25914 }
25915 function normalizeRangeRule(value, fieldType, key) {
25916 const validator = fieldType.validate[key];
25917 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25918 return { constraint: value, validate: validator };
25919 }
25920 return void 0;
25921 }
25922 function getIsValid(field, fieldType) {
25923 const rules = field.isValid;
25924 let required;
25925 if (rules?.required === true && fieldType.validate.required !== void 0) {
25926 required = {
25927 constraint: true,
25928 validate: fieldType.validate.required
25929 };
25930 }
25931 let elements;
25932 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25933 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25934 elements = {
25935 constraint: true,
25936 validate: fieldType.validate.elements
25937 };
25938 }
25939 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25940 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25941 const minLengthValue = rules?.minLength;
25942 let minLength;
25943 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25944 minLength = {
25945 constraint: minLengthValue,
25946 validate: fieldType.validate.minLength
25947 };
25948 }
25949 const maxLengthValue = rules?.maxLength;
25950 let maxLength;
25951 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25952 maxLength = {
25953 constraint: maxLengthValue,
25954 validate: fieldType.validate.maxLength
25955 };
25956 }
25957 const patternValue = rules?.pattern;
25958 let pattern;
25959 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25960 pattern = {
25961 constraint: patternValue,
25962 validate: fieldType.validate.pattern
25963 };
25964 }
25965 const custom = rules?.custom ?? fieldType.validate.custom;
25966 return {
25967 required,
25968 elements,
25969 min: min2,
25970 max: max2,
25971 minLength,
25972 maxLength,
25973 pattern,
25974 custom
25975 };
25976 }
25977
25978 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25979 function getFilter(fieldType) {
25980 return fieldType.validOperators.reduce((accumulator, operator) => {
25981 const operatorObj = getOperatorByName(operator);
25982 if (operatorObj?.filter) {
25983 accumulator[operator] = operatorObj.filter;
25984 }
25985 return accumulator;
25986 }, {});
25987 }
25988
25989 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25990 function getFormat(field, fieldType) {
25991 return {
25992 ...fieldType.format,
25993 ...field.format
25994 };
25995 }
25996 var get_format_default = getFormat;
25997
25998 // packages/dataviews/build-module/field-types/index.mjs
25999 function getFieldTypeByName(type) {
26000 const found = [
26001 email_default,
26002 integer_default,
26003 number_default,
26004 text_default,
26005 datetime_default,
26006 date_default,
26007 boolean_default,
26008 media_default,
26009 array_default,
26010 password_default,
26011 telephone_default,
26012 color_default,
26013 url_default
26014 ].find((fieldType) => fieldType?.type === type);
26015 if (!!found) {
26016 return found;
26017 }
26018 return no_type_default;
26019 }
26020 function normalizeFields(fields) {
26021 return fields.map((field) => {
26022 const fieldType = getFieldTypeByName(field.type);
26023 const getValue = field.getValue || get_value_from_id_default(field.id);
26024 const sort7 = function(a2, b2, direction) {
26025 const aValue = getValue({ item: a2 });
26026 const bValue = getValue({ item: b2 });
26027 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26028 };
26029 return {
26030 id: field.id,
26031 label: field.label || field.id,
26032 header: field.header || field.label || field.id,
26033 description: field.description,
26034 placeholder: field.placeholder,
26035 getValue,
26036 setValue: field.setValue || set_value_from_id_default(field.id),
26037 elements: field.elements,
26038 getElements: field.getElements,
26039 hasElements: hasElements(field),
26040 isVisible: field.isVisible,
26041 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26042 enableHiding: field.enableHiding ?? true,
26043 readOnly: field.readOnly ?? false,
26044 // The type provides defaults for the following props
26045 type: fieldType.type,
26046 render: field.render ?? fieldType.render,
26047 Edit: getControl(field, fieldType.Edit),
26048 sort: sort7,
26049 enableSorting: field.enableSorting ?? fieldType.enableSorting,
26050 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26051 isValid: getIsValid(field, fieldType),
26052 filterBy: get_filter_by_default(
26053 field,
26054 fieldType.defaultOperators,
26055 fieldType.validOperators
26056 ),
26057 filter: getFilter(fieldType),
26058 format: get_format_default(field, fieldType),
26059 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26060 };
26061 });
26062 }
26063
26064 // packages/dataviews/build-module/hooks/use-data.mjs
26065 var import_element80 = __toESM(require_element(), 1);
26066 function useData({
26067 view,
26068 data: shownData,
26069 getItemId,
26070 isLoading,
26071 paginationInfo,
26072 selection
26073 }) {
26074 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26075 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element80.useState)(
26076 !isLoading
26077 );
26078 (0, import_element80.useEffect)(() => {
26079 if (!isLoading) {
26080 setHasInitiallyLoaded(true);
26081 }
26082 }, [isLoading]);
26083 const previousDataRef = (0, import_element80.useRef)(shownData);
26084 const previousPaginationInfoRef = (0, import_element80.useRef)(paginationInfo);
26085 (0, import_element80.useEffect)(() => {
26086 if (!isLoading) {
26087 previousDataRef.current = shownData;
26088 previousPaginationInfoRef.current = paginationInfo;
26089 }
26090 }, [shownData, isLoading, paginationInfo]);
26091 const [visibleEntries, setVisibleEntries] = (0, import_element80.useState)([]);
26092 const positionMapRef = (0, import_element80.useRef)(/* @__PURE__ */ new Map());
26093 const allLoadedRecordsRef = (0, import_element80.useRef)([]);
26094 const prevViewParamsRef = (0, import_element80.useRef)({
26095 search: void 0,
26096 filters: void 0,
26097 perPage: void 0
26098 });
26099 const scrollDirectionRef = (0, import_element80.useRef)(void 0);
26100 const prevStartPositionRef = (0, import_element80.useRef)(void 0);
26101 const hasInitializedRef = (0, import_element80.useRef)(false);
26102 const allLoadedRecords = (0, import_element80.useMemo)(() => {
26103 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26104 if (view.startPosition < prevStartPositionRef.current) {
26105 scrollDirectionRef.current = "up";
26106 } else if (view.startPosition > prevStartPositionRef.current) {
26107 scrollDirectionRef.current = "down";
26108 }
26109 }
26110 prevStartPositionRef.current = view.startPosition;
26111 const currentFiltersKey = JSON.stringify(view.filters ?? []);
26112 const prevFiltersKey = prevViewParamsRef.current.filters;
26113 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26114 hasInitializedRef.current = true;
26115 prevViewParamsRef.current = {
26116 search: view.search,
26117 filters: currentFiltersKey,
26118 perPage: view.perPage
26119 };
26120 if (shouldReset) {
26121 positionMapRef.current.clear();
26122 scrollDirectionRef.current = void 0;
26123 const startPosition = view.search ? 1 : view.startPosition ?? 1;
26124 const records = shownData.map((record, index2) => {
26125 const position = startPosition + index2;
26126 positionMapRef.current.set(getItemId(record), position);
26127 return {
26128 ...record,
26129 position
26130 };
26131 });
26132 allLoadedRecordsRef.current = records;
26133 return records;
26134 }
26135 const prev = allLoadedRecordsRef.current;
26136 const shownDataIds = new Set(shownData.map(getItemId));
26137 const scrollDirection = scrollDirectionRef.current;
26138 const basePosition = view.search ? 1 : view.startPosition ?? 1;
26139 const newRecords = shownData.map((record, index2) => {
26140 const itemId = getItemId(record);
26141 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26142 if (position !== void 0) {
26143 positionMapRef.current.set(itemId, position);
26144 }
26145 return {
26146 ...record,
26147 position
26148 };
26149 });
26150 if (newRecords.length === 0) {
26151 return prev;
26152 }
26153 const prevWithoutDuplicates = prev.filter(
26154 (record) => !shownDataIds.has(getItemId(record))
26155 );
26156 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26157 allRecords.sort((a2, b2) => {
26158 const posA = a2.position;
26159 const posB = b2.position;
26160 return posA - posB;
26161 });
26162 let result = allRecords;
26163 if (visibleEntries.length > 0) {
26164 const visibleMin = Math.min(...visibleEntries);
26165 const visibleMax = Math.max(...visibleEntries);
26166 const buffer = 20;
26167 const recordPositions = allRecords.map(
26168 (r3) => r3.position
26169 );
26170 const minRecordPos = Math.min(...recordPositions);
26171 const maxRecordPos = Math.max(...recordPositions);
26172 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26173 if (hasOverlap) {
26174 result = allRecords.filter((record) => {
26175 const itemId = getItemId(record);
26176 const isSelected2 = selection?.includes(itemId);
26177 if (isSelected2) {
26178 return true;
26179 }
26180 const itemPosition = record.position;
26181 if (scrollDirection === "up") {
26182 return itemPosition <= visibleMax + buffer;
26183 } else if (scrollDirection === "down") {
26184 return itemPosition >= visibleMin - buffer;
26185 }
26186 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26187 });
26188 }
26189 }
26190 allLoadedRecordsRef.current = result;
26191 return result;
26192 }, [
26193 shownData,
26194 view.search,
26195 view.filters,
26196 view.perPage,
26197 view.startPosition,
26198 view.infiniteScrollEnabled,
26199 visibleEntries,
26200 selection,
26201 getItemId
26202 ]);
26203 if (!isInfiniteScrollEnabled) {
26204 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26205 return {
26206 data: dataToReturn.map((item) => ({
26207 ...item,
26208 position: void 0
26209 })),
26210 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26211 hasInitiallyLoaded,
26212 setVisibleEntries: void 0
26213 };
26214 }
26215 return {
26216 data: allLoadedRecords,
26217 paginationInfo,
26218 hasInitiallyLoaded,
26219 setVisibleEntries
26220 };
26221 }
26222
26223 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26224 var import_element81 = __toESM(require_element(), 1);
26225 var import_compose12 = __toESM(require_compose(), 1);
26226 function captureAnchorElement(container, anchorElementRef, direction) {
26227 const containerRect = container.getBoundingClientRect();
26228 const centerY = containerRect.top + containerRect.height / 2;
26229 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26230 if (items.length === 0) {
26231 return false;
26232 }
26233 const bestAnchor = items.reduce((best, item) => {
26234 const itemRect = item.getBoundingClientRect();
26235 const itemCenterY = itemRect.top + itemRect.height / 2;
26236 const distance = Math.abs(itemCenterY - centerY);
26237 const bestRect = best.getBoundingClientRect();
26238 const bestCenterY = bestRect.top + bestRect.height / 2;
26239 const bestDistance = Math.abs(bestCenterY - centerY);
26240 return distance < bestDistance ? item : best;
26241 });
26242 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26243 const anchorRect = bestAnchor.getBoundingClientRect();
26244 anchorElementRef.current = {
26245 posinset,
26246 viewportOffset: anchorRect.top - containerRect.top,
26247 direction
26248 };
26249 return true;
26250 }
26251 function useInfiniteScroll({
26252 view,
26253 onChangeView,
26254 isLoading,
26255 paginationInfo,
26256 containerRef,
26257 setVisibleEntries
26258 }) {
26259 const anchorElementRef = (0, import_element81.useRef)(null);
26260 const viewRef = (0, import_element81.useRef)(view);
26261 const isLoadingRef = (0, import_element81.useRef)(isLoading);
26262 const onChangeViewRef = (0, import_element81.useRef)(onChangeView);
26263 const totalItemsRef = (0, import_element81.useRef)(paginationInfo.totalItems);
26264 (0, import_element81.useLayoutEffect)(() => {
26265 viewRef.current = view;
26266 isLoadingRef.current = isLoading;
26267 onChangeViewRef.current = onChangeView;
26268 totalItemsRef.current = paginationInfo.totalItems;
26269 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26270 const intersectionObserverCallback = (0, import_element81.useCallback)(
26271 (entries) => {
26272 if (!setVisibleEntries) {
26273 return;
26274 }
26275 setVisibleEntries((prev) => {
26276 const newVisibleEntries = new Set(prev);
26277 let hasChanged = false;
26278 entries.forEach((entry) => {
26279 const posInSet = Number(
26280 entry.target?.attributes?.getNamedItem(
26281 "aria-posinset"
26282 )?.value
26283 );
26284 if (isNaN(posInSet)) {
26285 return;
26286 }
26287 if (entry.isIntersecting) {
26288 if (!newVisibleEntries.has(posInSet)) {
26289 newVisibleEntries.add(posInSet);
26290 hasChanged = true;
26291 }
26292 } else if (newVisibleEntries.has(posInSet)) {
26293 newVisibleEntries.delete(posInSet);
26294 hasChanged = true;
26295 }
26296 });
26297 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26298 });
26299 },
26300 [setVisibleEntries]
26301 );
26302 (0, import_element81.useLayoutEffect)(() => {
26303 const container = containerRef.current;
26304 const anchor = anchorElementRef.current;
26305 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26306 return;
26307 }
26308 const anchorElement = container.querySelector(
26309 `[aria-posinset="${anchor.posinset}"]`
26310 );
26311 if (anchorElement) {
26312 const containerRect = container.getBoundingClientRect();
26313 const anchorRect = anchorElement.getBoundingClientRect();
26314 const currentOffset = anchorRect.top - containerRect.top;
26315 const scrollAdjustment = currentOffset - anchor.viewportOffset;
26316 if (Math.abs(scrollAdjustment) > 1) {
26317 container.scrollTop += scrollAdjustment;
26318 }
26319 }
26320 anchorElementRef.current = null;
26321 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26322 const intersectionObserverRef = (0, import_element81.useRef)(
26323 null
26324 );
26325 (0, import_element81.useEffect)(() => {
26326 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26327 if (intersectionObserverRef.current) {
26328 intersectionObserverRef.current.disconnect();
26329 intersectionObserverRef.current = null;
26330 }
26331 return;
26332 }
26333 intersectionObserverRef.current = new IntersectionObserver(
26334 intersectionObserverCallback,
26335 { root: null, rootMargin: "0px", threshold: 0.1 }
26336 );
26337 return () => {
26338 if (intersectionObserverRef.current) {
26339 intersectionObserverRef.current.disconnect();
26340 intersectionObserverRef.current = null;
26341 }
26342 };
26343 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26344 (0, import_element81.useEffect)(() => {
26345 if (!view.infiniteScrollEnabled || !containerRef.current) {
26346 return;
26347 }
26348 let lastScrollTop = 0;
26349 const BOTTOM_THRESHOLD = 600;
26350 const TOP_THRESHOLD = 800;
26351 const handleScroll = (0, import_compose12.throttle)((event) => {
26352 const currentView = viewRef.current;
26353 const totalItems = totalItemsRef.current;
26354 const target = event.target;
26355 const scrollTop = target.scrollTop;
26356 const scrollHeight = target.scrollHeight;
26357 const clientHeight = target.clientHeight;
26358 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26359 lastScrollTop = scrollTop;
26360 if (isLoadingRef.current) {
26361 return;
26362 }
26363 const currentStartPosition = currentView.startPosition || 1;
26364 const batchSize = currentView.perPage || 10;
26365 const currentEndPosition = Math.min(
26366 currentStartPosition + batchSize,
26367 totalItems
26368 );
26369 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26370 if (currentEndPosition < totalItems) {
26371 const newStartPosition = currentEndPosition;
26372 captureAnchorElement(target, anchorElementRef, "down");
26373 onChangeViewRef.current({
26374 ...currentView,
26375 startPosition: newStartPosition
26376 });
26377 }
26378 }
26379 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26380 if (currentStartPosition > 1) {
26381 const calculatedStartPosition = currentStartPosition - batchSize;
26382 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26383 captureAnchorElement(target, anchorElementRef, "up");
26384 onChangeViewRef.current({
26385 ...currentView,
26386 startPosition: newStartPosition
26387 });
26388 }
26389 }
26390 }, 50);
26391 const container = containerRef.current;
26392 container.addEventListener("scroll", handleScroll);
26393 return () => {
26394 container.removeEventListener("scroll", handleScroll);
26395 handleScroll.cancel();
26396 };
26397 }, [containerRef, view.infiniteScrollEnabled]);
26398 return {
26399 intersectionObserver: intersectionObserverRef.current
26400 };
26401 }
26402
26403 // packages/dataviews/build-module/dataviews/index.mjs
26404 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
26405 var defaultGetItemId = (item) => item.id;
26406 var defaultIsItemClickable = () => true;
26407 var EMPTY_ARRAY6 = [];
26408 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
26409 var dataViewsLayouts = VIEW_LAYOUTS.filter(
26410 (viewLayout) => !viewLayout.isPicker
26411 );
26412 function DefaultUI({
26413 header,
26414 search = true,
26415 searchLabel = void 0
26416 }) {
26417 const { view } = (0, import_element82.useContext)(dataviews_context_default);
26418 const isInfiniteScroll = view.infiniteScrollEnabled;
26419 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_jsx_runtime118.Fragment, { children: [
26420 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
26421 Stack,
26422 {
26423 direction: "row",
26424 align: "top",
26425 justify: "space-between",
26426 className: clsx_default("dataviews__view-actions", {
26427 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26428 }),
26429 gap: "xs",
26430 children: [
26431 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
26432 Stack,
26433 {
26434 direction: "row",
26435 justify: "start",
26436 gap: "sm",
26437 className: "dataviews__search",
26438 children: [
26439 search && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_search_default, { label: searchLabel }),
26440 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(toggle_default, {})
26441 ]
26442 }
26443 ),
26444 /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26445 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_view_config_default, {}),
26446 header
26447 ] })
26448 ]
26449 }
26450 ),
26451 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26452 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DataViewsLayout, {}),
26453 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DataViewsFooter, {})
26454 ] });
26455 }
26456 function DataViews({
26457 view,
26458 onChangeView,
26459 fields,
26460 search = true,
26461 searchLabel = void 0,
26462 actions = EMPTY_ARRAY6,
26463 data,
26464 getItemId = defaultGetItemId,
26465 getItemLevel,
26466 isLoading = false,
26467 paginationInfo,
26468 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26469 selection: selectionProperty,
26470 onChangeSelection,
26471 onClickItem,
26472 renderItemLink,
26473 isItemClickable = defaultIsItemClickable,
26474 header,
26475 children,
26476 config = { perPageSizes: [10, 20, 50, 100] },
26477 empty,
26478 onReset
26479 }) {
26480 const [selectionState, setSelectionState] = (0, import_element82.useState)([]);
26481 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26482 const selection = isUncontrolled ? selectionState : selectionProperty;
26483 const {
26484 data: displayData,
26485 paginationInfo: displayPaginationInfo,
26486 hasInitiallyLoaded,
26487 setVisibleEntries
26488 } = useData({
26489 view,
26490 data,
26491 getItemId,
26492 isLoading,
26493 selection,
26494 paginationInfo
26495 });
26496 const containerRef = (0, import_element82.useRef)(null);
26497 const [containerWidth, setContainerWidth] = (0, import_element82.useState)(0);
26498 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
26499 (resizeObserverEntries) => {
26500 setContainerWidth(
26501 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26502 );
26503 },
26504 { box: "border-box" }
26505 );
26506 const [openedFilter, setOpenedFilter] = (0, import_element82.useState)(null);
26507 function setSelectionWithChange(value) {
26508 const newValue = typeof value === "function" ? value(selection) : value;
26509 if (isUncontrolled) {
26510 setSelectionState(newValue);
26511 }
26512 if (onChangeSelection) {
26513 onChangeSelection(newValue);
26514 }
26515 }
26516 const _fields = (0, import_element82.useMemo)(() => normalizeFields(fields), [fields]);
26517 const _selection = (0, import_element82.useMemo)(() => {
26518 if (view.infiniteScrollEnabled) {
26519 return selection;
26520 }
26521 return selection.filter(
26522 (id) => data.some((item) => getItemId(item) === id)
26523 );
26524 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26525 const filters = use_filters_default(_fields, view);
26526 const hasPrimaryOrLockedFilters = (0, import_element82.useMemo)(
26527 () => (filters || []).some(
26528 (filter) => filter.isPrimary || filter.isLocked
26529 ),
26530 [filters]
26531 );
26532 const [isShowingFilter, setIsShowingFilter] = (0, import_element82.useState)(
26533 hasPrimaryOrLockedFilters
26534 );
26535 const { intersectionObserver } = useInfiniteScroll({
26536 view,
26537 onChangeView,
26538 isLoading,
26539 paginationInfo,
26540 containerRef,
26541 setVisibleEntries
26542 });
26543 (0, import_element82.useEffect)(() => {
26544 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26545 setIsShowingFilter(true);
26546 }
26547 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26548 const defaultLayouts = (0, import_element82.useMemo)(
26549 () => Object.fromEntries(
26550 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26551 return dataViewsLayouts.some(
26552 (viewLayout) => viewLayout.type === layoutType
26553 );
26554 }).map(([key, value]) => [
26555 key,
26556 value === true ? {} : value
26557 ])
26558 ),
26559 [defaultLayoutsProperty]
26560 );
26561 if (!defaultLayouts[view.type]) {
26562 return null;
26563 }
26564 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26565 dataviews_context_default.Provider,
26566 {
26567 value: {
26568 view,
26569 onChangeView,
26570 fields: _fields,
26571 actions,
26572 data: displayData,
26573 isLoading,
26574 paginationInfo: displayPaginationInfo,
26575 selection: _selection,
26576 onChangeSelection: setSelectionWithChange,
26577 openedFilter,
26578 setOpenedFilter,
26579 getItemId,
26580 getItemLevel,
26581 isItemClickable,
26582 onClickItem,
26583 renderItemLink,
26584 containerWidth,
26585 containerRef,
26586 resizeObserverRef,
26587 defaultLayouts,
26588 filters,
26589 isShowingFilter,
26590 setIsShowingFilter,
26591 config,
26592 empty,
26593 hasInitiallyLoaded,
26594 onReset,
26595 intersectionObserver
26596 },
26597 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
26598 DefaultUI,
26599 {
26600 header,
26601 search,
26602 searchLabel
26603 }
26604 ) })
26605 }
26606 );
26607 }
26608 var DataViewsSubComponents = DataViews;
26609 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26610 DataViewsSubComponents.Filters = filters_default;
26611 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26612 DataViewsSubComponents.FiltersToggle = toggle_default;
26613 DataViewsSubComponents.Layout = DataViewsLayout;
26614 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26615 DataViewsSubComponents.Pagination = DataViewsPagination;
26616 DataViewsSubComponents.Search = dataviews_search_default;
26617 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26618 DataViewsSubComponents.Footer = DataViewsFooter;
26619 var dataviews_default = DataViewsSubComponents;
26620
26621 // widgets/news/components/news-list/news-list.tsx
26622 var import_date10 = __toESM(require_date());
26623 var import_element83 = __toESM(require_element());
26624 var import_html_entities = __toESM(require_html_entities());
26625 var import_i18n45 = __toESM(require_i18n());
26626
26627 // packages/style-runtime/src/index.ts
26628 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26629 function getRuntime14() {
26630 const globalScope = globalThis;
26631 if (globalScope.__wpStyleRuntime) {
26632 return globalScope.__wpStyleRuntime;
26633 }
26634 globalScope.__wpStyleRuntime = {
26635 documents: /* @__PURE__ */ new Map(),
26636 styles: /* @__PURE__ */ new Map(),
26637 injectedStyles: /* @__PURE__ */ new WeakMap()
26638 };
26639 if (typeof document !== "undefined") {
26640 registerDocument14(document);
26641 }
26642 return globalScope.__wpStyleRuntime;
26643 }
26644 function documentContainsStyleHash14(targetDocument, hash) {
26645 if (!targetDocument.head) {
26646 return false;
26647 }
26648 for (const style of targetDocument.head.querySelectorAll(
26649 `style[${STYLE_HASH_ATTRIBUTE14}]`
26650 )) {
26651 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26652 return true;
26653 }
26654 }
26655 return false;
26656 }
26657 function injectStyle14(targetDocument, hash, css) {
26658 if (!targetDocument.head) {
26659 return;
26660 }
26661 const runtime = getRuntime14();
26662 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26663 if (!injectedStyles) {
26664 injectedStyles = /* @__PURE__ */ new Set();
26665 runtime.injectedStyles.set(targetDocument, injectedStyles);
26666 }
26667 if (injectedStyles.has(hash)) {
26668 return;
26669 }
26670 if (documentContainsStyleHash14(targetDocument, hash)) {
26671 injectedStyles.add(hash);
26672 return;
26673 }
26674 const style = targetDocument.createElement("style");
26675 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26676 style.appendChild(targetDocument.createTextNode(css));
26677 targetDocument.head.appendChild(style);
26678 injectedStyles.add(hash);
26679 }
26680 function registerDocument14(targetDocument) {
26681 const runtime = getRuntime14();
26682 runtime.documents.set(
26683 targetDocument,
26684 (runtime.documents.get(targetDocument) ?? 0) + 1
26685 );
26686 for (const [hash, css] of runtime.styles) {
26687 injectStyle14(targetDocument, hash, css);
26688 }
26689 return () => {
26690 const count = runtime.documents.get(targetDocument);
26691 if (count === void 0) {
26692 return;
26693 }
26694 if (count <= 1) {
26695 runtime.documents.delete(targetDocument);
26696 return;
26697 }
26698 runtime.documents.set(targetDocument, count - 1);
26699 };
26700 }
26701 function registerStyle14(hash, css) {
26702 const runtime = getRuntime14();
26703 runtime.styles.set(hash, css);
26704 for (const targetDocument of runtime.documents.keys()) {
26705 injectStyle14(targetDocument, hash, css);
26706 }
26707 }
26708
26709 // widgets/news/components/news-list/news-list.module.css
26710 if (typeof process === "undefined" || true) {
26711 registerStyle14("78d188327d", ".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,#f0f0f0);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)}");
26712 }
26713 var news_list_default = { "root": "bdaa5dfae93273b5__root", "feedIcon": "_2861fc2db3e2384a__feedIcon", "titleLink": "_0b17b846e53f552a__titleLink", "meta": "_33e124d0c35f629a__meta" };
26714
26715 // widgets/news/components/news-list/news-list.tsx
26716 var import_jsx_runtime119 = __toESM(require_jsx_runtime());
26717 var NEWS_FEEDS = [
26718 {
26719 key: "news",
26720 label: (0, import_i18n45.__)("WordPress Blog"),
26721 siteUrl: (0, import_i18n45._x)("https://wordpress.org/news/", "News dashboard widget"),
26722 apiUrl: "https://wordpress.org/news/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26723 },
26724 {
26725 key: "planet",
26726 label: (0, import_i18n45.__)("Other WordPress News"),
26727 siteUrl: (0, import_i18n45._x)("https://planet.wordpress.org/", "News dashboard widget"),
26728 apiUrl: "https://planet.wordpress.org/wp-json/wp/v2/posts?per_page=4&_fields=id,title,link,date"
26729 }
26730 ];
26731 var DEFAULT_LAYOUTS2 = { list: {} };
26732 var INITIAL_VIEW = {
26733 type: "list",
26734 page: 1,
26735 perPage: 4,
26736 search: "",
26737 filters: [],
26738 fields: [],
26739 titleField: "title",
26740 descriptionField: "meta",
26741 mediaField: "feedIcon",
26742 showMedia: true,
26743 layout: { density: "compact" }
26744 };
26745 function FeedIcon({ item }) {
26746 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: news_list_default.feedIcon, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(Icon, { icon: item.feedKey === "news" ? wordpress_default : globe_default }) });
26747 }
26748 function NewsTitle({ item }) {
26749 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(Link, { href: item.url, openInNewTab: true, className: news_list_default.titleLink, children: item.title });
26750 }
26751 function NewsMeta({ item }) {
26752 return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(Text, { variant: "body-sm", className: news_list_default.meta, children: [
26753 item.feedLabel,
26754 " \xB7 ",
26755 (0, import_date10.dateI18n)((0, import_i18n45.__)("M j, Y g:i a"), item.date)
26756 ] });
26757 }
26758 var emptyState = /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(Stack, { align: "center", justify: "center", style: { margin: "24px 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(empty_state_exports.Root, { children: [
26759 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
26760 /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(empty_state_exports.Title, { children: (0, import_i18n45.__)("Quiet for now \u2014 the next headline is on its way.") })
26761 ] }) });
26762 function combineFeedPosts(newsFeeds) {
26763 return newsFeeds.flatMap(
26764 (feed) => feed.posts.map((post) => ({
26765 id: `${feed.key}-${post.id}`,
26766 feedKey: feed.key,
26767 feedLabel: feed.label,
26768 title: (0, import_html_entities.decodeEntities)(post.title.rendered),
26769 url: post.link,
26770 date: post.date
26771 }))
26772 ).sort(
26773 (a2, b2) => new Date(b2.date).getTime() - new Date(a2.date).getTime()
26774 );
26775 }
26776 function NewsList() {
26777 const [view, setView] = (0, import_element83.useState)(INITIAL_VIEW);
26778 const [newsFeeds, setNewsFeeds] = (0, import_element83.useState)([]);
26779 const [isLoading, setIsLoading] = (0, import_element83.useState)(true);
26780 (0, import_element83.useEffect)(() => {
26781 Promise.all(
26782 NEWS_FEEDS.map(async (feed) => {
26783 try {
26784 const posts = await fetch(feed.apiUrl).then(
26785 (r3) => r3.json()
26786 );
26787 return {
26788 key: feed.key,
26789 label: feed.label,
26790 siteUrl: feed.siteUrl,
26791 posts
26792 };
26793 } catch {
26794 return {
26795 key: feed.key,
26796 label: feed.label,
26797 siteUrl: feed.siteUrl,
26798 posts: []
26799 };
26800 }
26801 })
26802 ).then(setNewsFeeds).finally(() => setIsLoading(false));
26803 }, []);
26804 const items = (0, import_element83.useMemo)(() => combineFeedPosts(newsFeeds), [newsFeeds]);
26805 const fields = (0, import_element83.useMemo)(
26806 () => [
26807 {
26808 id: "title",
26809 label: (0, import_i18n45.__)("Title"),
26810 enableSorting: false,
26811 enableHiding: false,
26812 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(NewsTitle, { item })
26813 },
26814 {
26815 id: "meta",
26816 label: (0, import_i18n45.__)("Source"),
26817 enableSorting: false,
26818 enableHiding: false,
26819 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(NewsMeta, { item })
26820 },
26821 {
26822 id: "feedIcon",
26823 label: (0, import_i18n45.__)("Source"),
26824 enableSorting: false,
26825 enableHiding: false,
26826 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(FeedIcon, { item })
26827 }
26828 ],
26829 []
26830 );
26831 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("div", { className: news_list_default.root, children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
26832 dataviews_default,
26833 {
26834 data: items,
26835 fields,
26836 view,
26837 onChangeView: setView,
26838 getItemId: (item) => item.id,
26839 isLoading,
26840 paginationInfo: {
26841 totalItems: items.length,
26842 totalPages: 1
26843 },
26844 defaultLayouts: DEFAULT_LAYOUTS2,
26845 empty: emptyState,
26846 children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(dataviews_default.Layout, {})
26847 }
26848 ) });
26849 }
26850
26851 // widgets/news/render.module.css
26852 if (typeof process === "undefined" || true) {
26853 registerStyle14("316bb0f754", "._2ab2c8be44ad767d__footer{border-block-start:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);padding-block:var(--wpds-dimension-padding-lg,16px);padding-inline:var(--wpds-dimension-padding-2xl,24px)}");
26854 }
26855 var render_default = { "footer": "_2ab2c8be44ad767d__footer" };
26856
26857 // widgets/news/render.tsx
26858 var import_jsx_runtime120 = __toESM(require_jsx_runtime());
26859 function WordPressNews() {
26860 return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_jsx_runtime120.Fragment, { children: [
26861 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(NewsList, {}),
26862 /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("div", { className: render_default.footer, children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
26863 Link,
26864 {
26865 href: (0, import_i18n46._x)(
26866 "https://wordpress.org/news/all-posts/",
26867 "News dashboard widget"
26868 ),
26869 openInNewTab: true,
26870 children: (0, import_i18n46.__)("See all")
26871 }
26872 ) })
26873 ] });
26874 }
26875 export {
26876 WordPressNews as default
26877 };
26878 /*! Bundled license information:
26879
26880 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26881 (**
26882 * @license React
26883 * use-sync-external-store-shim.development.js
26884 *
26885 * Copyright (c) Meta Platforms, Inc. and affiliates.
26886 *
26887 * This source code is licensed under the MIT license found in the
26888 * LICENSE file in the root directory of this source tree.
26889 *)
26890
26891 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26892 (**
26893 * @license React
26894 * use-sync-external-store-shim/with-selector.development.js
26895 *
26896 * Copyright (c) Meta Platforms, Inc. and affiliates.
26897 *
26898 * This source code is licensed under the MIT license found in the
26899 * LICENSE file in the root directory of this source tree.
26900 *)
26901 */
26902