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 / activity / render.js

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

27,113 lines 933.9 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/element
32 var require_element = __commonJS({
33 "package-external:@wordpress/element"(exports, module) {
34 module.exports = window.wp.element;
35 }
36 });
37
38 // package-external:@wordpress/data
39 var require_data = __commonJS({
40 "package-external:@wordpress/data"(exports, module) {
41 module.exports = window.wp.data;
42 }
43 });
44
45 // package-external:@wordpress/core-data
46 var require_core_data = __commonJS({
47 "package-external:@wordpress/core-data"(exports, module) {
48 module.exports = window.wp.coreData;
49 }
50 });
51
52 // package-external:@wordpress/i18n
53 var require_i18n = __commonJS({
54 "package-external:@wordpress/i18n"(exports, module) {
55 module.exports = window.wp.i18n;
56 }
57 });
58
59 // package-external:@wordpress/date
60 var require_date = __commonJS({
61 "package-external:@wordpress/date"(exports, module) {
62 module.exports = window.wp.date;
63 }
64 });
65
66 // package-external:@wordpress/html-entities
67 var require_html_entities = __commonJS({
68 "package-external:@wordpress/html-entities"(exports, module) {
69 module.exports = window.wp.htmlEntities;
70 }
71 });
72
73 // package-external:@wordpress/components
74 var require_components = __commonJS({
75 "package-external:@wordpress/components"(exports, module) {
76 module.exports = window.wp.components;
77 }
78 });
79
80 // package-external:@wordpress/primitives
81 var require_primitives = __commonJS({
82 "package-external:@wordpress/primitives"(exports, module) {
83 module.exports = window.wp.primitives;
84 }
85 });
86
87 // vendor-external:react/jsx-runtime
88 var require_jsx_runtime = __commonJS({
89 "vendor-external:react/jsx-runtime"(exports, module) {
90 module.exports = window.ReactJSXRuntime;
91 }
92 });
93
94 // package-external:@wordpress/compose
95 var require_compose = __commonJS({
96 "package-external:@wordpress/compose"(exports, module) {
97 module.exports = window.wp.compose;
98 }
99 });
100
101 // vendor-external:react
102 var require_react = __commonJS({
103 "vendor-external:react"(exports, module) {
104 module.exports = window.React;
105 }
106 });
107
108 // vendor-external:react-dom
109 var require_react_dom = __commonJS({
110 "vendor-external:react-dom"(exports, module) {
111 module.exports = window.ReactDOM;
112 }
113 });
114
115 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
116 var require_use_sync_external_store_shim_development = __commonJS({
117 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
118 "use strict";
119 (function() {
120 function is(x2, y2) {
121 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
122 }
123 function useSyncExternalStore$2(subscribe2, getSnapshot) {
124 didWarnOld18Alpha || void 0 === React50.startTransition || (didWarnOld18Alpha = true, console.error(
125 "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."
126 ));
127 var value = getSnapshot();
128 if (!didWarnUncachedGetSnapshot) {
129 var cachedValue = getSnapshot();
130 objectIs(value, cachedValue) || (console.error(
131 "The result of getSnapshot should be cached to avoid an infinite loop"
132 ), didWarnUncachedGetSnapshot = true);
133 }
134 cachedValue = useState36({
135 inst: { value, getSnapshot }
136 });
137 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
138 useLayoutEffect5(
139 function() {
140 inst.value = value;
141 inst.getSnapshot = getSnapshot;
142 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
143 },
144 [subscribe2, value, getSnapshot]
145 );
146 useEffect31(
147 function() {
148 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
149 return subscribe2(function() {
150 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
151 });
152 },
153 [subscribe2]
154 );
155 useDebugValue2(value);
156 return value;
157 }
158 function checkIfSnapshotChanged(inst) {
159 var latestGetSnapshot = inst.getSnapshot;
160 inst = inst.value;
161 try {
162 var nextValue = latestGetSnapshot();
163 return !objectIs(inst, nextValue);
164 } catch (error) {
165 return true;
166 }
167 }
168 function useSyncExternalStore$1(subscribe2, getSnapshot) {
169 return getSnapshot();
170 }
171 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
172 var React50 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React50.useState, useEffect31 = 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;
173 exports.useSyncExternalStore = void 0 !== React50.useSyncExternalStore ? React50.useSyncExternalStore : shim;
174 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
175 })();
176 }
177 });
178
179 // node_modules/use-sync-external-store/shim/index.js
180 var require_shim = __commonJS({
181 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
182 "use strict";
183 if (false) {
184 module.exports = null;
185 } else {
186 module.exports = require_use_sync_external_store_shim_development();
187 }
188 }
189 });
190
191 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
192 var require_with_selector_development = __commonJS({
193 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
194 "use strict";
195 (function() {
196 function is(x2, y2) {
197 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
198 }
199 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
200 var React50 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef46 = React50.useRef, useEffect31 = React50.useEffect, useMemo40 = React50.useMemo, useDebugValue2 = React50.useDebugValue;
201 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
202 var instRef = useRef46(null);
203 if (null === instRef.current) {
204 var inst = { hasValue: false, value: null };
205 instRef.current = inst;
206 } else inst = instRef.current;
207 instRef = useMemo40(
208 function() {
209 function memoizedSelector(nextSnapshot) {
210 if (!hasMemo) {
211 hasMemo = true;
212 memoizedSnapshot = nextSnapshot;
213 nextSnapshot = selector2(nextSnapshot);
214 if (void 0 !== isEqual && inst.hasValue) {
215 var currentSelection = inst.value;
216 if (isEqual(currentSelection, nextSnapshot))
217 return memoizedSelection = currentSelection;
218 }
219 return memoizedSelection = nextSnapshot;
220 }
221 currentSelection = memoizedSelection;
222 if (objectIs(memoizedSnapshot, nextSnapshot))
223 return currentSelection;
224 var nextSelection = selector2(nextSnapshot);
225 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
226 return memoizedSnapshot = nextSnapshot, currentSelection;
227 memoizedSnapshot = nextSnapshot;
228 return memoizedSelection = nextSelection;
229 }
230 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
231 return [
232 function() {
233 return memoizedSelector(getSnapshot());
234 },
235 null === maybeGetServerSnapshot ? void 0 : function() {
236 return memoizedSelector(maybeGetServerSnapshot());
237 }
238 ];
239 },
240 [getSnapshot, getServerSnapshot, selector2, isEqual]
241 );
242 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
243 useEffect31(
244 function() {
245 inst.hasValue = true;
246 inst.value = value;
247 },
248 [value]
249 );
250 useDebugValue2(value);
251 return value;
252 };
253 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
254 })();
255 }
256 });
257
258 // node_modules/use-sync-external-store/shim/with-selector.js
259 var require_with_selector = __commonJS({
260 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
261 "use strict";
262 if (false) {
263 module.exports = null;
264 } else {
265 module.exports = require_with_selector_development();
266 }
267 }
268 });
269
270 // package-external:@wordpress/theme
271 var require_theme = __commonJS({
272 "package-external:@wordpress/theme"(exports, module) {
273 module.exports = window.wp.theme;
274 }
275 });
276
277 // package-external:@wordpress/private-apis
278 var require_private_apis = __commonJS({
279 "package-external:@wordpress/private-apis"(exports, module) {
280 module.exports = window.wp.privateApis;
281 }
282 });
283
284 // package-external:@wordpress/keycodes
285 var require_keycodes = __commonJS({
286 "package-external:@wordpress/keycodes"(exports, module) {
287 module.exports = window.wp.keycodes;
288 }
289 });
290
291 // node_modules/remove-accents/index.js
292 var require_remove_accents = __commonJS({
293 "node_modules/remove-accents/index.js"(exports, module) {
294 var characterMap = {
295 "\xC0": "A",
296 "\xC1": "A",
297 "\xC2": "A",
298 "\xC3": "A",
299 "\xC4": "A",
300 "\xC5": "A",
301 "\u1EA4": "A",
302 "\u1EAE": "A",
303 "\u1EB2": "A",
304 "\u1EB4": "A",
305 "\u1EB6": "A",
306 "\xC6": "AE",
307 "\u1EA6": "A",
308 "\u1EB0": "A",
309 "\u0202": "A",
310 "\u1EA2": "A",
311 "\u1EA0": "A",
312 "\u1EA8": "A",
313 "\u1EAA": "A",
314 "\u1EAC": "A",
315 "\xC7": "C",
316 "\u1E08": "C",
317 "\xC8": "E",
318 "\xC9": "E",
319 "\xCA": "E",
320 "\xCB": "E",
321 "\u1EBE": "E",
322 "\u1E16": "E",
323 "\u1EC0": "E",
324 "\u1E14": "E",
325 "\u1E1C": "E",
326 "\u0206": "E",
327 "\u1EBA": "E",
328 "\u1EBC": "E",
329 "\u1EB8": "E",
330 "\u1EC2": "E",
331 "\u1EC4": "E",
332 "\u1EC6": "E",
333 "\xCC": "I",
334 "\xCD": "I",
335 "\xCE": "I",
336 "\xCF": "I",
337 "\u1E2E": "I",
338 "\u020A": "I",
339 "\u1EC8": "I",
340 "\u1ECA": "I",
341 "\xD0": "D",
342 "\xD1": "N",
343 "\xD2": "O",
344 "\xD3": "O",
345 "\xD4": "O",
346 "\xD5": "O",
347 "\xD6": "O",
348 "\xD8": "O",
349 "\u1ED0": "O",
350 "\u1E4C": "O",
351 "\u1E52": "O",
352 "\u020E": "O",
353 "\u1ECE": "O",
354 "\u1ECC": "O",
355 "\u1ED4": "O",
356 "\u1ED6": "O",
357 "\u1ED8": "O",
358 "\u1EDC": "O",
359 "\u1EDE": "O",
360 "\u1EE0": "O",
361 "\u1EDA": "O",
362 "\u1EE2": "O",
363 "\xD9": "U",
364 "\xDA": "U",
365 "\xDB": "U",
366 "\xDC": "U",
367 "\u1EE6": "U",
368 "\u1EE4": "U",
369 "\u1EEC": "U",
370 "\u1EEE": "U",
371 "\u1EF0": "U",
372 "\xDD": "Y",
373 "\xE0": "a",
374 "\xE1": "a",
375 "\xE2": "a",
376 "\xE3": "a",
377 "\xE4": "a",
378 "\xE5": "a",
379 "\u1EA5": "a",
380 "\u1EAF": "a",
381 "\u1EB3": "a",
382 "\u1EB5": "a",
383 "\u1EB7": "a",
384 "\xE6": "ae",
385 "\u1EA7": "a",
386 "\u1EB1": "a",
387 "\u0203": "a",
388 "\u1EA3": "a",
389 "\u1EA1": "a",
390 "\u1EA9": "a",
391 "\u1EAB": "a",
392 "\u1EAD": "a",
393 "\xE7": "c",
394 "\u1E09": "c",
395 "\xE8": "e",
396 "\xE9": "e",
397 "\xEA": "e",
398 "\xEB": "e",
399 "\u1EBF": "e",
400 "\u1E17": "e",
401 "\u1EC1": "e",
402 "\u1E15": "e",
403 "\u1E1D": "e",
404 "\u0207": "e",
405 "\u1EBB": "e",
406 "\u1EBD": "e",
407 "\u1EB9": "e",
408 "\u1EC3": "e",
409 "\u1EC5": "e",
410 "\u1EC7": "e",
411 "\xEC": "i",
412 "\xED": "i",
413 "\xEE": "i",
414 "\xEF": "i",
415 "\u1E2F": "i",
416 "\u020B": "i",
417 "\u1EC9": "i",
418 "\u1ECB": "i",
419 "\xF0": "d",
420 "\xF1": "n",
421 "\xF2": "o",
422 "\xF3": "o",
423 "\xF4": "o",
424 "\xF5": "o",
425 "\xF6": "o",
426 "\xF8": "o",
427 "\u1ED1": "o",
428 "\u1E4D": "o",
429 "\u1E53": "o",
430 "\u020F": "o",
431 "\u1ECF": "o",
432 "\u1ECD": "o",
433 "\u1ED5": "o",
434 "\u1ED7": "o",
435 "\u1ED9": "o",
436 "\u1EDD": "o",
437 "\u1EDF": "o",
438 "\u1EE1": "o",
439 "\u1EDB": "o",
440 "\u1EE3": "o",
441 "\xF9": "u",
442 "\xFA": "u",
443 "\xFB": "u",
444 "\xFC": "u",
445 "\u1EE7": "u",
446 "\u1EE5": "u",
447 "\u1EED": "u",
448 "\u1EEF": "u",
449 "\u1EF1": "u",
450 "\xFD": "y",
451 "\xFF": "y",
452 "\u0100": "A",
453 "\u0101": "a",
454 "\u0102": "A",
455 "\u0103": "a",
456 "\u0104": "A",
457 "\u0105": "a",
458 "\u0106": "C",
459 "\u0107": "c",
460 "\u0108": "C",
461 "\u0109": "c",
462 "\u010A": "C",
463 "\u010B": "c",
464 "\u010C": "C",
465 "\u010D": "c",
466 "C\u0306": "C",
467 "c\u0306": "c",
468 "\u010E": "D",
469 "\u010F": "d",
470 "\u0110": "D",
471 "\u0111": "d",
472 "\u0112": "E",
473 "\u0113": "e",
474 "\u0114": "E",
475 "\u0115": "e",
476 "\u0116": "E",
477 "\u0117": "e",
478 "\u0118": "E",
479 "\u0119": "e",
480 "\u011A": "E",
481 "\u011B": "e",
482 "\u011C": "G",
483 "\u01F4": "G",
484 "\u011D": "g",
485 "\u01F5": "g",
486 "\u011E": "G",
487 "\u011F": "g",
488 "\u0120": "G",
489 "\u0121": "g",
490 "\u0122": "G",
491 "\u0123": "g",
492 "\u0124": "H",
493 "\u0125": "h",
494 "\u0126": "H",
495 "\u0127": "h",
496 "\u1E2A": "H",
497 "\u1E2B": "h",
498 "\u0128": "I",
499 "\u0129": "i",
500 "\u012A": "I",
501 "\u012B": "i",
502 "\u012C": "I",
503 "\u012D": "i",
504 "\u012E": "I",
505 "\u012F": "i",
506 "\u0130": "I",
507 "\u0131": "i",
508 "\u0132": "IJ",
509 "\u0133": "ij",
510 "\u0134": "J",
511 "\u0135": "j",
512 "\u0136": "K",
513 "\u0137": "k",
514 "\u1E30": "K",
515 "\u1E31": "k",
516 "K\u0306": "K",
517 "k\u0306": "k",
518 "\u0139": "L",
519 "\u013A": "l",
520 "\u013B": "L",
521 "\u013C": "l",
522 "\u013D": "L",
523 "\u013E": "l",
524 "\u013F": "L",
525 "\u0140": "l",
526 "\u0141": "l",
527 "\u0142": "l",
528 "\u1E3E": "M",
529 "\u1E3F": "m",
530 "M\u0306": "M",
531 "m\u0306": "m",
532 "\u0143": "N",
533 "\u0144": "n",
534 "\u0145": "N",
535 "\u0146": "n",
536 "\u0147": "N",
537 "\u0148": "n",
538 "\u0149": "n",
539 "N\u0306": "N",
540 "n\u0306": "n",
541 "\u014C": "O",
542 "\u014D": "o",
543 "\u014E": "O",
544 "\u014F": "o",
545 "\u0150": "O",
546 "\u0151": "o",
547 "\u0152": "OE",
548 "\u0153": "oe",
549 "P\u0306": "P",
550 "p\u0306": "p",
551 "\u0154": "R",
552 "\u0155": "r",
553 "\u0156": "R",
554 "\u0157": "r",
555 "\u0158": "R",
556 "\u0159": "r",
557 "R\u0306": "R",
558 "r\u0306": "r",
559 "\u0212": "R",
560 "\u0213": "r",
561 "\u015A": "S",
562 "\u015B": "s",
563 "\u015C": "S",
564 "\u015D": "s",
565 "\u015E": "S",
566 "\u0218": "S",
567 "\u0219": "s",
568 "\u015F": "s",
569 "\u0160": "S",
570 "\u0161": "s",
571 "\u0162": "T",
572 "\u0163": "t",
573 "\u021B": "t",
574 "\u021A": "T",
575 "\u0164": "T",
576 "\u0165": "t",
577 "\u0166": "T",
578 "\u0167": "t",
579 "T\u0306": "T",
580 "t\u0306": "t",
581 "\u0168": "U",
582 "\u0169": "u",
583 "\u016A": "U",
584 "\u016B": "u",
585 "\u016C": "U",
586 "\u016D": "u",
587 "\u016E": "U",
588 "\u016F": "u",
589 "\u0170": "U",
590 "\u0171": "u",
591 "\u0172": "U",
592 "\u0173": "u",
593 "\u0216": "U",
594 "\u0217": "u",
595 "V\u0306": "V",
596 "v\u0306": "v",
597 "\u0174": "W",
598 "\u0175": "w",
599 "\u1E82": "W",
600 "\u1E83": "w",
601 "X\u0306": "X",
602 "x\u0306": "x",
603 "\u0176": "Y",
604 "\u0177": "y",
605 "\u0178": "Y",
606 "Y\u0306": "Y",
607 "y\u0306": "y",
608 "\u0179": "Z",
609 "\u017A": "z",
610 "\u017B": "Z",
611 "\u017C": "z",
612 "\u017D": "Z",
613 "\u017E": "z",
614 "\u017F": "s",
615 "\u0192": "f",
616 "\u01A0": "O",
617 "\u01A1": "o",
618 "\u01AF": "U",
619 "\u01B0": "u",
620 "\u01CD": "A",
621 "\u01CE": "a",
622 "\u01CF": "I",
623 "\u01D0": "i",
624 "\u01D1": "O",
625 "\u01D2": "o",
626 "\u01D3": "U",
627 "\u01D4": "u",
628 "\u01D5": "U",
629 "\u01D6": "u",
630 "\u01D7": "U",
631 "\u01D8": "u",
632 "\u01D9": "U",
633 "\u01DA": "u",
634 "\u01DB": "U",
635 "\u01DC": "u",
636 "\u1EE8": "U",
637 "\u1EE9": "u",
638 "\u1E78": "U",
639 "\u1E79": "u",
640 "\u01FA": "A",
641 "\u01FB": "a",
642 "\u01FC": "AE",
643 "\u01FD": "ae",
644 "\u01FE": "O",
645 "\u01FF": "o",
646 "\xDE": "TH",
647 "\xFE": "th",
648 "\u1E54": "P",
649 "\u1E55": "p",
650 "\u1E64": "S",
651 "\u1E65": "s",
652 "X\u0301": "X",
653 "x\u0301": "x",
654 "\u0403": "\u0413",
655 "\u0453": "\u0433",
656 "\u040C": "\u041A",
657 "\u045C": "\u043A",
658 "A\u030B": "A",
659 "a\u030B": "a",
660 "E\u030B": "E",
661 "e\u030B": "e",
662 "I\u030B": "I",
663 "i\u030B": "i",
664 "\u01F8": "N",
665 "\u01F9": "n",
666 "\u1ED2": "O",
667 "\u1ED3": "o",
668 "\u1E50": "O",
669 "\u1E51": "o",
670 "\u1EEA": "U",
671 "\u1EEB": "u",
672 "\u1E80": "W",
673 "\u1E81": "w",
674 "\u1EF2": "Y",
675 "\u1EF3": "y",
676 "\u0200": "A",
677 "\u0201": "a",
678 "\u0204": "E",
679 "\u0205": "e",
680 "\u0208": "I",
681 "\u0209": "i",
682 "\u020C": "O",
683 "\u020D": "o",
684 "\u0210": "R",
685 "\u0211": "r",
686 "\u0214": "U",
687 "\u0215": "u",
688 "B\u030C": "B",
689 "b\u030C": "b",
690 "\u010C\u0323": "C",
691 "\u010D\u0323": "c",
692 "\xCA\u030C": "E",
693 "\xEA\u030C": "e",
694 "F\u030C": "F",
695 "f\u030C": "f",
696 "\u01E6": "G",
697 "\u01E7": "g",
698 "\u021E": "H",
699 "\u021F": "h",
700 "J\u030C": "J",
701 "\u01F0": "j",
702 "\u01E8": "K",
703 "\u01E9": "k",
704 "M\u030C": "M",
705 "m\u030C": "m",
706 "P\u030C": "P",
707 "p\u030C": "p",
708 "Q\u030C": "Q",
709 "q\u030C": "q",
710 "\u0158\u0329": "R",
711 "\u0159\u0329": "r",
712 "\u1E66": "S",
713 "\u1E67": "s",
714 "V\u030C": "V",
715 "v\u030C": "v",
716 "W\u030C": "W",
717 "w\u030C": "w",
718 "X\u030C": "X",
719 "x\u030C": "x",
720 "Y\u030C": "Y",
721 "y\u030C": "y",
722 "A\u0327": "A",
723 "a\u0327": "a",
724 "B\u0327": "B",
725 "b\u0327": "b",
726 "\u1E10": "D",
727 "\u1E11": "d",
728 "\u0228": "E",
729 "\u0229": "e",
730 "\u0190\u0327": "E",
731 "\u025B\u0327": "e",
732 "\u1E28": "H",
733 "\u1E29": "h",
734 "I\u0327": "I",
735 "i\u0327": "i",
736 "\u0197\u0327": "I",
737 "\u0268\u0327": "i",
738 "M\u0327": "M",
739 "m\u0327": "m",
740 "O\u0327": "O",
741 "o\u0327": "o",
742 "Q\u0327": "Q",
743 "q\u0327": "q",
744 "U\u0327": "U",
745 "u\u0327": "u",
746 "X\u0327": "X",
747 "x\u0327": "x",
748 "Z\u0327": "Z",
749 "z\u0327": "z",
750 "\u0439": "\u0438",
751 "\u0419": "\u0418",
752 "\u0451": "\u0435",
753 "\u0401": "\u0415"
754 };
755 var chars = Object.keys(characterMap).join("|");
756 var allAccents = new RegExp(chars, "g");
757 var firstAccent = new RegExp(chars, "");
758 function matcher(match2) {
759 return characterMap[match2];
760 }
761 var removeAccents3 = function(string) {
762 return string.replace(allAccents, matcher);
763 };
764 var hasAccents = function(string) {
765 return !!string.match(firstAccent);
766 };
767 module.exports = removeAccents3;
768 module.exports.has = hasAccents;
769 module.exports.remove = removeAccents3;
770 }
771 });
772
773 // node_modules/fast-deep-equal/es6/index.js
774 var require_es6 = __commonJS({
775 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
776 "use strict";
777 module.exports = function equal(a2, b2) {
778 if (a2 === b2) return true;
779 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
780 if (a2.constructor !== b2.constructor) return false;
781 var length, i2, keys;
782 if (Array.isArray(a2)) {
783 length = a2.length;
784 if (length != b2.length) return false;
785 for (i2 = length; i2-- !== 0; )
786 if (!equal(a2[i2], b2[i2])) return false;
787 return true;
788 }
789 if (a2 instanceof Map && b2 instanceof Map) {
790 if (a2.size !== b2.size) return false;
791 for (i2 of a2.entries())
792 if (!b2.has(i2[0])) return false;
793 for (i2 of a2.entries())
794 if (!equal(i2[1], b2.get(i2[0]))) return false;
795 return true;
796 }
797 if (a2 instanceof Set && b2 instanceof Set) {
798 if (a2.size !== b2.size) return false;
799 for (i2 of a2.entries())
800 if (!b2.has(i2[0])) return false;
801 return true;
802 }
803 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
804 length = a2.length;
805 if (length != b2.length) return false;
806 for (i2 = length; i2-- !== 0; )
807 if (a2[i2] !== b2[i2]) return false;
808 return true;
809 }
810 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
811 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
812 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
813 keys = Object.keys(a2);
814 length = keys.length;
815 if (length !== Object.keys(b2).length) return false;
816 for (i2 = length; i2-- !== 0; )
817 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
818 for (i2 = length; i2-- !== 0; ) {
819 var key = keys[i2];
820 if (!equal(a2[key], b2[key])) return false;
821 }
822 return true;
823 }
824 return a2 !== a2 && b2 !== b2;
825 };
826 }
827 });
828
829 // package-external:@wordpress/warning
830 var require_warning = __commonJS({
831 "package-external:@wordpress/warning"(exports, module) {
832 module.exports = window.wp.warning;
833 }
834 });
835
836 // package-external:@wordpress/deprecated
837 var require_deprecated = __commonJS({
838 "package-external:@wordpress/deprecated"(exports, module) {
839 module.exports = window.wp.deprecated;
840 }
841 });
842
843 // widgets/activity/render.tsx
844 var import_element84 = __toESM(require_element());
845 var import_data6 = __toESM(require_data());
846 var import_core_data = __toESM(require_core_data());
847 var import_i18n45 = __toESM(require_i18n());
848 var import_date10 = __toESM(require_date());
849 var import_html_entities = __toESM(require_html_entities());
850 var import_components46 = __toESM(require_components());
851
852 // packages/icons/build-module/icon/index.mjs
853 var import_element = __toESM(require_element(), 1);
854 var icon_default = (0, import_element.forwardRef)(
855 ({ icon, size: size4 = 24, ...props }, ref) => {
856 return (0, import_element.cloneElement)(icon, {
857 width: size4,
858 height: size4,
859 ...props,
860 ref
861 });
862 }
863 );
864
865 // packages/icons/build-module/library/arrow-down.mjs
866 var import_primitives = __toESM(require_primitives(), 1);
867 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
868 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
869
870 // packages/icons/build-module/library/arrow-left.mjs
871 var import_primitives2 = __toESM(require_primitives(), 1);
872 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
873 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
874
875 // packages/icons/build-module/library/arrow-right.mjs
876 var import_primitives3 = __toESM(require_primitives(), 1);
877 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
878 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
879
880 // packages/icons/build-module/library/arrow-up.mjs
881 var import_primitives4 = __toESM(require_primitives(), 1);
882 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
883 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
884
885 // packages/icons/build-module/library/block-table.mjs
886 var import_primitives5 = __toESM(require_primitives(), 1);
887 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
888 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
889
890 // packages/icons/build-module/library/category.mjs
891 var import_primitives6 = __toESM(require_primitives(), 1);
892 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
893 var category_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
894
895 // packages/icons/build-module/library/check.mjs
896 var import_primitives7 = __toESM(require_primitives(), 1);
897 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
898 var check_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
899
900 // packages/icons/build-module/library/close-small.mjs
901 var import_primitives8 = __toESM(require_primitives(), 1);
902 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
903 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
904
905 // packages/icons/build-module/library/cog.mjs
906 var import_primitives9 = __toESM(require_primitives(), 1);
907 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
908 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
909
910 // packages/icons/build-module/library/comment.mjs
911 var import_primitives10 = __toESM(require_primitives(), 1);
912 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
913 var comment_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { d: "M18 4H6c-1.1 0-2 .9-2 2v12.9c0 .6.5 1.1 1.1 1.1.3 0 .5-.1.8-.3L8.5 17H18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5H7.9l-2.4 2.4V6c0-.3.2-.5.5-.5h12c.3 0 .5.2.5.5v9z" }) });
914
915 // packages/icons/build-module/library/envelope.mjs
916 var import_primitives11 = __toESM(require_primitives(), 1);
917 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
918 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
919
920 // packages/icons/build-module/library/error.mjs
921 var import_primitives12 = __toESM(require_primitives(), 1);
922 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
923 var error_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { 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" }) });
924
925 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
926 var import_primitives13 = __toESM(require_primitives(), 1);
927 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
928 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { d: "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" }) });
929
930 // packages/icons/build-module/library/format-list-bullets.mjs
931 var import_primitives14 = __toESM(require_primitives(), 1);
932 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
933 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { d: "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" }) });
934
935 // packages/icons/build-module/library/funnel.mjs
936 var import_primitives15 = __toESM(require_primitives(), 1);
937 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
938 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
939
940 // packages/icons/build-module/library/link.mjs
941 var import_primitives16 = __toESM(require_primitives(), 1);
942 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
943 var link_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "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" }) });
944
945 // packages/icons/build-module/library/mobile.mjs
946 var import_primitives17 = __toESM(require_primitives(), 1);
947 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
948 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "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" }) });
949
950 // packages/icons/build-module/library/more-vertical.mjs
951 var import_primitives18 = __toESM(require_primitives(), 1);
952 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
953 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
954
955 // packages/icons/build-module/library/next.mjs
956 var import_primitives19 = __toESM(require_primitives(), 1);
957 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
958 var next_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "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" }) });
959
960 // packages/icons/build-module/library/post-list.mjs
961 var import_primitives20 = __toESM(require_primitives(), 1);
962 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
963 var post_list_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { 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" }) });
964
965 // packages/icons/build-module/library/previous.mjs
966 var import_primitives21 = __toESM(require_primitives(), 1);
967 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
968 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "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" }) });
969
970 // packages/icons/build-module/library/scheduled.mjs
971 var import_primitives22 = __toESM(require_primitives(), 1);
972 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
973 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { 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" }) });
974
975 // packages/icons/build-module/library/search.mjs
976 var import_primitives23 = __toESM(require_primitives(), 1);
977 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
978 var search_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "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" }) });
979
980 // packages/icons/build-module/library/seen.mjs
981 var import_primitives24 = __toESM(require_primitives(), 1);
982 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
983 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.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" }) });
984
985 // packages/icons/build-module/library/unseen.mjs
986 var import_primitives25 = __toESM(require_primitives(), 1);
987 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
988 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.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" }) });
989
990 // node_modules/clsx/dist/clsx.mjs
991 function r(e2) {
992 var t2, f2, n2 = "";
993 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
994 else if ("object" == typeof e2) if (Array.isArray(e2)) {
995 var o2 = e2.length;
996 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
997 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
998 return n2;
999 }
1000 function clsx() {
1001 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1002 return n2;
1003 }
1004 var clsx_default = clsx;
1005
1006 // packages/dataviews/build-module/dataviews/index.mjs
1007 var import_element83 = __toESM(require_element(), 1);
1008 var import_compose13 = __toESM(require_compose(), 1);
1009
1010 // node_modules/@base-ui/utils/esm/safeReact.js
1011 var React = __toESM(require_react(), 1);
1012 var SafeReact = {
1013 ...React
1014 };
1015
1016 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1017 var React2 = __toESM(require_react(), 1);
1018 var UNINITIALIZED = {};
1019 function useRefWithInit(init2, initArg) {
1020 const ref = React2.useRef(UNINITIALIZED);
1021 if (ref.current === UNINITIALIZED) {
1022 ref.current = init2(initArg);
1023 }
1024 return ref;
1025 }
1026
1027 // node_modules/@base-ui/utils/esm/useStableCallback.js
1028 var useInsertionEffect = SafeReact.useInsertionEffect;
1029 var useSafeInsertionEffect = (
1030 // React 17 doesn't have useInsertionEffect.
1031 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1032 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1033 );
1034 function useStableCallback(callback) {
1035 const stable = useRefWithInit(createStableCallback).current;
1036 stable.next = callback;
1037 useSafeInsertionEffect(stable.effect);
1038 return stable.trampoline;
1039 }
1040 function createStableCallback() {
1041 const stable = {
1042 next: void 0,
1043 callback: assertNotCalled,
1044 trampoline: (...args) => stable.callback?.(...args),
1045 effect: () => {
1046 stable.callback = stable.next;
1047 }
1048 };
1049 return stable;
1050 }
1051 function assertNotCalled() {
1052 if (true) {
1053 throw (
1054 /* minify-error-disabled */
1055 new Error("Base UI: Cannot call an event handler while rendering.")
1056 );
1057 }
1058 }
1059
1060 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1061 var React3 = __toESM(require_react(), 1);
1062 var noop = () => {
1063 };
1064 var useIsoLayoutEffect = typeof document !== "undefined" ? React3.useLayoutEffect : noop;
1065
1066 // node_modules/@base-ui/utils/esm/warn.js
1067 var set;
1068 if (true) {
1069 set = /* @__PURE__ */ new Set();
1070 }
1071 function warn(...messages) {
1072 if (true) {
1073 const messageKey = messages.join(" ");
1074 if (!set.has(messageKey)) {
1075 set.add(messageKey);
1076 console.warn(`Base UI: ${messageKey}`);
1077 }
1078 }
1079 }
1080
1081 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1082 var React4 = __toESM(require_react(), 1);
1083 var DirectionContext = /* @__PURE__ */ React4.createContext(void 0);
1084 if (true) DirectionContext.displayName = "DirectionContext";
1085 function useDirection() {
1086 const context = React4.useContext(DirectionContext);
1087 return context?.direction ?? "ltr";
1088 }
1089
1090 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1091 var React7 = __toESM(require_react(), 1);
1092
1093 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1094 function useMergedRefs(a2, b2, c2, d2) {
1095 const forkRef = useRefWithInit(createForkRef).current;
1096 if (didChange(forkRef, a2, b2, c2, d2)) {
1097 update(forkRef, [a2, b2, c2, d2]);
1098 }
1099 return forkRef.callback;
1100 }
1101 function useMergedRefsN(refs) {
1102 const forkRef = useRefWithInit(createForkRef).current;
1103 if (didChangeN(forkRef, refs)) {
1104 update(forkRef, refs);
1105 }
1106 return forkRef.callback;
1107 }
1108 function createForkRef() {
1109 return {
1110 callback: null,
1111 cleanup: null,
1112 refs: []
1113 };
1114 }
1115 function didChange(forkRef, a2, b2, c2, d2) {
1116 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1117 }
1118 function didChangeN(forkRef, newRefs) {
1119 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1120 }
1121 function update(forkRef, refs) {
1122 forkRef.refs = refs;
1123 if (refs.every((ref) => ref == null)) {
1124 forkRef.callback = null;
1125 return;
1126 }
1127 forkRef.callback = (instance) => {
1128 if (forkRef.cleanup) {
1129 forkRef.cleanup();
1130 forkRef.cleanup = null;
1131 }
1132 if (instance != null) {
1133 const cleanupCallbacks = Array(refs.length).fill(null);
1134 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1135 const ref = refs[i2];
1136 if (ref == null) {
1137 continue;
1138 }
1139 switch (typeof ref) {
1140 case "function": {
1141 const refCleanup = ref(instance);
1142 if (typeof refCleanup === "function") {
1143 cleanupCallbacks[i2] = refCleanup;
1144 }
1145 break;
1146 }
1147 case "object": {
1148 ref.current = instance;
1149 break;
1150 }
1151 default:
1152 }
1153 }
1154 forkRef.cleanup = () => {
1155 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1156 const ref = refs[i2];
1157 if (ref == null) {
1158 continue;
1159 }
1160 switch (typeof ref) {
1161 case "function": {
1162 const cleanupCallback = cleanupCallbacks[i2];
1163 if (typeof cleanupCallback === "function") {
1164 cleanupCallback();
1165 } else {
1166 ref(null);
1167 }
1168 break;
1169 }
1170 case "object": {
1171 ref.current = null;
1172 break;
1173 }
1174 default:
1175 }
1176 }
1177 };
1178 }
1179 };
1180 }
1181
1182 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1183 var React6 = __toESM(require_react(), 1);
1184
1185 // node_modules/@base-ui/utils/esm/reactVersion.js
1186 var React5 = __toESM(require_react(), 1);
1187 var majorVersion = parseInt(React5.version, 10);
1188 function isReactVersionAtLeast(reactVersionToCheck) {
1189 return majorVersion >= reactVersionToCheck;
1190 }
1191
1192 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1193 function getReactElementRef(element) {
1194 if (!/* @__PURE__ */ React6.isValidElement(element)) {
1195 return null;
1196 }
1197 const reactElement = element;
1198 const propsWithRef = reactElement.props;
1199 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1200 }
1201
1202 // node_modules/@base-ui/utils/esm/mergeObjects.js
1203 function mergeObjects(a2, b2) {
1204 if (a2 && !b2) {
1205 return a2;
1206 }
1207 if (!a2 && b2) {
1208 return b2;
1209 }
1210 if (a2 || b2) {
1211 return {
1212 ...a2,
1213 ...b2
1214 };
1215 }
1216 return void 0;
1217 }
1218
1219 // node_modules/@base-ui/utils/esm/empty.js
1220 function NOOP() {
1221 }
1222 var EMPTY_ARRAY = Object.freeze([]);
1223 var EMPTY_OBJECT = Object.freeze({});
1224
1225 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1226 function getStateAttributesProps(state, customMapping) {
1227 const props = {};
1228 for (const key in state) {
1229 const value = state[key];
1230 if (customMapping?.hasOwnProperty(key)) {
1231 const customProps = customMapping[key](value);
1232 if (customProps != null) {
1233 Object.assign(props, customProps);
1234 }
1235 continue;
1236 }
1237 if (value === true) {
1238 props[`data-${key.toLowerCase()}`] = "";
1239 } else if (value) {
1240 props[`data-${key.toLowerCase()}`] = value.toString();
1241 }
1242 }
1243 return props;
1244 }
1245
1246 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1247 function resolveClassName(className, state) {
1248 return typeof className === "function" ? className(state) : className;
1249 }
1250
1251 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1252 function resolveStyle(style, state) {
1253 return typeof style === "function" ? style(state) : style;
1254 }
1255
1256 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1257 var EMPTY_PROPS = {};
1258 function mergeProps(a2, b2, c2, d2, e2) {
1259 if (!c2 && !d2 && !e2 && !a2) {
1260 return createInitialMergedProps(b2);
1261 }
1262 let merged = createInitialMergedProps(a2);
1263 if (b2) {
1264 merged = mergeInto(merged, b2);
1265 }
1266 if (c2) {
1267 merged = mergeInto(merged, c2);
1268 }
1269 if (d2) {
1270 merged = mergeInto(merged, d2);
1271 }
1272 if (e2) {
1273 merged = mergeInto(merged, e2);
1274 }
1275 return merged;
1276 }
1277 function mergePropsN(props) {
1278 if (props.length === 0) {
1279 return EMPTY_PROPS;
1280 }
1281 if (props.length === 1) {
1282 return createInitialMergedProps(props[0]);
1283 }
1284 let merged = createInitialMergedProps(props[0]);
1285 for (let i2 = 1; i2 < props.length; i2 += 1) {
1286 merged = mergeInto(merged, props[i2]);
1287 }
1288 return merged;
1289 }
1290 function createInitialMergedProps(inputProps) {
1291 if (isPropsGetter(inputProps)) {
1292 return {
1293 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1294 };
1295 }
1296 return copyInitialProps(inputProps);
1297 }
1298 function mergeInto(merged, inputProps) {
1299 if (isPropsGetter(inputProps)) {
1300 return resolvePropsGetter(inputProps, merged);
1301 }
1302 return mutablyMergeInto(merged, inputProps);
1303 }
1304 function copyInitialProps(inputProps) {
1305 const copiedProps = {
1306 ...inputProps
1307 };
1308 for (const propName in copiedProps) {
1309 const propValue = copiedProps[propName];
1310 if (isEventHandler(propName, propValue)) {
1311 copiedProps[propName] = wrapEventHandler(propValue);
1312 }
1313 }
1314 return copiedProps;
1315 }
1316 function mutablyMergeInto(mergedProps, externalProps) {
1317 if (!externalProps) {
1318 return mergedProps;
1319 }
1320 for (const propName in externalProps) {
1321 const externalPropValue = externalProps[propName];
1322 switch (propName) {
1323 case "style": {
1324 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1325 break;
1326 }
1327 case "className": {
1328 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1329 break;
1330 }
1331 default: {
1332 if (isEventHandler(propName, externalPropValue)) {
1333 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1334 } else {
1335 mergedProps[propName] = externalPropValue;
1336 }
1337 }
1338 }
1339 }
1340 return mergedProps;
1341 }
1342 function isEventHandler(key, value) {
1343 const code0 = key.charCodeAt(0);
1344 const code1 = key.charCodeAt(1);
1345 const code2 = key.charCodeAt(2);
1346 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1347 }
1348 function isPropsGetter(inputProps) {
1349 return typeof inputProps === "function";
1350 }
1351 function resolvePropsGetter(inputProps, previousProps) {
1352 if (isPropsGetter(inputProps)) {
1353 return inputProps(previousProps);
1354 }
1355 return inputProps ?? EMPTY_PROPS;
1356 }
1357 function mergeEventHandlers(ourHandler, theirHandler) {
1358 if (!theirHandler) {
1359 return ourHandler;
1360 }
1361 if (!ourHandler) {
1362 return wrapEventHandler(theirHandler);
1363 }
1364 return (...args) => {
1365 const event = args[0];
1366 if (isSyntheticEvent(event)) {
1367 const baseUIEvent = event;
1368 makeEventPreventable(baseUIEvent);
1369 const result2 = theirHandler(...args);
1370 if (!baseUIEvent.baseUIHandlerPrevented) {
1371 ourHandler?.(...args);
1372 }
1373 return result2;
1374 }
1375 const result = theirHandler(...args);
1376 ourHandler?.(...args);
1377 return result;
1378 };
1379 }
1380 function wrapEventHandler(handler) {
1381 if (!handler) {
1382 return handler;
1383 }
1384 return (...args) => {
1385 const event = args[0];
1386 if (isSyntheticEvent(event)) {
1387 makeEventPreventable(event);
1388 }
1389 return handler(...args);
1390 };
1391 }
1392 function makeEventPreventable(event) {
1393 event.preventBaseUIHandler = () => {
1394 event.baseUIHandlerPrevented = true;
1395 };
1396 return event;
1397 }
1398 function mergeClassNames(ourClassName, theirClassName) {
1399 if (theirClassName) {
1400 if (ourClassName) {
1401 return theirClassName + " " + ourClassName;
1402 }
1403 return theirClassName;
1404 }
1405 return ourClassName;
1406 }
1407 function isSyntheticEvent(event) {
1408 return event != null && typeof event === "object" && "nativeEvent" in event;
1409 }
1410
1411 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1412 var import_react = __toESM(require_react(), 1);
1413 function useRenderElement(element, componentProps, params = {}) {
1414 const renderProp = componentProps.render;
1415 const outProps = useRenderElementProps(componentProps, params);
1416 if (params.enabled === false) {
1417 return null;
1418 }
1419 const state = params.state ?? EMPTY_OBJECT;
1420 return evaluateRenderProp(element, renderProp, outProps, state);
1421 }
1422 function useRenderElementProps(componentProps, params = {}) {
1423 const {
1424 className: classNameProp,
1425 style: styleProp,
1426 render: renderProp
1427 } = componentProps;
1428 const {
1429 state = EMPTY_OBJECT,
1430 ref,
1431 props,
1432 stateAttributesMapping: stateAttributesMapping3,
1433 enabled = true
1434 } = params;
1435 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1436 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1437 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1438 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1439 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1440 if (typeof document !== "undefined") {
1441 if (!enabled) {
1442 useMergedRefs(null, null);
1443 } else if (Array.isArray(ref)) {
1444 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1445 } else {
1446 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1447 }
1448 }
1449 if (!enabled) {
1450 return EMPTY_OBJECT;
1451 }
1452 if (className !== void 0) {
1453 outProps.className = mergeClassNames(outProps.className, className);
1454 }
1455 if (style !== void 0) {
1456 outProps.style = mergeObjects(outProps.style, style);
1457 }
1458 return outProps;
1459 }
1460 function resolveRenderFunctionProps(props) {
1461 if (Array.isArray(props)) {
1462 return mergePropsN(props);
1463 }
1464 return mergeProps(void 0, props);
1465 }
1466 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1467 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1468 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1469 function evaluateRenderProp(element, render4, props, state) {
1470 if (render4) {
1471 if (typeof render4 === "function") {
1472 if (true) {
1473 warnIfRenderPropLooksLikeComponent(render4);
1474 }
1475 return render4(props, state);
1476 }
1477 const mergedProps = mergeProps(props, render4.props);
1478 mergedProps.ref = props.ref;
1479 let newElement = render4;
1480 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1481 const children = React7.Children.toArray(render4);
1482 newElement = children[0];
1483 }
1484 if (true) {
1485 if (!/* @__PURE__ */ React7.isValidElement(newElement)) {
1486 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"));
1487 }
1488 }
1489 return /* @__PURE__ */ React7.cloneElement(newElement, mergedProps);
1490 }
1491 if (element) {
1492 if (typeof element === "string") {
1493 return renderTag(element, props);
1494 }
1495 }
1496 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1497 }
1498 function warnIfRenderPropLooksLikeComponent(renderFn) {
1499 const functionName = renderFn.name;
1500 if (functionName.length === 0) {
1501 return;
1502 }
1503 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1504 return;
1505 }
1506 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1507 return;
1508 }
1509 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");
1510 }
1511 function renderTag(Tag, props) {
1512 if (Tag === "button") {
1513 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1514 type: "button",
1515 ...props,
1516 key: props.key
1517 });
1518 }
1519 if (Tag === "img") {
1520 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1521 alt: "",
1522 ...props,
1523 key: props.key
1524 });
1525 }
1526 return /* @__PURE__ */ React7.createElement(Tag, props);
1527 }
1528
1529 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1530 var reason_parts_exports = {};
1531 __export(reason_parts_exports, {
1532 cancelOpen: () => cancelOpen,
1533 chipRemovePress: () => chipRemovePress,
1534 clearPress: () => clearPress,
1535 closePress: () => closePress,
1536 closeWatcher: () => closeWatcher,
1537 decrementPress: () => decrementPress,
1538 disabled: () => disabled,
1539 drag: () => drag,
1540 escapeKey: () => escapeKey,
1541 focusOut: () => focusOut,
1542 imperativeAction: () => imperativeAction,
1543 incrementPress: () => incrementPress,
1544 initial: () => initial,
1545 inputBlur: () => inputBlur,
1546 inputChange: () => inputChange,
1547 inputClear: () => inputClear,
1548 inputPaste: () => inputPaste,
1549 inputPress: () => inputPress,
1550 itemPress: () => itemPress,
1551 keyboard: () => keyboard,
1552 linkPress: () => linkPress,
1553 listNavigation: () => listNavigation,
1554 missing: () => missing,
1555 none: () => none,
1556 outsidePress: () => outsidePress,
1557 pointer: () => pointer,
1558 scrub: () => scrub,
1559 siblingOpen: () => siblingOpen,
1560 swipe: () => swipe,
1561 trackPress: () => trackPress,
1562 triggerFocus: () => triggerFocus,
1563 triggerHover: () => triggerHover,
1564 triggerPress: () => triggerPress,
1565 wheel: () => wheel,
1566 windowResize: () => windowResize
1567 });
1568 var none = "none";
1569 var triggerPress = "trigger-press";
1570 var triggerHover = "trigger-hover";
1571 var triggerFocus = "trigger-focus";
1572 var outsidePress = "outside-press";
1573 var itemPress = "item-press";
1574 var closePress = "close-press";
1575 var linkPress = "link-press";
1576 var clearPress = "clear-press";
1577 var chipRemovePress = "chip-remove-press";
1578 var trackPress = "track-press";
1579 var incrementPress = "increment-press";
1580 var decrementPress = "decrement-press";
1581 var inputChange = "input-change";
1582 var inputClear = "input-clear";
1583 var inputBlur = "input-blur";
1584 var inputPaste = "input-paste";
1585 var inputPress = "input-press";
1586 var focusOut = "focus-out";
1587 var escapeKey = "escape-key";
1588 var closeWatcher = "close-watcher";
1589 var listNavigation = "list-navigation";
1590 var keyboard = "keyboard";
1591 var pointer = "pointer";
1592 var drag = "drag";
1593 var wheel = "wheel";
1594 var scrub = "scrub";
1595 var cancelOpen = "cancel-open";
1596 var siblingOpen = "sibling-open";
1597 var disabled = "disabled";
1598 var missing = "missing";
1599 var initial = "initial";
1600 var imperativeAction = "imperative-action";
1601 var swipe = "swipe";
1602 var windowResize = "window-resize";
1603
1604 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1605 function createChangeEventDetails(reason, event, trigger, customProperties) {
1606 let canceled = false;
1607 let allowPropagation = false;
1608 const custom = customProperties ?? EMPTY_OBJECT;
1609 const details = {
1610 reason,
1611 event: event ?? new Event("base-ui"),
1612 cancel() {
1613 canceled = true;
1614 },
1615 allowPropagation() {
1616 allowPropagation = true;
1617 },
1618 get isCanceled() {
1619 return canceled;
1620 },
1621 get isPropagationAllowed() {
1622 return allowPropagation;
1623 },
1624 trigger,
1625 ...custom
1626 };
1627 return details;
1628 }
1629
1630 // node_modules/@base-ui/utils/esm/useId.js
1631 var React8 = __toESM(require_react(), 1);
1632 var globalId = 0;
1633 function useGlobalId(idOverride, prefix = "mui") {
1634 const [defaultId, setDefaultId] = React8.useState(idOverride);
1635 const id = idOverride || defaultId;
1636 React8.useEffect(() => {
1637 if (defaultId == null) {
1638 globalId += 1;
1639 setDefaultId(`${prefix}-${globalId}`);
1640 }
1641 }, [defaultId, prefix]);
1642 return id;
1643 }
1644 var maybeReactUseId = SafeReact.useId;
1645 function useId(idOverride, prefix) {
1646 if (maybeReactUseId !== void 0) {
1647 const reactId = maybeReactUseId();
1648 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1649 }
1650 return useGlobalId(idOverride, prefix);
1651 }
1652
1653 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1654 function useBaseUiId(idOverride) {
1655 return useId(idOverride, "base-ui");
1656 }
1657
1658 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1659 var React10 = __toESM(require_react(), 1);
1660
1661 // node_modules/@base-ui/utils/esm/useOnMount.js
1662 var React9 = __toESM(require_react(), 1);
1663 var EMPTY = [];
1664 function useOnMount(fn) {
1665 React9.useEffect(fn, EMPTY);
1666 }
1667
1668 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1669 var EMPTY2 = null;
1670 var LAST_RAF = globalThis.requestAnimationFrame;
1671 var Scheduler = class {
1672 /* This implementation uses an array as a backing data-structure for frame callbacks.
1673 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1674 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1675 * be much more efficient if there is a call pattern that alterns as
1676 * "request-cancel-request-cancel-…".
1677 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1678 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1679 callbacks = [];
1680 callbacksCount = 0;
1681 nextId = 1;
1682 startId = 1;
1683 isScheduled = false;
1684 tick = (timestamp) => {
1685 this.isScheduled = false;
1686 const currentCallbacks = this.callbacks;
1687 const currentCallbacksCount = this.callbacksCount;
1688 this.callbacks = [];
1689 this.callbacksCount = 0;
1690 this.startId = this.nextId;
1691 if (currentCallbacksCount > 0) {
1692 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1693 currentCallbacks[i2]?.(timestamp);
1694 }
1695 }
1696 };
1697 request(fn) {
1698 const id = this.nextId;
1699 this.nextId += 1;
1700 this.callbacks.push(fn);
1701 this.callbacksCount += 1;
1702 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1703 if (!this.isScheduled || didRAFChange) {
1704 requestAnimationFrame(this.tick);
1705 this.isScheduled = true;
1706 }
1707 return id;
1708 }
1709 cancel(id) {
1710 const index2 = id - this.startId;
1711 if (index2 < 0 || index2 >= this.callbacks.length) {
1712 return;
1713 }
1714 this.callbacks[index2] = null;
1715 this.callbacksCount -= 1;
1716 }
1717 };
1718 var scheduler = new Scheduler();
1719 var AnimationFrame = class _AnimationFrame {
1720 static create() {
1721 return new _AnimationFrame();
1722 }
1723 static request(fn) {
1724 return scheduler.request(fn);
1725 }
1726 static cancel(id) {
1727 return scheduler.cancel(id);
1728 }
1729 currentId = EMPTY2;
1730 /**
1731 * Executes `fn` after `delay`, clearing any previously scheduled call.
1732 */
1733 request(fn) {
1734 this.cancel();
1735 this.currentId = scheduler.request(() => {
1736 this.currentId = EMPTY2;
1737 fn();
1738 });
1739 }
1740 cancel = () => {
1741 if (this.currentId !== EMPTY2) {
1742 scheduler.cancel(this.currentId);
1743 this.currentId = EMPTY2;
1744 }
1745 };
1746 disposeEffect = () => {
1747 return this.cancel;
1748 };
1749 };
1750 function useAnimationFrame() {
1751 const timeout = useRefWithInit(AnimationFrame.create).current;
1752 useOnMount(timeout.disposeEffect);
1753 return timeout;
1754 }
1755
1756 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1757 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1758 const [transitionStatus, setTransitionStatus] = React10.useState(open && enableIdleState ? "idle" : void 0);
1759 const [mounted, setMounted] = React10.useState(open);
1760 if (open && !mounted) {
1761 setMounted(true);
1762 setTransitionStatus("starting");
1763 }
1764 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1765 setTransitionStatus("ending");
1766 }
1767 if (!open && !mounted && transitionStatus === "ending") {
1768 setTransitionStatus(void 0);
1769 }
1770 useIsoLayoutEffect(() => {
1771 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1772 const frame = AnimationFrame.request(() => {
1773 setTransitionStatus("ending");
1774 });
1775 return () => {
1776 AnimationFrame.cancel(frame);
1777 };
1778 }
1779 return void 0;
1780 }, [open, mounted, transitionStatus, deferEndingState]);
1781 useIsoLayoutEffect(() => {
1782 if (!open || enableIdleState) {
1783 return void 0;
1784 }
1785 const frame = AnimationFrame.request(() => {
1786 setTransitionStatus(void 0);
1787 });
1788 return () => {
1789 AnimationFrame.cancel(frame);
1790 };
1791 }, [enableIdleState, open]);
1792 useIsoLayoutEffect(() => {
1793 if (!open || !enableIdleState) {
1794 return void 0;
1795 }
1796 if (open && mounted && transitionStatus !== "idle") {
1797 setTransitionStatus("starting");
1798 }
1799 const frame = AnimationFrame.request(() => {
1800 setTransitionStatus("idle");
1801 });
1802 return () => {
1803 AnimationFrame.cancel(frame);
1804 };
1805 }, [enableIdleState, open, mounted, transitionStatus]);
1806 return {
1807 mounted,
1808 setMounted,
1809 transitionStatus
1810 };
1811 }
1812
1813 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1814 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1815 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1816 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1817 return TransitionStatusDataAttributes2;
1818 })({});
1819 var STARTING_HOOK = {
1820 [TransitionStatusDataAttributes.startingStyle]: ""
1821 };
1822 var ENDING_HOOK = {
1823 [TransitionStatusDataAttributes.endingStyle]: ""
1824 };
1825 var transitionStatusMapping = {
1826 transitionStatus(value) {
1827 if (value === "starting") {
1828 return STARTING_HOOK;
1829 }
1830 if (value === "ending") {
1831 return ENDING_HOOK;
1832 }
1833 return null;
1834 }
1835 };
1836
1837 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
1838 function hasWindow() {
1839 return typeof window !== "undefined";
1840 }
1841 function getNodeName(node) {
1842 if (isNode(node)) {
1843 return (node.nodeName || "").toLowerCase();
1844 }
1845 return "#document";
1846 }
1847 function getWindow(node) {
1848 var _node$ownerDocument;
1849 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1850 }
1851 function getDocumentElement(node) {
1852 var _ref;
1853 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1854 }
1855 function isNode(value) {
1856 if (!hasWindow()) {
1857 return false;
1858 }
1859 return value instanceof Node || value instanceof getWindow(value).Node;
1860 }
1861 function isElement(value) {
1862 if (!hasWindow()) {
1863 return false;
1864 }
1865 return value instanceof Element || value instanceof getWindow(value).Element;
1866 }
1867 function isHTMLElement(value) {
1868 if (!hasWindow()) {
1869 return false;
1870 }
1871 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1872 }
1873 function isShadowRoot(value) {
1874 if (!hasWindow() || typeof ShadowRoot === "undefined") {
1875 return false;
1876 }
1877 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1878 }
1879 function isOverflowElement(element) {
1880 const {
1881 overflow,
1882 overflowX,
1883 overflowY,
1884 display
1885 } = getComputedStyle2(element);
1886 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
1887 }
1888 function isTableElement(element) {
1889 return /^(table|td|th)$/.test(getNodeName(element));
1890 }
1891 function isTopLayer(element) {
1892 try {
1893 if (element.matches(":popover-open")) {
1894 return true;
1895 }
1896 } catch (_e) {
1897 }
1898 try {
1899 return element.matches(":modal");
1900 } catch (_e) {
1901 return false;
1902 }
1903 }
1904 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
1905 var containRe = /paint|layout|strict|content/;
1906 var isNotNone = (value) => !!value && value !== "none";
1907 var isWebKitValue;
1908 function isContainingBlock(elementOrCss) {
1909 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
1910 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 || "");
1911 }
1912 function getContainingBlock(element) {
1913 let currentNode = getParentNode(element);
1914 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1915 if (isContainingBlock(currentNode)) {
1916 return currentNode;
1917 } else if (isTopLayer(currentNode)) {
1918 return null;
1919 }
1920 currentNode = getParentNode(currentNode);
1921 }
1922 return null;
1923 }
1924 function isWebKit() {
1925 if (isWebKitValue == null) {
1926 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
1927 }
1928 return isWebKitValue;
1929 }
1930 function isLastTraversableNode(node) {
1931 return /^(html|body|#document)$/.test(getNodeName(node));
1932 }
1933 function getComputedStyle2(element) {
1934 return getWindow(element).getComputedStyle(element);
1935 }
1936 function getNodeScroll(element) {
1937 if (isElement(element)) {
1938 return {
1939 scrollLeft: element.scrollLeft,
1940 scrollTop: element.scrollTop
1941 };
1942 }
1943 return {
1944 scrollLeft: element.scrollX,
1945 scrollTop: element.scrollY
1946 };
1947 }
1948 function getParentNode(node) {
1949 if (getNodeName(node) === "html") {
1950 return node;
1951 }
1952 const result = (
1953 // Step into the shadow DOM of the parent of a slotted node.
1954 node.assignedSlot || // DOM Element detected.
1955 node.parentNode || // ShadowRoot detected.
1956 isShadowRoot(node) && node.host || // Fallback.
1957 getDocumentElement(node)
1958 );
1959 return isShadowRoot(result) ? result.host : result;
1960 }
1961 function getNearestOverflowAncestor(node) {
1962 const parentNode = getParentNode(node);
1963 if (isLastTraversableNode(parentNode)) {
1964 return node.ownerDocument ? node.ownerDocument.body : node.body;
1965 }
1966 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1967 return parentNode;
1968 }
1969 return getNearestOverflowAncestor(parentNode);
1970 }
1971 function getOverflowAncestors(node, list, traverseIframes) {
1972 var _node$ownerDocument2;
1973 if (list === void 0) {
1974 list = [];
1975 }
1976 if (traverseIframes === void 0) {
1977 traverseIframes = true;
1978 }
1979 const scrollableAncestor = getNearestOverflowAncestor(node);
1980 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1981 const win = getWindow(scrollableAncestor);
1982 if (isBody) {
1983 const frameElement = getFrameElement(win);
1984 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1985 } else {
1986 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1987 }
1988 }
1989 function getFrameElement(win) {
1990 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1991 }
1992
1993 // node_modules/@base-ui/utils/esm/detectBrowser.js
1994 var hasNavigator = typeof navigator !== "undefined";
1995 var nav = getNavigatorData();
1996 var platform = getPlatform();
1997 var userAgent = getUserAgent();
1998 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
1999 var isIOS = (
2000 // iPads can claim to be MacIntel
2001 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2002 );
2003 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2004 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2005 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2006 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2007 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2008 var isJSDOM = userAgent.includes("jsdom/");
2009 function getNavigatorData() {
2010 if (!hasNavigator) {
2011 return {
2012 platform: "",
2013 maxTouchPoints: -1
2014 };
2015 }
2016 const uaData = navigator.userAgentData;
2017 if (uaData?.platform) {
2018 return {
2019 platform: uaData.platform,
2020 maxTouchPoints: navigator.maxTouchPoints
2021 };
2022 }
2023 return {
2024 platform: navigator.platform ?? "",
2025 maxTouchPoints: navigator.maxTouchPoints ?? -1
2026 };
2027 }
2028 function getUserAgent() {
2029 if (!hasNavigator) {
2030 return "";
2031 }
2032 const uaData = navigator.userAgentData;
2033 if (uaData && Array.isArray(uaData.brands)) {
2034 return uaData.brands.map(({
2035 brand,
2036 version: version2
2037 }) => `${brand}/${version2}`).join(" ");
2038 }
2039 return navigator.userAgent;
2040 }
2041 function getPlatform() {
2042 if (!hasNavigator) {
2043 return "";
2044 }
2045 const uaData = navigator.userAgentData;
2046 if (uaData?.platform) {
2047 return uaData.platform;
2048 }
2049 return navigator.platform ?? "";
2050 }
2051
2052 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2053 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2054 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2055
2056 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2057 function activeElement(doc) {
2058 let element = doc.activeElement;
2059 while (element?.shadowRoot?.activeElement != null) {
2060 element = element.shadowRoot.activeElement;
2061 }
2062 return element;
2063 }
2064 function contains(parent, child) {
2065 if (!parent || !child) {
2066 return false;
2067 }
2068 const rootNode = child.getRootNode?.();
2069 if (parent.contains(child)) {
2070 return true;
2071 }
2072 if (rootNode && isShadowRoot(rootNode)) {
2073 let next = child;
2074 while (next) {
2075 if (parent === next) {
2076 return true;
2077 }
2078 next = next.parentNode || next.host;
2079 }
2080 }
2081 return false;
2082 }
2083 function getTarget(event) {
2084 if ("composedPath" in event) {
2085 return event.composedPath()[0];
2086 }
2087 return event.target;
2088 }
2089
2090 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2091 function isTargetInsideEnabledTrigger(target, triggerElements) {
2092 if (!isElement(target)) {
2093 return false;
2094 }
2095 const targetElement = target;
2096 if (triggerElements.hasElement(targetElement)) {
2097 return !targetElement.hasAttribute("data-trigger-disabled");
2098 }
2099 for (const [, trigger] of triggerElements.entries()) {
2100 if (contains(trigger, targetElement)) {
2101 return !trigger.hasAttribute("data-trigger-disabled");
2102 }
2103 }
2104 return false;
2105 }
2106 function isEventTargetWithin(event, node) {
2107 if (node == null) {
2108 return false;
2109 }
2110 if ("composedPath" in event) {
2111 return event.composedPath().includes(node);
2112 }
2113 const eventAgain = event;
2114 return eventAgain.target != null && node.contains(eventAgain.target);
2115 }
2116 function isRootElement(element) {
2117 return element.matches("html,body");
2118 }
2119 function isTypeableElement(element) {
2120 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2121 }
2122 function isInteractiveElement(element) {
2123 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2124 }
2125 function matchesFocusVisible(element) {
2126 if (!element || isJSDOM) {
2127 return true;
2128 }
2129 try {
2130 return element.matches(":focus-visible");
2131 } catch (_e) {
2132 return true;
2133 }
2134 }
2135
2136 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2137 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2138 const directChildren = nodes.filter((node) => node.parentId === id);
2139 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2140 }
2141
2142 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2143 function isReactEvent(event) {
2144 return "nativeEvent" in event;
2145 }
2146 function isMouseLikePointerType(pointerType, strict) {
2147 const values = ["mouse", "pen"];
2148 if (!strict) {
2149 values.push("", void 0);
2150 }
2151 return values.includes(pointerType);
2152 }
2153 function isClickLikeEvent(event) {
2154 const type = event.type;
2155 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2156 }
2157
2158 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2159 var sides = ["top", "right", "bottom", "left"];
2160 var min = Math.min;
2161 var max = Math.max;
2162 var round = Math.round;
2163 var floor = Math.floor;
2164 var createCoords = (v2) => ({
2165 x: v2,
2166 y: v2
2167 });
2168 var oppositeSideMap = {
2169 left: "right",
2170 right: "left",
2171 bottom: "top",
2172 top: "bottom"
2173 };
2174 function clamp(start, value, end) {
2175 return max(start, min(value, end));
2176 }
2177 function evaluate(value, param) {
2178 return typeof value === "function" ? value(param) : value;
2179 }
2180 function getSide(placement) {
2181 return placement.split("-")[0];
2182 }
2183 function getAlignment(placement) {
2184 return placement.split("-")[1];
2185 }
2186 function getOppositeAxis(axis) {
2187 return axis === "x" ? "y" : "x";
2188 }
2189 function getAxisLength(axis) {
2190 return axis === "y" ? "height" : "width";
2191 }
2192 function getSideAxis(placement) {
2193 const firstChar = placement[0];
2194 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2195 }
2196 function getAlignmentAxis(placement) {
2197 return getOppositeAxis(getSideAxis(placement));
2198 }
2199 function getAlignmentSides(placement, rects, rtl) {
2200 if (rtl === void 0) {
2201 rtl = false;
2202 }
2203 const alignment = getAlignment(placement);
2204 const alignmentAxis = getAlignmentAxis(placement);
2205 const length = getAxisLength(alignmentAxis);
2206 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2207 if (rects.reference[length] > rects.floating[length]) {
2208 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2209 }
2210 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2211 }
2212 function getExpandedPlacements(placement) {
2213 const oppositePlacement = getOppositePlacement(placement);
2214 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2215 }
2216 function getOppositeAlignmentPlacement(placement) {
2217 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2218 }
2219 var lrPlacement = ["left", "right"];
2220 var rlPlacement = ["right", "left"];
2221 var tbPlacement = ["top", "bottom"];
2222 var btPlacement = ["bottom", "top"];
2223 function getSideList(side, isStart, rtl) {
2224 switch (side) {
2225 case "top":
2226 case "bottom":
2227 if (rtl) return isStart ? rlPlacement : lrPlacement;
2228 return isStart ? lrPlacement : rlPlacement;
2229 case "left":
2230 case "right":
2231 return isStart ? tbPlacement : btPlacement;
2232 default:
2233 return [];
2234 }
2235 }
2236 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2237 const alignment = getAlignment(placement);
2238 let list = getSideList(getSide(placement), direction === "start", rtl);
2239 if (alignment) {
2240 list = list.map((side) => side + "-" + alignment);
2241 if (flipAlignment) {
2242 list = list.concat(list.map(getOppositeAlignmentPlacement));
2243 }
2244 }
2245 return list;
2246 }
2247 function getOppositePlacement(placement) {
2248 const side = getSide(placement);
2249 return oppositeSideMap[side] + placement.slice(side.length);
2250 }
2251 function expandPaddingObject(padding) {
2252 return {
2253 top: 0,
2254 right: 0,
2255 bottom: 0,
2256 left: 0,
2257 ...padding
2258 };
2259 }
2260 function getPaddingObject(padding) {
2261 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2262 top: padding,
2263 right: padding,
2264 bottom: padding,
2265 left: padding
2266 };
2267 }
2268 function rectToClientRect(rect) {
2269 const {
2270 x: x2,
2271 y: y2,
2272 width,
2273 height
2274 } = rect;
2275 return {
2276 width,
2277 height,
2278 top: y2,
2279 left: x2,
2280 right: x2 + width,
2281 bottom: y2 + height,
2282 x: x2,
2283 y: y2
2284 };
2285 }
2286
2287 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2288 function isHiddenByStyles(styles) {
2289 return styles.visibility === "hidden" || styles.visibility === "collapse";
2290 }
2291 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2292 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2293 return false;
2294 }
2295 if (typeof element.checkVisibility === "function") {
2296 return element.checkVisibility();
2297 }
2298 return styles.display !== "none" && styles.display !== "contents";
2299 }
2300
2301 // node_modules/@base-ui/utils/esm/owner.js
2302 function ownerDocument(node) {
2303 return node?.ownerDocument || document;
2304 }
2305
2306 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2307 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2308 function getParentElement(element) {
2309 const assignedSlot = element.assignedSlot;
2310 if (assignedSlot) {
2311 return assignedSlot;
2312 }
2313 if (element.parentElement) {
2314 return element.parentElement;
2315 }
2316 const rootNode = element.getRootNode();
2317 return isShadowRoot(rootNode) ? rootNode.host : null;
2318 }
2319 function getDetailsSummary(details) {
2320 for (const child of Array.from(details.children)) {
2321 if (getNodeName(child) === "summary") {
2322 return child;
2323 }
2324 }
2325 return null;
2326 }
2327 function isWithinOpenDetailsSummary(element, details) {
2328 const summary = getDetailsSummary(details);
2329 return !!summary && (element === summary || contains(summary, element));
2330 }
2331 function isFocusableCandidate(element) {
2332 const nodeName = element ? getNodeName(element) : "";
2333 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");
2334 }
2335 function isFocusableElement(element) {
2336 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2337 return false;
2338 }
2339 for (let current = element; current; current = getParentElement(current)) {
2340 const isAncestor = current !== element;
2341 const isSlot = getNodeName(current) === "slot";
2342 if (current.hasAttribute("inert")) {
2343 return false;
2344 }
2345 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2346 return false;
2347 }
2348 }
2349 return true;
2350 }
2351 function isVisibleInTabbableTree(element, isAncestor) {
2352 const styles = getComputedStyle2(element);
2353 if (!isAncestor) {
2354 return isElementVisible(element, styles);
2355 }
2356 return styles.display !== "none";
2357 }
2358 function getTabIndex(element) {
2359 const tabIndex = element.tabIndex;
2360 if (tabIndex < 0) {
2361 const nodeName = getNodeName(element);
2362 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2363 return 0;
2364 }
2365 }
2366 return tabIndex;
2367 }
2368 function getNamedRadioInput(element) {
2369 if (getNodeName(element) !== "input") {
2370 return null;
2371 }
2372 const input = element;
2373 return input.type === "radio" && input.name !== "" ? input : null;
2374 }
2375 function isTabbableRadio(element, candidates) {
2376 const input = getNamedRadioInput(element);
2377 if (!input) {
2378 return true;
2379 }
2380 const checkedRadio = candidates.find((candidate) => {
2381 const radio = getNamedRadioInput(candidate);
2382 return radio?.name === input.name && radio.form === input.form && radio.checked;
2383 });
2384 if (checkedRadio) {
2385 return checkedRadio === input;
2386 }
2387 return candidates.find((candidate) => {
2388 const radio = getNamedRadioInput(candidate);
2389 return radio?.name === input.name && radio.form === input.form;
2390 }) === input;
2391 }
2392 function getComposedChildren(container) {
2393 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2394 const assignedElements = container.assignedElements({
2395 flatten: true
2396 });
2397 if (assignedElements.length > 0) {
2398 return assignedElements;
2399 }
2400 }
2401 if (isHTMLElement(container) && container.shadowRoot) {
2402 return Array.from(container.shadowRoot.children);
2403 }
2404 return Array.from(container.children);
2405 }
2406 function appendCandidates(container, list) {
2407 getComposedChildren(container).forEach((child) => {
2408 if (isFocusableCandidate(child)) {
2409 list.push(child);
2410 }
2411 appendCandidates(child, list);
2412 });
2413 }
2414 function appendMatchingElements(container, selector2, list) {
2415 getComposedChildren(container).forEach((child) => {
2416 if (isHTMLElement(child) && child.matches(selector2)) {
2417 list.push(child);
2418 }
2419 appendMatchingElements(child, selector2, list);
2420 });
2421 }
2422 function focusable(container) {
2423 const candidates = [];
2424 appendCandidates(container, candidates);
2425 return candidates.filter(isFocusableElement);
2426 }
2427 function tabbable(container) {
2428 const candidates = focusable(container);
2429 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2430 }
2431 function getTabbableIn(container, dir) {
2432 const list = tabbable(container);
2433 const len = list.length;
2434 if (len === 0) {
2435 return void 0;
2436 }
2437 const active = activeElement(ownerDocument(container));
2438 const index2 = list.indexOf(active);
2439 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2440 return list[nextIndex];
2441 }
2442 function getNextTabbable(referenceElement) {
2443 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2444 }
2445 function getPreviousTabbable(referenceElement) {
2446 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2447 }
2448 function isOutsideEvent(event, container) {
2449 const containerElement = container || event.currentTarget;
2450 const relatedTarget = event.relatedTarget;
2451 return !relatedTarget || !contains(containerElement, relatedTarget);
2452 }
2453 function disableFocusInside(container) {
2454 const tabbableElements = tabbable(container);
2455 tabbableElements.forEach((element) => {
2456 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2457 element.setAttribute("tabindex", "-1");
2458 });
2459 }
2460 function enableFocusInside(container) {
2461 const elements = [];
2462 appendMatchingElements(container, "[data-tabindex]", elements);
2463 elements.forEach((element) => {
2464 const tabindex = element.dataset.tabindex;
2465 delete element.dataset.tabindex;
2466 if (tabindex) {
2467 element.setAttribute("tabindex", tabindex);
2468 } else {
2469 element.removeAttribute("tabindex");
2470 }
2471 });
2472 }
2473
2474 // node_modules/@base-ui/utils/esm/addEventListener.js
2475 function addEventListener(target, type, listener, options) {
2476 target.addEventListener(type, listener, options);
2477 return () => {
2478 target.removeEventListener(type, listener, options);
2479 };
2480 }
2481
2482 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2483 function useValueAsRef(value) {
2484 const latest = useRefWithInit(createLatestRef, value).current;
2485 latest.next = value;
2486 useIsoLayoutEffect(latest.effect);
2487 return latest;
2488 }
2489 function createLatestRef(value) {
2490 const latest = {
2491 current: value,
2492 next: value,
2493 effect: () => {
2494 latest.current = latest.next;
2495 }
2496 };
2497 return latest;
2498 }
2499
2500 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2501 var React11 = __toESM(require_react(), 1);
2502
2503 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2504 var ReactDOM = __toESM(require_react_dom(), 1);
2505
2506 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2507 function resolveRef(maybeRef) {
2508 if (maybeRef == null) {
2509 return maybeRef;
2510 }
2511 return "current" in maybeRef ? maybeRef.current : maybeRef;
2512 }
2513
2514 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2515 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2516 const frame = useAnimationFrame();
2517 return useStableCallback((fnToExecute, signal = null) => {
2518 frame.cancel();
2519 const element = resolveRef(elementOrRef);
2520 if (element == null) {
2521 return;
2522 }
2523 const resolvedElement = element;
2524 const done = () => {
2525 ReactDOM.flushSync(fnToExecute);
2526 };
2527 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2528 fnToExecute();
2529 return;
2530 }
2531 function exec() {
2532 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2533 if (!signal?.aborted) {
2534 done();
2535 }
2536 }).catch(() => {
2537 if (treatAbortedAsFinished) {
2538 if (!signal?.aborted) {
2539 done();
2540 }
2541 return;
2542 }
2543 const currentAnimations = resolvedElement.getAnimations();
2544 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2545 exec();
2546 }
2547 });
2548 }
2549 if (waitForStartingStyleRemoved) {
2550 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2551 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2552 frame.request(exec);
2553 return;
2554 }
2555 const attributeObserver = new MutationObserver(() => {
2556 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2557 attributeObserver.disconnect();
2558 exec();
2559 }
2560 });
2561 attributeObserver.observe(resolvedElement, {
2562 attributes: true,
2563 attributeFilter: [startingStyleAttribute]
2564 });
2565 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2566 once: true
2567 });
2568 return;
2569 }
2570 frame.request(exec);
2571 });
2572 }
2573
2574 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2575 function useOpenChangeComplete(parameters) {
2576 const {
2577 enabled = true,
2578 open,
2579 ref,
2580 onComplete: onCompleteParam
2581 } = parameters;
2582 const onComplete = useStableCallback(onCompleteParam);
2583 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2584 React11.useEffect(() => {
2585 if (!enabled) {
2586 return void 0;
2587 }
2588 const abortController = new AbortController();
2589 runOnceAnimationsFinish(onComplete, abortController.signal);
2590 return () => {
2591 abortController.abort();
2592 };
2593 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2594 }
2595
2596 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2597 var React12 = __toESM(require_react(), 1);
2598 function useOnFirstRender(fn) {
2599 const ref = React12.useRef(true);
2600 if (ref.current) {
2601 ref.current = false;
2602 fn();
2603 }
2604 }
2605
2606 // node_modules/@base-ui/utils/esm/useTimeout.js
2607 var EMPTY3 = 0;
2608 var Timeout = class _Timeout {
2609 static create() {
2610 return new _Timeout();
2611 }
2612 currentId = EMPTY3;
2613 /**
2614 * Executes `fn` after `delay`, clearing any previously scheduled call.
2615 */
2616 start(delay, fn) {
2617 this.clear();
2618 this.currentId = setTimeout(() => {
2619 this.currentId = EMPTY3;
2620 fn();
2621 }, delay);
2622 }
2623 isStarted() {
2624 return this.currentId !== EMPTY3;
2625 }
2626 clear = () => {
2627 if (this.currentId !== EMPTY3) {
2628 clearTimeout(this.currentId);
2629 this.currentId = EMPTY3;
2630 }
2631 };
2632 disposeEffect = () => {
2633 return this.clear;
2634 };
2635 };
2636 function useTimeout() {
2637 const timeout = useRefWithInit(Timeout.create).current;
2638 useOnMount(timeout.disposeEffect);
2639 return timeout;
2640 }
2641
2642 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2643 var React13 = __toESM(require_react(), 1);
2644
2645 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2646 function resolveValue(value, pointerType) {
2647 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2648 return 0;
2649 }
2650 if (typeof value === "function") {
2651 return value();
2652 }
2653 return value;
2654 }
2655 function getDelay(value, prop, pointerType) {
2656 const result = resolveValue(value, pointerType);
2657 if (typeof result === "number") {
2658 return result;
2659 }
2660 return result?.[prop];
2661 }
2662 function getRestMs(value) {
2663 if (typeof value === "function") {
2664 return value();
2665 }
2666 return value;
2667 }
2668 function isClickLikeOpenEvent(openEventType, interactedInside) {
2669 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2670 }
2671 function isHoverOpenEvent(openEventType) {
2672 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2673 }
2674
2675 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2676 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
2677 var FloatingDelayGroupContext = /* @__PURE__ */ React13.createContext({
2678 hasProvider: false,
2679 timeoutMs: 0,
2680 delayRef: {
2681 current: 0
2682 },
2683 initialDelayRef: {
2684 current: 0
2685 },
2686 timeout: new Timeout(),
2687 currentIdRef: {
2688 current: null
2689 },
2690 currentContextRef: {
2691 current: null
2692 }
2693 });
2694 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2695 function FloatingDelayGroup(props) {
2696 const {
2697 children,
2698 delay,
2699 timeoutMs = 0
2700 } = props;
2701 const delayRef = React13.useRef(delay);
2702 const initialDelayRef = React13.useRef(delay);
2703 const currentIdRef = React13.useRef(null);
2704 const currentContextRef = React13.useRef(null);
2705 const timeout = useTimeout();
2706 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(FloatingDelayGroupContext.Provider, {
2707 value: React13.useMemo(() => ({
2708 hasProvider: true,
2709 delayRef,
2710 initialDelayRef,
2711 currentIdRef,
2712 timeoutMs,
2713 currentContextRef,
2714 timeout
2715 }), [timeoutMs, timeout]),
2716 children
2717 });
2718 }
2719 function useDelayGroup(context, options = {
2720 open: false
2721 }) {
2722 const {
2723 open
2724 } = options;
2725 const store = "rootStore" in context ? context.rootStore : context;
2726 const floatingId = store.useState("floatingId");
2727 const groupContext = React13.useContext(FloatingDelayGroupContext);
2728 const {
2729 currentIdRef,
2730 delayRef,
2731 timeoutMs,
2732 initialDelayRef,
2733 currentContextRef,
2734 hasProvider,
2735 timeout
2736 } = groupContext;
2737 const [isInstantPhase, setIsInstantPhase] = React13.useState(false);
2738 useIsoLayoutEffect(() => {
2739 function unset() {
2740 setIsInstantPhase(false);
2741 currentContextRef.current?.setIsInstantPhase(false);
2742 currentIdRef.current = null;
2743 currentContextRef.current = null;
2744 delayRef.current = initialDelayRef.current;
2745 }
2746 if (!currentIdRef.current) {
2747 return void 0;
2748 }
2749 if (!open && currentIdRef.current === floatingId) {
2750 setIsInstantPhase(false);
2751 if (timeoutMs) {
2752 const closingId = floatingId;
2753 timeout.start(timeoutMs, () => {
2754 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2755 return;
2756 }
2757 unset();
2758 });
2759 return () => {
2760 timeout.clear();
2761 };
2762 }
2763 unset();
2764 }
2765 return void 0;
2766 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2767 useIsoLayoutEffect(() => {
2768 if (!open) {
2769 return;
2770 }
2771 const prevContext = currentContextRef.current;
2772 const prevId = currentIdRef.current;
2773 timeout.clear();
2774 currentContextRef.current = {
2775 onOpenChange: store.setOpen,
2776 setIsInstantPhase
2777 };
2778 currentIdRef.current = floatingId;
2779 delayRef.current = {
2780 open: 0,
2781 close: getDelay(initialDelayRef.current, "close")
2782 };
2783 if (prevId !== null && prevId !== floatingId) {
2784 setIsInstantPhase(true);
2785 prevContext?.setIsInstantPhase(true);
2786 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2787 } else {
2788 setIsInstantPhase(false);
2789 prevContext?.setIsInstantPhase(false);
2790 }
2791 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2792 useIsoLayoutEffect(() => {
2793 return () => {
2794 currentContextRef.current = null;
2795 };
2796 }, [currentContextRef]);
2797 return React13.useMemo(() => ({
2798 hasProvider,
2799 delayRef,
2800 isInstantPhase
2801 }), [hasProvider, delayRef, isInstantPhase]);
2802 }
2803
2804 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2805 function mergeCleanups(...cleanups) {
2806 return () => {
2807 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2808 const cleanup = cleanups[i2];
2809 if (cleanup) {
2810 cleanup();
2811 }
2812 }
2813 };
2814 }
2815
2816 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2817 var React14 = __toESM(require_react(), 1);
2818
2819 // node_modules/@base-ui/utils/esm/visuallyHidden.js
2820 var visuallyHiddenBase = {
2821 clipPath: "inset(50%)",
2822 overflow: "hidden",
2823 whiteSpace: "nowrap",
2824 border: 0,
2825 padding: 0,
2826 width: 1,
2827 height: 1,
2828 margin: -1
2829 };
2830 var visuallyHidden = {
2831 ...visuallyHiddenBase,
2832 position: "fixed",
2833 top: 0,
2834 left: 0
2835 };
2836 var visuallyHiddenInput = {
2837 ...visuallyHiddenBase,
2838 position: "absolute"
2839 };
2840
2841 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
2842 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
2843 var FocusGuard = /* @__PURE__ */ React14.forwardRef(function FocusGuard2(props, ref) {
2844 const [role, setRole] = React14.useState();
2845 useIsoLayoutEffect(() => {
2846 if (isSafari) {
2847 setRole("button");
2848 }
2849 }, []);
2850 const restProps = {
2851 tabIndex: 0,
2852 // Role is only for VoiceOver
2853 role
2854 };
2855 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", {
2856 ...props,
2857 ref,
2858 style: visuallyHidden,
2859 "aria-hidden": role ? void 0 : true,
2860 ...restProps,
2861 "data-base-ui-focus-guard": ""
2862 });
2863 });
2864 if (true) FocusGuard.displayName = "FocusGuard";
2865
2866 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
2867 function createAttribute(name) {
2868 return `data-base-ui-${name}`;
2869 }
2870
2871 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2872 var React15 = __toESM(require_react(), 1);
2873 var ReactDOM2 = __toESM(require_react_dom(), 1);
2874
2875 // node_modules/@base-ui/react/esm/internals/constants.js
2876 var DISABLED_TRANSITIONS_STYLE = {
2877 style: {
2878 transition: "none"
2879 }
2880 };
2881 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2882 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2883 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2884 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2885 var POPUP_COLLISION_AVOIDANCE = {
2886 fallbackAxisSide: "end"
2887 };
2888 var ownerVisuallyHidden = {
2889 clipPath: "inset(50%)",
2890 position: "fixed",
2891 top: 0,
2892 left: 0
2893 };
2894
2895 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
2896 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
2897 var PortalContext = /* @__PURE__ */ React15.createContext(null);
2898 if (true) PortalContext.displayName = "PortalContext";
2899 var usePortalContext = () => React15.useContext(PortalContext);
2900 var attr = createAttribute("portal");
2901 function useFloatingPortalNode(props = {}) {
2902 const {
2903 ref,
2904 container: containerProp,
2905 componentProps = EMPTY_OBJECT,
2906 elementProps
2907 } = props;
2908 const uniqueId = useId();
2909 const portalContext = usePortalContext();
2910 const parentPortalNode = portalContext?.portalNode;
2911 const [containerElement, setContainerElement] = React15.useState(null);
2912 const [portalNode, setPortalNode] = React15.useState(null);
2913 const setPortalNodeRef = useStableCallback((node) => {
2914 if (node !== null) {
2915 setPortalNode(node);
2916 }
2917 });
2918 const containerRef = React15.useRef(null);
2919 useIsoLayoutEffect(() => {
2920 if (containerProp === null) {
2921 if (containerRef.current) {
2922 containerRef.current = null;
2923 setPortalNode(null);
2924 setContainerElement(null);
2925 }
2926 return;
2927 }
2928 if (uniqueId == null) {
2929 return;
2930 }
2931 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
2932 if (resolvedContainer == null) {
2933 if (containerRef.current) {
2934 containerRef.current = null;
2935 setPortalNode(null);
2936 setContainerElement(null);
2937 }
2938 return;
2939 }
2940 if (containerRef.current !== resolvedContainer) {
2941 containerRef.current = resolvedContainer;
2942 setPortalNode(null);
2943 setContainerElement(resolvedContainer);
2944 }
2945 }, [containerProp, parentPortalNode, uniqueId]);
2946 const portalElement = useRenderElement("div", componentProps, {
2947 ref: [ref, setPortalNodeRef],
2948 props: [{
2949 id: uniqueId,
2950 [attr]: ""
2951 }, elementProps]
2952 });
2953 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
2954 return {
2955 portalNode,
2956 portalSubtree
2957 };
2958 }
2959 var FloatingPortal = /* @__PURE__ */ React15.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
2960 const {
2961 render: render4,
2962 className,
2963 style,
2964 children,
2965 container,
2966 renderGuards,
2967 ...elementProps
2968 } = componentProps;
2969 const {
2970 portalNode,
2971 portalSubtree
2972 } = useFloatingPortalNode({
2973 container,
2974 ref: forwardedRef,
2975 componentProps,
2976 elementProps
2977 });
2978 const beforeOutsideRef = React15.useRef(null);
2979 const afterOutsideRef = React15.useRef(null);
2980 const beforeInsideRef = React15.useRef(null);
2981 const afterInsideRef = React15.useRef(null);
2982 const [focusManagerState, setFocusManagerState] = React15.useState(null);
2983 const focusInsideDisabledRef = React15.useRef(false);
2984 const modal = focusManagerState?.modal;
2985 const open = focusManagerState?.open;
2986 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
2987 React15.useEffect(() => {
2988 if (!portalNode || modal) {
2989 return void 0;
2990 }
2991 function onFocus(event) {
2992 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
2993 if (event.type === "focusin") {
2994 if (focusInsideDisabledRef.current) {
2995 enableFocusInside(portalNode);
2996 focusInsideDisabledRef.current = false;
2997 }
2998 } else {
2999 disableFocusInside(portalNode);
3000 focusInsideDisabledRef.current = true;
3001 }
3002 }
3003 }
3004 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3005 }, [portalNode, modal]);
3006 React15.useEffect(() => {
3007 if (!portalNode || open !== false) {
3008 return;
3009 }
3010 enableFocusInside(portalNode);
3011 focusInsideDisabledRef.current = false;
3012 }, [open, portalNode]);
3013 const portalContextValue = React15.useMemo(() => ({
3014 beforeOutsideRef,
3015 afterOutsideRef,
3016 beforeInsideRef,
3017 afterInsideRef,
3018 portalNode,
3019 setFocusManagerState
3020 }), [portalNode]);
3021 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(React15.Fragment, {
3022 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(PortalContext.Provider, {
3023 value: portalContextValue,
3024 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3025 "data-type": "outside",
3026 ref: beforeOutsideRef,
3027 onFocus: (event) => {
3028 if (isOutsideEvent(event, portalNode)) {
3029 beforeInsideRef.current?.focus();
3030 } else {
3031 const domReference = focusManagerState ? focusManagerState.domReference : null;
3032 const prevTabbable = getPreviousTabbable(domReference);
3033 prevTabbable?.focus();
3034 }
3035 }
3036 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", {
3037 "aria-owns": portalNode.id,
3038 style: ownerVisuallyHidden
3039 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FocusGuard, {
3040 "data-type": "outside",
3041 ref: afterOutsideRef,
3042 onFocus: (event) => {
3043 if (isOutsideEvent(event, portalNode)) {
3044 afterInsideRef.current?.focus();
3045 } else {
3046 const domReference = focusManagerState ? focusManagerState.domReference : null;
3047 const nextTabbable = getNextTabbable(domReference);
3048 nextTabbable?.focus();
3049 if (focusManagerState?.closeOnFocusOut) {
3050 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3051 }
3052 }
3053 }
3054 })]
3055 })]
3056 });
3057 });
3058 if (true) FloatingPortal.displayName = "FloatingPortal";
3059
3060 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3061 var React16 = __toESM(require_react(), 1);
3062
3063 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3064 function createEventEmitter() {
3065 const map = /* @__PURE__ */ new Map();
3066 return {
3067 emit(event, data) {
3068 map.get(event)?.forEach((listener) => listener(data));
3069 },
3070 on(event, listener) {
3071 if (!map.has(event)) {
3072 map.set(event, /* @__PURE__ */ new Set());
3073 }
3074 map.get(event).add(listener);
3075 },
3076 off(event, listener) {
3077 map.get(event)?.delete(listener);
3078 }
3079 };
3080 }
3081
3082 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3083 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3084 var FloatingNodeContext = /* @__PURE__ */ React16.createContext(null);
3085 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3086 var FloatingTreeContext = /* @__PURE__ */ React16.createContext(null);
3087 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3088 var useFloatingParentNodeId = () => React16.useContext(FloatingNodeContext)?.id || null;
3089 var useFloatingTree = (externalTree) => {
3090 const contextTree = React16.useContext(FloatingTreeContext);
3091 return externalTree ?? contextTree;
3092 };
3093
3094 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3095 var React17 = __toESM(require_react(), 1);
3096 function createVirtualElement(domElement, data) {
3097 let offsetX = null;
3098 let offsetY = null;
3099 let isAutoUpdateEvent = false;
3100 return {
3101 contextElement: domElement || void 0,
3102 getBoundingClientRect() {
3103 const domRect = domElement?.getBoundingClientRect() || {
3104 width: 0,
3105 height: 0,
3106 x: 0,
3107 y: 0
3108 };
3109 const isXAxis = data.axis === "x" || data.axis === "both";
3110 const isYAxis = data.axis === "y" || data.axis === "both";
3111 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3112 let width = domRect.width;
3113 let height = domRect.height;
3114 let x2 = domRect.x;
3115 let y2 = domRect.y;
3116 if (offsetX == null && data.x && isXAxis) {
3117 offsetX = domRect.x - data.x;
3118 }
3119 if (offsetY == null && data.y && isYAxis) {
3120 offsetY = domRect.y - data.y;
3121 }
3122 x2 -= offsetX || 0;
3123 y2 -= offsetY || 0;
3124 width = 0;
3125 height = 0;
3126 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3127 width = data.axis === "y" ? domRect.width : 0;
3128 height = data.axis === "x" ? domRect.height : 0;
3129 x2 = isXAxis && data.x != null ? data.x : x2;
3130 y2 = isYAxis && data.y != null ? data.y : y2;
3131 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3132 height = data.axis === "x" ? domRect.height : height;
3133 width = data.axis === "y" ? domRect.width : width;
3134 }
3135 isAutoUpdateEvent = true;
3136 return {
3137 width,
3138 height,
3139 x: x2,
3140 y: y2,
3141 top: y2,
3142 right: x2 + width,
3143 bottom: y2 + height,
3144 left: x2
3145 };
3146 }
3147 };
3148 }
3149 function isMouseBasedEvent(event) {
3150 return event != null && event.clientX != null;
3151 }
3152 function useClientPoint(context, props = {}) {
3153 const {
3154 enabled = true,
3155 axis = "both"
3156 } = props;
3157 const store = "rootStore" in context ? context.rootStore : context;
3158 const open = store.useState("open");
3159 const floating = store.useState("floatingElement");
3160 const domReference = store.useState("domReferenceElement");
3161 const dataRef = store.context.dataRef;
3162 const initialRef = React17.useRef(false);
3163 const cleanupListenerRef = React17.useRef(null);
3164 const [pointerType, setPointerType] = React17.useState();
3165 const [reactive, setReactive] = React17.useState([]);
3166 const resetReference = useStableCallback((reference2) => {
3167 store.set("positionReference", reference2);
3168 });
3169 const setReference = useStableCallback((newX, newY, referenceElement) => {
3170 if (initialRef.current) {
3171 return;
3172 }
3173 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3174 return;
3175 }
3176 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3177 x: newX,
3178 y: newY,
3179 axis,
3180 dataRef,
3181 pointerType
3182 }));
3183 });
3184 const handleReferenceEnterOrMove = useStableCallback((event) => {
3185 if (!open) {
3186 setReference(event.clientX, event.clientY, event.currentTarget);
3187 } else if (!cleanupListenerRef.current) {
3188 setReference(event.clientX, event.clientY, event.currentTarget);
3189 setReactive([]);
3190 }
3191 });
3192 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3193 React17.useEffect(() => {
3194 if (!enabled) {
3195 resetReference(domReference);
3196 return void 0;
3197 }
3198 if (!openCheck) {
3199 return void 0;
3200 }
3201 function cleanupListener() {
3202 cleanupListenerRef.current?.();
3203 cleanupListenerRef.current = null;
3204 }
3205 const win = getWindow(floating);
3206 function handleMouseMove(event) {
3207 const target = getTarget(event);
3208 if (!contains(floating, target)) {
3209 setReference(event.clientX, event.clientY);
3210 } else {
3211 cleanupListener();
3212 }
3213 }
3214 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3215 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3216 } else {
3217 resetReference(domReference);
3218 }
3219 return cleanupListener;
3220 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3221 React17.useEffect(() => () => {
3222 store.set("positionReference", null);
3223 }, [store]);
3224 React17.useEffect(() => {
3225 if (enabled && !floating) {
3226 initialRef.current = false;
3227 }
3228 }, [enabled, floating]);
3229 React17.useEffect(() => {
3230 if (!enabled && open) {
3231 initialRef.current = true;
3232 }
3233 }, [enabled, open]);
3234 const reference = React17.useMemo(() => {
3235 function setPointerTypeRef(event) {
3236 setPointerType(event.pointerType);
3237 }
3238 return {
3239 onPointerDown: setPointerTypeRef,
3240 onPointerEnter: setPointerTypeRef,
3241 onMouseMove: handleReferenceEnterOrMove,
3242 onMouseEnter: handleReferenceEnterOrMove
3243 };
3244 }, [handleReferenceEnterOrMove]);
3245 return React17.useMemo(() => enabled ? {
3246 reference,
3247 trigger: reference
3248 } : {}, [enabled, reference]);
3249 }
3250
3251 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3252 var React18 = __toESM(require_react(), 1);
3253 var bubbleHandlerKeys = {
3254 intentional: "onClick",
3255 sloppy: "onPointerDown"
3256 };
3257 function alwaysFalse() {
3258 return false;
3259 }
3260 function normalizeProp(normalizable) {
3261 return {
3262 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3263 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3264 };
3265 }
3266 function useDismiss(context, props = {}) {
3267 const {
3268 enabled = true,
3269 escapeKey: escapeKey2 = true,
3270 outsidePress: outsidePressProp = true,
3271 outsidePressEvent = "sloppy",
3272 referencePress = alwaysFalse,
3273 referencePressEvent = "sloppy",
3274 bubbles,
3275 externalTree
3276 } = props;
3277 const store = "rootStore" in context ? context.rootStore : context;
3278 const open = store.useState("open");
3279 const floatingElement = store.useState("floatingElement");
3280 const {
3281 dataRef
3282 } = store.context;
3283 const tree = useFloatingTree(externalTree);
3284 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3285 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3286 const outsidePressEnabled = outsidePress2 !== false;
3287 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3288 const {
3289 escapeKey: escapeKeyBubbles,
3290 outsidePress: outsidePressBubbles
3291 } = normalizeProp(bubbles);
3292 const pressStartedInsideRef = React18.useRef(false);
3293 const pressStartPreventedRef = React18.useRef(false);
3294 const suppressNextOutsideClickRef = React18.useRef(false);
3295 const isComposingRef = React18.useRef(false);
3296 const currentPointerTypeRef = React18.useRef("");
3297 const touchStateRef = React18.useRef(null);
3298 const cancelDismissOnEndTimeout = useTimeout();
3299 const clearInsideReactTreeTimeout = useTimeout();
3300 const clearInsideReactTree = useStableCallback(() => {
3301 clearInsideReactTreeTimeout.clear();
3302 dataRef.current.insideReactTree = false;
3303 });
3304 const hasBlockingChild = useStableCallback((bubbleKey) => {
3305 const nodeId = dataRef.current.floatingContext?.nodeId;
3306 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3307 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3308 });
3309 const isEventWithinOwnElements = useStableCallback((event) => {
3310 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3311 });
3312 const closeOnReferencePress = useStableCallback((event) => {
3313 if (!referencePress()) {
3314 return;
3315 }
3316 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3317 });
3318 const closeOnEscapeKeyDown = useStableCallback((event) => {
3319 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3320 return;
3321 }
3322 if (isComposingRef.current) {
3323 return;
3324 }
3325 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3326 return;
3327 }
3328 const native = isReactEvent(event) ? event.nativeEvent : event;
3329 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3330 store.setOpen(false, eventDetails);
3331 if (!eventDetails.isCanceled) {
3332 event.preventDefault();
3333 }
3334 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3335 event.stopPropagation();
3336 }
3337 });
3338 const markInsideReactTree = useStableCallback(() => {
3339 dataRef.current.insideReactTree = true;
3340 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3341 });
3342 const markPressStartedInsideReactTree = useStableCallback((event) => {
3343 if (!open || !enabled || event.button !== 0) {
3344 return;
3345 }
3346 const target = getTarget(event.nativeEvent);
3347 if (!contains(store.select("floatingElement"), target)) {
3348 return;
3349 }
3350 if (!pressStartedInsideRef.current) {
3351 pressStartedInsideRef.current = true;
3352 pressStartPreventedRef.current = false;
3353 }
3354 });
3355 const markInsidePressStartPrevented = useStableCallback((event) => {
3356 if (!open || !enabled) {
3357 return;
3358 }
3359 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3360 return;
3361 }
3362 if (pressStartedInsideRef.current) {
3363 pressStartPreventedRef.current = true;
3364 }
3365 });
3366 React18.useEffect(() => {
3367 if (!open || !enabled) {
3368 return void 0;
3369 }
3370 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3371 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3372 const compositionTimeout = new Timeout();
3373 const preventedPressSuppressionTimeout = new Timeout();
3374 function handleCompositionStart() {
3375 compositionTimeout.clear();
3376 isComposingRef.current = true;
3377 }
3378 function handleCompositionEnd() {
3379 compositionTimeout.start(
3380 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3381 // Only apply to WebKit for the test to remain 0ms.
3382 isWebKit() ? 5 : 0,
3383 () => {
3384 isComposingRef.current = false;
3385 }
3386 );
3387 }
3388 function suppressImmediateOutsideClickAfterPreventedStart() {
3389 suppressNextOutsideClickRef.current = true;
3390 preventedPressSuppressionTimeout.start(0, () => {
3391 suppressNextOutsideClickRef.current = false;
3392 });
3393 }
3394 function resetPressStartState() {
3395 pressStartedInsideRef.current = false;
3396 pressStartPreventedRef.current = false;
3397 }
3398 function getOutsidePressEvent() {
3399 const type = currentPointerTypeRef.current;
3400 const computedType = type === "pen" || !type ? "mouse" : type;
3401 const outsidePressEventValue = getOutsidePressEventProp();
3402 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3403 if (typeof resolved === "string") {
3404 return resolved;
3405 }
3406 return resolved[computedType];
3407 }
3408 function shouldIgnoreEvent(event) {
3409 const computedOutsidePressEvent = getOutsidePressEvent();
3410 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3411 }
3412 function isEventWithinFloatingTree(event) {
3413 const nodeId = dataRef.current.floatingContext?.nodeId;
3414 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3415 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3416 }
3417 function closeOnPressOutside(event) {
3418 if (shouldIgnoreEvent(event)) {
3419 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3420 preventedPressSuppressionTimeout.clear();
3421 suppressNextOutsideClickRef.current = false;
3422 }
3423 clearInsideReactTree();
3424 return;
3425 }
3426 if (dataRef.current.insideReactTree) {
3427 clearInsideReactTree();
3428 return;
3429 }
3430 const target = getTarget(event);
3431 const inertSelector = `[${createAttribute("inert")}]`;
3432 const targetRoot = isElement(target) ? target.getRootNode() : null;
3433 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3434 const triggers = store.context.triggerElements;
3435 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3436 return;
3437 }
3438 let targetRootAncestor = isElement(target) ? target : null;
3439 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3440 const nextParent = getParentNode(targetRootAncestor);
3441 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3442 break;
3443 }
3444 targetRootAncestor = nextParent;
3445 }
3446 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3447 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3448 // element was injected after the floating element rendered.
3449 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3450 return;
3451 }
3452 if (isHTMLElement(target) && !("touches" in event)) {
3453 const lastTraversableNode = isLastTraversableNode(target);
3454 const style = getComputedStyle2(target);
3455 const scrollRe = /auto|scroll/;
3456 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3457 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3458 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3459 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3460 const isRTL7 = style.direction === "rtl";
3461 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3462 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3463 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3464 return;
3465 }
3466 }
3467 if (isEventWithinFloatingTree(event)) {
3468 return;
3469 }
3470 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3471 preventedPressSuppressionTimeout.clear();
3472 suppressNextOutsideClickRef.current = false;
3473 return;
3474 }
3475 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3476 return;
3477 }
3478 if (hasBlockingChild("__outsidePressBubbles")) {
3479 return;
3480 }
3481 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3482 clearInsideReactTree();
3483 }
3484 function handlePointerDown(event) {
3485 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3486 return;
3487 }
3488 closeOnPressOutside(event);
3489 }
3490 function handleTouchStart(event) {
3491 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3492 return;
3493 }
3494 const touch = event.touches[0];
3495 if (touch) {
3496 touchStateRef.current = {
3497 startTime: Date.now(),
3498 startX: touch.clientX,
3499 startY: touch.clientY,
3500 dismissOnTouchEnd: false,
3501 dismissOnMouseDown: true
3502 };
3503 cancelDismissOnEndTimeout.start(1e3, () => {
3504 if (touchStateRef.current) {
3505 touchStateRef.current.dismissOnTouchEnd = false;
3506 touchStateRef.current.dismissOnMouseDown = false;
3507 }
3508 });
3509 }
3510 }
3511 function addTargetEventListenerOnce(event, listener) {
3512 const target = getTarget(event);
3513 if (!target) {
3514 return;
3515 }
3516 const unsubscribe2 = addEventListener(target, event.type, () => {
3517 listener(event);
3518 unsubscribe2();
3519 });
3520 }
3521 function handleTouchStartCapture(event) {
3522 currentPointerTypeRef.current = "touch";
3523 addTargetEventListenerOnce(event, handleTouchStart);
3524 }
3525 function closeOnPressOutsideCapture(event) {
3526 cancelDismissOnEndTimeout.clear();
3527 if (event.type === "pointerdown") {
3528 currentPointerTypeRef.current = event.pointerType;
3529 }
3530 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3531 return;
3532 }
3533 addTargetEventListenerOnce(event, (targetEvent) => {
3534 if (targetEvent.type === "pointerdown") {
3535 handlePointerDown(targetEvent);
3536 } else {
3537 closeOnPressOutside(targetEvent);
3538 }
3539 });
3540 }
3541 function handlePressEndCapture(event) {
3542 if (!pressStartedInsideRef.current) {
3543 return;
3544 }
3545 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3546 resetPressStartState();
3547 if (getOutsidePressEvent() !== "intentional") {
3548 return;
3549 }
3550 if (event.type === "pointercancel") {
3551 if (pressStartedInsideDefaultPrevented) {
3552 suppressImmediateOutsideClickAfterPreventedStart();
3553 }
3554 return;
3555 }
3556 if (isEventWithinFloatingTree(event)) {
3557 return;
3558 }
3559 if (pressStartedInsideDefaultPrevented) {
3560 suppressImmediateOutsideClickAfterPreventedStart();
3561 return;
3562 }
3563 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3564 return;
3565 }
3566 preventedPressSuppressionTimeout.clear();
3567 suppressNextOutsideClickRef.current = true;
3568 clearInsideReactTree();
3569 }
3570 function handleTouchMove(event) {
3571 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3572 return;
3573 }
3574 const touch = event.touches[0];
3575 if (!touch) {
3576 return;
3577 }
3578 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3579 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3580 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3581 if (distance > 5) {
3582 touchStateRef.current.dismissOnTouchEnd = true;
3583 }
3584 if (distance > 10) {
3585 closeOnPressOutside(event);
3586 cancelDismissOnEndTimeout.clear();
3587 touchStateRef.current = null;
3588 }
3589 }
3590 function handleTouchMoveCapture(event) {
3591 addTargetEventListenerOnce(event, handleTouchMove);
3592 }
3593 function handleTouchEnd(event) {
3594 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3595 return;
3596 }
3597 if (touchStateRef.current.dismissOnTouchEnd) {
3598 closeOnPressOutside(event);
3599 }
3600 cancelDismissOnEndTimeout.clear();
3601 touchStateRef.current = null;
3602 }
3603 function handleTouchEndCapture(event) {
3604 addTargetEventListenerOnce(event, handleTouchEnd);
3605 }
3606 const doc = ownerDocument(floatingElement);
3607 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)));
3608 return () => {
3609 unsubscribe();
3610 compositionTimeout.clear();
3611 preventedPressSuppressionTimeout.clear();
3612 resetPressStartState();
3613 suppressNextOutsideClickRef.current = false;
3614 };
3615 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3616 React18.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3617 const reference = React18.useMemo(() => ({
3618 onKeyDown: closeOnEscapeKeyDown,
3619 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3620 ...referencePressEvent !== "intentional" && {
3621 onClick: closeOnReferencePress
3622 }
3623 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3624 const floating = React18.useMemo(() => ({
3625 onKeyDown: closeOnEscapeKeyDown,
3626 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3627 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3628 // See https://github.com/mui/base-ui/pull/3379
3629 onPointerDown: markInsidePressStartPrevented,
3630 onMouseDown: markInsidePressStartPrevented,
3631 onClickCapture: markInsideReactTree,
3632 onMouseDownCapture(event) {
3633 markInsideReactTree();
3634 markPressStartedInsideReactTree(event);
3635 },
3636 onPointerDownCapture(event) {
3637 markInsideReactTree();
3638 markPressStartedInsideReactTree(event);
3639 },
3640 onMouseUpCapture: markInsideReactTree,
3641 onTouchEndCapture: markInsideReactTree,
3642 onTouchMoveCapture: markInsideReactTree
3643 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3644 return React18.useMemo(() => enabled ? {
3645 reference,
3646 floating,
3647 trigger: reference
3648 } : {}, [enabled, reference, floating]);
3649 }
3650
3651 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3652 var React25 = __toESM(require_react(), 1);
3653
3654 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3655 function computeCoordsFromPlacement(_ref, placement, rtl) {
3656 let {
3657 reference,
3658 floating
3659 } = _ref;
3660 const sideAxis = getSideAxis(placement);
3661 const alignmentAxis = getAlignmentAxis(placement);
3662 const alignLength = getAxisLength(alignmentAxis);
3663 const side = getSide(placement);
3664 const isVertical = sideAxis === "y";
3665 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3666 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3667 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3668 let coords;
3669 switch (side) {
3670 case "top":
3671 coords = {
3672 x: commonX,
3673 y: reference.y - floating.height
3674 };
3675 break;
3676 case "bottom":
3677 coords = {
3678 x: commonX,
3679 y: reference.y + reference.height
3680 };
3681 break;
3682 case "right":
3683 coords = {
3684 x: reference.x + reference.width,
3685 y: commonY
3686 };
3687 break;
3688 case "left":
3689 coords = {
3690 x: reference.x - floating.width,
3691 y: commonY
3692 };
3693 break;
3694 default:
3695 coords = {
3696 x: reference.x,
3697 y: reference.y
3698 };
3699 }
3700 switch (getAlignment(placement)) {
3701 case "start":
3702 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3703 break;
3704 case "end":
3705 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3706 break;
3707 }
3708 return coords;
3709 }
3710 async function detectOverflow(state, options) {
3711 var _await$platform$isEle;
3712 if (options === void 0) {
3713 options = {};
3714 }
3715 const {
3716 x: x2,
3717 y: y2,
3718 platform: platform3,
3719 rects,
3720 elements,
3721 strategy
3722 } = state;
3723 const {
3724 boundary = "clippingAncestors",
3725 rootBoundary = "viewport",
3726 elementContext = "floating",
3727 altBoundary = false,
3728 padding = 0
3729 } = evaluate(options, state);
3730 const paddingObject = getPaddingObject(padding);
3731 const altContext = elementContext === "floating" ? "reference" : "floating";
3732 const element = elements[altBoundary ? altContext : elementContext];
3733 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3734 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)),
3735 boundary,
3736 rootBoundary,
3737 strategy
3738 }));
3739 const rect = elementContext === "floating" ? {
3740 x: x2,
3741 y: y2,
3742 width: rects.floating.width,
3743 height: rects.floating.height
3744 } : rects.reference;
3745 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3746 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3747 x: 1,
3748 y: 1
3749 } : {
3750 x: 1,
3751 y: 1
3752 };
3753 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3754 elements,
3755 rect,
3756 offsetParent,
3757 strategy
3758 }) : rect);
3759 return {
3760 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3761 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3762 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3763 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3764 };
3765 }
3766 var MAX_RESET_COUNT = 50;
3767 var computePosition = async (reference, floating, config) => {
3768 const {
3769 placement = "bottom",
3770 strategy = "absolute",
3771 middleware = [],
3772 platform: platform3
3773 } = config;
3774 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3775 ...platform3,
3776 detectOverflow
3777 };
3778 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3779 let rects = await platform3.getElementRects({
3780 reference,
3781 floating,
3782 strategy
3783 });
3784 let {
3785 x: x2,
3786 y: y2
3787 } = computeCoordsFromPlacement(rects, placement, rtl);
3788 let statefulPlacement = placement;
3789 let resetCount = 0;
3790 const middlewareData = {};
3791 for (let i2 = 0; i2 < middleware.length; i2++) {
3792 const currentMiddleware = middleware[i2];
3793 if (!currentMiddleware) {
3794 continue;
3795 }
3796 const {
3797 name,
3798 fn
3799 } = currentMiddleware;
3800 const {
3801 x: nextX,
3802 y: nextY,
3803 data,
3804 reset
3805 } = await fn({
3806 x: x2,
3807 y: y2,
3808 initialPlacement: placement,
3809 placement: statefulPlacement,
3810 strategy,
3811 middlewareData,
3812 rects,
3813 platform: platformWithDetectOverflow,
3814 elements: {
3815 reference,
3816 floating
3817 }
3818 });
3819 x2 = nextX != null ? nextX : x2;
3820 y2 = nextY != null ? nextY : y2;
3821 middlewareData[name] = {
3822 ...middlewareData[name],
3823 ...data
3824 };
3825 if (reset && resetCount < MAX_RESET_COUNT) {
3826 resetCount++;
3827 if (typeof reset === "object") {
3828 if (reset.placement) {
3829 statefulPlacement = reset.placement;
3830 }
3831 if (reset.rects) {
3832 rects = reset.rects === true ? await platform3.getElementRects({
3833 reference,
3834 floating,
3835 strategy
3836 }) : reset.rects;
3837 }
3838 ({
3839 x: x2,
3840 y: y2
3841 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
3842 }
3843 i2 = -1;
3844 }
3845 }
3846 return {
3847 x: x2,
3848 y: y2,
3849 placement: statefulPlacement,
3850 strategy,
3851 middlewareData
3852 };
3853 };
3854 var flip = function(options) {
3855 if (options === void 0) {
3856 options = {};
3857 }
3858 return {
3859 name: "flip",
3860 options,
3861 async fn(state) {
3862 var _middlewareData$arrow, _middlewareData$flip;
3863 const {
3864 placement,
3865 middlewareData,
3866 rects,
3867 initialPlacement,
3868 platform: platform3,
3869 elements
3870 } = state;
3871 const {
3872 mainAxis: checkMainAxis = true,
3873 crossAxis: checkCrossAxis = true,
3874 fallbackPlacements: specifiedFallbackPlacements,
3875 fallbackStrategy = "bestFit",
3876 fallbackAxisSideDirection = "none",
3877 flipAlignment = true,
3878 ...detectOverflowOptions
3879 } = evaluate(options, state);
3880 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
3881 return {};
3882 }
3883 const side = getSide(placement);
3884 const initialSideAxis = getSideAxis(initialPlacement);
3885 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
3886 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
3887 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
3888 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
3889 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
3890 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
3891 }
3892 const placements2 = [initialPlacement, ...fallbackPlacements];
3893 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
3894 const overflows = [];
3895 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
3896 if (checkMainAxis) {
3897 overflows.push(overflow[side]);
3898 }
3899 if (checkCrossAxis) {
3900 const sides2 = getAlignmentSides(placement, rects, rtl);
3901 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
3902 }
3903 overflowsData = [...overflowsData, {
3904 placement,
3905 overflows
3906 }];
3907 if (!overflows.every((side2) => side2 <= 0)) {
3908 var _middlewareData$flip2, _overflowsData$filter;
3909 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
3910 const nextPlacement = placements2[nextIndex];
3911 if (nextPlacement) {
3912 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
3913 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
3914 // overflows the main axis.
3915 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
3916 return {
3917 data: {
3918 index: nextIndex,
3919 overflows: overflowsData
3920 },
3921 reset: {
3922 placement: nextPlacement
3923 }
3924 };
3925 }
3926 }
3927 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;
3928 if (!resetPlacement) {
3929 switch (fallbackStrategy) {
3930 case "bestFit": {
3931 var _overflowsData$filter2;
3932 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
3933 if (hasFallbackAxisSideDirection) {
3934 const currentSideAxis = getSideAxis(d2.placement);
3935 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
3936 // reading directions favoring greater width.
3937 currentSideAxis === "y";
3938 }
3939 return true;
3940 }).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];
3941 if (placement2) {
3942 resetPlacement = placement2;
3943 }
3944 break;
3945 }
3946 case "initialPlacement":
3947 resetPlacement = initialPlacement;
3948 break;
3949 }
3950 }
3951 if (placement !== resetPlacement) {
3952 return {
3953 reset: {
3954 placement: resetPlacement
3955 }
3956 };
3957 }
3958 }
3959 return {};
3960 }
3961 };
3962 };
3963 function getSideOffsets(overflow, rect) {
3964 return {
3965 top: overflow.top - rect.height,
3966 right: overflow.right - rect.width,
3967 bottom: overflow.bottom - rect.height,
3968 left: overflow.left - rect.width
3969 };
3970 }
3971 function isAnySideFullyClipped(overflow) {
3972 return sides.some((side) => overflow[side] >= 0);
3973 }
3974 var hide = function(options) {
3975 if (options === void 0) {
3976 options = {};
3977 }
3978 return {
3979 name: "hide",
3980 options,
3981 async fn(state) {
3982 const {
3983 rects,
3984 platform: platform3
3985 } = state;
3986 const {
3987 strategy = "referenceHidden",
3988 ...detectOverflowOptions
3989 } = evaluate(options, state);
3990 switch (strategy) {
3991 case "referenceHidden": {
3992 const overflow = await platform3.detectOverflow(state, {
3993 ...detectOverflowOptions,
3994 elementContext: "reference"
3995 });
3996 const offsets = getSideOffsets(overflow, rects.reference);
3997 return {
3998 data: {
3999 referenceHiddenOffsets: offsets,
4000 referenceHidden: isAnySideFullyClipped(offsets)
4001 }
4002 };
4003 }
4004 case "escaped": {
4005 const overflow = await platform3.detectOverflow(state, {
4006 ...detectOverflowOptions,
4007 altBoundary: true
4008 });
4009 const offsets = getSideOffsets(overflow, rects.floating);
4010 return {
4011 data: {
4012 escapedOffsets: offsets,
4013 escaped: isAnySideFullyClipped(offsets)
4014 }
4015 };
4016 }
4017 default: {
4018 return {};
4019 }
4020 }
4021 }
4022 };
4023 };
4024 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4025 async function convertValueToCoords(state, options) {
4026 const {
4027 placement,
4028 platform: platform3,
4029 elements
4030 } = state;
4031 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4032 const side = getSide(placement);
4033 const alignment = getAlignment(placement);
4034 const isVertical = getSideAxis(placement) === "y";
4035 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4036 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4037 const rawValue = evaluate(options, state);
4038 let {
4039 mainAxis,
4040 crossAxis,
4041 alignmentAxis
4042 } = typeof rawValue === "number" ? {
4043 mainAxis: rawValue,
4044 crossAxis: 0,
4045 alignmentAxis: null
4046 } : {
4047 mainAxis: rawValue.mainAxis || 0,
4048 crossAxis: rawValue.crossAxis || 0,
4049 alignmentAxis: rawValue.alignmentAxis
4050 };
4051 if (alignment && typeof alignmentAxis === "number") {
4052 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4053 }
4054 return isVertical ? {
4055 x: crossAxis * crossAxisMulti,
4056 y: mainAxis * mainAxisMulti
4057 } : {
4058 x: mainAxis * mainAxisMulti,
4059 y: crossAxis * crossAxisMulti
4060 };
4061 }
4062 var offset = function(options) {
4063 if (options === void 0) {
4064 options = 0;
4065 }
4066 return {
4067 name: "offset",
4068 options,
4069 async fn(state) {
4070 var _middlewareData$offse, _middlewareData$arrow;
4071 const {
4072 x: x2,
4073 y: y2,
4074 placement,
4075 middlewareData
4076 } = state;
4077 const diffCoords = await convertValueToCoords(state, options);
4078 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4079 return {};
4080 }
4081 return {
4082 x: x2 + diffCoords.x,
4083 y: y2 + diffCoords.y,
4084 data: {
4085 ...diffCoords,
4086 placement
4087 }
4088 };
4089 }
4090 };
4091 };
4092 var shift = function(options) {
4093 if (options === void 0) {
4094 options = {};
4095 }
4096 return {
4097 name: "shift",
4098 options,
4099 async fn(state) {
4100 const {
4101 x: x2,
4102 y: y2,
4103 placement,
4104 platform: platform3
4105 } = state;
4106 const {
4107 mainAxis: checkMainAxis = true,
4108 crossAxis: checkCrossAxis = false,
4109 limiter = {
4110 fn: (_ref) => {
4111 let {
4112 x: x3,
4113 y: y3
4114 } = _ref;
4115 return {
4116 x: x3,
4117 y: y3
4118 };
4119 }
4120 },
4121 ...detectOverflowOptions
4122 } = evaluate(options, state);
4123 const coords = {
4124 x: x2,
4125 y: y2
4126 };
4127 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4128 const crossAxis = getSideAxis(getSide(placement));
4129 const mainAxis = getOppositeAxis(crossAxis);
4130 let mainAxisCoord = coords[mainAxis];
4131 let crossAxisCoord = coords[crossAxis];
4132 if (checkMainAxis) {
4133 const minSide = mainAxis === "y" ? "top" : "left";
4134 const maxSide = mainAxis === "y" ? "bottom" : "right";
4135 const min2 = mainAxisCoord + overflow[minSide];
4136 const max2 = mainAxisCoord - overflow[maxSide];
4137 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4138 }
4139 if (checkCrossAxis) {
4140 const minSide = crossAxis === "y" ? "top" : "left";
4141 const maxSide = crossAxis === "y" ? "bottom" : "right";
4142 const min2 = crossAxisCoord + overflow[minSide];
4143 const max2 = crossAxisCoord - overflow[maxSide];
4144 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4145 }
4146 const limitedCoords = limiter.fn({
4147 ...state,
4148 [mainAxis]: mainAxisCoord,
4149 [crossAxis]: crossAxisCoord
4150 });
4151 return {
4152 ...limitedCoords,
4153 data: {
4154 x: limitedCoords.x - x2,
4155 y: limitedCoords.y - y2,
4156 enabled: {
4157 [mainAxis]: checkMainAxis,
4158 [crossAxis]: checkCrossAxis
4159 }
4160 }
4161 };
4162 }
4163 };
4164 };
4165 var limitShift = function(options) {
4166 if (options === void 0) {
4167 options = {};
4168 }
4169 return {
4170 options,
4171 fn(state) {
4172 const {
4173 x: x2,
4174 y: y2,
4175 placement,
4176 rects,
4177 middlewareData
4178 } = state;
4179 const {
4180 offset: offset4 = 0,
4181 mainAxis: checkMainAxis = true,
4182 crossAxis: checkCrossAxis = true
4183 } = evaluate(options, state);
4184 const coords = {
4185 x: x2,
4186 y: y2
4187 };
4188 const crossAxis = getSideAxis(placement);
4189 const mainAxis = getOppositeAxis(crossAxis);
4190 let mainAxisCoord = coords[mainAxis];
4191 let crossAxisCoord = coords[crossAxis];
4192 const rawOffset = evaluate(offset4, state);
4193 const computedOffset = typeof rawOffset === "number" ? {
4194 mainAxis: rawOffset,
4195 crossAxis: 0
4196 } : {
4197 mainAxis: 0,
4198 crossAxis: 0,
4199 ...rawOffset
4200 };
4201 if (checkMainAxis) {
4202 const len = mainAxis === "y" ? "height" : "width";
4203 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4204 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4205 if (mainAxisCoord < limitMin) {
4206 mainAxisCoord = limitMin;
4207 } else if (mainAxisCoord > limitMax) {
4208 mainAxisCoord = limitMax;
4209 }
4210 }
4211 if (checkCrossAxis) {
4212 var _middlewareData$offse, _middlewareData$offse2;
4213 const len = mainAxis === "y" ? "width" : "height";
4214 const isOriginSide = originSides.has(getSide(placement));
4215 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);
4216 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);
4217 if (crossAxisCoord < limitMin) {
4218 crossAxisCoord = limitMin;
4219 } else if (crossAxisCoord > limitMax) {
4220 crossAxisCoord = limitMax;
4221 }
4222 }
4223 return {
4224 [mainAxis]: mainAxisCoord,
4225 [crossAxis]: crossAxisCoord
4226 };
4227 }
4228 };
4229 };
4230 var size = function(options) {
4231 if (options === void 0) {
4232 options = {};
4233 }
4234 return {
4235 name: "size",
4236 options,
4237 async fn(state) {
4238 var _state$middlewareData, _state$middlewareData2;
4239 const {
4240 placement,
4241 rects,
4242 platform: platform3,
4243 elements
4244 } = state;
4245 const {
4246 apply = () => {
4247 },
4248 ...detectOverflowOptions
4249 } = evaluate(options, state);
4250 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4251 const side = getSide(placement);
4252 const alignment = getAlignment(placement);
4253 const isYAxis = getSideAxis(placement) === "y";
4254 const {
4255 width,
4256 height
4257 } = rects.floating;
4258 let heightSide;
4259 let widthSide;
4260 if (side === "top" || side === "bottom") {
4261 heightSide = side;
4262 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4263 } else {
4264 widthSide = side;
4265 heightSide = alignment === "end" ? "top" : "bottom";
4266 }
4267 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4268 const maximumClippingWidth = width - overflow.left - overflow.right;
4269 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4270 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4271 const noShift = !state.middlewareData.shift;
4272 let availableHeight = overflowAvailableHeight;
4273 let availableWidth = overflowAvailableWidth;
4274 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4275 availableWidth = maximumClippingWidth;
4276 }
4277 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4278 availableHeight = maximumClippingHeight;
4279 }
4280 if (noShift && !alignment) {
4281 const xMin = max(overflow.left, 0);
4282 const xMax = max(overflow.right, 0);
4283 const yMin = max(overflow.top, 0);
4284 const yMax = max(overflow.bottom, 0);
4285 if (isYAxis) {
4286 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4287 } else {
4288 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4289 }
4290 }
4291 await apply({
4292 ...state,
4293 availableWidth,
4294 availableHeight
4295 });
4296 const nextDimensions = await platform3.getDimensions(elements.floating);
4297 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4298 return {
4299 reset: {
4300 rects: true
4301 }
4302 };
4303 }
4304 return {};
4305 }
4306 };
4307 };
4308
4309 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4310 function getCssDimensions(element) {
4311 const css = getComputedStyle2(element);
4312 let width = parseFloat(css.width) || 0;
4313 let height = parseFloat(css.height) || 0;
4314 const hasOffset = isHTMLElement(element);
4315 const offsetWidth = hasOffset ? element.offsetWidth : width;
4316 const offsetHeight = hasOffset ? element.offsetHeight : height;
4317 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4318 if (shouldFallback) {
4319 width = offsetWidth;
4320 height = offsetHeight;
4321 }
4322 return {
4323 width,
4324 height,
4325 $: shouldFallback
4326 };
4327 }
4328 function unwrapElement(element) {
4329 return !isElement(element) ? element.contextElement : element;
4330 }
4331 function getScale(element) {
4332 const domElement = unwrapElement(element);
4333 if (!isHTMLElement(domElement)) {
4334 return createCoords(1);
4335 }
4336 const rect = domElement.getBoundingClientRect();
4337 const {
4338 width,
4339 height,
4340 $: $2
4341 } = getCssDimensions(domElement);
4342 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4343 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4344 if (!x2 || !Number.isFinite(x2)) {
4345 x2 = 1;
4346 }
4347 if (!y2 || !Number.isFinite(y2)) {
4348 y2 = 1;
4349 }
4350 return {
4351 x: x2,
4352 y: y2
4353 };
4354 }
4355 var noOffsets = /* @__PURE__ */ createCoords(0);
4356 function getVisualOffsets(element) {
4357 const win = getWindow(element);
4358 if (!isWebKit() || !win.visualViewport) {
4359 return noOffsets;
4360 }
4361 return {
4362 x: win.visualViewport.offsetLeft,
4363 y: win.visualViewport.offsetTop
4364 };
4365 }
4366 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4367 if (isFixed === void 0) {
4368 isFixed = false;
4369 }
4370 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4371 return false;
4372 }
4373 return isFixed;
4374 }
4375 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4376 if (includeScale === void 0) {
4377 includeScale = false;
4378 }
4379 if (isFixedStrategy === void 0) {
4380 isFixedStrategy = false;
4381 }
4382 const clientRect = element.getBoundingClientRect();
4383 const domElement = unwrapElement(element);
4384 let scale = createCoords(1);
4385 if (includeScale) {
4386 if (offsetParent) {
4387 if (isElement(offsetParent)) {
4388 scale = getScale(offsetParent);
4389 }
4390 } else {
4391 scale = getScale(element);
4392 }
4393 }
4394 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4395 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4396 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4397 let width = clientRect.width / scale.x;
4398 let height = clientRect.height / scale.y;
4399 if (domElement) {
4400 const win = getWindow(domElement);
4401 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4402 let currentWin = win;
4403 let currentIFrame = getFrameElement(currentWin);
4404 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4405 const iframeScale = getScale(currentIFrame);
4406 const iframeRect = currentIFrame.getBoundingClientRect();
4407 const css = getComputedStyle2(currentIFrame);
4408 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4409 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4410 x2 *= iframeScale.x;
4411 y2 *= iframeScale.y;
4412 width *= iframeScale.x;
4413 height *= iframeScale.y;
4414 x2 += left;
4415 y2 += top;
4416 currentWin = getWindow(currentIFrame);
4417 currentIFrame = getFrameElement(currentWin);
4418 }
4419 }
4420 return rectToClientRect({
4421 width,
4422 height,
4423 x: x2,
4424 y: y2
4425 });
4426 }
4427 function getWindowScrollBarX(element, rect) {
4428 const leftScroll = getNodeScroll(element).scrollLeft;
4429 if (!rect) {
4430 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4431 }
4432 return rect.left + leftScroll;
4433 }
4434 function getHTMLOffset(documentElement, scroll) {
4435 const htmlRect = documentElement.getBoundingClientRect();
4436 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4437 const y2 = htmlRect.top + scroll.scrollTop;
4438 return {
4439 x: x2,
4440 y: y2
4441 };
4442 }
4443 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4444 let {
4445 elements,
4446 rect,
4447 offsetParent,
4448 strategy
4449 } = _ref;
4450 const isFixed = strategy === "fixed";
4451 const documentElement = getDocumentElement(offsetParent);
4452 const topLayer = elements ? isTopLayer(elements.floating) : false;
4453 if (offsetParent === documentElement || topLayer && isFixed) {
4454 return rect;
4455 }
4456 let scroll = {
4457 scrollLeft: 0,
4458 scrollTop: 0
4459 };
4460 let scale = createCoords(1);
4461 const offsets = createCoords(0);
4462 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4463 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4464 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4465 scroll = getNodeScroll(offsetParent);
4466 }
4467 if (isOffsetParentAnElement) {
4468 const offsetRect = getBoundingClientRect(offsetParent);
4469 scale = getScale(offsetParent);
4470 offsets.x = offsetRect.x + offsetParent.clientLeft;
4471 offsets.y = offsetRect.y + offsetParent.clientTop;
4472 }
4473 }
4474 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4475 return {
4476 width: rect.width * scale.x,
4477 height: rect.height * scale.y,
4478 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4479 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4480 };
4481 }
4482 function getClientRects(element) {
4483 return Array.from(element.getClientRects());
4484 }
4485 function getDocumentRect(element) {
4486 const html = getDocumentElement(element);
4487 const scroll = getNodeScroll(element);
4488 const body = element.ownerDocument.body;
4489 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4490 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4491 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4492 const y2 = -scroll.scrollTop;
4493 if (getComputedStyle2(body).direction === "rtl") {
4494 x2 += max(html.clientWidth, body.clientWidth) - width;
4495 }
4496 return {
4497 width,
4498 height,
4499 x: x2,
4500 y: y2
4501 };
4502 }
4503 var SCROLLBAR_MAX = 25;
4504 function getViewportRect(element, strategy) {
4505 const win = getWindow(element);
4506 const html = getDocumentElement(element);
4507 const visualViewport = win.visualViewport;
4508 let width = html.clientWidth;
4509 let height = html.clientHeight;
4510 let x2 = 0;
4511 let y2 = 0;
4512 if (visualViewport) {
4513 width = visualViewport.width;
4514 height = visualViewport.height;
4515 const visualViewportBased = isWebKit();
4516 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4517 x2 = visualViewport.offsetLeft;
4518 y2 = visualViewport.offsetTop;
4519 }
4520 }
4521 const windowScrollbarX = getWindowScrollBarX(html);
4522 if (windowScrollbarX <= 0) {
4523 const doc = html.ownerDocument;
4524 const body = doc.body;
4525 const bodyStyles = getComputedStyle(body);
4526 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4527 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4528 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4529 width -= clippingStableScrollbarWidth;
4530 }
4531 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4532 width += windowScrollbarX;
4533 }
4534 return {
4535 width,
4536 height,
4537 x: x2,
4538 y: y2
4539 };
4540 }
4541 function getInnerBoundingClientRect(element, strategy) {
4542 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4543 const top = clientRect.top + element.clientTop;
4544 const left = clientRect.left + element.clientLeft;
4545 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4546 const width = element.clientWidth * scale.x;
4547 const height = element.clientHeight * scale.y;
4548 const x2 = left * scale.x;
4549 const y2 = top * scale.y;
4550 return {
4551 width,
4552 height,
4553 x: x2,
4554 y: y2
4555 };
4556 }
4557 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4558 let rect;
4559 if (clippingAncestor === "viewport") {
4560 rect = getViewportRect(element, strategy);
4561 } else if (clippingAncestor === "document") {
4562 rect = getDocumentRect(getDocumentElement(element));
4563 } else if (isElement(clippingAncestor)) {
4564 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4565 } else {
4566 const visualOffsets = getVisualOffsets(element);
4567 rect = {
4568 x: clippingAncestor.x - visualOffsets.x,
4569 y: clippingAncestor.y - visualOffsets.y,
4570 width: clippingAncestor.width,
4571 height: clippingAncestor.height
4572 };
4573 }
4574 return rectToClientRect(rect);
4575 }
4576 function hasFixedPositionAncestor(element, stopNode) {
4577 const parentNode = getParentNode(element);
4578 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4579 return false;
4580 }
4581 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4582 }
4583 function getClippingElementAncestors(element, cache) {
4584 const cachedResult = cache.get(element);
4585 if (cachedResult) {
4586 return cachedResult;
4587 }
4588 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4589 let currentContainingBlockComputedStyle = null;
4590 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4591 let currentNode = elementIsFixed ? getParentNode(element) : element;
4592 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4593 const computedStyle = getComputedStyle2(currentNode);
4594 const currentNodeIsContaining = isContainingBlock(currentNode);
4595 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4596 currentContainingBlockComputedStyle = null;
4597 }
4598 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4599 if (shouldDropCurrentNode) {
4600 result = result.filter((ancestor) => ancestor !== currentNode);
4601 } else {
4602 currentContainingBlockComputedStyle = computedStyle;
4603 }
4604 currentNode = getParentNode(currentNode);
4605 }
4606 cache.set(element, result);
4607 return result;
4608 }
4609 function getClippingRect(_ref) {
4610 let {
4611 element,
4612 boundary,
4613 rootBoundary,
4614 strategy
4615 } = _ref;
4616 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4617 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4618 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4619 let top = firstRect.top;
4620 let right = firstRect.right;
4621 let bottom = firstRect.bottom;
4622 let left = firstRect.left;
4623 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4624 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4625 top = max(rect.top, top);
4626 right = min(rect.right, right);
4627 bottom = min(rect.bottom, bottom);
4628 left = max(rect.left, left);
4629 }
4630 return {
4631 width: right - left,
4632 height: bottom - top,
4633 x: left,
4634 y: top
4635 };
4636 }
4637 function getDimensions(element) {
4638 const {
4639 width,
4640 height
4641 } = getCssDimensions(element);
4642 return {
4643 width,
4644 height
4645 };
4646 }
4647 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4648 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4649 const documentElement = getDocumentElement(offsetParent);
4650 const isFixed = strategy === "fixed";
4651 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4652 let scroll = {
4653 scrollLeft: 0,
4654 scrollTop: 0
4655 };
4656 const offsets = createCoords(0);
4657 function setLeftRTLScrollbarOffset() {
4658 offsets.x = getWindowScrollBarX(documentElement);
4659 }
4660 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4661 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4662 scroll = getNodeScroll(offsetParent);
4663 }
4664 if (isOffsetParentAnElement) {
4665 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4666 offsets.x = offsetRect.x + offsetParent.clientLeft;
4667 offsets.y = offsetRect.y + offsetParent.clientTop;
4668 } else if (documentElement) {
4669 setLeftRTLScrollbarOffset();
4670 }
4671 }
4672 if (isFixed && !isOffsetParentAnElement && documentElement) {
4673 setLeftRTLScrollbarOffset();
4674 }
4675 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4676 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4677 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4678 return {
4679 x: x2,
4680 y: y2,
4681 width: rect.width,
4682 height: rect.height
4683 };
4684 }
4685 function isStaticPositioned(element) {
4686 return getComputedStyle2(element).position === "static";
4687 }
4688 function getTrueOffsetParent(element, polyfill) {
4689 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4690 return null;
4691 }
4692 if (polyfill) {
4693 return polyfill(element);
4694 }
4695 let rawOffsetParent = element.offsetParent;
4696 if (getDocumentElement(element) === rawOffsetParent) {
4697 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4698 }
4699 return rawOffsetParent;
4700 }
4701 function getOffsetParent(element, polyfill) {
4702 const win = getWindow(element);
4703 if (isTopLayer(element)) {
4704 return win;
4705 }
4706 if (!isHTMLElement(element)) {
4707 let svgOffsetParent = getParentNode(element);
4708 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4709 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4710 return svgOffsetParent;
4711 }
4712 svgOffsetParent = getParentNode(svgOffsetParent);
4713 }
4714 return win;
4715 }
4716 let offsetParent = getTrueOffsetParent(element, polyfill);
4717 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4718 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4719 }
4720 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4721 return win;
4722 }
4723 return offsetParent || getContainingBlock(element) || win;
4724 }
4725 var getElementRects = async function(data) {
4726 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4727 const getDimensionsFn = this.getDimensions;
4728 const floatingDimensions = await getDimensionsFn(data.floating);
4729 return {
4730 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4731 floating: {
4732 x: 0,
4733 y: 0,
4734 width: floatingDimensions.width,
4735 height: floatingDimensions.height
4736 }
4737 };
4738 };
4739 function isRTL(element) {
4740 return getComputedStyle2(element).direction === "rtl";
4741 }
4742 var platform2 = {
4743 convertOffsetParentRelativeRectToViewportRelativeRect,
4744 getDocumentElement,
4745 getClippingRect,
4746 getOffsetParent,
4747 getElementRects,
4748 getClientRects,
4749 getDimensions,
4750 getScale,
4751 isElement,
4752 isRTL
4753 };
4754 function rectsAreEqual(a2, b2) {
4755 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4756 }
4757 function observeMove(element, onMove) {
4758 let io = null;
4759 let timeoutId;
4760 const root = getDocumentElement(element);
4761 function cleanup() {
4762 var _io;
4763 clearTimeout(timeoutId);
4764 (_io = io) == null || _io.disconnect();
4765 io = null;
4766 }
4767 function refresh(skip, threshold) {
4768 if (skip === void 0) {
4769 skip = false;
4770 }
4771 if (threshold === void 0) {
4772 threshold = 1;
4773 }
4774 cleanup();
4775 const elementRectForRootMargin = element.getBoundingClientRect();
4776 const {
4777 left,
4778 top,
4779 width,
4780 height
4781 } = elementRectForRootMargin;
4782 if (!skip) {
4783 onMove();
4784 }
4785 if (!width || !height) {
4786 return;
4787 }
4788 const insetTop = floor(top);
4789 const insetRight = floor(root.clientWidth - (left + width));
4790 const insetBottom = floor(root.clientHeight - (top + height));
4791 const insetLeft = floor(left);
4792 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4793 const options = {
4794 rootMargin,
4795 threshold: max(0, min(1, threshold)) || 1
4796 };
4797 let isFirstUpdate = true;
4798 function handleObserve(entries) {
4799 const ratio = entries[0].intersectionRatio;
4800 if (ratio !== threshold) {
4801 if (!isFirstUpdate) {
4802 return refresh();
4803 }
4804 if (!ratio) {
4805 timeoutId = setTimeout(() => {
4806 refresh(false, 1e-7);
4807 }, 1e3);
4808 } else {
4809 refresh(false, ratio);
4810 }
4811 }
4812 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
4813 refresh();
4814 }
4815 isFirstUpdate = false;
4816 }
4817 try {
4818 io = new IntersectionObserver(handleObserve, {
4819 ...options,
4820 // Handle <iframe>s
4821 root: root.ownerDocument
4822 });
4823 } catch (_e) {
4824 io = new IntersectionObserver(handleObserve, options);
4825 }
4826 io.observe(element);
4827 }
4828 refresh(true);
4829 return cleanup;
4830 }
4831 function autoUpdate(reference, floating, update2, options) {
4832 if (options === void 0) {
4833 options = {};
4834 }
4835 const {
4836 ancestorScroll = true,
4837 ancestorResize = true,
4838 elementResize = typeof ResizeObserver === "function",
4839 layoutShift = typeof IntersectionObserver === "function",
4840 animationFrame = false
4841 } = options;
4842 const referenceEl = unwrapElement(reference);
4843 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
4844 ancestors.forEach((ancestor) => {
4845 ancestorScroll && ancestor.addEventListener("scroll", update2, {
4846 passive: true
4847 });
4848 ancestorResize && ancestor.addEventListener("resize", update2);
4849 });
4850 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
4851 let reobserveFrame = -1;
4852 let resizeObserver = null;
4853 if (elementResize) {
4854 resizeObserver = new ResizeObserver((_ref) => {
4855 let [firstEntry] = _ref;
4856 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
4857 resizeObserver.unobserve(floating);
4858 cancelAnimationFrame(reobserveFrame);
4859 reobserveFrame = requestAnimationFrame(() => {
4860 var _resizeObserver;
4861 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
4862 });
4863 }
4864 update2();
4865 });
4866 if (referenceEl && !animationFrame) {
4867 resizeObserver.observe(referenceEl);
4868 }
4869 if (floating) {
4870 resizeObserver.observe(floating);
4871 }
4872 }
4873 let frameId;
4874 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
4875 if (animationFrame) {
4876 frameLoop();
4877 }
4878 function frameLoop() {
4879 const nextRefRect = getBoundingClientRect(reference);
4880 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
4881 update2();
4882 }
4883 prevRefRect = nextRefRect;
4884 frameId = requestAnimationFrame(frameLoop);
4885 }
4886 update2();
4887 return () => {
4888 var _resizeObserver2;
4889 ancestors.forEach((ancestor) => {
4890 ancestorScroll && ancestor.removeEventListener("scroll", update2);
4891 ancestorResize && ancestor.removeEventListener("resize", update2);
4892 });
4893 cleanupIo == null || cleanupIo();
4894 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
4895 resizeObserver = null;
4896 if (animationFrame) {
4897 cancelAnimationFrame(frameId);
4898 }
4899 };
4900 }
4901 var offset2 = offset;
4902 var shift2 = shift;
4903 var flip2 = flip;
4904 var size2 = size;
4905 var hide2 = hide;
4906 var limitShift2 = limitShift;
4907 var computePosition2 = (reference, floating, options) => {
4908 const cache = /* @__PURE__ */ new Map();
4909 const mergedOptions = {
4910 platform: platform2,
4911 ...options
4912 };
4913 const platformWithCache = {
4914 ...mergedOptions.platform,
4915 _c: cache
4916 };
4917 return computePosition(reference, floating, {
4918 ...mergedOptions,
4919 platform: platformWithCache
4920 });
4921 };
4922
4923 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
4924 var React19 = __toESM(require_react(), 1);
4925 var import_react2 = __toESM(require_react(), 1);
4926 var ReactDOM3 = __toESM(require_react_dom(), 1);
4927 var isClient = typeof document !== "undefined";
4928 var noop2 = function noop3() {
4929 };
4930 var index = isClient ? import_react2.useLayoutEffect : noop2;
4931 function deepEqual(a2, b2) {
4932 if (a2 === b2) {
4933 return true;
4934 }
4935 if (typeof a2 !== typeof b2) {
4936 return false;
4937 }
4938 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
4939 return true;
4940 }
4941 let length;
4942 let i2;
4943 let keys;
4944 if (a2 && b2 && typeof a2 === "object") {
4945 if (Array.isArray(a2)) {
4946 length = a2.length;
4947 if (length !== b2.length) return false;
4948 for (i2 = length; i2-- !== 0; ) {
4949 if (!deepEqual(a2[i2], b2[i2])) {
4950 return false;
4951 }
4952 }
4953 return true;
4954 }
4955 keys = Object.keys(a2);
4956 length = keys.length;
4957 if (length !== Object.keys(b2).length) {
4958 return false;
4959 }
4960 for (i2 = length; i2-- !== 0; ) {
4961 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
4962 return false;
4963 }
4964 }
4965 for (i2 = length; i2-- !== 0; ) {
4966 const key = keys[i2];
4967 if (key === "_owner" && a2.$$typeof) {
4968 continue;
4969 }
4970 if (!deepEqual(a2[key], b2[key])) {
4971 return false;
4972 }
4973 }
4974 return true;
4975 }
4976 return a2 !== a2 && b2 !== b2;
4977 }
4978 function getDPR(element) {
4979 if (typeof window === "undefined") {
4980 return 1;
4981 }
4982 const win = element.ownerDocument.defaultView || window;
4983 return win.devicePixelRatio || 1;
4984 }
4985 function roundByDPR(element, value) {
4986 const dpr = getDPR(element);
4987 return Math.round(value * dpr) / dpr;
4988 }
4989 function useLatestRef(value) {
4990 const ref = React19.useRef(value);
4991 index(() => {
4992 ref.current = value;
4993 });
4994 return ref;
4995 }
4996 function useFloating(options) {
4997 if (options === void 0) {
4998 options = {};
4999 }
5000 const {
5001 placement = "bottom",
5002 strategy = "absolute",
5003 middleware = [],
5004 platform: platform3,
5005 elements: {
5006 reference: externalReference,
5007 floating: externalFloating
5008 } = {},
5009 transform = true,
5010 whileElementsMounted,
5011 open
5012 } = options;
5013 const [data, setData] = React19.useState({
5014 x: 0,
5015 y: 0,
5016 strategy,
5017 placement,
5018 middlewareData: {},
5019 isPositioned: false
5020 });
5021 const [latestMiddleware, setLatestMiddleware] = React19.useState(middleware);
5022 if (!deepEqual(latestMiddleware, middleware)) {
5023 setLatestMiddleware(middleware);
5024 }
5025 const [_reference, _setReference] = React19.useState(null);
5026 const [_floating, _setFloating] = React19.useState(null);
5027 const setReference = React19.useCallback((node) => {
5028 if (node !== referenceRef.current) {
5029 referenceRef.current = node;
5030 _setReference(node);
5031 }
5032 }, []);
5033 const setFloating = React19.useCallback((node) => {
5034 if (node !== floatingRef.current) {
5035 floatingRef.current = node;
5036 _setFloating(node);
5037 }
5038 }, []);
5039 const referenceEl = externalReference || _reference;
5040 const floatingEl = externalFloating || _floating;
5041 const referenceRef = React19.useRef(null);
5042 const floatingRef = React19.useRef(null);
5043 const dataRef = React19.useRef(data);
5044 const hasWhileElementsMounted = whileElementsMounted != null;
5045 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5046 const platformRef = useLatestRef(platform3);
5047 const openRef = useLatestRef(open);
5048 const update2 = React19.useCallback(() => {
5049 if (!referenceRef.current || !floatingRef.current) {
5050 return;
5051 }
5052 const config = {
5053 placement,
5054 strategy,
5055 middleware: latestMiddleware
5056 };
5057 if (platformRef.current) {
5058 config.platform = platformRef.current;
5059 }
5060 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5061 const fullData = {
5062 ...data2,
5063 // The floating element's position may be recomputed while it's closed
5064 // but still mounted (such as when transitioning out). To ensure
5065 // `isPositioned` will be `false` initially on the next open, avoid
5066 // setting it to `true` when `open === false` (must be specified).
5067 isPositioned: openRef.current !== false
5068 };
5069 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5070 dataRef.current = fullData;
5071 ReactDOM3.flushSync(() => {
5072 setData(fullData);
5073 });
5074 }
5075 });
5076 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5077 index(() => {
5078 if (open === false && dataRef.current.isPositioned) {
5079 dataRef.current.isPositioned = false;
5080 setData((data2) => ({
5081 ...data2,
5082 isPositioned: false
5083 }));
5084 }
5085 }, [open]);
5086 const isMountedRef = React19.useRef(false);
5087 index(() => {
5088 isMountedRef.current = true;
5089 return () => {
5090 isMountedRef.current = false;
5091 };
5092 }, []);
5093 index(() => {
5094 if (referenceEl) referenceRef.current = referenceEl;
5095 if (floatingEl) floatingRef.current = floatingEl;
5096 if (referenceEl && floatingEl) {
5097 if (whileElementsMountedRef.current) {
5098 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5099 }
5100 update2();
5101 }
5102 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5103 const refs = React19.useMemo(() => ({
5104 reference: referenceRef,
5105 floating: floatingRef,
5106 setReference,
5107 setFloating
5108 }), [setReference, setFloating]);
5109 const elements = React19.useMemo(() => ({
5110 reference: referenceEl,
5111 floating: floatingEl
5112 }), [referenceEl, floatingEl]);
5113 const floatingStyles = React19.useMemo(() => {
5114 const initialStyles = {
5115 position: strategy,
5116 left: 0,
5117 top: 0
5118 };
5119 if (!elements.floating) {
5120 return initialStyles;
5121 }
5122 const x2 = roundByDPR(elements.floating, data.x);
5123 const y2 = roundByDPR(elements.floating, data.y);
5124 if (transform) {
5125 return {
5126 ...initialStyles,
5127 transform: "translate(" + x2 + "px, " + y2 + "px)",
5128 ...getDPR(elements.floating) >= 1.5 && {
5129 willChange: "transform"
5130 }
5131 };
5132 }
5133 return {
5134 position: strategy,
5135 left: x2,
5136 top: y2
5137 };
5138 }, [strategy, transform, elements.floating, data.x, data.y]);
5139 return React19.useMemo(() => ({
5140 ...data,
5141 update: update2,
5142 refs,
5143 elements,
5144 floatingStyles
5145 }), [data, update2, refs, elements, floatingStyles]);
5146 }
5147 var offset3 = (options, deps) => {
5148 const result = offset2(options);
5149 return {
5150 name: result.name,
5151 fn: result.fn,
5152 options: [options, deps]
5153 };
5154 };
5155 var shift3 = (options, deps) => {
5156 const result = shift2(options);
5157 return {
5158 name: result.name,
5159 fn: result.fn,
5160 options: [options, deps]
5161 };
5162 };
5163 var limitShift3 = (options, deps) => {
5164 const result = limitShift2(options);
5165 return {
5166 fn: result.fn,
5167 options: [options, deps]
5168 };
5169 };
5170 var flip3 = (options, deps) => {
5171 const result = flip2(options);
5172 return {
5173 name: result.name,
5174 fn: result.fn,
5175 options: [options, deps]
5176 };
5177 };
5178 var size3 = (options, deps) => {
5179 const result = size2(options);
5180 return {
5181 name: result.name,
5182 fn: result.fn,
5183 options: [options, deps]
5184 };
5185 };
5186 var hide3 = (options, deps) => {
5187 const result = hide2(options);
5188 return {
5189 name: result.name,
5190 fn: result.fn,
5191 options: [options, deps]
5192 };
5193 };
5194
5195 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5196 var React24 = __toESM(require_react(), 1);
5197
5198 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5199 var React23 = __toESM(require_react(), 1);
5200
5201 // node_modules/@base-ui/utils/esm/store/createSelector.js
5202 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5203 if (other.length > 0) {
5204 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5205 }
5206 let selector2;
5207 if (a2 && b2 && c2 && d2 && e2 && f2) {
5208 selector2 = (state, a1, a22, a3) => {
5209 const va = a2(state, a1, a22, a3);
5210 const vb = b2(state, a1, a22, a3);
5211 const vc = c2(state, a1, a22, a3);
5212 const vd = d2(state, a1, a22, a3);
5213 const ve = e2(state, a1, a22, a3);
5214 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5215 };
5216 } else if (a2 && b2 && c2 && d2 && e2) {
5217 selector2 = (state, a1, a22, a3) => {
5218 const va = a2(state, a1, a22, a3);
5219 const vb = b2(state, a1, a22, a3);
5220 const vc = c2(state, a1, a22, a3);
5221 const vd = d2(state, a1, a22, a3);
5222 return e2(va, vb, vc, vd, a1, a22, a3);
5223 };
5224 } else if (a2 && b2 && c2 && d2) {
5225 selector2 = (state, a1, a22, a3) => {
5226 const va = a2(state, a1, a22, a3);
5227 const vb = b2(state, a1, a22, a3);
5228 const vc = c2(state, a1, a22, a3);
5229 return d2(va, vb, vc, a1, a22, a3);
5230 };
5231 } else if (a2 && b2 && c2) {
5232 selector2 = (state, a1, a22, a3) => {
5233 const va = a2(state, a1, a22, a3);
5234 const vb = b2(state, a1, a22, a3);
5235 return c2(va, vb, a1, a22, a3);
5236 };
5237 } else if (a2 && b2) {
5238 selector2 = (state, a1, a22, a3) => {
5239 const va = a2(state, a1, a22, a3);
5240 return b2(va, a1, a22, a3);
5241 };
5242 } else if (a2) {
5243 selector2 = a2;
5244 } else {
5245 throw (
5246 /* minify-error-disabled */
5247 new Error("Missing arguments")
5248 );
5249 }
5250 return selector2;
5251 };
5252
5253 // node_modules/@base-ui/utils/esm/store/useStore.js
5254 var React21 = __toESM(require_react(), 1);
5255 var import_shim = __toESM(require_shim(), 1);
5256 var import_with_selector = __toESM(require_with_selector(), 1);
5257
5258 // node_modules/@base-ui/utils/esm/fastHooks.js
5259 var React20 = __toESM(require_react(), 1);
5260 var hooks = [];
5261 var currentInstance = void 0;
5262 function getInstance() {
5263 return currentInstance;
5264 }
5265 function register(hook) {
5266 hooks.push(hook);
5267 }
5268 function fastComponent(fn) {
5269 const FastComponent = (props, forwardedRef) => {
5270 const instance = useRefWithInit(createInstance).current;
5271 let result;
5272 try {
5273 currentInstance = instance;
5274 for (const hook of hooks) {
5275 hook.before(instance);
5276 }
5277 result = fn(props, forwardedRef);
5278 for (const hook of hooks) {
5279 hook.after(instance);
5280 }
5281 instance.didInitialize = true;
5282 } finally {
5283 currentInstance = void 0;
5284 }
5285 return result;
5286 };
5287 FastComponent.displayName = fn.displayName || fn.name;
5288 return FastComponent;
5289 }
5290 function fastComponentRef(fn) {
5291 return /* @__PURE__ */ React20.forwardRef(fastComponent(fn));
5292 }
5293 function createInstance() {
5294 return {
5295 didInitialize: false
5296 };
5297 }
5298
5299 // node_modules/@base-ui/utils/esm/store/useStore.js
5300 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5301 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5302 function useStore(store, selector2, a1, a2, a3) {
5303 return useStoreImplementation(store, selector2, a1, a2, a3);
5304 }
5305 function useStoreR19(store, selector2, a1, a2, a3) {
5306 const getSelection = React21.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5307 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5308 }
5309 register({
5310 before(instance) {
5311 instance.syncIndex = 0;
5312 if (!instance.didInitialize) {
5313 instance.syncTick = 1;
5314 instance.syncHooks = [];
5315 instance.didChangeStore = true;
5316 instance.getSnapshot = () => {
5317 let didChange2 = false;
5318 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5319 const hook = instance.syncHooks[i2];
5320 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5321 if (hook.didChange || !Object.is(hook.value, value)) {
5322 didChange2 = true;
5323 hook.value = value;
5324 hook.didChange = false;
5325 }
5326 }
5327 if (didChange2) {
5328 instance.syncTick += 1;
5329 }
5330 return instance.syncTick;
5331 };
5332 }
5333 },
5334 after(instance) {
5335 if (instance.syncHooks.length > 0) {
5336 if (instance.didChangeStore) {
5337 instance.didChangeStore = false;
5338 instance.subscribe = (onStoreChange) => {
5339 const stores = /* @__PURE__ */ new Set();
5340 for (const hook of instance.syncHooks) {
5341 stores.add(hook.store);
5342 }
5343 const unsubscribes = [];
5344 for (const store of stores) {
5345 unsubscribes.push(store.subscribe(onStoreChange));
5346 }
5347 return () => {
5348 for (const unsubscribe of unsubscribes) {
5349 unsubscribe();
5350 }
5351 };
5352 };
5353 }
5354 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5355 }
5356 }
5357 });
5358 function useStoreFast(store, selector2, a1, a2, a3) {
5359 const instance = getInstance();
5360 if (!instance) {
5361 return useStoreR19(store, selector2, a1, a2, a3);
5362 }
5363 const index2 = instance.syncIndex;
5364 instance.syncIndex += 1;
5365 let hook;
5366 if (!instance.didInitialize) {
5367 hook = {
5368 store,
5369 selector: selector2,
5370 a1,
5371 a2,
5372 a3,
5373 value: selector2(store.getSnapshot(), a1, a2, a3),
5374 didChange: false
5375 };
5376 instance.syncHooks.push(hook);
5377 } else {
5378 hook = instance.syncHooks[index2];
5379 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5380 if (hook.store !== store) {
5381 instance.didChangeStore = true;
5382 }
5383 hook.store = store;
5384 hook.selector = selector2;
5385 hook.a1 = a1;
5386 hook.a2 = a2;
5387 hook.a3 = a3;
5388 hook.didChange = true;
5389 }
5390 }
5391 return hook.value;
5392 }
5393 function useStoreLegacy(store, selector2, a1, a2, a3) {
5394 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5395 }
5396
5397 // node_modules/@base-ui/utils/esm/store/Store.js
5398 var Store = class {
5399 /**
5400 * The current state of the store.
5401 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5402 * 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).
5403 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5404 *
5405 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5406 */
5407 // Internal state to handle recursive `setState()` calls
5408 constructor(state) {
5409 this.state = state;
5410 this.listeners = /* @__PURE__ */ new Set();
5411 this.updateTick = 0;
5412 }
5413 /**
5414 * Registers a listener that will be called whenever the store's state changes.
5415 *
5416 * @param fn The listener function to be called on state changes.
5417 * @returns A function to unsubscribe the listener.
5418 */
5419 subscribe = (fn) => {
5420 this.listeners.add(fn);
5421 return () => {
5422 this.listeners.delete(fn);
5423 };
5424 };
5425 /**
5426 * Returns the current state of the store.
5427 */
5428 getSnapshot = () => {
5429 return this.state;
5430 };
5431 /**
5432 * Updates the entire store's state and notifies all registered listeners.
5433 *
5434 * @param newState The new state to set for the store.
5435 */
5436 setState(newState) {
5437 if (this.state === newState) {
5438 return;
5439 }
5440 this.state = newState;
5441 this.updateTick += 1;
5442 const currentTick = this.updateTick;
5443 for (const listener of this.listeners) {
5444 if (currentTick !== this.updateTick) {
5445 return;
5446 }
5447 listener(newState);
5448 }
5449 }
5450 /**
5451 * Merges the provided changes into the current state and notifies listeners if there are changes.
5452 *
5453 * @param changes An object containing the changes to apply to the current state.
5454 */
5455 update(changes) {
5456 for (const key in changes) {
5457 if (!Object.is(this.state[key], changes[key])) {
5458 this.setState({
5459 ...this.state,
5460 ...changes
5461 });
5462 return;
5463 }
5464 }
5465 }
5466 /**
5467 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5468 *
5469 * @param key The key in the store's state to update.
5470 * @param value The new value to set for the specified key.
5471 */
5472 set(key, value) {
5473 if (!Object.is(this.state[key], value)) {
5474 this.setState({
5475 ...this.state,
5476 [key]: value
5477 });
5478 }
5479 }
5480 /**
5481 * Gives the state a new reference and updates all registered listeners.
5482 */
5483 notifyAll() {
5484 const newState = {
5485 ...this.state
5486 };
5487 this.setState(newState);
5488 }
5489 use(selector2, a1, a2, a3) {
5490 return useStore(this, selector2, a1, a2, a3);
5491 }
5492 };
5493
5494 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5495 var React22 = __toESM(require_react(), 1);
5496 var ReactStore = class extends Store {
5497 /**
5498 * Creates a new ReactStore instance.
5499 *
5500 * @param state Initial state of the store.
5501 * @param context Non-reactive context values.
5502 * @param selectors Optional selectors for use with `useState`.
5503 */
5504 constructor(state, context = {}, selectors3) {
5505 super(state);
5506 this.context = context;
5507 this.selectors = selectors3;
5508 }
5509 /**
5510 * Non-reactive values such as refs, callbacks, etc.
5511 */
5512 /**
5513 * Synchronizes a single external value into the store.
5514 *
5515 * Note that the while the value in `state` is updated immediately, the value returned
5516 * by `useState` is updated before the next render (similarly to React's `useState`).
5517 */
5518 useSyncedValue(key, value) {
5519 React22.useDebugValue(key);
5520 const store = this;
5521 useIsoLayoutEffect(() => {
5522 if (store.state[key] !== value) {
5523 store.set(key, value);
5524 }
5525 }, [store, key, value]);
5526 }
5527 /**
5528 * Synchronizes a single external value into the store and
5529 * cleans it up (sets to `undefined`) on unmount.
5530 *
5531 * Note that the while the value in `state` is updated immediately, the value returned
5532 * by `useState` is updated before the next render (similarly to React's `useState`).
5533 */
5534 useSyncedValueWithCleanup(key, value) {
5535 const store = this;
5536 useIsoLayoutEffect(() => {
5537 if (store.state[key] !== value) {
5538 store.set(key, value);
5539 }
5540 return () => {
5541 store.set(key, void 0);
5542 };
5543 }, [store, key, value]);
5544 }
5545 /**
5546 * Synchronizes multiple external values into the store.
5547 *
5548 * Note that the while the values in `state` are updated immediately, the values returned
5549 * by `useState` are updated before the next render (similarly to React's `useState`).
5550 */
5551 useSyncedValues(statePart) {
5552 const store = this;
5553 if (true) {
5554 React22.useDebugValue(statePart, (p2) => Object.keys(p2));
5555 const keys = React22.useRef(Object.keys(statePart)).current;
5556 const nextKeys = Object.keys(statePart);
5557 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5558 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5559 }
5560 }
5561 const dependencies = Object.values(statePart);
5562 useIsoLayoutEffect(() => {
5563 store.update(statePart);
5564 }, [store, ...dependencies]);
5565 }
5566 /**
5567 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5568 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5569 */
5570 useControlledProp(key, controlled) {
5571 React22.useDebugValue(key);
5572 const store = this;
5573 const isControlled = controlled !== void 0;
5574 useIsoLayoutEffect(() => {
5575 if (isControlled && !Object.is(store.state[key], controlled)) {
5576 store.setState({
5577 ...store.state,
5578 [key]: controlled
5579 });
5580 }
5581 }, [store, key, controlled, isControlled]);
5582 if (true) {
5583 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5584 if (!cache.has(key)) {
5585 cache.set(key, isControlled);
5586 }
5587 const previouslyControlled = cache.get(key);
5588 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5589 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).`);
5590 }
5591 }
5592 }
5593 /** Gets the current value from the store using a selector with the provided key.
5594 *
5595 * @param key Key of the selector to use.
5596 */
5597 select(key, a1, a2, a3) {
5598 const selector2 = this.selectors[key];
5599 return selector2(this.state, a1, a2, a3);
5600 }
5601 /**
5602 * Returns a value from the store's state using a selector function.
5603 * Used to subscribe to specific parts of the state.
5604 * This methods causes a rerender whenever the selected state changes.
5605 *
5606 * @param key Key of the selector to use.
5607 */
5608 useState(key, a1, a2, a3) {
5609 React22.useDebugValue(key);
5610 return useStore(this, this.selectors[key], a1, a2, a3);
5611 }
5612 /**
5613 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5614 * and assigns it to the context.
5615 *
5616 * @param key Key of the event callback. Must be a function in the context.
5617 * @param fn Function to assign.
5618 */
5619 useContextCallback(key, fn) {
5620 React22.useDebugValue(key);
5621 const stableFunction = useStableCallback(fn ?? NOOP);
5622 this.context[key] = stableFunction;
5623 }
5624 /**
5625 * Returns a stable setter function for a specific key in the store's state.
5626 * It's commonly used to pass as a ref callback to React elements.
5627 *
5628 * @param key Key of the state to set.
5629 */
5630 useStateSetter(key) {
5631 const ref = React22.useRef(void 0);
5632 if (ref.current === void 0) {
5633 ref.current = (value) => {
5634 this.set(key, value);
5635 };
5636 }
5637 return ref.current;
5638 }
5639 /**
5640 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5641 *
5642 * @param key Key of the selector to observe.
5643 * @param listener Listener function called when the selector result changes.
5644 */
5645 observe(selector2, listener) {
5646 let selectFn;
5647 if (typeof selector2 === "function") {
5648 selectFn = selector2;
5649 } else {
5650 selectFn = this.selectors[selector2];
5651 }
5652 let prevValue = selectFn(this.state);
5653 listener(prevValue, prevValue, this);
5654 return this.subscribe((nextState) => {
5655 const nextValue = selectFn(nextState);
5656 if (!Object.is(prevValue, nextValue)) {
5657 const oldValue = prevValue;
5658 prevValue = nextValue;
5659 listener(nextValue, oldValue, this);
5660 }
5661 });
5662 }
5663 };
5664
5665 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5666 var selectors = {
5667 open: createSelector((state) => state.open),
5668 transitionStatus: createSelector((state) => state.transitionStatus),
5669 domReferenceElement: createSelector((state) => state.domReferenceElement),
5670 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5671 floatingElement: createSelector((state) => state.floatingElement),
5672 floatingId: createSelector((state) => state.floatingId)
5673 };
5674 var FloatingRootStore = class extends ReactStore {
5675 constructor(options) {
5676 const {
5677 syncOnly,
5678 nested,
5679 onOpenChange,
5680 triggerElements,
5681 ...initialState
5682 } = options;
5683 super({
5684 ...initialState,
5685 positionReference: initialState.referenceElement,
5686 domReferenceElement: initialState.referenceElement
5687 }, {
5688 onOpenChange,
5689 dataRef: {
5690 current: {}
5691 },
5692 events: createEventEmitter(),
5693 nested,
5694 triggerElements
5695 }, selectors);
5696 this.syncOnly = syncOnly;
5697 }
5698 /**
5699 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5700 */
5701 syncOpenEvent = (newOpen, event) => {
5702 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5703 // click events to upgrade a hover-open.
5704 event != null && isClickLikeEvent(event)) {
5705 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5706 }
5707 };
5708 /**
5709 * Runs the root-owned side effects for an open state change.
5710 */
5711 dispatchOpenChange = (newOpen, eventDetails) => {
5712 this.syncOpenEvent(newOpen, eventDetails.event);
5713 const details = {
5714 open: newOpen,
5715 reason: eventDetails.reason,
5716 nativeEvent: eventDetails.event,
5717 nested: this.context.nested,
5718 triggerElement: eventDetails.trigger
5719 };
5720 this.context.events.emit("openchange", details);
5721 };
5722 /**
5723 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5724 *
5725 * @param newOpen The new open state.
5726 * @param eventDetails Details about the event that triggered the open state change.
5727 */
5728 setOpen = (newOpen, eventDetails) => {
5729 if (this.syncOnly) {
5730 this.context.onOpenChange?.(newOpen, eventDetails);
5731 return;
5732 }
5733 this.dispatchOpenChange(newOpen, eventDetails);
5734 this.context.onOpenChange?.(newOpen, eventDetails);
5735 };
5736 };
5737
5738 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5739 function useSyncedFloatingRootContext(options) {
5740 const {
5741 popupStore,
5742 treatPopupAsFloatingElement = false,
5743 floatingRootContext: floatingRootContextProp,
5744 floatingId,
5745 nested,
5746 onOpenChange
5747 } = options;
5748 const open = popupStore.useState("open");
5749 const referenceElement = popupStore.useState("activeTriggerElement");
5750 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5751 const triggerElements = popupStore.context.triggerElements;
5752 const handleOpenChange = onOpenChange;
5753 const internalStoreRef = React23.useRef(null);
5754 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5755 internalStoreRef.current = new FloatingRootStore({
5756 open,
5757 transitionStatus: void 0,
5758 referenceElement,
5759 floatingElement,
5760 triggerElements,
5761 onOpenChange: handleOpenChange,
5762 floatingId,
5763 syncOnly: true,
5764 nested
5765 });
5766 }
5767 const store = floatingRootContextProp ?? internalStoreRef.current;
5768 popupStore.useSyncedValue("floatingId", floatingId);
5769 useIsoLayoutEffect(() => {
5770 const valuesToSync = {
5771 open,
5772 floatingId,
5773 referenceElement,
5774 floatingElement
5775 };
5776 if (isElement(referenceElement)) {
5777 valuesToSync.domReferenceElement = referenceElement;
5778 }
5779 if (store.state.positionReference === store.state.referenceElement) {
5780 valuesToSync.positionReference = referenceElement;
5781 }
5782 store.update(valuesToSync);
5783 }, [open, floatingId, referenceElement, floatingElement, store]);
5784 store.context.onOpenChange = handleOpenChange;
5785 store.context.nested = nested;
5786 return store;
5787 }
5788
5789 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5790 var FOCUSABLE_POPUP_PROPS = {
5791 tabIndex: -1,
5792 [FOCUSABLE_ATTRIBUTE]: ""
5793 };
5794 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
5795 const floatingId = useId();
5796 const nested = useFloatingParentNodeId() != null;
5797 const internalStoreRef = React24.useRef(null);
5798 if (externalStore === void 0 && internalStoreRef.current === null) {
5799 internalStoreRef.current = createStore2(floatingId, nested);
5800 }
5801 const store = externalStore ?? internalStoreRef.current;
5802 useSyncedFloatingRootContext({
5803 popupStore: store,
5804 treatPopupAsFloatingElement,
5805 floatingRootContext: store.state.floatingRootContext,
5806 floatingId,
5807 nested,
5808 onOpenChange: store.setOpen
5809 });
5810 return {
5811 store,
5812 internalStore: internalStoreRef.current
5813 };
5814 }
5815 function useTriggerRegistration(id, store) {
5816 const registeredElementIdRef = React24.useRef(null);
5817 const registeredElementRef = React24.useRef(null);
5818 return React24.useCallback((element) => {
5819 if (id === void 0) {
5820 return;
5821 }
5822 let shouldSyncTriggerCount = false;
5823 if (registeredElementIdRef.current !== null) {
5824 const registeredId = registeredElementIdRef.current;
5825 const registeredElement = registeredElementRef.current;
5826 const currentElement = store.context.triggerElements.getById(registeredId);
5827 if (registeredElement && currentElement === registeredElement) {
5828 store.context.triggerElements.delete(registeredId);
5829 shouldSyncTriggerCount = true;
5830 }
5831 registeredElementIdRef.current = null;
5832 registeredElementRef.current = null;
5833 }
5834 if (element !== null) {
5835 registeredElementIdRef.current = id;
5836 registeredElementRef.current = element;
5837 store.context.triggerElements.add(id, element);
5838 shouldSyncTriggerCount = true;
5839 }
5840 if (shouldSyncTriggerCount) {
5841 const triggerCount = store.context.triggerElements.size;
5842 if (store.select("open") && store.state.triggerCount !== triggerCount) {
5843 store.set("triggerCount", triggerCount);
5844 }
5845 }
5846 }, [store, id]);
5847 }
5848 function setOpenTriggerState(state, open, trigger) {
5849 const triggerId = trigger?.id ?? null;
5850 if (triggerId || open) {
5851 state.activeTriggerId = triggerId;
5852 state.activeTriggerElement = trigger ?? null;
5853 }
5854 }
5855 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5856 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5857 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5858 const registerTrigger = useStableCallback((element) => {
5859 baseRegisterTrigger(element);
5860 if (!element) {
5861 return;
5862 }
5863 const open = store.select("open");
5864 const activeTriggerId = store.select("activeTriggerId");
5865 if (activeTriggerId === triggerId) {
5866 store.update({
5867 activeTriggerElement: element,
5868 ...open ? stateUpdates : null
5869 });
5870 return;
5871 }
5872 if (activeTriggerId == null && open) {
5873 store.update({
5874 activeTriggerId: triggerId,
5875 activeTriggerElement: element,
5876 ...stateUpdates
5877 });
5878 }
5879 });
5880 useIsoLayoutEffect(() => {
5881 if (isMountedByThisTrigger) {
5882 store.update({
5883 activeTriggerElement: triggerElementRef.current,
5884 ...stateUpdates
5885 });
5886 }
5887 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5888 return {
5889 registerTrigger,
5890 isMountedByThisTrigger
5891 };
5892 }
5893 function useImplicitActiveTrigger(store) {
5894 const open = store.useState("open");
5895 const reactiveTriggerCount = store.useState("triggerCount");
5896 useIsoLayoutEffect(() => {
5897 if (!open) {
5898 if (store.state.triggerCount !== 0) {
5899 store.set("triggerCount", 0);
5900 }
5901 return;
5902 }
5903 const triggerCount = store.context.triggerElements.size;
5904 const stateUpdates = {};
5905 if (store.state.triggerCount !== triggerCount) {
5906 stateUpdates.triggerCount = triggerCount;
5907 }
5908 if (!store.select("activeTriggerId") && triggerCount === 1) {
5909 const iteratorResult = store.context.triggerElements.entries().next();
5910 if (!iteratorResult.done) {
5911 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5912 stateUpdates.activeTriggerId = implicitTriggerId;
5913 stateUpdates.activeTriggerElement = implicitTriggerElement;
5914 }
5915 }
5916 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
5917 store.update(stateUpdates);
5918 }
5919 }, [open, store, reactiveTriggerCount]);
5920 }
5921 function useOpenStateTransitions(open, store, onUnmount) {
5922 const {
5923 mounted,
5924 setMounted,
5925 transitionStatus
5926 } = useTransitionStatus(open);
5927 store.useSyncedValues({
5928 mounted,
5929 transitionStatus
5930 });
5931 const forceUnmount = useStableCallback(() => {
5932 setMounted(false);
5933 store.update({
5934 activeTriggerId: null,
5935 activeTriggerElement: null,
5936 mounted: false,
5937 preventUnmountingOnClose: false
5938 });
5939 onUnmount?.();
5940 store.context.onOpenChangeComplete?.(false);
5941 });
5942 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
5943 useOpenChangeComplete({
5944 enabled: mounted && !open && !preventUnmountingOnClose,
5945 open,
5946 ref: store.context.popupRef,
5947 onComplete() {
5948 if (!open) {
5949 forceUnmount();
5950 }
5951 }
5952 });
5953 return {
5954 forceUnmount,
5955 transitionStatus
5956 };
5957 }
5958 function usePopupInteractionProps(store, statePart) {
5959 store.useSyncedValues(statePart);
5960 useIsoLayoutEffect(() => () => {
5961 store.update({
5962 activeTriggerProps: EMPTY_OBJECT,
5963 inactiveTriggerProps: EMPTY_OBJECT,
5964 popupProps: EMPTY_OBJECT
5965 });
5966 }, [store]);
5967 }
5968
5969 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
5970 var PopupTriggerMap = class {
5971 constructor() {
5972 this.elementsSet = /* @__PURE__ */ new Set();
5973 this.idMap = /* @__PURE__ */ new Map();
5974 }
5975 /**
5976 * Adds a trigger element with the given ID.
5977 *
5978 * Note: The provided element is assumed to not be registered under multiple IDs.
5979 */
5980 add(id, element) {
5981 const existingElement = this.idMap.get(id);
5982 if (existingElement === element) {
5983 return;
5984 }
5985 if (existingElement !== void 0) {
5986 this.elementsSet.delete(existingElement);
5987 }
5988 this.elementsSet.add(element);
5989 this.idMap.set(id, element);
5990 if (true) {
5991 if (this.elementsSet.size !== this.idMap.size) {
5992 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
5993 }
5994 }
5995 }
5996 /**
5997 * Removes the trigger element with the given ID.
5998 */
5999 delete(id) {
6000 const element = this.idMap.get(id);
6001 if (element) {
6002 this.elementsSet.delete(element);
6003 this.idMap.delete(id);
6004 }
6005 }
6006 /**
6007 * Whether the given element is registered as a trigger.
6008 */
6009 hasElement(element) {
6010 return this.elementsSet.has(element);
6011 }
6012 /**
6013 * Whether there is a registered trigger element matching the given predicate.
6014 */
6015 hasMatchingElement(predicate) {
6016 for (const element of this.elementsSet) {
6017 if (predicate(element)) {
6018 return true;
6019 }
6020 }
6021 return false;
6022 }
6023 /**
6024 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6025 */
6026 getById(id) {
6027 return this.idMap.get(id);
6028 }
6029 /**
6030 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6031 */
6032 entries() {
6033 return this.idMap.entries();
6034 }
6035 /**
6036 * Returns an iterable of all registered trigger elements.
6037 */
6038 elements() {
6039 return this.elementsSet.values();
6040 }
6041 /**
6042 * Returns the number of registered trigger elements.
6043 */
6044 get size() {
6045 return this.idMap.size;
6046 }
6047 };
6048
6049 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6050 function getEmptyRootContext() {
6051 return new FloatingRootStore({
6052 open: false,
6053 transitionStatus: void 0,
6054 floatingElement: null,
6055 referenceElement: null,
6056 triggerElements: new PopupTriggerMap(),
6057 floatingId: void 0,
6058 syncOnly: false,
6059 nested: false,
6060 onOpenChange: void 0
6061 });
6062 }
6063
6064 // node_modules/@base-ui/react/esm/utils/popups/store.js
6065 function createInitialPopupStoreState() {
6066 return {
6067 open: false,
6068 openProp: void 0,
6069 mounted: false,
6070 transitionStatus: void 0,
6071 floatingRootContext: getEmptyRootContext(),
6072 floatingId: void 0,
6073 triggerCount: 0,
6074 preventUnmountingOnClose: false,
6075 payload: void 0,
6076 activeTriggerId: null,
6077 activeTriggerElement: null,
6078 triggerIdProp: void 0,
6079 popupElement: null,
6080 positionerElement: null,
6081 activeTriggerProps: EMPTY_OBJECT,
6082 inactiveTriggerProps: EMPTY_OBJECT,
6083 popupProps: EMPTY_OBJECT
6084 };
6085 }
6086 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6087 return new FloatingRootStore({
6088 open: false,
6089 transitionStatus: void 0,
6090 floatingElement: null,
6091 referenceElement: null,
6092 triggerElements,
6093 floatingId,
6094 syncOnly: true,
6095 nested,
6096 onOpenChange: void 0
6097 });
6098 }
6099 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6100 var openSelector = createSelector((state) => state.openProp ?? state.open);
6101 var popupIdSelector = createSelector((state) => {
6102 const popupId = state.popupElement?.id ?? state.floatingId;
6103 return popupId || void 0;
6104 });
6105 function triggerOwnsOpenPopup(state, triggerId) {
6106 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6107 }
6108 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6109 if (triggerOwnsOpenPopup(state, triggerId)) {
6110 return true;
6111 }
6112 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6113 }
6114 var popupStoreSelectors = {
6115 open: openSelector,
6116 mounted: createSelector((state) => state.mounted),
6117 transitionStatus: createSelector((state) => state.transitionStatus),
6118 floatingRootContext: createSelector((state) => state.floatingRootContext),
6119 triggerCount: createSelector((state) => state.triggerCount),
6120 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6121 payload: createSelector((state) => state.payload),
6122 activeTriggerId: activeTriggerIdSelector,
6123 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6124 popupId: popupIdSelector,
6125 /**
6126 * Whether the trigger with the given ID was used to open the popup.
6127 */
6128 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6129 /**
6130 * Whether the popup is open and was activated by a trigger with the given ID.
6131 */
6132 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6133 /**
6134 * Whether the popup is mounted and was activated by a trigger with the given ID.
6135 */
6136 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6137 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6138 /**
6139 * Popup id for the trigger that currently owns the open popup.
6140 */
6141 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6142 popupProps: createSelector((state) => state.popupProps),
6143 popupElement: createSelector((state) => state.popupElement),
6144 positionerElement: createSelector((state) => state.positionerElement)
6145 };
6146
6147 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6148 function useFloatingRootContext(options) {
6149 const {
6150 open = false,
6151 onOpenChange,
6152 elements = {}
6153 } = options;
6154 const floatingId = useId();
6155 const nested = useFloatingParentNodeId() != null;
6156 if (true) {
6157 const optionDomReference = elements.reference;
6158 if (optionDomReference && !isElement(optionDomReference)) {
6159 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6160 }
6161 }
6162 const store = useRefWithInit(() => new FloatingRootStore({
6163 open,
6164 transitionStatus: void 0,
6165 onOpenChange,
6166 referenceElement: elements.reference ?? null,
6167 floatingElement: elements.floating ?? null,
6168 triggerElements: new PopupTriggerMap(),
6169 floatingId,
6170 syncOnly: false,
6171 nested
6172 })).current;
6173 useIsoLayoutEffect(() => {
6174 const valuesToSync = {
6175 open,
6176 floatingId
6177 };
6178 if (elements.reference !== void 0) {
6179 valuesToSync.referenceElement = elements.reference;
6180 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6181 }
6182 if (elements.floating !== void 0) {
6183 valuesToSync.floatingElement = elements.floating;
6184 }
6185 store.update(valuesToSync);
6186 }, [open, floatingId, elements.reference, elements.floating, store]);
6187 store.context.onOpenChange = onOpenChange;
6188 store.context.nested = nested;
6189 return store;
6190 }
6191
6192 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6193 function useFloating2(options = {}) {
6194 const {
6195 nodeId,
6196 externalTree
6197 } = options;
6198 const internalStore = useFloatingRootContext(options);
6199 const store = options.rootContext || internalStore;
6200 const referenceElement = store.useState("referenceElement");
6201 const floatingElement = store.useState("floatingElement");
6202 const domReferenceElement = store.useState("domReferenceElement");
6203 const open = store.useState("open");
6204 const floatingId = store.useState("floatingId");
6205 const [positionReference, setPositionReferenceRaw] = React25.useState(null);
6206 const [localDomReference, setLocalDomReference] = React25.useState(void 0);
6207 const [localFloatingElement, setLocalFloatingElement] = React25.useState(void 0);
6208 const domReferenceRef = React25.useRef(null);
6209 const tree = useFloatingTree(externalTree);
6210 const storeElements = React25.useMemo(() => ({
6211 reference: referenceElement,
6212 floating: floatingElement,
6213 domReference: domReferenceElement
6214 }), [referenceElement, floatingElement, domReferenceElement]);
6215 const position = useFloating({
6216 ...options,
6217 elements: {
6218 ...storeElements,
6219 ...positionReference && {
6220 reference: positionReference
6221 }
6222 }
6223 });
6224 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6225 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6226 store.useSyncedValue("referenceElement", localDomReference ?? null);
6227 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6228 store.useSyncedValue("floatingElement", syncedFloatingElement);
6229 const setPositionReference = React25.useCallback((node) => {
6230 const computedPositionReference = isElement(node) ? {
6231 getBoundingClientRect: () => node.getBoundingClientRect(),
6232 getClientRects: () => node.getClientRects(),
6233 contextElement: node
6234 } : node;
6235 setPositionReferenceRaw(computedPositionReference);
6236 position.refs.setReference(computedPositionReference);
6237 }, [position.refs]);
6238 const setReference = React25.useCallback((node) => {
6239 if (isElement(node) || node === null) {
6240 domReferenceRef.current = node;
6241 setLocalDomReference(node);
6242 }
6243 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6244 // `null` to support `positionReference` + an unstable `reference`
6245 // callback ref.
6246 node !== null && !isElement(node)) {
6247 position.refs.setReference(node);
6248 }
6249 }, [position.refs, setLocalDomReference]);
6250 const setFloating = React25.useCallback((node) => {
6251 setLocalFloatingElement(node);
6252 position.refs.setFloating(node);
6253 }, [position.refs]);
6254 const refs = React25.useMemo(() => ({
6255 ...position.refs,
6256 setReference,
6257 setFloating,
6258 setPositionReference,
6259 domReference: domReferenceRef
6260 }), [position.refs, setReference, setFloating, setPositionReference]);
6261 const elements = React25.useMemo(() => ({
6262 ...position.elements,
6263 domReference: domReferenceElement
6264 }), [position.elements, domReferenceElement]);
6265 const context = React25.useMemo(() => ({
6266 ...position,
6267 dataRef: store.context.dataRef,
6268 open,
6269 onOpenChange: store.setOpen,
6270 events: store.context.events,
6271 floatingId,
6272 refs,
6273 elements,
6274 nodeId,
6275 rootStore: store
6276 }), [position, refs, elements, nodeId, store, open, floatingId]);
6277 useIsoLayoutEffect(() => {
6278 if (domReferenceElement) {
6279 domReferenceRef.current = domReferenceElement;
6280 }
6281 }, [domReferenceElement]);
6282 useIsoLayoutEffect(() => {
6283 store.context.dataRef.current.floatingContext = context;
6284 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6285 if (node) {
6286 node.context = context;
6287 }
6288 });
6289 return React25.useMemo(() => ({
6290 ...position,
6291 context,
6292 refs,
6293 elements,
6294 rootStore: store
6295 }), [position, refs, elements, context, store]);
6296 }
6297
6298 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6299 var React26 = __toESM(require_react(), 1);
6300 var isMacSafari = isMac && isSafari;
6301 function useFocus(context, props = {}) {
6302 const {
6303 enabled = true,
6304 delay
6305 } = props;
6306 const store = "rootStore" in context ? context.rootStore : context;
6307 const {
6308 events,
6309 dataRef
6310 } = store.context;
6311 const blockFocusRef = React26.useRef(false);
6312 const blockedReferenceRef = React26.useRef(null);
6313 const keyboardModalityRef = React26.useRef(true);
6314 const timeout = useTimeout();
6315 React26.useEffect(() => {
6316 const domReference = store.select("domReferenceElement");
6317 if (!enabled) {
6318 return void 0;
6319 }
6320 const win = getWindow(domReference);
6321 function onBlur() {
6322 const currentDomReference = store.select("domReferenceElement");
6323 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6324 blockFocusRef.current = true;
6325 }
6326 }
6327 function onKeyDown() {
6328 keyboardModalityRef.current = true;
6329 }
6330 function onPointerDown() {
6331 keyboardModalityRef.current = false;
6332 }
6333 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6334 }, [store, enabled]);
6335 React26.useEffect(() => {
6336 if (!enabled) {
6337 return void 0;
6338 }
6339 function onOpenChangeLocal(details) {
6340 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6341 const referenceElement = store.select("domReferenceElement");
6342 if (isElement(referenceElement)) {
6343 blockedReferenceRef.current = referenceElement;
6344 blockFocusRef.current = true;
6345 }
6346 }
6347 }
6348 events.on("openchange", onOpenChangeLocal);
6349 return () => {
6350 events.off("openchange", onOpenChangeLocal);
6351 };
6352 }, [events, enabled, store]);
6353 const reference = React26.useMemo(() => {
6354 function resetBlockedFocus() {
6355 blockFocusRef.current = false;
6356 blockedReferenceRef.current = null;
6357 }
6358 return {
6359 onMouseLeave() {
6360 resetBlockedFocus();
6361 },
6362 onFocus(event) {
6363 const focusTarget = event.currentTarget;
6364 if (blockFocusRef.current) {
6365 if (blockedReferenceRef.current === focusTarget) {
6366 return;
6367 }
6368 resetBlockedFocus();
6369 }
6370 const target = getTarget(event.nativeEvent);
6371 if (isElement(target)) {
6372 if (isMacSafari && !event.relatedTarget) {
6373 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6374 return;
6375 }
6376 } else if (!matchesFocusVisible(target)) {
6377 return;
6378 }
6379 }
6380 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6381 const {
6382 nativeEvent,
6383 currentTarget
6384 } = event;
6385 const delayValue = typeof delay === "function" ? delay() : delay;
6386 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6387 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6388 return;
6389 }
6390 timeout.start(delayValue, () => {
6391 if (blockFocusRef.current) {
6392 return;
6393 }
6394 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6395 });
6396 },
6397 onBlur(event) {
6398 resetBlockedFocus();
6399 const relatedTarget = event.relatedTarget;
6400 const nativeEvent = event.nativeEvent;
6401 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6402 timeout.start(0, () => {
6403 const domReference = store.select("domReferenceElement");
6404 const activeEl = activeElement(ownerDocument(domReference));
6405 if (!relatedTarget && activeEl === domReference) {
6406 return;
6407 }
6408 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6409 return;
6410 }
6411 const nextFocusedElement = relatedTarget ?? activeEl;
6412 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6413 return;
6414 }
6415 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6416 });
6417 }
6418 };
6419 }, [dataRef, delay, store, timeout]);
6420 return React26.useMemo(() => enabled ? {
6421 reference,
6422 trigger: reference
6423 } : {}, [enabled, reference]);
6424 }
6425
6426 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6427 var React27 = __toESM(require_react(), 1);
6428
6429 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6430 var HoverInteraction = class _HoverInteraction {
6431 constructor() {
6432 this.pointerType = void 0;
6433 this.interactedInside = false;
6434 this.handler = void 0;
6435 this.blockMouseMove = true;
6436 this.performedPointerEventsMutation = false;
6437 this.pointerEventsScopeElement = null;
6438 this.pointerEventsReferenceElement = null;
6439 this.pointerEventsFloatingElement = null;
6440 this.restTimeoutPending = false;
6441 this.openChangeTimeout = new Timeout();
6442 this.restTimeout = new Timeout();
6443 this.handleCloseOptions = void 0;
6444 }
6445 static create() {
6446 return new _HoverInteraction();
6447 }
6448 dispose = () => {
6449 this.openChangeTimeout.clear();
6450 this.restTimeout.clear();
6451 };
6452 disposeEffect = () => {
6453 return this.dispose;
6454 };
6455 };
6456 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6457 function clearSafePolygonPointerEventsMutation(instance) {
6458 if (!instance.performedPointerEventsMutation) {
6459 return;
6460 }
6461 const scopeElement = instance.pointerEventsScopeElement;
6462 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6463 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6464 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6465 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6466 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6467 }
6468 instance.performedPointerEventsMutation = false;
6469 instance.pointerEventsScopeElement = null;
6470 instance.pointerEventsReferenceElement = null;
6471 instance.pointerEventsFloatingElement = null;
6472 }
6473 function applySafePolygonPointerEventsMutation(instance, options) {
6474 const {
6475 scopeElement,
6476 referenceElement,
6477 floatingElement
6478 } = options;
6479 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6480 if (existingOwner && existingOwner !== instance) {
6481 clearSafePolygonPointerEventsMutation(existingOwner);
6482 }
6483 clearSafePolygonPointerEventsMutation(instance);
6484 instance.performedPointerEventsMutation = true;
6485 instance.pointerEventsScopeElement = scopeElement;
6486 instance.pointerEventsReferenceElement = referenceElement;
6487 instance.pointerEventsFloatingElement = floatingElement;
6488 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6489 scopeElement.style.pointerEvents = "none";
6490 referenceElement.style.pointerEvents = "auto";
6491 floatingElement.style.pointerEvents = "auto";
6492 }
6493 function useHoverInteractionSharedState(store) {
6494 const data = store.context.dataRef.current;
6495 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6496 if (!data.hoverInteractionState) {
6497 data.hoverInteractionState = instance;
6498 }
6499 useOnMount(data.hoverInteractionState.disposeEffect);
6500 return data.hoverInteractionState;
6501 }
6502
6503 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6504 function useHoverFloatingInteraction(context, parameters = {}) {
6505 const {
6506 enabled = true,
6507 closeDelay: closeDelayProp = 0,
6508 nodeId: nodeIdProp
6509 } = parameters;
6510 const store = "rootStore" in context ? context.rootStore : context;
6511 const open = store.useState("open");
6512 const floatingElement = store.useState("floatingElement");
6513 const domReferenceElement = store.useState("domReferenceElement");
6514 const {
6515 dataRef
6516 } = store.context;
6517 const tree = useFloatingTree();
6518 const parentId = useFloatingParentNodeId();
6519 const instance = useHoverInteractionSharedState(store);
6520 const childClosedTimeout = useTimeout();
6521 const isClickLikeOpenEvent2 = useStableCallback(() => {
6522 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6523 });
6524 const isHoverOpen = useStableCallback(() => {
6525 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6526 });
6527 const clearPointerEvents = useStableCallback(() => {
6528 clearSafePolygonPointerEventsMutation(instance);
6529 });
6530 useIsoLayoutEffect(() => {
6531 if (!open) {
6532 instance.pointerType = void 0;
6533 instance.restTimeoutPending = false;
6534 instance.interactedInside = false;
6535 clearPointerEvents();
6536 }
6537 }, [open, instance, clearPointerEvents]);
6538 React27.useEffect(() => {
6539 return clearPointerEvents;
6540 }, [clearPointerEvents]);
6541 useIsoLayoutEffect(() => {
6542 if (!enabled) {
6543 return void 0;
6544 }
6545 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6546 const ref = domReferenceElement;
6547 const floatingEl = floatingElement;
6548 const doc = ownerDocument(floatingElement);
6549 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6550 if (parentFloating) {
6551 parentFloating.style.pointerEvents = "";
6552 }
6553 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6554 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6555 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6556 applySafePolygonPointerEventsMutation(instance, {
6557 scopeElement,
6558 referenceElement: ref,
6559 floatingElement: floatingEl
6560 });
6561 return () => {
6562 clearPointerEvents();
6563 };
6564 }
6565 return void 0;
6566 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6567 React27.useEffect(() => {
6568 if (!enabled) {
6569 return void 0;
6570 }
6571 function hasParentChildren() {
6572 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6573 }
6574 function closeWithDelay(event) {
6575 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6576 const close = () => {
6577 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6578 tree?.events.emit("floating.closed", event);
6579 };
6580 if (closeDelay) {
6581 instance.openChangeTimeout.start(closeDelay, close);
6582 } else {
6583 instance.openChangeTimeout.clear();
6584 close();
6585 }
6586 }
6587 function handleInteractInside(event) {
6588 const target = getTarget(event);
6589 if (!isInteractiveElement(target)) {
6590 instance.interactedInside = false;
6591 return;
6592 }
6593 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6594 }
6595 function onFloatingMouseEnter() {
6596 instance.openChangeTimeout.clear();
6597 childClosedTimeout.clear();
6598 tree?.events.off("floating.closed", onNodeClosed);
6599 clearPointerEvents();
6600 }
6601 function onFloatingMouseLeave(event) {
6602 if (hasParentChildren() && tree) {
6603 tree.events.on("floating.closed", onNodeClosed);
6604 return;
6605 }
6606 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6607 return;
6608 }
6609 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6610 const relatedTarget = event.relatedTarget;
6611 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6612 if (isMovingIntoDescendantFloating) {
6613 return;
6614 }
6615 if (instance.handler) {
6616 instance.handler(event);
6617 return;
6618 }
6619 clearPointerEvents();
6620 if (!isClickLikeOpenEvent2()) {
6621 closeWithDelay(event);
6622 }
6623 }
6624 function onNodeClosed(event) {
6625 if (!tree || !parentId || hasParentChildren()) {
6626 return;
6627 }
6628 childClosedTimeout.start(0, () => {
6629 tree.events.off("floating.closed", onNodeClosed);
6630 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6631 tree.events.emit("floating.closed", event);
6632 });
6633 }
6634 const floating = floatingElement;
6635 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6636 tree?.events.off("floating.closed", onNodeClosed);
6637 });
6638 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6639 }
6640
6641 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6642 var React28 = __toESM(require_react(), 1);
6643 var ReactDOM4 = __toESM(require_react_dom(), 1);
6644 var EMPTY_REF = {
6645 current: null
6646 };
6647 function useHoverReferenceInteraction(context, props = {}) {
6648 const {
6649 enabled = true,
6650 delay = 0,
6651 handleClose = null,
6652 mouseOnly = false,
6653 restMs = 0,
6654 move = true,
6655 triggerElementRef = EMPTY_REF,
6656 externalTree,
6657 isActiveTrigger = true,
6658 getHandleCloseContext,
6659 isClosing,
6660 shouldOpen: shouldOpenProp
6661 } = props;
6662 const store = "rootStore" in context ? context.rootStore : context;
6663 const {
6664 dataRef,
6665 events
6666 } = store.context;
6667 const tree = useFloatingTree(externalTree);
6668 const instance = useHoverInteractionSharedState(store);
6669 const isHoverCloseActiveRef = React28.useRef(false);
6670 const handleCloseRef = useValueAsRef(handleClose);
6671 const delayRef = useValueAsRef(delay);
6672 const restMsRef = useValueAsRef(restMs);
6673 const enabledRef = useValueAsRef(enabled);
6674 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6675 const isClosingRef = useValueAsRef(isClosing);
6676 const isClickLikeOpenEvent2 = useStableCallback(() => {
6677 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6678 });
6679 const checkShouldOpen = useStableCallback(() => {
6680 return shouldOpenRef.current?.() !== false;
6681 });
6682 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6683 const allTriggers = store.context.triggerElements;
6684 if (allTriggers.hasElement(currentTarget)) {
6685 return !currentDomReference || !contains(currentDomReference, currentTarget);
6686 }
6687 if (!isElement(target)) {
6688 return false;
6689 }
6690 const targetElement = target;
6691 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6692 });
6693 const cleanupMouseMoveHandler = useStableCallback(() => {
6694 if (!instance.handler) {
6695 return;
6696 }
6697 const doc = ownerDocument(store.select("domReferenceElement"));
6698 doc.removeEventListener("mousemove", instance.handler);
6699 instance.handler = void 0;
6700 });
6701 const clearPointerEvents = useStableCallback(() => {
6702 clearSafePolygonPointerEventsMutation(instance);
6703 });
6704 if (isActiveTrigger) {
6705 instance.handleCloseOptions = handleCloseRef.current?.__options;
6706 }
6707 React28.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6708 React28.useEffect(() => {
6709 if (!enabled) {
6710 return void 0;
6711 }
6712 function onOpenChangeLocal(details) {
6713 if (!details.open) {
6714 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6715 cleanupMouseMoveHandler();
6716 instance.openChangeTimeout.clear();
6717 instance.restTimeout.clear();
6718 instance.blockMouseMove = true;
6719 instance.restTimeoutPending = false;
6720 } else {
6721 isHoverCloseActiveRef.current = false;
6722 }
6723 }
6724 events.on("openchange", onOpenChangeLocal);
6725 return () => {
6726 events.off("openchange", onOpenChangeLocal);
6727 };
6728 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6729 React28.useEffect(() => {
6730 if (!enabled) {
6731 return void 0;
6732 }
6733 function closeWithDelay(event, runElseBranch = true) {
6734 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6735 if (closeDelay) {
6736 instance.openChangeTimeout.start(closeDelay, () => {
6737 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6738 tree?.events.emit("floating.closed", event);
6739 });
6740 } else if (runElseBranch) {
6741 instance.openChangeTimeout.clear();
6742 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6743 tree?.events.emit("floating.closed", event);
6744 }
6745 }
6746 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6747 if (!isElement(trigger)) {
6748 return void 0;
6749 }
6750 function onMouseEnter(event) {
6751 instance.openChangeTimeout.clear();
6752 instance.blockMouseMove = false;
6753 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6754 return;
6755 }
6756 const restMsValue = getRestMs(restMsRef.current);
6757 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6758 const eventTarget = getTarget(event);
6759 const currentTarget = event.currentTarget ?? null;
6760 const currentDomReference = store.select("domReferenceElement");
6761 let triggerNode = currentTarget;
6762 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6763 for (const triggerElement of store.context.triggerElements.elements()) {
6764 if (contains(triggerElement, eventTarget)) {
6765 triggerNode = triggerElement;
6766 break;
6767 }
6768 }
6769 }
6770 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6771 triggerNode = currentDomReference;
6772 }
6773 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6774 const isOpen = store.select("open");
6775 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6776 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6777 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6778 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6779 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6780 const shouldOpen = !isOpen || isOverInactive;
6781 if (shouldOpenImmediately) {
6782 if (checkShouldOpen()) {
6783 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6784 }
6785 return;
6786 }
6787 if (isRestOnlyDelay) {
6788 return;
6789 }
6790 if (openDelay) {
6791 instance.openChangeTimeout.start(openDelay, () => {
6792 if (shouldOpen && checkShouldOpen()) {
6793 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6794 }
6795 });
6796 } else if (shouldOpen) {
6797 if (checkShouldOpen()) {
6798 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6799 }
6800 }
6801 }
6802 function onMouseLeave(event) {
6803 if (isClickLikeOpenEvent2()) {
6804 clearPointerEvents();
6805 return;
6806 }
6807 cleanupMouseMoveHandler();
6808 const domReferenceElement = store.select("domReferenceElement");
6809 const doc = ownerDocument(domReferenceElement);
6810 instance.restTimeout.clear();
6811 instance.restTimeoutPending = false;
6812 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6813 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6814 return;
6815 }
6816 if (handleCloseRef.current && handleCloseContextBase) {
6817 if (!store.select("open")) {
6818 instance.openChangeTimeout.clear();
6819 }
6820 const currentTrigger = triggerElementRef.current;
6821 instance.handler = handleCloseRef.current({
6822 ...handleCloseContextBase,
6823 tree,
6824 x: event.clientX,
6825 y: event.clientY,
6826 onClose() {
6827 clearPointerEvents();
6828 cleanupMouseMoveHandler();
6829 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6830 closeWithDelay(event, true);
6831 }
6832 }
6833 });
6834 doc.addEventListener("mousemove", instance.handler);
6835 instance.handler(event);
6836 return;
6837 }
6838 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6839 if (shouldClose) {
6840 closeWithDelay(event);
6841 }
6842 }
6843 if (move) {
6844 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6845 once: true
6846 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6847 }
6848 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6849 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
6850 return React28.useMemo(() => {
6851 if (!enabled) {
6852 return void 0;
6853 }
6854 function setPointerRef(event) {
6855 instance.pointerType = event.pointerType;
6856 }
6857 return {
6858 onPointerDown: setPointerRef,
6859 onPointerEnter: setPointerRef,
6860 onMouseMove(event) {
6861 const {
6862 nativeEvent
6863 } = event;
6864 const trigger = event.currentTarget;
6865 const currentDomReference = store.select("domReferenceElement");
6866 const currentOpen = store.select("open");
6867 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6868 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6869 return;
6870 }
6871 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6872 const floatingElement = store.select("floatingElement");
6873 if (floatingElement) {
6874 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6875 applySafePolygonPointerEventsMutation(instance, {
6876 scopeElement,
6877 referenceElement: trigger,
6878 floatingElement
6879 });
6880 }
6881 }
6882 const restMsValue = getRestMs(restMsRef.current);
6883 if (currentOpen && !isOverInactive || restMsValue === 0) {
6884 return;
6885 }
6886 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6887 return;
6888 }
6889 instance.restTimeout.clear();
6890 function handleMouseMove() {
6891 instance.restTimeoutPending = false;
6892 if (isClickLikeOpenEvent2()) {
6893 return;
6894 }
6895 const latestOpen = store.select("open");
6896 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
6897 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6898 }
6899 }
6900 if (instance.pointerType === "touch") {
6901 ReactDOM4.flushSync(() => {
6902 handleMouseMove();
6903 });
6904 } else if (isOverInactive && currentOpen) {
6905 handleMouseMove();
6906 } else {
6907 instance.restTimeoutPending = true;
6908 instance.restTimeout.start(restMsValue, handleMouseMove);
6909 }
6910 }
6911 };
6912 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
6913 }
6914
6915 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
6916 var CURSOR_SPEED_THRESHOLD = 0.1;
6917 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
6918 var POLYGON_BUFFER = 0.5;
6919 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
6920 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
6921 }
6922 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
6923 let isInsideValue = false;
6924 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
6925 isInsideValue = !isInsideValue;
6926 }
6927 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
6928 isInsideValue = !isInsideValue;
6929 }
6930 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
6931 isInsideValue = !isInsideValue;
6932 }
6933 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
6934 isInsideValue = !isInsideValue;
6935 }
6936 return isInsideValue;
6937 }
6938 function isInsideRect(pointX, pointY, rect) {
6939 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
6940 }
6941 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
6942 const minX = Math.min(x1, x2);
6943 const maxX = Math.max(x1, x2);
6944 const minY = Math.min(y1, y2);
6945 const maxY = Math.max(y1, y2);
6946 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
6947 }
6948 function safePolygon(options = {}) {
6949 const {
6950 blockPointerEvents = false
6951 } = options;
6952 const timeout = new Timeout();
6953 const fn = ({
6954 x: x2,
6955 y: y2,
6956 placement,
6957 elements,
6958 onClose,
6959 nodeId,
6960 tree
6961 }) => {
6962 const side = placement?.split("-")[0];
6963 let hasLanded = false;
6964 let lastX = null;
6965 let lastY = null;
6966 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
6967 function isCursorMovingSlowly(nextX, nextY) {
6968 const currentTime = performance.now();
6969 const elapsedTime = currentTime - lastCursorTime;
6970 if (lastX === null || lastY === null || elapsedTime === 0) {
6971 lastX = nextX;
6972 lastY = nextY;
6973 lastCursorTime = currentTime;
6974 return false;
6975 }
6976 const deltaX = nextX - lastX;
6977 const deltaY = nextY - lastY;
6978 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
6979 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
6980 lastX = nextX;
6981 lastY = nextY;
6982 lastCursorTime = currentTime;
6983 return distanceSquared < thresholdSquared;
6984 }
6985 function close() {
6986 timeout.clear();
6987 onClose();
6988 }
6989 return function onMouseMove(event) {
6990 timeout.clear();
6991 const domReference = elements.domReference;
6992 const floating = elements.floating;
6993 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
6994 return void 0;
6995 }
6996 const {
6997 clientX,
6998 clientY
6999 } = event;
7000 const target = getTarget(event);
7001 const isLeave = event.type === "mouseleave";
7002 const isOverFloatingEl = contains(floating, target);
7003 const isOverReferenceEl = contains(domReference, target);
7004 if (isOverFloatingEl) {
7005 hasLanded = true;
7006 if (!isLeave) {
7007 return void 0;
7008 }
7009 }
7010 if (isOverReferenceEl) {
7011 hasLanded = false;
7012 if (!isLeave) {
7013 hasLanded = true;
7014 return void 0;
7015 }
7016 }
7017 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7018 return void 0;
7019 }
7020 function hasOpenChildNode() {
7021 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7022 }
7023 function closeIfNoOpenChild() {
7024 if (!hasOpenChildNode()) {
7025 close();
7026 }
7027 }
7028 if (hasOpenChildNode()) {
7029 return void 0;
7030 }
7031 const refRect = domReference.getBoundingClientRect();
7032 const rect = floating.getBoundingClientRect();
7033 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7034 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7035 const isFloatingWider = rect.width > refRect.width;
7036 const isFloatingTaller = rect.height > refRect.height;
7037 const left = (isFloatingWider ? refRect : rect).left;
7038 const right = (isFloatingWider ? refRect : rect).right;
7039 const top = (isFloatingTaller ? refRect : rect).top;
7040 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7041 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) {
7042 closeIfNoOpenChild();
7043 return void 0;
7044 }
7045 let isInsideTroughRect = false;
7046 switch (side) {
7047 case "top":
7048 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7049 break;
7050 case "bottom":
7051 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7052 break;
7053 case "left":
7054 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7055 break;
7056 case "right":
7057 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7058 break;
7059 default:
7060 }
7061 if (isInsideTroughRect) {
7062 return void 0;
7063 }
7064 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7065 closeIfNoOpenChild();
7066 return void 0;
7067 }
7068 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7069 closeIfNoOpenChild();
7070 return void 0;
7071 }
7072 let isInsidePolygon = false;
7073 switch (side) {
7074 case "top": {
7075 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7076 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7077 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7078 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7079 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7080 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7081 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7082 break;
7083 }
7084 case "bottom": {
7085 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7086 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7087 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7088 const cursorPointY = y2 - POLYGON_BUFFER;
7089 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7090 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7091 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7092 break;
7093 }
7094 case "left": {
7095 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7096 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7097 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7098 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7099 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7100 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7101 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7102 break;
7103 }
7104 case "right": {
7105 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7106 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7107 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7108 const cursorPointX = x2 - POLYGON_BUFFER;
7109 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7110 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7111 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7112 break;
7113 }
7114 default:
7115 }
7116 if (!isInsidePolygon) {
7117 closeIfNoOpenChild();
7118 } else if (!hasLanded) {
7119 timeout.start(40, closeIfNoOpenChild);
7120 }
7121 return void 0;
7122 };
7123 };
7124 fn.__options = {
7125 ...options,
7126 blockPointerEvents
7127 };
7128 return fn;
7129 }
7130
7131 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7132 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7133 CommonPopupDataAttributes2["open"] = "data-open";
7134 CommonPopupDataAttributes2["closed"] = "data-closed";
7135 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7136 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7137 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7138 CommonPopupDataAttributes2["side"] = "data-side";
7139 CommonPopupDataAttributes2["align"] = "data-align";
7140 return CommonPopupDataAttributes2;
7141 })({});
7142 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7143 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7144 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7145 return CommonTriggerDataAttributes2;
7146 })({});
7147 var TRIGGER_HOOK = {
7148 [CommonTriggerDataAttributes.popupOpen]: ""
7149 };
7150 var PRESSABLE_TRIGGER_HOOK = {
7151 [CommonTriggerDataAttributes.popupOpen]: "",
7152 [CommonTriggerDataAttributes.pressed]: ""
7153 };
7154 var POPUP_OPEN_HOOK = {
7155 [CommonPopupDataAttributes.open]: ""
7156 };
7157 var POPUP_CLOSED_HOOK = {
7158 [CommonPopupDataAttributes.closed]: ""
7159 };
7160 var ANCHOR_HIDDEN_HOOK = {
7161 [CommonPopupDataAttributes.anchorHidden]: ""
7162 };
7163 var triggerOpenStateMapping = {
7164 open(value) {
7165 if (value) {
7166 return TRIGGER_HOOK;
7167 }
7168 return null;
7169 }
7170 };
7171 var popupStateMapping = {
7172 open(value) {
7173 if (value) {
7174 return POPUP_OPEN_HOOK;
7175 }
7176 return POPUP_CLOSED_HOOK;
7177 },
7178 anchorHidden(value) {
7179 if (value) {
7180 return ANCHOR_HIDDEN_HOOK;
7181 }
7182 return null;
7183 }
7184 };
7185
7186 // node_modules/@base-ui/utils/esm/inertValue.js
7187 function inertValue(value) {
7188 if (isReactVersionAtLeast(19)) {
7189 return value;
7190 }
7191 return value ? "true" : void 0;
7192 }
7193
7194 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7195 var React29 = __toESM(require_react(), 1);
7196
7197 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7198 var baseArrow = (options) => ({
7199 name: "arrow",
7200 options,
7201 async fn(state) {
7202 const {
7203 x: x2,
7204 y: y2,
7205 placement,
7206 rects,
7207 platform: platform3,
7208 elements,
7209 middlewareData
7210 } = state;
7211 const {
7212 element,
7213 padding = 0,
7214 offsetParent = "real"
7215 } = evaluate(options, state) || {};
7216 if (element == null) {
7217 return {};
7218 }
7219 const paddingObject = getPaddingObject(padding);
7220 const coords = {
7221 x: x2,
7222 y: y2
7223 };
7224 const axis = getAlignmentAxis(placement);
7225 const length = getAxisLength(axis);
7226 const arrowDimensions = await platform3.getDimensions(element);
7227 const isYAxis = axis === "y";
7228 const minProp = isYAxis ? "top" : "left";
7229 const maxProp = isYAxis ? "bottom" : "right";
7230 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7231 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7232 const startDiff = coords[axis] - rects.reference[axis];
7233 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7234 let clientSize = elements.floating[clientProp] || rects.floating[length];
7235 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7236 clientSize = elements.floating[clientProp] || rects.floating[length];
7237 }
7238 const centerToReference = endDiff / 2 - startDiff / 2;
7239 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7240 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7241 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7242 const min2 = minPadding;
7243 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7244 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7245 const offset4 = clamp(min2, center, max2);
7246 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7247 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7248 return {
7249 [axis]: coords[axis] + alignmentOffset,
7250 data: {
7251 [axis]: offset4,
7252 centerOffset: center - offset4 - alignmentOffset,
7253 ...shouldAddOffset && {
7254 alignmentOffset
7255 }
7256 },
7257 reset: shouldAddOffset
7258 };
7259 }
7260 });
7261 var arrow4 = (options, deps) => ({
7262 ...baseArrow(options),
7263 options: [options, deps]
7264 });
7265
7266 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7267 var hide4 = {
7268 name: "hide",
7269 async fn(state) {
7270 const {
7271 width,
7272 height,
7273 x: x2,
7274 y: y2
7275 } = state.rects.reference;
7276 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7277 const nativeHideResult = await hide3().fn(state);
7278 return {
7279 data: {
7280 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7281 }
7282 };
7283 }
7284 };
7285
7286 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7287 var DEFAULT_SIDES = {
7288 sideX: "left",
7289 sideY: "top"
7290 };
7291 var adaptiveOrigin = {
7292 name: "adaptiveOrigin",
7293 async fn(state) {
7294 const {
7295 x: rawX,
7296 y: rawY,
7297 rects: {
7298 floating: floatRect
7299 },
7300 elements: {
7301 floating
7302 },
7303 platform: platform3,
7304 strategy,
7305 placement
7306 } = state;
7307 const win = getWindow(floating);
7308 const styles = win.getComputedStyle(floating);
7309 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7310 if (!hasTransition) {
7311 return {
7312 x: rawX,
7313 y: rawY,
7314 data: DEFAULT_SIDES
7315 };
7316 }
7317 const offsetParent = await platform3.getOffsetParent?.(floating);
7318 let offsetDimensions = {
7319 width: 0,
7320 height: 0
7321 };
7322 if (strategy === "fixed" && win?.visualViewport) {
7323 offsetDimensions = {
7324 width: win.visualViewport.width,
7325 height: win.visualViewport.height
7326 };
7327 } else if (offsetParent === win) {
7328 const doc = ownerDocument(floating);
7329 offsetDimensions = {
7330 width: doc.documentElement.clientWidth,
7331 height: doc.documentElement.clientHeight
7332 };
7333 } else if (await platform3.isElement?.(offsetParent)) {
7334 offsetDimensions = await platform3.getDimensions(offsetParent);
7335 }
7336 const currentSide = getSide(placement);
7337 let x2 = rawX;
7338 let y2 = rawY;
7339 if (currentSide === "left") {
7340 x2 = offsetDimensions.width - (rawX + floatRect.width);
7341 }
7342 if (currentSide === "top") {
7343 y2 = offsetDimensions.height - (rawY + floatRect.height);
7344 }
7345 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7346 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7347 return {
7348 x: x2,
7349 y: y2,
7350 data: {
7351 sideX,
7352 sideY
7353 }
7354 };
7355 }
7356 };
7357
7358 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7359 function getLogicalSide(sideParam, renderedSide, isRtl) {
7360 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7361 const logicalRight = isRtl ? "inline-start" : "inline-end";
7362 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7363 return {
7364 top: "top",
7365 right: isLogicalSideParam ? logicalRight : "right",
7366 bottom: "bottom",
7367 left: isLogicalSideParam ? logicalLeft : "left"
7368 }[renderedSide];
7369 }
7370 function getOffsetData(state, sideParam, isRtl) {
7371 const {
7372 rects,
7373 placement
7374 } = state;
7375 const data = {
7376 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7377 align: getAlignment(placement) || "center",
7378 anchor: {
7379 width: rects.reference.width,
7380 height: rects.reference.height
7381 },
7382 positioner: {
7383 width: rects.floating.width,
7384 height: rects.floating.height
7385 }
7386 };
7387 return data;
7388 }
7389 function useAnchorPositioning(params) {
7390 const {
7391 // Public parameters
7392 anchor,
7393 positionMethod = "absolute",
7394 side: sideParam = "bottom",
7395 sideOffset = 0,
7396 align = "center",
7397 alignOffset = 0,
7398 collisionBoundary,
7399 collisionPadding: collisionPaddingParam = 5,
7400 sticky = false,
7401 arrowPadding = 5,
7402 disableAnchorTracking = false,
7403 inline: inlineMiddleware,
7404 // Private parameters
7405 keepMounted = false,
7406 floatingRootContext,
7407 mounted,
7408 collisionAvoidance,
7409 shiftCrossAxis = false,
7410 nodeId,
7411 adaptiveOrigin: adaptiveOrigin2,
7412 lazyFlip = false,
7413 externalTree
7414 } = params;
7415 const [mountSide, setMountSide] = React29.useState(null);
7416 if (!mounted && mountSide !== null) {
7417 setMountSide(null);
7418 }
7419 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7420 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7421 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7422 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7423 const anchorFnCallback = useStableCallback(anchorFn);
7424 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7425 const anchorValueRef = useValueAsRef(anchor);
7426 const mountedRef = useValueAsRef(mounted);
7427 const direction = useDirection();
7428 const isRtl = direction === "rtl";
7429 const side = mountSide || {
7430 top: "top",
7431 right: "right",
7432 bottom: "bottom",
7433 left: "left",
7434 "inline-end": isRtl ? "left" : "right",
7435 "inline-start": isRtl ? "right" : "left"
7436 }[sideParam];
7437 const placement = align === "center" ? side : `${side}-${align}`;
7438 let collisionPadding = collisionPaddingParam;
7439 const bias = 1;
7440 const biasTop = sideParam === "bottom" ? bias : 0;
7441 const biasBottom = sideParam === "top" ? bias : 0;
7442 const biasLeft = sideParam === "right" ? bias : 0;
7443 const biasRight = sideParam === "left" ? bias : 0;
7444 if (typeof collisionPadding === "number") {
7445 collisionPadding = {
7446 top: collisionPadding + biasTop,
7447 right: collisionPadding + biasRight,
7448 bottom: collisionPadding + biasBottom,
7449 left: collisionPadding + biasLeft
7450 };
7451 } else if (collisionPadding) {
7452 collisionPadding = {
7453 top: (collisionPadding.top || 0) + biasTop,
7454 right: (collisionPadding.right || 0) + biasRight,
7455 bottom: (collisionPadding.bottom || 0) + biasBottom,
7456 left: (collisionPadding.left || 0) + biasLeft
7457 };
7458 }
7459 const commonCollisionProps = {
7460 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7461 padding: collisionPadding
7462 };
7463 const arrowRef = React29.useRef(null);
7464 const sideOffsetRef = useValueAsRef(sideOffset);
7465 const alignOffsetRef = useValueAsRef(alignOffset);
7466 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7467 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7468 const middleware = [];
7469 if (inlineMiddleware) {
7470 middleware.push(inlineMiddleware);
7471 }
7472 middleware.push(offset3((state) => {
7473 const data = getOffsetData(state, sideParam, isRtl);
7474 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7475 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7476 return {
7477 mainAxis: sideAxis,
7478 crossAxis: alignAxis,
7479 alignmentAxis: alignAxis
7480 };
7481 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7482 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7483 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7484 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7485 ...commonCollisionProps,
7486 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7487 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7488 padding: {
7489 top: collisionPadding.top + bias,
7490 right: collisionPadding.right + bias,
7491 bottom: collisionPadding.bottom + bias,
7492 left: collisionPadding.left + bias
7493 },
7494 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7495 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7496 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7497 });
7498 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7499 const html = ownerDocument(data.elements.floating).documentElement;
7500 return {
7501 ...commonCollisionProps,
7502 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7503 // for context menus.
7504 rootBoundary: shiftCrossAxis ? {
7505 x: 0,
7506 y: 0,
7507 width: html.clientWidth,
7508 height: html.clientHeight
7509 } : void 0,
7510 mainAxis: collisionAvoidanceAlign !== "none",
7511 crossAxis: crossAxisShiftEnabled,
7512 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7513 if (!arrowRef.current) {
7514 return {};
7515 }
7516 const {
7517 width,
7518 height
7519 } = arrowRef.current.getBoundingClientRect();
7520 const sideAxis = getSideAxis(getSide(limitData.placement));
7521 const arrowSize = sideAxis === "y" ? width : height;
7522 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7523 return {
7524 offset: arrowSize / 2 + offsetAmount / 2
7525 };
7526 })
7527 };
7528 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7529 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7530 middleware.push(shiftMiddleware, flipMiddleware);
7531 } else {
7532 middleware.push(flipMiddleware, shiftMiddleware);
7533 }
7534 middleware.push(size3({
7535 ...commonCollisionProps,
7536 apply({
7537 elements: {
7538 floating
7539 },
7540 availableWidth,
7541 availableHeight,
7542 rects
7543 }) {
7544 if (!mountedRef.current) {
7545 return;
7546 }
7547 const floatingStyle = floating.style;
7548 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7549 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7550 const dpr = getWindow(floating).devicePixelRatio || 1;
7551 const {
7552 x: x3,
7553 y: y3,
7554 width,
7555 height
7556 } = rects.reference;
7557 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7558 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7559 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7560 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7561 }
7562 }), arrow4((state) => ({
7563 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7564 // we'll create a fake element.
7565 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7566 padding: arrowPadding,
7567 offsetParent: "floating"
7568 }), [arrowPadding]), {
7569 name: "transformOrigin",
7570 fn(state) {
7571 const {
7572 elements: elements2,
7573 middlewareData: middlewareData2,
7574 placement: renderedPlacement2,
7575 rects,
7576 y: y3
7577 } = state;
7578 const currentRenderedSide = getSide(renderedPlacement2);
7579 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7580 const arrowEl = arrowRef.current;
7581 const arrowX = middlewareData2.arrow?.x || 0;
7582 const arrowY = middlewareData2.arrow?.y || 0;
7583 const arrowWidth = arrowEl?.clientWidth || 0;
7584 const arrowHeight = arrowEl?.clientHeight || 0;
7585 const transformX = arrowX + arrowWidth / 2;
7586 const transformY = arrowY + arrowHeight / 2;
7587 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7588 const halfAnchorHeight = rects.reference.height / 2;
7589 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7590 const isOverlappingAnchor = shiftY > sideOffsetValue;
7591 const adjacentTransformOrigin = {
7592 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7593 bottom: `${transformX}px ${-sideOffsetValue}px`,
7594 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7595 right: `${-sideOffsetValue}px ${transformY}px`
7596 }[currentRenderedSide];
7597 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7598 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7599 return {};
7600 }
7601 }, hide4, adaptiveOrigin2);
7602 useIsoLayoutEffect(() => {
7603 if (!mounted && floatingRootContext) {
7604 floatingRootContext.update({
7605 referenceElement: null,
7606 floatingElement: null,
7607 domReferenceElement: null,
7608 positionReference: null
7609 });
7610 }
7611 }, [mounted, floatingRootContext]);
7612 const autoUpdateOptions = React29.useMemo(() => ({
7613 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7614 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7615 }), [disableAnchorTracking]);
7616 const {
7617 refs,
7618 elements,
7619 x: x2,
7620 y: y2,
7621 middlewareData,
7622 update: update2,
7623 placement: renderedPlacement,
7624 context,
7625 isPositioned,
7626 floatingStyles: originalFloatingStyles
7627 } = useFloating2({
7628 rootContext: floatingRootContext,
7629 open: keepMounted ? mounted : void 0,
7630 placement,
7631 middleware,
7632 strategy: positionMethod,
7633 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7634 nodeId,
7635 externalTree
7636 });
7637 const {
7638 sideX,
7639 sideY
7640 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7641 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7642 const floatingStyles = React29.useMemo(() => {
7643 const base = adaptiveOrigin2 ? {
7644 position: resolvedPosition,
7645 [sideX]: x2,
7646 [sideY]: y2
7647 } : {
7648 position: resolvedPosition,
7649 ...originalFloatingStyles
7650 };
7651 if (!isPositioned) {
7652 base.opacity = 0;
7653 }
7654 return base;
7655 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7656 const registeredPositionReferenceRef = React29.useRef(null);
7657 useIsoLayoutEffect(() => {
7658 if (!mounted) {
7659 return;
7660 }
7661 const anchorValue = anchorValueRef.current;
7662 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7663 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7664 const finalAnchor = unwrappedElement || null;
7665 if (finalAnchor !== registeredPositionReferenceRef.current) {
7666 refs.setPositionReference(finalAnchor);
7667 registeredPositionReferenceRef.current = finalAnchor;
7668 }
7669 }, [mounted, refs, anchorDep, anchorValueRef]);
7670 React29.useEffect(() => {
7671 if (!mounted) {
7672 return;
7673 }
7674 const anchorValue = anchorValueRef.current;
7675 if (typeof anchorValue === "function") {
7676 return;
7677 }
7678 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7679 refs.setPositionReference(anchorValue.current);
7680 registeredPositionReferenceRef.current = anchorValue.current;
7681 }
7682 }, [mounted, refs, anchorDep, anchorValueRef]);
7683 React29.useEffect(() => {
7684 if (keepMounted && mounted && elements.domReference && elements.floating) {
7685 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7686 }
7687 return void 0;
7688 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7689 const renderedSide = getSide(renderedPlacement);
7690 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7691 const renderedAlign = getAlignment(renderedPlacement) || "center";
7692 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7693 useIsoLayoutEffect(() => {
7694 if (lazyFlip && mounted && isPositioned) {
7695 setMountSide(renderedSide);
7696 }
7697 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7698 const arrowStyles = React29.useMemo(() => ({
7699 position: "absolute",
7700 top: middlewareData.arrow?.y,
7701 left: middlewareData.arrow?.x
7702 }), [middlewareData.arrow]);
7703 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7704 return React29.useMemo(() => ({
7705 positionerStyles: floatingStyles,
7706 arrowStyles,
7707 arrowRef,
7708 arrowUncentered,
7709 side: logicalRenderedSide,
7710 align: renderedAlign,
7711 physicalSide: renderedSide,
7712 anchorHidden,
7713 refs,
7714 context,
7715 isPositioned,
7716 update: update2
7717 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7718 }
7719 function isRef(param) {
7720 return param != null && "current" in param;
7721 }
7722
7723 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7724 function getDisabledMountTransitionStyles(transitionStatus) {
7725 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7726 }
7727
7728 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7729 function usePositioner(componentProps, state, {
7730 styles,
7731 transitionStatus,
7732 props,
7733 refs,
7734 hidden,
7735 inert = false
7736 }) {
7737 const style = {
7738 ...styles
7739 };
7740 if (inert) {
7741 style.pointerEvents = "none";
7742 }
7743 return useRenderElement("div", componentProps, {
7744 state,
7745 ref: refs,
7746 props: [{
7747 role: "presentation",
7748 hidden,
7749 style
7750 }, getDisabledMountTransitionStyles(transitionStatus), props],
7751 stateAttributesMapping: popupStateMapping
7752 });
7753 }
7754
7755 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7756 var React32 = __toESM(require_react(), 1);
7757 var ReactDOM5 = __toESM(require_react_dom(), 1);
7758
7759 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7760 var React30 = __toESM(require_react(), 1);
7761 function usePreviousValue(value) {
7762 const [state, setState] = React30.useState({
7763 current: value,
7764 previous: null
7765 });
7766 if (value !== state.current) {
7767 setState({
7768 current: value,
7769 previous: state.current
7770 });
7771 }
7772 return state.previous;
7773 }
7774
7775 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7776 var React31 = __toESM(require_react(), 1);
7777
7778 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7779 function getCssDimensions2(element) {
7780 const css = getComputedStyle2(element);
7781 let width = parseFloat(css.width) || 0;
7782 let height = parseFloat(css.height) || 0;
7783 const hasOffset = isHTMLElement(element);
7784 const offsetWidth = hasOffset ? element.offsetWidth : width;
7785 const offsetHeight = hasOffset ? element.offsetHeight : height;
7786 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7787 if (shouldFallback) {
7788 width = offsetWidth;
7789 height = offsetHeight;
7790 }
7791 return {
7792 width,
7793 height
7794 };
7795 }
7796
7797 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7798 var DEFAULT_ENABLED = () => true;
7799 function usePopupAutoResize(parameters) {
7800 const {
7801 popupElement,
7802 positionerElement,
7803 content,
7804 mounted,
7805 enabled = DEFAULT_ENABLED,
7806 onMeasureLayout: onMeasureLayoutParam,
7807 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7808 side,
7809 direction
7810 } = parameters;
7811 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7812 const animationFrame = useAnimationFrame();
7813 const committedDimensionsRef = React31.useRef(null);
7814 const liveDimensionsRef = React31.useRef(null);
7815 const isInitialRenderRef = React31.useRef(true);
7816 const restoreAnchoringStylesRef = React31.useRef(NOOP);
7817 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7818 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7819 const anchoringStyles = React31.useMemo(() => {
7820 let isOriginSide = side === "top";
7821 let isPhysicalLeft = side === "left";
7822 if (direction === "rtl") {
7823 isOriginSide = isOriginSide || side === "inline-end";
7824 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7825 } else {
7826 isOriginSide = isOriginSide || side === "inline-start";
7827 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7828 }
7829 return isOriginSide ? {
7830 position: "absolute",
7831 [side === "top" ? "bottom" : "top"]: "0",
7832 [isPhysicalLeft ? "right" : "left"]: "0"
7833 } : EMPTY_OBJECT;
7834 }, [side, direction]);
7835 useIsoLayoutEffect(() => {
7836 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7837 restoreAnchoringStylesRef.current = NOOP;
7838 isInitialRenderRef.current = true;
7839 committedDimensionsRef.current = null;
7840 liveDimensionsRef.current = null;
7841 return void 0;
7842 }
7843 if (!popupElement || !positionerElement) {
7844 return void 0;
7845 }
7846 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7847 const observer = new ResizeObserver((entries) => {
7848 const entry = entries[0];
7849 if (entry) {
7850 liveDimensionsRef.current = {
7851 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
7852 height: Math.ceil(entry.borderBoxSize[0].blockSize)
7853 };
7854 }
7855 });
7856 observer.observe(popupElement);
7857 setPopupCssSize(popupElement, "auto");
7858 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
7859 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
7860 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
7861 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
7862 "--available-width": "max-content",
7863 "--available-height": "max-content"
7864 });
7865 function restoreMeasurementOverrides() {
7866 restorePopupPosition();
7867 restorePopupTransform();
7868 restorePositionerAvailableSize();
7869 }
7870 function restoreMeasurementOverridesIncludingScale() {
7871 restoreMeasurementOverrides();
7872 restorePopupScale();
7873 }
7874 onMeasureLayout?.();
7875 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
7876 setPositionerCssSize(positionerElement, "max-content");
7877 const dimensions = getCssDimensions2(popupElement);
7878 committedDimensionsRef.current = dimensions;
7879 setPositionerCssSize(positionerElement, dimensions);
7880 restoreMeasurementOverridesIncludingScale();
7881 onMeasureLayoutComplete?.(null, dimensions);
7882 isInitialRenderRef.current = false;
7883 return () => {
7884 observer.disconnect();
7885 restoreAnchoringStylesRef.current();
7886 restoreAnchoringStylesRef.current = NOOP;
7887 };
7888 }
7889 setPopupCssSize(popupElement, "auto");
7890 setPositionerCssSize(positionerElement, "max-content");
7891 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
7892 const newDimensions = getCssDimensions2(popupElement);
7893 committedDimensionsRef.current = newDimensions;
7894 if (!previousDimensions) {
7895 setPositionerCssSize(positionerElement, newDimensions);
7896 restoreMeasurementOverridesIncludingScale();
7897 onMeasureLayoutComplete?.(null, newDimensions);
7898 return () => {
7899 observer.disconnect();
7900 animationFrame.cancel();
7901 restoreAnchoringStylesRef.current();
7902 restoreAnchoringStylesRef.current = NOOP;
7903 };
7904 }
7905 setPopupCssSize(popupElement, previousDimensions);
7906 restoreMeasurementOverridesIncludingScale();
7907 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
7908 setPositionerCssSize(positionerElement, newDimensions);
7909 const abortController = new AbortController();
7910 animationFrame.request(() => {
7911 setPopupCssSize(popupElement, newDimensions);
7912 runOnceAnimationsFinish(() => {
7913 popupElement.style.setProperty("--popup-width", "auto");
7914 popupElement.style.setProperty("--popup-height", "auto");
7915 }, abortController.signal);
7916 });
7917 return () => {
7918 observer.disconnect();
7919 abortController.abort();
7920 animationFrame.cancel();
7921 restoreAnchoringStylesRef.current();
7922 restoreAnchoringStylesRef.current = NOOP;
7923 };
7924 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
7925 }
7926 function overrideElementStyle(element, property, value) {
7927 const originalValue = element.style.getPropertyValue(property);
7928 element.style.setProperty(property, value);
7929 return () => {
7930 element.style.setProperty(property, originalValue);
7931 };
7932 }
7933 function applyElementStyles(element, styles) {
7934 const restorers = [];
7935 for (const [key, value] of Object.entries(styles)) {
7936 restorers.push(overrideElementStyle(element, key, value));
7937 }
7938 return restorers.length ? () => {
7939 restorers.forEach((restore) => restore());
7940 } : NOOP;
7941 }
7942 function setPopupCssSize(popupElement, size4) {
7943 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
7944 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
7945 popupElement.style.setProperty("--popup-width", width);
7946 popupElement.style.setProperty("--popup-height", height);
7947 }
7948 function setPositionerCssSize(positionerElement, size4) {
7949 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
7950 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
7951 positionerElement.style.setProperty("--positioner-width", width);
7952 positionerElement.style.setProperty("--positioner-height", height);
7953 }
7954
7955 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7956 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
7957 function usePopupViewport(parameters) {
7958 const {
7959 store,
7960 side,
7961 cssVars,
7962 children
7963 } = parameters;
7964 const direction = useDirection();
7965 const activeTrigger = store.useState("activeTriggerElement");
7966 const activeTriggerId = store.useState("activeTriggerId");
7967 const open = store.useState("open");
7968 const payload = store.useState("payload");
7969 const mounted = store.useState("mounted");
7970 const popupElement = store.useState("popupElement");
7971 const positionerElement = store.useState("positionerElement");
7972 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
7973 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
7974 const capturedNodeRef = React32.useRef(null);
7975 const [previousContentNode, setPreviousContentNode] = React32.useState(null);
7976 const [newTriggerOffset, setNewTriggerOffset] = React32.useState(null);
7977 const currentContainerRef = React32.useRef(null);
7978 const previousContainerRef = React32.useRef(null);
7979 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
7980 const cleanupFrame = useAnimationFrame();
7981 const [previousContentDimensions, setPreviousContentDimensions] = React32.useState(null);
7982 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React32.useState(false);
7983 useIsoLayoutEffect(() => {
7984 store.set("hasViewport", true);
7985 return () => {
7986 store.set("hasViewport", false);
7987 };
7988 }, [store]);
7989 const handleMeasureLayout = useStableCallback(() => {
7990 currentContainerRef.current?.style.setProperty("animation", "none");
7991 currentContainerRef.current?.style.setProperty("transition", "none");
7992 previousContainerRef.current?.style.setProperty("display", "none");
7993 });
7994 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
7995 currentContainerRef.current?.style.removeProperty("animation");
7996 currentContainerRef.current?.style.removeProperty("transition");
7997 previousContainerRef.current?.style.removeProperty("display");
7998 if (previousDimensions) {
7999 setPreviousContentDimensions(previousDimensions);
8000 }
8001 });
8002 const lastHandledTriggerRef = React32.useRef(null);
8003 useIsoLayoutEffect(() => {
8004 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8005 setPreviousContentNode(capturedNodeRef.current);
8006 setShowStartingStyleAttribute(true);
8007 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8008 setNewTriggerOffset(offset4);
8009 cleanupFrame.request(() => {
8010 ReactDOM5.flushSync(() => {
8011 setShowStartingStyleAttribute(false);
8012 });
8013 onAnimationsFinished(() => {
8014 setPreviousContentNode(null);
8015 setPreviousContentDimensions(null);
8016 capturedNodeRef.current = null;
8017 });
8018 });
8019 lastHandledTriggerRef.current = activeTrigger;
8020 }
8021 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8022 useIsoLayoutEffect(() => {
8023 const source = currentContainerRef.current;
8024 if (!source) {
8025 return;
8026 }
8027 const wrapper = ownerDocument(source).createElement("div");
8028 for (const child of Array.from(source.childNodes)) {
8029 wrapper.appendChild(child.cloneNode(true));
8030 }
8031 capturedNodeRef.current = wrapper;
8032 });
8033 const isTransitioning = previousContentNode != null;
8034 let childrenToRender;
8035 if (!isTransitioning) {
8036 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8037 "data-current": true,
8038 ref: currentContainerRef,
8039 children
8040 }, currentContentKey);
8041 } else {
8042 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React32.Fragment, {
8043 children: [/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8044 "data-previous": true,
8045 inert: inertValue(true),
8046 ref: previousContainerRef,
8047 style: {
8048 ...previousContentDimensions ? {
8049 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8050 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8051 } : null,
8052 position: "absolute"
8053 },
8054 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8055 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", {
8056 "data-current": true,
8057 ref: currentContainerRef,
8058 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8059 children
8060 }, currentContentKey)]
8061 });
8062 }
8063 useIsoLayoutEffect(() => {
8064 const container = previousContainerRef.current;
8065 if (!container || !previousContentNode) {
8066 return;
8067 }
8068 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8069 }, [previousContentNode]);
8070 usePopupAutoResize({
8071 popupElement,
8072 positionerElement,
8073 mounted,
8074 content: payload,
8075 onMeasureLayout: handleMeasureLayout,
8076 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8077 side,
8078 direction
8079 });
8080 const state = {
8081 activationDirection: getActivationDirection(newTriggerOffset),
8082 transitioning: isTransitioning
8083 };
8084 return {
8085 children: childrenToRender,
8086 state
8087 };
8088 }
8089 function getActivationDirection(offset4) {
8090 if (!offset4) {
8091 return void 0;
8092 }
8093 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8094 }
8095 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8096 if (value > tolerance) {
8097 return positiveLabel;
8098 }
8099 if (value < -tolerance) {
8100 return negativeLabel;
8101 }
8102 return "";
8103 }
8104 function calculateRelativePosition(from, to) {
8105 const fromRect = from.getBoundingClientRect();
8106 const toRect = to.getBoundingClientRect();
8107 const fromCenter = {
8108 x: fromRect.left + fromRect.width / 2,
8109 y: fromRect.top + fromRect.height / 2
8110 };
8111 const toCenter = {
8112 x: toRect.left + toRect.width / 2,
8113 y: toRect.top + toRect.height / 2
8114 };
8115 return {
8116 horizontal: toCenter.x - fromCenter.x,
8117 vertical: toCenter.y - fromCenter.y
8118 };
8119 }
8120 function usePopupContentKey(activeTriggerId, payload) {
8121 const [contentKey, setContentKey] = React32.useState(0);
8122 const previousActiveTriggerIdRef = React32.useRef(activeTriggerId);
8123 const previousPayloadRef = React32.useRef(payload);
8124 const pendingPayloadUpdateRef = React32.useRef(false);
8125 useIsoLayoutEffect(() => {
8126 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8127 const previousPayload = previousPayloadRef.current;
8128 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8129 const payloadChanged = payload !== previousPayload;
8130 if (triggerIdChanged) {
8131 setContentKey((value) => value + 1);
8132 pendingPayloadUpdateRef.current = !payloadChanged;
8133 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8134 setContentKey((value) => value + 1);
8135 pendingPayloadUpdateRef.current = false;
8136 }
8137 previousActiveTriggerIdRef.current = activeTriggerId;
8138 previousPayloadRef.current = payload;
8139 }, [activeTriggerId, payload]);
8140 return `${activeTriggerId ?? "current"}-${contentKey}`;
8141 }
8142
8143 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8144 var React33 = __toESM(require_react(), 1);
8145 var ReactDOM6 = __toESM(require_react_dom(), 1);
8146 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
8147 var FloatingPortalLite = /* @__PURE__ */ React33.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8148 const {
8149 children,
8150 container,
8151 className,
8152 render: render4,
8153 style,
8154 ...elementProps
8155 } = componentProps;
8156 const {
8157 portalNode,
8158 portalSubtree
8159 } = useFloatingPortalNode({
8160 container,
8161 ref: forwardedRef,
8162 componentProps,
8163 elementProps
8164 });
8165 if (!portalSubtree && !portalNode) {
8166 return null;
8167 }
8168 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(React33.Fragment, {
8169 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8170 });
8171 });
8172 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8173
8174 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8175 var index_parts_exports = {};
8176 __export(index_parts_exports, {
8177 Arrow: () => TooltipArrow,
8178 Handle: () => TooltipHandle,
8179 Popup: () => TooltipPopup,
8180 Portal: () => TooltipPortal,
8181 Positioner: () => TooltipPositioner,
8182 Provider: () => TooltipProvider,
8183 Root: () => TooltipRoot,
8184 Trigger: () => TooltipTrigger,
8185 Viewport: () => TooltipViewport,
8186 createHandle: () => createTooltipHandle
8187 });
8188
8189 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8190 var React36 = __toESM(require_react(), 1);
8191
8192 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8193 var React34 = __toESM(require_react(), 1);
8194 var TooltipRootContext = /* @__PURE__ */ React34.createContext(void 0);
8195 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8196 function useTooltipRootContext(optional) {
8197 const context = React34.useContext(TooltipRootContext);
8198 if (context === void 0 && !optional) {
8199 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8200 }
8201 return context;
8202 }
8203
8204 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8205 var React35 = __toESM(require_react(), 1);
8206 var ReactDOM7 = __toESM(require_react_dom(), 1);
8207 var selectors2 = {
8208 ...popupStoreSelectors,
8209 disabled: createSelector((state) => state.disabled),
8210 instantType: createSelector((state) => state.instantType),
8211 isInstantPhase: createSelector((state) => state.isInstantPhase),
8212 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8213 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8214 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8215 closeOnClick: createSelector((state) => state.closeOnClick),
8216 closeDelay: createSelector((state) => state.closeDelay),
8217 hasViewport: createSelector((state) => state.hasViewport)
8218 };
8219 var TooltipStore = class _TooltipStore extends ReactStore {
8220 constructor(initialState, floatingId, nested = false) {
8221 const triggerElements = new PopupTriggerMap();
8222 const state = {
8223 ...createInitialState(),
8224 ...initialState
8225 };
8226 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8227 super(state, {
8228 popupRef: /* @__PURE__ */ React35.createRef(),
8229 onOpenChange: void 0,
8230 onOpenChangeComplete: void 0,
8231 triggerElements
8232 }, selectors2);
8233 }
8234 setOpen = (nextOpen, eventDetails) => {
8235 const reason = eventDetails.reason;
8236 const isHover = reason === reason_parts_exports.triggerHover;
8237 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8238 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8239 eventDetails.preventUnmountOnClose = () => {
8240 this.set("preventUnmountingOnClose", true);
8241 };
8242 this.context.onOpenChange?.(nextOpen, eventDetails);
8243 if (eventDetails.isCanceled) {
8244 return;
8245 }
8246 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8247 const changeState = () => {
8248 const updatedState = {
8249 open: nextOpen,
8250 openChangeReason: reason
8251 };
8252 if (isFocusOpen) {
8253 updatedState.instantType = "focus";
8254 } else if (isDismissClose) {
8255 updatedState.instantType = "dismiss";
8256 } else if (reason === reason_parts_exports.triggerHover) {
8257 updatedState.instantType = void 0;
8258 }
8259 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
8260 this.update(updatedState);
8261 };
8262 if (isHover) {
8263 ReactDOM7.flushSync(changeState);
8264 } else {
8265 changeState();
8266 }
8267 };
8268 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8269 cancelPendingOpen(event) {
8270 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8271 }
8272 static useStore(externalStore, initialState) {
8273 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8274 return store;
8275 }
8276 };
8277 function createInitialState() {
8278 return {
8279 ...createInitialPopupStoreState(),
8280 disabled: false,
8281 instantType: void 0,
8282 isInstantPhase: false,
8283 trackCursorAxis: "none",
8284 disableHoverablePopup: false,
8285 openChangeReason: null,
8286 closeOnClick: true,
8287 closeDelay: 0,
8288 hasViewport: false
8289 };
8290 }
8291
8292 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8293 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
8294 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8295 const {
8296 disabled: disabled2 = false,
8297 defaultOpen = false,
8298 open: openProp,
8299 disableHoverablePopup = false,
8300 trackCursorAxis = "none",
8301 actionsRef,
8302 onOpenChange,
8303 onOpenChangeComplete,
8304 handle,
8305 triggerId: triggerIdProp,
8306 defaultTriggerId: defaultTriggerIdProp = null,
8307 children
8308 } = props;
8309 const store = TooltipStore.useStore(handle?.store, {
8310 open: defaultOpen,
8311 openProp,
8312 activeTriggerId: defaultTriggerIdProp,
8313 triggerIdProp
8314 });
8315 useOnFirstRender(() => {
8316 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8317 store.update({
8318 open: true,
8319 activeTriggerId: defaultTriggerIdProp
8320 });
8321 }
8322 });
8323 store.useControlledProp("openProp", openProp);
8324 store.useControlledProp("triggerIdProp", triggerIdProp);
8325 store.useContextCallback("onOpenChange", onOpenChange);
8326 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8327 const openState = store.useState("open");
8328 const open = !disabled2 && openState;
8329 const activeTriggerId = store.useState("activeTriggerId");
8330 const mounted = store.useState("mounted");
8331 const payload = store.useState("payload");
8332 store.useSyncedValues({
8333 trackCursorAxis,
8334 disableHoverablePopup
8335 });
8336 store.useSyncedValue("disabled", disabled2);
8337 useImplicitActiveTrigger(store);
8338 const {
8339 forceUnmount,
8340 transitionStatus
8341 } = useOpenStateTransitions(open, store);
8342 const isInstantPhase = store.useState("isInstantPhase");
8343 const instantType = store.useState("instantType");
8344 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8345 const previousInstantTypeRef = React36.useRef(null);
8346 useIsoLayoutEffect(() => {
8347 if (openState && disabled2) {
8348 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8349 }
8350 }, [openState, disabled2, store]);
8351 useIsoLayoutEffect(() => {
8352 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8353 if (instantType !== "delay") {
8354 previousInstantTypeRef.current = instantType;
8355 }
8356 store.set("instantType", "delay");
8357 } else if (previousInstantTypeRef.current !== null) {
8358 store.set("instantType", previousInstantTypeRef.current);
8359 previousInstantTypeRef.current = null;
8360 }
8361 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8362 useIsoLayoutEffect(() => {
8363 if (open) {
8364 if (activeTriggerId == null) {
8365 store.set("payload", void 0);
8366 }
8367 }
8368 }, [store, activeTriggerId, open]);
8369 const handleImperativeClose = React36.useCallback(() => {
8370 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8371 }, [store]);
8372 React36.useImperativeHandle(actionsRef, () => ({
8373 unmount: forceUnmount,
8374 close: handleImperativeClose
8375 }), [forceUnmount, handleImperativeClose]);
8376 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8377 return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(TooltipRootContext.Provider, {
8378 value: store,
8379 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(TooltipInteractions, {
8380 store,
8381 disabled: disabled2,
8382 trackCursorAxis
8383 }), typeof children === "function" ? children({
8384 payload
8385 }) : children]
8386 });
8387 });
8388 if (true) TooltipRoot.displayName = "TooltipRoot";
8389 function TooltipInteractions({
8390 store,
8391 disabled: disabled2,
8392 trackCursorAxis
8393 }) {
8394 const floatingRootContext = store.useState("floatingRootContext");
8395 const dismiss = useDismiss(floatingRootContext, {
8396 enabled: !disabled2,
8397 referencePress: () => store.select("closeOnClick")
8398 });
8399 const clientPoint = useClientPoint(floatingRootContext, {
8400 enabled: !disabled2 && trackCursorAxis !== "none",
8401 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8402 });
8403 const activeTriggerProps = React36.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8404 const inactiveTriggerProps = React36.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8405 const popupProps = React36.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8406 usePopupInteractionProps(store, {
8407 activeTriggerProps,
8408 inactiveTriggerProps,
8409 popupProps
8410 });
8411 return null;
8412 }
8413
8414 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8415 var React38 = __toESM(require_react(), 1);
8416
8417 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8418 var React37 = __toESM(require_react(), 1);
8419 var TooltipProviderContext = /* @__PURE__ */ React37.createContext(void 0);
8420 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8421 function useTooltipProviderContext() {
8422 return React37.useContext(TooltipProviderContext);
8423 }
8424
8425 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8426 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8427 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8428 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8429 return TooltipTriggerDataAttributes2;
8430 })({});
8431
8432 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8433 var OPEN_DELAY = 600;
8434
8435 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8436 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8437 function getTargetElement(event) {
8438 if ("composedPath" in event) {
8439 const path = event.composedPath();
8440 for (let i2 = 0; i2 < path.length; i2 += 1) {
8441 const element = path[i2];
8442 if (isElement(element)) {
8443 return element;
8444 }
8445 }
8446 }
8447 const target = event.target;
8448 if (isElement(target)) {
8449 return target;
8450 }
8451 return null;
8452 }
8453 function closestEnabledTooltipTrigger(element) {
8454 let current = element;
8455 while (current) {
8456 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8457 return current;
8458 }
8459 const parentElement = current.parentElement;
8460 if (parentElement) {
8461 current = parentElement;
8462 continue;
8463 }
8464 const root = current.getRootNode();
8465 current = "host" in root && isElement(root.host) ? root.host : null;
8466 }
8467 return null;
8468 }
8469 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8470 const {
8471 render: render4,
8472 className,
8473 style,
8474 handle,
8475 payload,
8476 disabled: disabledProp,
8477 delay,
8478 closeOnClick = true,
8479 closeDelay,
8480 id: idProp,
8481 ...elementProps
8482 } = componentProps;
8483 const rootContext = useTooltipRootContext(true);
8484 const store = handle?.store ?? rootContext;
8485 if (!store) {
8486 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));
8487 }
8488 const thisTriggerId = useBaseUiId(idProp);
8489 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8490 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8491 const floatingRootContext = store.useState("floatingRootContext");
8492 const triggerElementRef = React38.useRef(null);
8493 const delayWithDefault = delay ?? OPEN_DELAY;
8494 const closeDelayWithDefault = closeDelay ?? 0;
8495 const {
8496 registerTrigger,
8497 isMountedByThisTrigger
8498 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8499 payload,
8500 closeOnClick,
8501 closeDelay: closeDelayWithDefault
8502 });
8503 const providerContext = useTooltipProviderContext();
8504 const {
8505 delayRef,
8506 isInstantPhase,
8507 hasProvider
8508 } = useDelayGroup(floatingRootContext, {
8509 open: isOpenedByThisTrigger
8510 });
8511 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8512 store.useSyncedValue("isInstantPhase", isInstantPhase);
8513 const rootDisabled = store.useState("disabled");
8514 const disabled2 = disabledProp ?? rootDisabled;
8515 const disabledRef = useValueAsRef(disabled2);
8516 const trackCursorAxis = store.useState("trackCursorAxis");
8517 const disableHoverablePopup = store.useState("disableHoverablePopup");
8518 const isNestedTriggerHoveredRef = React38.useRef(false);
8519 const nestedTriggerOpenTimeout = useTimeout();
8520 const pointerTypeRef = React38.useRef(void 0);
8521 function getOpenDelay() {
8522 const providerDelay = providerContext?.delay;
8523 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8524 let computedOpenDelay = delayWithDefault;
8525 if (hasProvider) {
8526 if (groupOpenValue !== 0) {
8527 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8528 } else {
8529 computedOpenDelay = 0;
8530 }
8531 }
8532 return computedOpenDelay;
8533 }
8534 function isEnabledNestedTriggerTarget(target) {
8535 const triggerEl = triggerElementRef.current;
8536 if (!triggerEl || !target) {
8537 return false;
8538 }
8539 const nearestTrigger = closestEnabledTooltipTrigger(target);
8540 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8541 }
8542 function detectNestedTriggerHover(target) {
8543 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8544 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8545 if (nestedTriggerHovered) {
8546 hoverInteraction.openChangeTimeout.clear();
8547 hoverInteraction.restTimeout.clear();
8548 hoverInteraction.restTimeoutPending = false;
8549 nestedTriggerOpenTimeout.clear();
8550 }
8551 return nestedTriggerHovered;
8552 }
8553 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8554 enabled: !disabled2,
8555 mouseOnly: true,
8556 move: false,
8557 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8558 restMs: getOpenDelay,
8559 delay() {
8560 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8561 let computedCloseDelay = closeDelayWithDefault;
8562 if (closeDelay == null && hasProvider) {
8563 computedCloseDelay = closeValue;
8564 }
8565 return {
8566 close: computedCloseDelay
8567 };
8568 },
8569 triggerElementRef,
8570 isActiveTrigger: isTriggerActive,
8571 isClosing: () => store.select("transitionStatus") === "ending",
8572 shouldOpen() {
8573 return !isNestedTriggerHoveredRef.current;
8574 }
8575 });
8576 const focusProps = useFocus(floatingRootContext, {
8577 enabled: !disabled2
8578 }).reference;
8579 const handleNestedTriggerHover = (event) => {
8580 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8581 const target = getTargetElement(event);
8582 const nestedTriggerHovered = detectNestedTriggerHover(target);
8583 const triggerEl = triggerElementRef.current;
8584 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8585 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8586 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8587 return;
8588 }
8589 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8590 isMouseLikePointerType(pointerTypeRef.current)) {
8591 const open = () => {
8592 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8593 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8594 }
8595 };
8596 const openDelay = getOpenDelay();
8597 if (openDelay === 0) {
8598 nestedTriggerOpenTimeout.clear();
8599 open();
8600 } else {
8601 nestedTriggerOpenTimeout.start(openDelay, open);
8602 }
8603 }
8604 };
8605 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8606 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8607 const state = {
8608 open: isOpenedByThisTrigger
8609 };
8610 const element = useRenderElement("button", componentProps, {
8611 state,
8612 ref: [forwardedRef, registerTrigger, triggerElementRef],
8613 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8614 onMouseOver(event) {
8615 handleNestedTriggerHover(event.nativeEvent);
8616 },
8617 onFocus(event) {
8618 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8619 event.preventBaseUIHandler();
8620 }
8621 },
8622 onMouseLeave() {
8623 isNestedTriggerHoveredRef.current = false;
8624 nestedTriggerOpenTimeout.clear();
8625 pointerTypeRef.current = void 0;
8626 },
8627 onPointerEnter(event) {
8628 pointerTypeRef.current = event.pointerType;
8629 },
8630 onPointerDown(event) {
8631 pointerTypeRef.current = event.pointerType;
8632 store.set("closeOnClick", closeOnClick);
8633 if (closeOnClick && !store.select("open")) {
8634 store.cancelPendingOpen(event.nativeEvent);
8635 }
8636 },
8637 onClick(event) {
8638 if (closeOnClick && !store.select("open")) {
8639 store.cancelPendingOpen(event.nativeEvent);
8640 }
8641 },
8642 id: thisTriggerId,
8643 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8644 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8645 }, elementProps],
8646 stateAttributesMapping: triggerOpenStateMapping
8647 });
8648 return element;
8649 });
8650 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8651
8652 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8653 var React40 = __toESM(require_react(), 1);
8654
8655 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8656 var React39 = __toESM(require_react(), 1);
8657 var TooltipPortalContext = /* @__PURE__ */ React39.createContext(void 0);
8658 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8659 function useTooltipPortalContext() {
8660 const value = React39.useContext(TooltipPortalContext);
8661 if (value === void 0) {
8662 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8663 }
8664 return value;
8665 }
8666
8667 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8668 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
8669 var TooltipPortal = /* @__PURE__ */ React40.forwardRef(function TooltipPortal2(props, forwardedRef) {
8670 const {
8671 keepMounted = false,
8672 ...portalProps
8673 } = props;
8674 const store = useTooltipRootContext();
8675 const mounted = store.useState("mounted");
8676 const shouldRender = mounted || keepMounted;
8677 if (!shouldRender) {
8678 return null;
8679 }
8680 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TooltipPortalContext.Provider, {
8681 value: keepMounted,
8682 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FloatingPortalLite, {
8683 ref: forwardedRef,
8684 ...portalProps
8685 })
8686 });
8687 });
8688 if (true) TooltipPortal.displayName = "TooltipPortal";
8689
8690 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8691 var React42 = __toESM(require_react(), 1);
8692
8693 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8694 var React41 = __toESM(require_react(), 1);
8695 var TooltipPositionerContext = /* @__PURE__ */ React41.createContext(void 0);
8696 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8697 function useTooltipPositionerContext() {
8698 const context = React41.useContext(TooltipPositionerContext);
8699 if (context === void 0) {
8700 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8701 }
8702 return context;
8703 }
8704
8705 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8706 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
8707 var TooltipPositioner = /* @__PURE__ */ React42.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8708 const {
8709 render: render4,
8710 className,
8711 anchor,
8712 positionMethod = "absolute",
8713 side = "top",
8714 align = "center",
8715 sideOffset = 0,
8716 alignOffset = 0,
8717 collisionBoundary = "clipping-ancestors",
8718 collisionPadding = 5,
8719 arrowPadding = 5,
8720 sticky = false,
8721 disableAnchorTracking = false,
8722 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8723 style,
8724 ...elementProps
8725 } = componentProps;
8726 const store = useTooltipRootContext();
8727 const keepMounted = useTooltipPortalContext();
8728 const open = store.useState("open");
8729 const mounted = store.useState("mounted");
8730 const trackCursorAxis = store.useState("trackCursorAxis");
8731 const disableHoverablePopup = store.useState("disableHoverablePopup");
8732 const floatingRootContext = store.useState("floatingRootContext");
8733 const instantType = store.useState("instantType");
8734 const transitionStatus = store.useState("transitionStatus");
8735 const hasViewport = store.useState("hasViewport");
8736 const positioning = useAnchorPositioning({
8737 anchor,
8738 positionMethod,
8739 floatingRootContext,
8740 mounted,
8741 side,
8742 sideOffset,
8743 align,
8744 alignOffset,
8745 collisionBoundary,
8746 collisionPadding,
8747 sticky,
8748 arrowPadding,
8749 disableAnchorTracking,
8750 keepMounted,
8751 collisionAvoidance,
8752 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8753 });
8754 const state = React42.useMemo(() => ({
8755 open,
8756 side: positioning.side,
8757 align: positioning.align,
8758 anchorHidden: positioning.anchorHidden,
8759 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8760 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8761 const element = usePositioner(componentProps, state, {
8762 styles: positioning.positionerStyles,
8763 transitionStatus,
8764 props: elementProps,
8765 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8766 hidden: !mounted,
8767 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8768 });
8769 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(TooltipPositionerContext.Provider, {
8770 value: positioning,
8771 children: element
8772 });
8773 });
8774 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8775
8776 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8777 var React43 = __toESM(require_react(), 1);
8778 var stateAttributesMapping = {
8779 ...popupStateMapping,
8780 ...transitionStatusMapping
8781 };
8782 var TooltipPopup = /* @__PURE__ */ React43.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8783 const {
8784 render: render4,
8785 className,
8786 style,
8787 ...elementProps
8788 } = componentProps;
8789 const store = useTooltipRootContext();
8790 const {
8791 side,
8792 align
8793 } = useTooltipPositionerContext();
8794 const open = store.useState("open");
8795 const instantType = store.useState("instantType");
8796 const transitionStatus = store.useState("transitionStatus");
8797 const popupProps = store.useState("popupProps");
8798 const floatingContext = store.useState("floatingRootContext");
8799 const disabled2 = store.useState("disabled");
8800 const closeDelay = store.useState("closeDelay");
8801 useOpenChangeComplete({
8802 open,
8803 ref: store.context.popupRef,
8804 onComplete() {
8805 if (open) {
8806 store.context.onOpenChangeComplete?.(true);
8807 }
8808 }
8809 });
8810 useHoverFloatingInteraction(floatingContext, {
8811 enabled: !disabled2,
8812 closeDelay
8813 });
8814 const setPopupElement = store.useStateSetter("popupElement");
8815 const state = {
8816 open,
8817 side,
8818 align,
8819 instant: instantType,
8820 transitionStatus
8821 };
8822 const element = useRenderElement("div", componentProps, {
8823 state,
8824 ref: [forwardedRef, store.context.popupRef, setPopupElement],
8825 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8826 stateAttributesMapping
8827 });
8828 return element;
8829 });
8830 if (true) TooltipPopup.displayName = "TooltipPopup";
8831
8832 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8833 var React44 = __toESM(require_react(), 1);
8834 var TooltipArrow = /* @__PURE__ */ React44.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8835 const {
8836 render: render4,
8837 className,
8838 style,
8839 ...elementProps
8840 } = componentProps;
8841 const store = useTooltipRootContext();
8842 const {
8843 arrowRef,
8844 side,
8845 align,
8846 arrowUncentered,
8847 arrowStyles
8848 } = useTooltipPositionerContext();
8849 const open = store.useState("open");
8850 const instantType = store.useState("instantType");
8851 const state = {
8852 open,
8853 side,
8854 align,
8855 uncentered: arrowUncentered,
8856 instant: instantType
8857 };
8858 const element = useRenderElement("div", componentProps, {
8859 state,
8860 ref: [forwardedRef, arrowRef],
8861 props: [{
8862 style: arrowStyles,
8863 "aria-hidden": true
8864 }, elementProps],
8865 stateAttributesMapping: popupStateMapping
8866 });
8867 return element;
8868 });
8869 if (true) TooltipArrow.displayName = "TooltipArrow";
8870
8871 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8872 var React45 = __toESM(require_react(), 1);
8873 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
8874 var TooltipProvider = function TooltipProvider2(props) {
8875 const {
8876 delay,
8877 closeDelay,
8878 timeout = 400
8879 } = props;
8880 const contextValue = React45.useMemo(() => ({
8881 delay,
8882 closeDelay
8883 }), [delay, closeDelay]);
8884 const delayValue = React45.useMemo(() => ({
8885 open: delay,
8886 close: closeDelay
8887 }), [delay, closeDelay]);
8888 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(TooltipProviderContext.Provider, {
8889 value: contextValue,
8890 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(FloatingDelayGroup, {
8891 delay: delayValue,
8892 timeoutMs: timeout,
8893 children: props.children
8894 })
8895 });
8896 };
8897 if (true) TooltipProvider.displayName = "TooltipProvider";
8898
8899 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8900 var React46 = __toESM(require_react(), 1);
8901
8902 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8903 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8904 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8905 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8906 return TooltipViewportCssVars2;
8907 })({});
8908
8909 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8910 var stateAttributesMapping2 = {
8911 activationDirection: (value) => value ? {
8912 "data-activation-direction": value
8913 } : null
8914 };
8915 var TooltipViewport = /* @__PURE__ */ React46.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8916 const {
8917 render: render4,
8918 className,
8919 style,
8920 children,
8921 ...elementProps
8922 } = componentProps;
8923 const store = useTooltipRootContext();
8924 const positioner = useTooltipPositionerContext();
8925 const instantType = store.useState("instantType");
8926 const {
8927 children: childrenToRender,
8928 state: viewportState
8929 } = usePopupViewport({
8930 store,
8931 side: positioner.side,
8932 cssVars: TooltipViewportCssVars,
8933 children
8934 });
8935 const state = {
8936 activationDirection: viewportState.activationDirection,
8937 transitioning: viewportState.transitioning,
8938 instant: instantType
8939 };
8940 return useRenderElement("div", componentProps, {
8941 state,
8942 ref: forwardedRef,
8943 props: [elementProps, {
8944 children: childrenToRender
8945 }],
8946 stateAttributesMapping: stateAttributesMapping2
8947 });
8948 });
8949 if (true) TooltipViewport.displayName = "TooltipViewport";
8950
8951 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8952 var TooltipHandle = class {
8953 /**
8954 * Internal store holding the tooltip state.
8955 * @internal
8956 */
8957 constructor() {
8958 this.store = new TooltipStore();
8959 }
8960 /**
8961 * Opens the tooltip and associates it with the trigger with the given ID.
8962 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8963 *
8964 * This method should only be called in an event handler or an effect (not during rendering).
8965 *
8966 * @param triggerId ID of the trigger to associate with the tooltip.
8967 */
8968 open(triggerId) {
8969 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
8970 if (triggerId && !triggerElement) {
8971 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
8972 }
8973 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
8974 }
8975 /**
8976 * Closes the tooltip.
8977 */
8978 close() {
8979 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
8980 }
8981 /**
8982 * Indicates whether the tooltip is currently open.
8983 */
8984 get isOpen() {
8985 return this.store.select("open");
8986 }
8987 };
8988 function createTooltipHandle() {
8989 return new TooltipHandle();
8990 }
8991
8992 // node_modules/@base-ui/react/esm/use-render/useRender.js
8993 function useRender(params) {
8994 return useRenderElement(params.defaultTagName ?? "div", params, params);
8995 }
8996
8997 // packages/ui/build-module/text/text.mjs
8998 var import_element11 = __toESM(require_element(), 1);
8999 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9000 function getRuntime() {
9001 const globalScope = globalThis;
9002 if (globalScope.__wpStyleRuntime) {
9003 return globalScope.__wpStyleRuntime;
9004 }
9005 globalScope.__wpStyleRuntime = {
9006 documents: /* @__PURE__ */ new Map(),
9007 styles: /* @__PURE__ */ new Map(),
9008 injectedStyles: /* @__PURE__ */ new WeakMap()
9009 };
9010 if (typeof document !== "undefined") {
9011 registerDocument(document);
9012 }
9013 return globalScope.__wpStyleRuntime;
9014 }
9015 function documentContainsStyleHash(targetDocument, hash) {
9016 if (!targetDocument.head) {
9017 return false;
9018 }
9019 for (const style of targetDocument.head.querySelectorAll(
9020 `style[${STYLE_HASH_ATTRIBUTE}]`
9021 )) {
9022 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9023 return true;
9024 }
9025 }
9026 return false;
9027 }
9028 function injectStyle(targetDocument, hash, css) {
9029 if (!targetDocument.head) {
9030 return;
9031 }
9032 const runtime = getRuntime();
9033 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9034 if (!injectedStyles) {
9035 injectedStyles = /* @__PURE__ */ new Set();
9036 runtime.injectedStyles.set(targetDocument, injectedStyles);
9037 }
9038 if (injectedStyles.has(hash)) {
9039 return;
9040 }
9041 if (documentContainsStyleHash(targetDocument, hash)) {
9042 injectedStyles.add(hash);
9043 return;
9044 }
9045 const style = targetDocument.createElement("style");
9046 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9047 style.appendChild(targetDocument.createTextNode(css));
9048 targetDocument.head.appendChild(style);
9049 injectedStyles.add(hash);
9050 }
9051 function registerDocument(targetDocument) {
9052 const runtime = getRuntime();
9053 runtime.documents.set(
9054 targetDocument,
9055 (runtime.documents.get(targetDocument) ?? 0) + 1
9056 );
9057 for (const [hash, css] of runtime.styles) {
9058 injectStyle(targetDocument, hash, css);
9059 }
9060 return () => {
9061 const count = runtime.documents.get(targetDocument);
9062 if (count === void 0) {
9063 return;
9064 }
9065 if (count <= 1) {
9066 runtime.documents.delete(targetDocument);
9067 return;
9068 }
9069 runtime.documents.set(targetDocument, count - 1);
9070 };
9071 }
9072 function registerStyle(hash, css) {
9073 const runtime = getRuntime();
9074 runtime.styles.set(hash, css);
9075 for (const targetDocument of runtime.documents.keys()) {
9076 injectStyle(targetDocument, hash, css);
9077 }
9078 }
9079 if (typeof process === "undefined" || true) {
9080 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)}}}');
9081 }
9082 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" };
9083 if (typeof process === "undefined" || true) {
9084 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)}");
9085 }
9086 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" };
9087 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9088 const element = useRender({
9089 render: render4,
9090 defaultTagName: "span",
9091 ref,
9092 props: mergeProps(props, {
9093 className: clsx_default(
9094 style_default.text,
9095 global_css_defense_default.heading,
9096 global_css_defense_default.p,
9097 style_default[variant],
9098 className
9099 )
9100 })
9101 });
9102 return element;
9103 });
9104
9105 // packages/ui/build-module/icon/icon.mjs
9106 var import_element12 = __toESM(require_element(), 1);
9107 var import_primitives26 = __toESM(require_primitives(), 1);
9108 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9109 var Icon = (0, import_element12.forwardRef)(function Icon2({ icon, size: size4 = 24, ...restProps }, ref) {
9110 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
9111 import_primitives26.SVG,
9112 {
9113 ref,
9114 fill: "currentColor",
9115 ...icon.props,
9116 ...restProps,
9117 width: size4,
9118 height: size4
9119 }
9120 );
9121 });
9122
9123 // packages/ui/build-module/utils/render-slot-with-children.mjs
9124 var import_element13 = __toESM(require_element(), 1);
9125 function renderSlotWithChildren(slot, defaultSlot, children) {
9126 return (0, import_element13.cloneElement)(slot ?? defaultSlot, { children });
9127 }
9128
9129 // packages/ui/build-module/lock-unlock.mjs
9130 var import_private_apis = __toESM(require_private_apis(), 1);
9131 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9132 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9133 "@wordpress/ui"
9134 );
9135
9136 // packages/ui/build-module/stack/stack.mjs
9137 var import_element14 = __toESM(require_element(), 1);
9138 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9139 function getRuntime2() {
9140 const globalScope = globalThis;
9141 if (globalScope.__wpStyleRuntime) {
9142 return globalScope.__wpStyleRuntime;
9143 }
9144 globalScope.__wpStyleRuntime = {
9145 documents: /* @__PURE__ */ new Map(),
9146 styles: /* @__PURE__ */ new Map(),
9147 injectedStyles: /* @__PURE__ */ new WeakMap()
9148 };
9149 if (typeof document !== "undefined") {
9150 registerDocument2(document);
9151 }
9152 return globalScope.__wpStyleRuntime;
9153 }
9154 function documentContainsStyleHash2(targetDocument, hash) {
9155 if (!targetDocument.head) {
9156 return false;
9157 }
9158 for (const style of targetDocument.head.querySelectorAll(
9159 `style[${STYLE_HASH_ATTRIBUTE2}]`
9160 )) {
9161 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9162 return true;
9163 }
9164 }
9165 return false;
9166 }
9167 function injectStyle2(targetDocument, hash, css) {
9168 if (!targetDocument.head) {
9169 return;
9170 }
9171 const runtime = getRuntime2();
9172 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9173 if (!injectedStyles) {
9174 injectedStyles = /* @__PURE__ */ new Set();
9175 runtime.injectedStyles.set(targetDocument, injectedStyles);
9176 }
9177 if (injectedStyles.has(hash)) {
9178 return;
9179 }
9180 if (documentContainsStyleHash2(targetDocument, hash)) {
9181 injectedStyles.add(hash);
9182 return;
9183 }
9184 const style = targetDocument.createElement("style");
9185 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9186 style.appendChild(targetDocument.createTextNode(css));
9187 targetDocument.head.appendChild(style);
9188 injectedStyles.add(hash);
9189 }
9190 function registerDocument2(targetDocument) {
9191 const runtime = getRuntime2();
9192 runtime.documents.set(
9193 targetDocument,
9194 (runtime.documents.get(targetDocument) ?? 0) + 1
9195 );
9196 for (const [hash, css] of runtime.styles) {
9197 injectStyle2(targetDocument, hash, css);
9198 }
9199 return () => {
9200 const count = runtime.documents.get(targetDocument);
9201 if (count === void 0) {
9202 return;
9203 }
9204 if (count <= 1) {
9205 runtime.documents.delete(targetDocument);
9206 return;
9207 }
9208 runtime.documents.set(targetDocument, count - 1);
9209 };
9210 }
9211 function registerStyle2(hash, css) {
9212 const runtime = getRuntime2();
9213 runtime.styles.set(hash, css);
9214 for (const targetDocument of runtime.documents.keys()) {
9215 injectStyle2(targetDocument, hash, css);
9216 }
9217 }
9218 if (typeof process === "undefined" || true) {
9219 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9220 }
9221 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9222 var gapTokens = {
9223 xs: "var(--wpds-dimension-gap-xs, 4px)",
9224 sm: "var(--wpds-dimension-gap-sm, 8px)",
9225 md: "var(--wpds-dimension-gap-md, 12px)",
9226 lg: "var(--wpds-dimension-gap-lg, 16px)",
9227 xl: "var(--wpds-dimension-gap-xl, 24px)",
9228 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9229 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9230 };
9231 var Stack = (0, import_element14.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9232 const style = {
9233 gap: gap && gapTokens[gap],
9234 alignItems: align,
9235 justifyContent: justify,
9236 flexDirection: direction,
9237 flexWrap: wrap
9238 };
9239 const element = useRender({
9240 render: render4,
9241 ref,
9242 props: mergeProps(props, { style, className: style_default2.stack })
9243 });
9244 return element;
9245 });
9246
9247 // packages/ui/build-module/tooltip/index.mjs
9248 var tooltip_exports = {};
9249 __export(tooltip_exports, {
9250 Popup: () => Popup,
9251 Portal: () => Portal,
9252 Positioner: () => Positioner,
9253 Provider: () => Provider,
9254 Root: () => Root,
9255 Trigger: () => Trigger
9256 });
9257
9258 // packages/ui/build-module/tooltip/popup.mjs
9259 var import_element17 = __toESM(require_element(), 1);
9260 var import_theme = __toESM(require_theme(), 1);
9261
9262 // packages/ui/build-module/tooltip/portal.mjs
9263 var import_element15 = __toESM(require_element(), 1);
9264
9265 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9266 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9267 function getRuntime3() {
9268 const globalScope = globalThis;
9269 if (globalScope.__wpStyleRuntime) {
9270 return globalScope.__wpStyleRuntime;
9271 }
9272 globalScope.__wpStyleRuntime = {
9273 documents: /* @__PURE__ */ new Map(),
9274 styles: /* @__PURE__ */ new Map(),
9275 injectedStyles: /* @__PURE__ */ new WeakMap()
9276 };
9277 if (typeof document !== "undefined") {
9278 registerDocument3(document);
9279 }
9280 return globalScope.__wpStyleRuntime;
9281 }
9282 function documentContainsStyleHash3(targetDocument, hash) {
9283 if (!targetDocument.head) {
9284 return false;
9285 }
9286 for (const style of targetDocument.head.querySelectorAll(
9287 `style[${STYLE_HASH_ATTRIBUTE3}]`
9288 )) {
9289 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9290 return true;
9291 }
9292 }
9293 return false;
9294 }
9295 function injectStyle3(targetDocument, hash, css) {
9296 if (!targetDocument.head) {
9297 return;
9298 }
9299 const runtime = getRuntime3();
9300 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9301 if (!injectedStyles) {
9302 injectedStyles = /* @__PURE__ */ new Set();
9303 runtime.injectedStyles.set(targetDocument, injectedStyles);
9304 }
9305 if (injectedStyles.has(hash)) {
9306 return;
9307 }
9308 if (documentContainsStyleHash3(targetDocument, hash)) {
9309 injectedStyles.add(hash);
9310 return;
9311 }
9312 const style = targetDocument.createElement("style");
9313 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9314 style.appendChild(targetDocument.createTextNode(css));
9315 targetDocument.head.appendChild(style);
9316 injectedStyles.add(hash);
9317 }
9318 function registerDocument3(targetDocument) {
9319 const runtime = getRuntime3();
9320 runtime.documents.set(
9321 targetDocument,
9322 (runtime.documents.get(targetDocument) ?? 0) + 1
9323 );
9324 for (const [hash, css] of runtime.styles) {
9325 injectStyle3(targetDocument, hash, css);
9326 }
9327 return () => {
9328 const count = runtime.documents.get(targetDocument);
9329 if (count === void 0) {
9330 return;
9331 }
9332 if (count <= 1) {
9333 runtime.documents.delete(targetDocument);
9334 return;
9335 }
9336 runtime.documents.set(targetDocument, count - 1);
9337 };
9338 }
9339 function registerStyle3(hash, css) {
9340 const runtime = getRuntime3();
9341 runtime.styles.set(hash, css);
9342 for (const targetDocument of runtime.documents.keys()) {
9343 injectStyle3(targetDocument, hash, css);
9344 }
9345 }
9346 if (typeof process === "undefined" || true) {
9347 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}}}");
9348 }
9349 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9350 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9351 function resolveOwnerDocument() {
9352 return typeof document === "undefined" ? null : document;
9353 }
9354 function isInWordPressEnvironment() {
9355 let topWp;
9356 try {
9357 topWp = window.top?.wp;
9358 } catch {
9359 }
9360 const wp = topWp ?? window.wp;
9361 return typeof wp?.components === "object" && wp.components !== null;
9362 }
9363 var cachedSlot = null;
9364 function createSlot(ownerDocument2) {
9365 const element = ownerDocument2.createElement("div");
9366 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9367 if (wp_compat_overlay_slot_default.slot) {
9368 element.classList.add(wp_compat_overlay_slot_default.slot);
9369 }
9370 ownerDocument2.body.appendChild(element);
9371 return element;
9372 }
9373 function getWpCompatOverlaySlot() {
9374 if (typeof window === "undefined") {
9375 return void 0;
9376 }
9377 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9378 return void 0;
9379 }
9380 const ownerDocument2 = resolveOwnerDocument();
9381 if (!ownerDocument2 || !ownerDocument2.body) {
9382 return void 0;
9383 }
9384 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9385 return cachedSlot;
9386 }
9387 const existing = ownerDocument2.querySelector(
9388 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9389 );
9390 if (existing instanceof HTMLDivElement) {
9391 cachedSlot = existing;
9392 return existing;
9393 }
9394 if (cachedSlot?.isConnected) {
9395 cachedSlot.remove();
9396 }
9397 cachedSlot = createSlot(ownerDocument2);
9398 return cachedSlot;
9399 }
9400
9401 // packages/ui/build-module/tooltip/portal.mjs
9402 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9403 var Portal = (0, import_element15.forwardRef)(
9404 function TooltipPortal3({ container, ...restProps }, ref) {
9405 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
9406 index_parts_exports.Portal,
9407 {
9408 container: container ?? getWpCompatOverlaySlot(),
9409 ...restProps,
9410 ref
9411 }
9412 );
9413 }
9414 );
9415
9416 // packages/ui/build-module/tooltip/positioner.mjs
9417 var import_element16 = __toESM(require_element(), 1);
9418 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9419 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9420 function getRuntime4() {
9421 const globalScope = globalThis;
9422 if (globalScope.__wpStyleRuntime) {
9423 return globalScope.__wpStyleRuntime;
9424 }
9425 globalScope.__wpStyleRuntime = {
9426 documents: /* @__PURE__ */ new Map(),
9427 styles: /* @__PURE__ */ new Map(),
9428 injectedStyles: /* @__PURE__ */ new WeakMap()
9429 };
9430 if (typeof document !== "undefined") {
9431 registerDocument4(document);
9432 }
9433 return globalScope.__wpStyleRuntime;
9434 }
9435 function documentContainsStyleHash4(targetDocument, hash) {
9436 if (!targetDocument.head) {
9437 return false;
9438 }
9439 for (const style of targetDocument.head.querySelectorAll(
9440 `style[${STYLE_HASH_ATTRIBUTE4}]`
9441 )) {
9442 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9443 return true;
9444 }
9445 }
9446 return false;
9447 }
9448 function injectStyle4(targetDocument, hash, css) {
9449 if (!targetDocument.head) {
9450 return;
9451 }
9452 const runtime = getRuntime4();
9453 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9454 if (!injectedStyles) {
9455 injectedStyles = /* @__PURE__ */ new Set();
9456 runtime.injectedStyles.set(targetDocument, injectedStyles);
9457 }
9458 if (injectedStyles.has(hash)) {
9459 return;
9460 }
9461 if (documentContainsStyleHash4(targetDocument, hash)) {
9462 injectedStyles.add(hash);
9463 return;
9464 }
9465 const style = targetDocument.createElement("style");
9466 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9467 style.appendChild(targetDocument.createTextNode(css));
9468 targetDocument.head.appendChild(style);
9469 injectedStyles.add(hash);
9470 }
9471 function registerDocument4(targetDocument) {
9472 const runtime = getRuntime4();
9473 runtime.documents.set(
9474 targetDocument,
9475 (runtime.documents.get(targetDocument) ?? 0) + 1
9476 );
9477 for (const [hash, css] of runtime.styles) {
9478 injectStyle4(targetDocument, hash, css);
9479 }
9480 return () => {
9481 const count = runtime.documents.get(targetDocument);
9482 if (count === void 0) {
9483 return;
9484 }
9485 if (count <= 1) {
9486 runtime.documents.delete(targetDocument);
9487 return;
9488 }
9489 runtime.documents.set(targetDocument, count - 1);
9490 };
9491 }
9492 function registerStyle4(hash, css) {
9493 const runtime = getRuntime4();
9494 runtime.styles.set(hash, css);
9495 for (const targetDocument of runtime.documents.keys()) {
9496 injectStyle4(targetDocument, hash, css);
9497 }
9498 }
9499 if (typeof process === "undefined" || true) {
9500 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9501 }
9502 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9503 if (typeof process === "undefined" || true) {
9504 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}}}}');
9505 }
9506 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9507 var Positioner = (0, import_element16.forwardRef)(
9508 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9509 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
9510 index_parts_exports.Positioner,
9511 {
9512 ref,
9513 align,
9514 side,
9515 sideOffset,
9516 ...props,
9517 className: clsx_default(
9518 resets_default["box-sizing"],
9519 style_default3.positioner,
9520 className
9521 )
9522 }
9523 );
9524 }
9525 );
9526
9527 // packages/ui/build-module/tooltip/popup.mjs
9528 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9529 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9530 function getRuntime5() {
9531 const globalScope = globalThis;
9532 if (globalScope.__wpStyleRuntime) {
9533 return globalScope.__wpStyleRuntime;
9534 }
9535 globalScope.__wpStyleRuntime = {
9536 documents: /* @__PURE__ */ new Map(),
9537 styles: /* @__PURE__ */ new Map(),
9538 injectedStyles: /* @__PURE__ */ new WeakMap()
9539 };
9540 if (typeof document !== "undefined") {
9541 registerDocument5(document);
9542 }
9543 return globalScope.__wpStyleRuntime;
9544 }
9545 function documentContainsStyleHash5(targetDocument, hash) {
9546 if (!targetDocument.head) {
9547 return false;
9548 }
9549 for (const style of targetDocument.head.querySelectorAll(
9550 `style[${STYLE_HASH_ATTRIBUTE5}]`
9551 )) {
9552 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9553 return true;
9554 }
9555 }
9556 return false;
9557 }
9558 function injectStyle5(targetDocument, hash, css) {
9559 if (!targetDocument.head) {
9560 return;
9561 }
9562 const runtime = getRuntime5();
9563 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9564 if (!injectedStyles) {
9565 injectedStyles = /* @__PURE__ */ new Set();
9566 runtime.injectedStyles.set(targetDocument, injectedStyles);
9567 }
9568 if (injectedStyles.has(hash)) {
9569 return;
9570 }
9571 if (documentContainsStyleHash5(targetDocument, hash)) {
9572 injectedStyles.add(hash);
9573 return;
9574 }
9575 const style = targetDocument.createElement("style");
9576 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9577 style.appendChild(targetDocument.createTextNode(css));
9578 targetDocument.head.appendChild(style);
9579 injectedStyles.add(hash);
9580 }
9581 function registerDocument5(targetDocument) {
9582 const runtime = getRuntime5();
9583 runtime.documents.set(
9584 targetDocument,
9585 (runtime.documents.get(targetDocument) ?? 0) + 1
9586 );
9587 for (const [hash, css] of runtime.styles) {
9588 injectStyle5(targetDocument, hash, css);
9589 }
9590 return () => {
9591 const count = runtime.documents.get(targetDocument);
9592 if (count === void 0) {
9593 return;
9594 }
9595 if (count <= 1) {
9596 runtime.documents.delete(targetDocument);
9597 return;
9598 }
9599 runtime.documents.set(targetDocument, count - 1);
9600 };
9601 }
9602 function registerStyle5(hash, css) {
9603 const runtime = getRuntime5();
9604 runtime.styles.set(hash, css);
9605 for (const targetDocument of runtime.documents.keys()) {
9606 injectStyle5(targetDocument, hash, css);
9607 }
9608 }
9609 if (typeof process === "undefined" || true) {
9610 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}}}}');
9611 }
9612 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9613 var ThemeProvider = unlock(import_theme.privateApis).ThemeProvider;
9614 var POPUP_COLOR = { background: "#1e1e1e" };
9615 var Popup = (0, import_element17.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9616 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
9617 index_parts_exports.Popup,
9618 {
9619 ref,
9620 className: clsx_default(style_default4.popup, className),
9621 ...props,
9622 children
9623 }
9624 ) });
9625 const positionedPopup = renderSlotWithChildren(
9626 positioner,
9627 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Positioner, {}),
9628 popupContent
9629 );
9630 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Portal, {}), positionedPopup);
9631 });
9632
9633 // packages/ui/build-module/tooltip/trigger.mjs
9634 var import_element18 = __toESM(require_element(), 1);
9635 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9636 var Trigger = (0, import_element18.forwardRef)(
9637 function TooltipTrigger3(props, ref) {
9638 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(index_parts_exports.Trigger, { ref, ...props });
9639 }
9640 );
9641
9642 // packages/ui/build-module/tooltip/root.mjs
9643 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
9644 function Root(props) {
9645 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(index_parts_exports.Root, { ...props });
9646 }
9647
9648 // packages/ui/build-module/tooltip/provider.mjs
9649 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
9650 function Provider({ ...props }) {
9651 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(index_parts_exports.Provider, { ...props });
9652 }
9653
9654 // packages/ui/build-module/empty-state/index.mjs
9655 var empty_state_exports = {};
9656 __export(empty_state_exports, {
9657 Actions: () => Actions,
9658 Description: () => Description,
9659 Icon: () => Icon3,
9660 Root: () => Root2,
9661 Title: () => Title,
9662 Visual: () => Visual
9663 });
9664
9665 // packages/ui/build-module/empty-state/root.mjs
9666 var import_element19 = __toESM(require_element(), 1);
9667 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9668 function getRuntime6() {
9669 const globalScope = globalThis;
9670 if (globalScope.__wpStyleRuntime) {
9671 return globalScope.__wpStyleRuntime;
9672 }
9673 globalScope.__wpStyleRuntime = {
9674 documents: /* @__PURE__ */ new Map(),
9675 styles: /* @__PURE__ */ new Map(),
9676 injectedStyles: /* @__PURE__ */ new WeakMap()
9677 };
9678 if (typeof document !== "undefined") {
9679 registerDocument6(document);
9680 }
9681 return globalScope.__wpStyleRuntime;
9682 }
9683 function documentContainsStyleHash6(targetDocument, hash) {
9684 if (!targetDocument.head) {
9685 return false;
9686 }
9687 for (const style of targetDocument.head.querySelectorAll(
9688 `style[${STYLE_HASH_ATTRIBUTE6}]`
9689 )) {
9690 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9691 return true;
9692 }
9693 }
9694 return false;
9695 }
9696 function injectStyle6(targetDocument, hash, css) {
9697 if (!targetDocument.head) {
9698 return;
9699 }
9700 const runtime = getRuntime6();
9701 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9702 if (!injectedStyles) {
9703 injectedStyles = /* @__PURE__ */ new Set();
9704 runtime.injectedStyles.set(targetDocument, injectedStyles);
9705 }
9706 if (injectedStyles.has(hash)) {
9707 return;
9708 }
9709 if (documentContainsStyleHash6(targetDocument, hash)) {
9710 injectedStyles.add(hash);
9711 return;
9712 }
9713 const style = targetDocument.createElement("style");
9714 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9715 style.appendChild(targetDocument.createTextNode(css));
9716 targetDocument.head.appendChild(style);
9717 injectedStyles.add(hash);
9718 }
9719 function registerDocument6(targetDocument) {
9720 const runtime = getRuntime6();
9721 runtime.documents.set(
9722 targetDocument,
9723 (runtime.documents.get(targetDocument) ?? 0) + 1
9724 );
9725 for (const [hash, css] of runtime.styles) {
9726 injectStyle6(targetDocument, hash, css);
9727 }
9728 return () => {
9729 const count = runtime.documents.get(targetDocument);
9730 if (count === void 0) {
9731 return;
9732 }
9733 if (count <= 1) {
9734 runtime.documents.delete(targetDocument);
9735 return;
9736 }
9737 runtime.documents.set(targetDocument, count - 1);
9738 };
9739 }
9740 function registerStyle6(hash, css) {
9741 const runtime = getRuntime6();
9742 runtime.styles.set(hash, css);
9743 for (const targetDocument of runtime.documents.keys()) {
9744 injectStyle6(targetDocument, hash, css);
9745 }
9746 }
9747 if (typeof process === "undefined" || true) {
9748 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}}}}');
9749 }
9750 var style_default5 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9751 var Root2 = (0, import_element19.forwardRef)(
9752 function EmptyStateRoot({ render: render4, ...props }, ref) {
9753 const className = clsx_default(style_default5.root);
9754 const element = useRender({
9755 defaultTagName: "div",
9756 render: render4,
9757 ref,
9758 props: mergeProps({ className }, props)
9759 });
9760 return element;
9761 }
9762 );
9763
9764 // packages/ui/build-module/empty-state/visual.mjs
9765 var import_element20 = __toESM(require_element(), 1);
9766 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
9767 function getRuntime7() {
9768 const globalScope = globalThis;
9769 if (globalScope.__wpStyleRuntime) {
9770 return globalScope.__wpStyleRuntime;
9771 }
9772 globalScope.__wpStyleRuntime = {
9773 documents: /* @__PURE__ */ new Map(),
9774 styles: /* @__PURE__ */ new Map(),
9775 injectedStyles: /* @__PURE__ */ new WeakMap()
9776 };
9777 if (typeof document !== "undefined") {
9778 registerDocument7(document);
9779 }
9780 return globalScope.__wpStyleRuntime;
9781 }
9782 function documentContainsStyleHash7(targetDocument, hash) {
9783 if (!targetDocument.head) {
9784 return false;
9785 }
9786 for (const style of targetDocument.head.querySelectorAll(
9787 `style[${STYLE_HASH_ATTRIBUTE7}]`
9788 )) {
9789 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
9790 return true;
9791 }
9792 }
9793 return false;
9794 }
9795 function injectStyle7(targetDocument, hash, css) {
9796 if (!targetDocument.head) {
9797 return;
9798 }
9799 const runtime = getRuntime7();
9800 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9801 if (!injectedStyles) {
9802 injectedStyles = /* @__PURE__ */ new Set();
9803 runtime.injectedStyles.set(targetDocument, injectedStyles);
9804 }
9805 if (injectedStyles.has(hash)) {
9806 return;
9807 }
9808 if (documentContainsStyleHash7(targetDocument, hash)) {
9809 injectedStyles.add(hash);
9810 return;
9811 }
9812 const style = targetDocument.createElement("style");
9813 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
9814 style.appendChild(targetDocument.createTextNode(css));
9815 targetDocument.head.appendChild(style);
9816 injectedStyles.add(hash);
9817 }
9818 function registerDocument7(targetDocument) {
9819 const runtime = getRuntime7();
9820 runtime.documents.set(
9821 targetDocument,
9822 (runtime.documents.get(targetDocument) ?? 0) + 1
9823 );
9824 for (const [hash, css] of runtime.styles) {
9825 injectStyle7(targetDocument, hash, css);
9826 }
9827 return () => {
9828 const count = runtime.documents.get(targetDocument);
9829 if (count === void 0) {
9830 return;
9831 }
9832 if (count <= 1) {
9833 runtime.documents.delete(targetDocument);
9834 return;
9835 }
9836 runtime.documents.set(targetDocument, count - 1);
9837 };
9838 }
9839 function registerStyle7(hash, css) {
9840 const runtime = getRuntime7();
9841 runtime.styles.set(hash, css);
9842 for (const targetDocument of runtime.documents.keys()) {
9843 injectStyle7(targetDocument, hash, css);
9844 }
9845 }
9846 if (typeof process === "undefined" || true) {
9847 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}}}}');
9848 }
9849 var style_default6 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9850 var Visual = (0, import_element20.forwardRef)(
9851 function EmptyStateVisual({ render: render4, ...props }, ref) {
9852 const className = clsx_default(style_default6.visual);
9853 const element = useRender({
9854 defaultTagName: "div",
9855 render: render4,
9856 ref,
9857 props: mergeProps({ className }, props)
9858 });
9859 return element;
9860 }
9861 );
9862
9863 // packages/ui/build-module/empty-state/icon.mjs
9864 var import_element21 = __toESM(require_element(), 1);
9865 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
9866 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
9867 function getRuntime8() {
9868 const globalScope = globalThis;
9869 if (globalScope.__wpStyleRuntime) {
9870 return globalScope.__wpStyleRuntime;
9871 }
9872 globalScope.__wpStyleRuntime = {
9873 documents: /* @__PURE__ */ new Map(),
9874 styles: /* @__PURE__ */ new Map(),
9875 injectedStyles: /* @__PURE__ */ new WeakMap()
9876 };
9877 if (typeof document !== "undefined") {
9878 registerDocument8(document);
9879 }
9880 return globalScope.__wpStyleRuntime;
9881 }
9882 function documentContainsStyleHash8(targetDocument, hash) {
9883 if (!targetDocument.head) {
9884 return false;
9885 }
9886 for (const style of targetDocument.head.querySelectorAll(
9887 `style[${STYLE_HASH_ATTRIBUTE8}]`
9888 )) {
9889 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
9890 return true;
9891 }
9892 }
9893 return false;
9894 }
9895 function injectStyle8(targetDocument, hash, css) {
9896 if (!targetDocument.head) {
9897 return;
9898 }
9899 const runtime = getRuntime8();
9900 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9901 if (!injectedStyles) {
9902 injectedStyles = /* @__PURE__ */ new Set();
9903 runtime.injectedStyles.set(targetDocument, injectedStyles);
9904 }
9905 if (injectedStyles.has(hash)) {
9906 return;
9907 }
9908 if (documentContainsStyleHash8(targetDocument, hash)) {
9909 injectedStyles.add(hash);
9910 return;
9911 }
9912 const style = targetDocument.createElement("style");
9913 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
9914 style.appendChild(targetDocument.createTextNode(css));
9915 targetDocument.head.appendChild(style);
9916 injectedStyles.add(hash);
9917 }
9918 function registerDocument8(targetDocument) {
9919 const runtime = getRuntime8();
9920 runtime.documents.set(
9921 targetDocument,
9922 (runtime.documents.get(targetDocument) ?? 0) + 1
9923 );
9924 for (const [hash, css] of runtime.styles) {
9925 injectStyle8(targetDocument, hash, css);
9926 }
9927 return () => {
9928 const count = runtime.documents.get(targetDocument);
9929 if (count === void 0) {
9930 return;
9931 }
9932 if (count <= 1) {
9933 runtime.documents.delete(targetDocument);
9934 return;
9935 }
9936 runtime.documents.set(targetDocument, count - 1);
9937 };
9938 }
9939 function registerStyle8(hash, css) {
9940 const runtime = getRuntime8();
9941 runtime.styles.set(hash, css);
9942 for (const targetDocument of runtime.documents.keys()) {
9943 injectStyle8(targetDocument, hash, css);
9944 }
9945 }
9946 if (typeof process === "undefined" || true) {
9947 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}}}}');
9948 }
9949 var style_default7 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
9950 var Icon3 = (0, import_element21.forwardRef)(
9951 function EmptyStateIcon({ icon, className, ...restProps }, ref) {
9952 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
9953 Visual,
9954 {
9955 ref,
9956 className: clsx_default(style_default7.icon, className),
9957 ...restProps,
9958 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { icon })
9959 }
9960 );
9961 }
9962 );
9963
9964 // packages/ui/build-module/empty-state/title.mjs
9965 var import_element22 = __toESM(require_element(), 1);
9966 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
9967 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
9968 function getRuntime9() {
9969 const globalScope = globalThis;
9970 if (globalScope.__wpStyleRuntime) {
9971 return globalScope.__wpStyleRuntime;
9972 }
9973 globalScope.__wpStyleRuntime = {
9974 documents: /* @__PURE__ */ new Map(),
9975 styles: /* @__PURE__ */ new Map(),
9976 injectedStyles: /* @__PURE__ */ new WeakMap()
9977 };
9978 if (typeof document !== "undefined") {
9979 registerDocument9(document);
9980 }
9981 return globalScope.__wpStyleRuntime;
9982 }
9983 function documentContainsStyleHash9(targetDocument, hash) {
9984 if (!targetDocument.head) {
9985 return false;
9986 }
9987 for (const style of targetDocument.head.querySelectorAll(
9988 `style[${STYLE_HASH_ATTRIBUTE9}]`
9989 )) {
9990 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
9991 return true;
9992 }
9993 }
9994 return false;
9995 }
9996 function injectStyle9(targetDocument, hash, css) {
9997 if (!targetDocument.head) {
9998 return;
9999 }
10000 const runtime = getRuntime9();
10001 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10002 if (!injectedStyles) {
10003 injectedStyles = /* @__PURE__ */ new Set();
10004 runtime.injectedStyles.set(targetDocument, injectedStyles);
10005 }
10006 if (injectedStyles.has(hash)) {
10007 return;
10008 }
10009 if (documentContainsStyleHash9(targetDocument, hash)) {
10010 injectedStyles.add(hash);
10011 return;
10012 }
10013 const style = targetDocument.createElement("style");
10014 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
10015 style.appendChild(targetDocument.createTextNode(css));
10016 targetDocument.head.appendChild(style);
10017 injectedStyles.add(hash);
10018 }
10019 function registerDocument9(targetDocument) {
10020 const runtime = getRuntime9();
10021 runtime.documents.set(
10022 targetDocument,
10023 (runtime.documents.get(targetDocument) ?? 0) + 1
10024 );
10025 for (const [hash, css] of runtime.styles) {
10026 injectStyle9(targetDocument, hash, css);
10027 }
10028 return () => {
10029 const count = runtime.documents.get(targetDocument);
10030 if (count === void 0) {
10031 return;
10032 }
10033 if (count <= 1) {
10034 runtime.documents.delete(targetDocument);
10035 return;
10036 }
10037 runtime.documents.set(targetDocument, count - 1);
10038 };
10039 }
10040 function registerStyle9(hash, css) {
10041 const runtime = getRuntime9();
10042 runtime.styles.set(hash, css);
10043 for (const targetDocument of runtime.documents.keys()) {
10044 injectStyle9(targetDocument, hash, css);
10045 }
10046 }
10047 if (typeof process === "undefined" || true) {
10048 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}}}}');
10049 }
10050 var style_default8 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10051 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h2", {});
10052 var Title = (0, import_element22.forwardRef)(
10053 function EmptyStateTitle({ render: render4 = DEFAULT_TAG, className, children, ...props }, ref) {
10054 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
10055 Text,
10056 {
10057 ref,
10058 variant: "heading-lg",
10059 render: render4,
10060 className: clsx_default(style_default8.title, className),
10061 ...props,
10062 children
10063 }
10064 );
10065 }
10066 );
10067
10068 // packages/ui/build-module/empty-state/description.mjs
10069 var import_element23 = __toESM(require_element(), 1);
10070 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10071 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
10072 function getRuntime10() {
10073 const globalScope = globalThis;
10074 if (globalScope.__wpStyleRuntime) {
10075 return globalScope.__wpStyleRuntime;
10076 }
10077 globalScope.__wpStyleRuntime = {
10078 documents: /* @__PURE__ */ new Map(),
10079 styles: /* @__PURE__ */ new Map(),
10080 injectedStyles: /* @__PURE__ */ new WeakMap()
10081 };
10082 if (typeof document !== "undefined") {
10083 registerDocument10(document);
10084 }
10085 return globalScope.__wpStyleRuntime;
10086 }
10087 function documentContainsStyleHash10(targetDocument, hash) {
10088 if (!targetDocument.head) {
10089 return false;
10090 }
10091 for (const style of targetDocument.head.querySelectorAll(
10092 `style[${STYLE_HASH_ATTRIBUTE10}]`
10093 )) {
10094 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
10095 return true;
10096 }
10097 }
10098 return false;
10099 }
10100 function injectStyle10(targetDocument, hash, css) {
10101 if (!targetDocument.head) {
10102 return;
10103 }
10104 const runtime = getRuntime10();
10105 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10106 if (!injectedStyles) {
10107 injectedStyles = /* @__PURE__ */ new Set();
10108 runtime.injectedStyles.set(targetDocument, injectedStyles);
10109 }
10110 if (injectedStyles.has(hash)) {
10111 return;
10112 }
10113 if (documentContainsStyleHash10(targetDocument, hash)) {
10114 injectedStyles.add(hash);
10115 return;
10116 }
10117 const style = targetDocument.createElement("style");
10118 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
10119 style.appendChild(targetDocument.createTextNode(css));
10120 targetDocument.head.appendChild(style);
10121 injectedStyles.add(hash);
10122 }
10123 function registerDocument10(targetDocument) {
10124 const runtime = getRuntime10();
10125 runtime.documents.set(
10126 targetDocument,
10127 (runtime.documents.get(targetDocument) ?? 0) + 1
10128 );
10129 for (const [hash, css] of runtime.styles) {
10130 injectStyle10(targetDocument, hash, css);
10131 }
10132 return () => {
10133 const count = runtime.documents.get(targetDocument);
10134 if (count === void 0) {
10135 return;
10136 }
10137 if (count <= 1) {
10138 runtime.documents.delete(targetDocument);
10139 return;
10140 }
10141 runtime.documents.set(targetDocument, count - 1);
10142 };
10143 }
10144 function registerStyle10(hash, css) {
10145 const runtime = getRuntime10();
10146 runtime.styles.set(hash, css);
10147 for (const targetDocument of runtime.documents.keys()) {
10148 injectStyle10(targetDocument, hash, css);
10149 }
10150 }
10151 if (typeof process === "undefined" || true) {
10152 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}}}}');
10153 }
10154 var style_default9 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10155 var DEFAULT_TAG2 = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", {});
10156 var Description = (0, import_element23.forwardRef)(function EmptyStateDescription({ render: render4 = DEFAULT_TAG2, className, children, ...props }, ref) {
10157 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10158 Text,
10159 {
10160 ref,
10161 variant: "body-md",
10162 render: render4,
10163 className: clsx_default(style_default9.description, className),
10164 ...props,
10165 children
10166 }
10167 );
10168 });
10169
10170 // packages/ui/build-module/empty-state/actions.mjs
10171 var import_element24 = __toESM(require_element(), 1);
10172 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
10173 function getRuntime11() {
10174 const globalScope = globalThis;
10175 if (globalScope.__wpStyleRuntime) {
10176 return globalScope.__wpStyleRuntime;
10177 }
10178 globalScope.__wpStyleRuntime = {
10179 documents: /* @__PURE__ */ new Map(),
10180 styles: /* @__PURE__ */ new Map(),
10181 injectedStyles: /* @__PURE__ */ new WeakMap()
10182 };
10183 if (typeof document !== "undefined") {
10184 registerDocument11(document);
10185 }
10186 return globalScope.__wpStyleRuntime;
10187 }
10188 function documentContainsStyleHash11(targetDocument, hash) {
10189 if (!targetDocument.head) {
10190 return false;
10191 }
10192 for (const style of targetDocument.head.querySelectorAll(
10193 `style[${STYLE_HASH_ATTRIBUTE11}]`
10194 )) {
10195 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
10196 return true;
10197 }
10198 }
10199 return false;
10200 }
10201 function injectStyle11(targetDocument, hash, css) {
10202 if (!targetDocument.head) {
10203 return;
10204 }
10205 const runtime = getRuntime11();
10206 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10207 if (!injectedStyles) {
10208 injectedStyles = /* @__PURE__ */ new Set();
10209 runtime.injectedStyles.set(targetDocument, injectedStyles);
10210 }
10211 if (injectedStyles.has(hash)) {
10212 return;
10213 }
10214 if (documentContainsStyleHash11(targetDocument, hash)) {
10215 injectedStyles.add(hash);
10216 return;
10217 }
10218 const style = targetDocument.createElement("style");
10219 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
10220 style.appendChild(targetDocument.createTextNode(css));
10221 targetDocument.head.appendChild(style);
10222 injectedStyles.add(hash);
10223 }
10224 function registerDocument11(targetDocument) {
10225 const runtime = getRuntime11();
10226 runtime.documents.set(
10227 targetDocument,
10228 (runtime.documents.get(targetDocument) ?? 0) + 1
10229 );
10230 for (const [hash, css] of runtime.styles) {
10231 injectStyle11(targetDocument, hash, css);
10232 }
10233 return () => {
10234 const count = runtime.documents.get(targetDocument);
10235 if (count === void 0) {
10236 return;
10237 }
10238 if (count <= 1) {
10239 runtime.documents.delete(targetDocument);
10240 return;
10241 }
10242 runtime.documents.set(targetDocument, count - 1);
10243 };
10244 }
10245 function registerStyle11(hash, css) {
10246 const runtime = getRuntime11();
10247 runtime.styles.set(hash, css);
10248 for (const targetDocument of runtime.documents.keys()) {
10249 injectStyle11(targetDocument, hash, css);
10250 }
10251 }
10252 if (typeof process === "undefined" || true) {
10253 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}}}}');
10254 }
10255 var style_default10 = { "root": "a23e08e65c8e62e5__root", "visual": "_01303b3680eaa216__visual", "icon": "_58c8e351db225608__icon", "title": "b8b96f70820333a1__title", "description": "_70f1dd22bad55b18__description", "actions": "_89ac025fd8e2bc52__actions" };
10256 var Actions = (0, import_element24.forwardRef)(
10257 function EmptyStateActions({ render: render4, ...props }, ref) {
10258 const className = clsx_default(style_default10.actions);
10259 const element = useRender({
10260 defaultTagName: "div",
10261 render: render4,
10262 ref,
10263 props: mergeProps({ className }, props)
10264 });
10265 return element;
10266 }
10267 );
10268
10269 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
10270 var import_element25 = __toESM(require_element(), 1);
10271 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
10272 function getRuntime12() {
10273 const globalScope = globalThis;
10274 if (globalScope.__wpStyleRuntime) {
10275 return globalScope.__wpStyleRuntime;
10276 }
10277 globalScope.__wpStyleRuntime = {
10278 documents: /* @__PURE__ */ new Map(),
10279 styles: /* @__PURE__ */ new Map(),
10280 injectedStyles: /* @__PURE__ */ new WeakMap()
10281 };
10282 if (typeof document !== "undefined") {
10283 registerDocument12(document);
10284 }
10285 return globalScope.__wpStyleRuntime;
10286 }
10287 function documentContainsStyleHash12(targetDocument, hash) {
10288 if (!targetDocument.head) {
10289 return false;
10290 }
10291 for (const style of targetDocument.head.querySelectorAll(
10292 `style[${STYLE_HASH_ATTRIBUTE12}]`
10293 )) {
10294 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
10295 return true;
10296 }
10297 }
10298 return false;
10299 }
10300 function injectStyle12(targetDocument, hash, css) {
10301 if (!targetDocument.head) {
10302 return;
10303 }
10304 const runtime = getRuntime12();
10305 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10306 if (!injectedStyles) {
10307 injectedStyles = /* @__PURE__ */ new Set();
10308 runtime.injectedStyles.set(targetDocument, injectedStyles);
10309 }
10310 if (injectedStyles.has(hash)) {
10311 return;
10312 }
10313 if (documentContainsStyleHash12(targetDocument, hash)) {
10314 injectedStyles.add(hash);
10315 return;
10316 }
10317 const style = targetDocument.createElement("style");
10318 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
10319 style.appendChild(targetDocument.createTextNode(css));
10320 targetDocument.head.appendChild(style);
10321 injectedStyles.add(hash);
10322 }
10323 function registerDocument12(targetDocument) {
10324 const runtime = getRuntime12();
10325 runtime.documents.set(
10326 targetDocument,
10327 (runtime.documents.get(targetDocument) ?? 0) + 1
10328 );
10329 for (const [hash, css] of runtime.styles) {
10330 injectStyle12(targetDocument, hash, css);
10331 }
10332 return () => {
10333 const count = runtime.documents.get(targetDocument);
10334 if (count === void 0) {
10335 return;
10336 }
10337 if (count <= 1) {
10338 runtime.documents.delete(targetDocument);
10339 return;
10340 }
10341 runtime.documents.set(targetDocument, count - 1);
10342 };
10343 }
10344 function registerStyle12(hash, css) {
10345 const runtime = getRuntime12();
10346 runtime.styles.set(hash, css);
10347 for (const targetDocument of runtime.documents.keys()) {
10348 injectStyle12(targetDocument, hash, css);
10349 }
10350 }
10351 if (typeof process === "undefined" || true) {
10352 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}}}");
10353 }
10354 var style_default11 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10355 var VisuallyHidden = (0, import_element25.forwardRef)(
10356 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10357 const element = useRender({
10358 render: render4,
10359 ref,
10360 props: mergeProps(
10361 { className: style_default11["visually-hidden"] },
10362 restProps,
10363 {
10364 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10365 "data-visually-hidden": ""
10366 }
10367 )
10368 });
10369 return element;
10370 }
10371 );
10372
10373 // packages/ui/build-module/link/link.mjs
10374 var import_element26 = __toESM(require_element(), 1);
10375 var import_i18n = __toESM(require_i18n(), 1);
10376 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
10377 var STYLE_HASH_ATTRIBUTE13 = "data-wp-hash";
10378 function getRuntime13() {
10379 const globalScope = globalThis;
10380 if (globalScope.__wpStyleRuntime) {
10381 return globalScope.__wpStyleRuntime;
10382 }
10383 globalScope.__wpStyleRuntime = {
10384 documents: /* @__PURE__ */ new Map(),
10385 styles: /* @__PURE__ */ new Map(),
10386 injectedStyles: /* @__PURE__ */ new WeakMap()
10387 };
10388 if (typeof document !== "undefined") {
10389 registerDocument13(document);
10390 }
10391 return globalScope.__wpStyleRuntime;
10392 }
10393 function documentContainsStyleHash13(targetDocument, hash) {
10394 if (!targetDocument.head) {
10395 return false;
10396 }
10397 for (const style of targetDocument.head.querySelectorAll(
10398 `style[${STYLE_HASH_ATTRIBUTE13}]`
10399 )) {
10400 if (style.getAttribute(STYLE_HASH_ATTRIBUTE13) === hash) {
10401 return true;
10402 }
10403 }
10404 return false;
10405 }
10406 function injectStyle13(targetDocument, hash, css) {
10407 if (!targetDocument.head) {
10408 return;
10409 }
10410 const runtime = getRuntime13();
10411 let injectedStyles = runtime.injectedStyles.get(targetDocument);
10412 if (!injectedStyles) {
10413 injectedStyles = /* @__PURE__ */ new Set();
10414 runtime.injectedStyles.set(targetDocument, injectedStyles);
10415 }
10416 if (injectedStyles.has(hash)) {
10417 return;
10418 }
10419 if (documentContainsStyleHash13(targetDocument, hash)) {
10420 injectedStyles.add(hash);
10421 return;
10422 }
10423 const style = targetDocument.createElement("style");
10424 style.setAttribute(STYLE_HASH_ATTRIBUTE13, hash);
10425 style.appendChild(targetDocument.createTextNode(css));
10426 targetDocument.head.appendChild(style);
10427 injectedStyles.add(hash);
10428 }
10429 function registerDocument13(targetDocument) {
10430 const runtime = getRuntime13();
10431 runtime.documents.set(
10432 targetDocument,
10433 (runtime.documents.get(targetDocument) ?? 0) + 1
10434 );
10435 for (const [hash, css] of runtime.styles) {
10436 injectStyle13(targetDocument, hash, css);
10437 }
10438 return () => {
10439 const count = runtime.documents.get(targetDocument);
10440 if (count === void 0) {
10441 return;
10442 }
10443 if (count <= 1) {
10444 runtime.documents.delete(targetDocument);
10445 return;
10446 }
10447 runtime.documents.set(targetDocument, count - 1);
10448 };
10449 }
10450 function registerStyle13(hash, css) {
10451 const runtime = getRuntime13();
10452 runtime.styles.set(hash, css);
10453 for (const targetDocument of runtime.documents.keys()) {
10454 injectStyle13(targetDocument, hash, css);
10455 }
10456 }
10457 if (typeof process === "undefined" || true) {
10458 registerStyle13("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
10459 }
10460 var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
10461 if (typeof process === "undefined" || true) {
10462 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))}}}");
10463 }
10464 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" };
10465 if (typeof process === "undefined" || true) {
10466 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"}}}');
10467 }
10468 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" };
10469 if (typeof process === "undefined" || true) {
10470 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)}");
10471 }
10472 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" };
10473 var Link = (0, import_element26.forwardRef)(function Link2({
10474 children,
10475 variant = "default",
10476 tone = "brand",
10477 openInNewTab = false,
10478 render: render4,
10479 className,
10480 ...props
10481 }, ref) {
10482 const element = useRender({
10483 render: render4,
10484 defaultTagName: "a",
10485 ref,
10486 props: mergeProps(props, {
10487 className: clsx_default(
10488 global_css_defense_default2.a,
10489 resets_default2["box-sizing"],
10490 focus_default["outset-ring--focus"],
10491 variant !== "unstyled" && style_default12.link,
10492 variant !== "unstyled" && style_default12[`is-${tone}`],
10493 variant === "unstyled" && style_default12["is-unstyled"],
10494 className
10495 ),
10496 target: openInNewTab ? "_blank" : void 0,
10497 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
10498 children,
10499 openInNewTab && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
10500 "span",
10501 {
10502 className: style_default12["link-icon"],
10503 role: "img",
10504 "aria-label": (
10505 /* translators: accessibility text appended to link text */
10506 (0, import_i18n.__)("(opens in a new tab)")
10507 )
10508 }
10509 )
10510 ] })
10511 })
10512 });
10513 return element;
10514 });
10515
10516 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10517 var import_element27 = __toESM(require_element(), 1);
10518
10519 // packages/dataviews/build-module/constants.mjs
10520 var import_i18n2 = __toESM(require_i18n(), 1);
10521 var OPERATOR_IS_ANY = "isAny";
10522 var OPERATOR_IS_NONE = "isNone";
10523 var OPERATOR_IS_ALL = "isAll";
10524 var OPERATOR_IS_NOT_ALL = "isNotAll";
10525 var OPERATOR_BETWEEN = "between";
10526 var OPERATOR_IN_THE_PAST = "inThePast";
10527 var OPERATOR_OVER = "over";
10528 var OPERATOR_IS = "is";
10529 var OPERATOR_IS_NOT = "isNot";
10530 var OPERATOR_LESS_THAN = "lessThan";
10531 var OPERATOR_GREATER_THAN = "greaterThan";
10532 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10533 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10534 var OPERATOR_BEFORE = "before";
10535 var OPERATOR_AFTER = "after";
10536 var OPERATOR_BEFORE_INC = "beforeInc";
10537 var OPERATOR_AFTER_INC = "afterInc";
10538 var OPERATOR_CONTAINS = "contains";
10539 var OPERATOR_NOT_CONTAINS = "notContains";
10540 var OPERATOR_STARTS_WITH = "startsWith";
10541 var OPERATOR_ON = "on";
10542 var OPERATOR_NOT_ON = "notOn";
10543 var SORTING_DIRECTIONS = ["asc", "desc"];
10544 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10545 var sortValues = { asc: "ascending", desc: "descending" };
10546 var sortLabels = {
10547 asc: (0, import_i18n2.__)("Sort ascending"),
10548 desc: (0, import_i18n2.__)("Sort descending")
10549 };
10550 var sortIcons = {
10551 asc: arrow_up_default,
10552 desc: arrow_down_default
10553 };
10554 var LAYOUT_TABLE = "table";
10555 var LAYOUT_GRID = "grid";
10556 var LAYOUT_LIST = "list";
10557 var LAYOUT_ACTIVITY = "activity";
10558 var LAYOUT_PICKER_GRID = "pickerGrid";
10559 var LAYOUT_PICKER_TABLE = "pickerTable";
10560 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10561
10562 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10563 var DataViewsContext = (0, import_element27.createContext)({
10564 view: { type: LAYOUT_TABLE },
10565 onChangeView: () => {
10566 },
10567 fields: [],
10568 data: [],
10569 paginationInfo: {
10570 totalItems: 0,
10571 totalPages: 0
10572 },
10573 selection: [],
10574 onChangeSelection: () => {
10575 },
10576 setOpenedFilter: () => {
10577 },
10578 openedFilter: null,
10579 getItemId: (item) => item.id,
10580 isItemClickable: () => true,
10581 renderItemLink: void 0,
10582 containerWidth: 0,
10583 containerRef: (0, import_element27.createRef)(),
10584 resizeObserverRef: () => {
10585 },
10586 defaultLayouts: { list: {}, grid: {}, table: {} },
10587 filters: [],
10588 isShowingFilter: false,
10589 setIsShowingFilter: () => {
10590 },
10591 hasInitiallyLoaded: false,
10592 config: {
10593 perPageSizes: []
10594 },
10595 intersectionObserver: null
10596 });
10597 DataViewsContext.displayName = "DataViewsContext";
10598 var dataviews_context_default = DataViewsContext;
10599
10600 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10601 var import_i18n23 = __toESM(require_i18n(), 1);
10602
10603 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10604 var import_i18n10 = __toESM(require_i18n(), 1);
10605 var import_components6 = __toESM(require_components(), 1);
10606 var import_element35 = __toESM(require_element(), 1);
10607 var import_keycodes = __toESM(require_keycodes(), 1);
10608
10609 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10610 var import_components = __toESM(require_components(), 1);
10611 var import_i18n3 = __toESM(require_i18n(), 1);
10612 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
10613 function DataViewsSelectionCheckbox({
10614 selection,
10615 onChangeSelection,
10616 item,
10617 getItemId,
10618 titleField,
10619 disabled: disabled2,
10620 ...extraProps
10621 }) {
10622 const id = getItemId(item);
10623 const isInSelectionArray = selection.includes(id);
10624 const checked = !disabled2 && isInSelectionArray;
10625 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
10626 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10627 import_components.CheckboxControl,
10628 {
10629 className: "dataviews-selection-checkbox",
10630 "aria-label": selectionLabel,
10631 "aria-disabled": disabled2,
10632 checked,
10633 onChange: () => {
10634 if (disabled2) {
10635 return;
10636 }
10637 onChangeSelection(
10638 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10639 );
10640 },
10641 ...extraProps
10642 }
10643 );
10644 }
10645
10646 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10647 var import_components2 = __toESM(require_components(), 1);
10648 var import_i18n4 = __toESM(require_i18n(), 1);
10649 var import_element28 = __toESM(require_element(), 1);
10650 var import_data = __toESM(require_data(), 1);
10651 var import_compose = __toESM(require_compose(), 1);
10652
10653 // packages/dataviews/build-module/lock-unlock.mjs
10654 var import_private_apis2 = __toESM(require_private_apis(), 1);
10655 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10656 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10657 "@wordpress/dataviews"
10658 );
10659
10660 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10661 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
10662 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
10663 function ButtonTrigger({
10664 action,
10665 onClick,
10666 items,
10667 variant
10668 }) {
10669 const label = typeof action.label === "string" ? action.label : action.label(items);
10670 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10671 import_components2.Button,
10672 {
10673 disabled: !!action.disabled,
10674 accessibleWhenDisabled: true,
10675 size: "compact",
10676 variant,
10677 onClick,
10678 children: label
10679 }
10680 );
10681 }
10682 function MenuItemTrigger({
10683 action,
10684 onClick,
10685 items
10686 }) {
10687 const label = typeof action.label === "string" ? action.label : action.label(items);
10688 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.ItemLabel, { children: label }) });
10689 }
10690 function ActionModal({
10691 action,
10692 items,
10693 closeModal
10694 }) {
10695 const label = typeof action.label === "string" ? action.label : action.label(items);
10696 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10697 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10698 import_components2.Modal,
10699 {
10700 title: modalHeader || label,
10701 __experimentalHideHeader: !!action.hideModalHeader,
10702 onRequestClose: closeModal,
10703 focusOnMount: action.modalFocusOnMount ?? true,
10704 size: action.modalSize || "medium",
10705 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10706 action.id
10707 )}`,
10708 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(action.RenderModal, { items, closeModal })
10709 }
10710 );
10711 }
10712 function ActionsMenuGroup({
10713 actions,
10714 item,
10715 registry,
10716 setActiveModalAction
10717 }) {
10718 const { primaryActions, regularActions } = (0, import_element28.useMemo)(() => {
10719 return actions.reduce(
10720 (acc, action) => {
10721 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10722 return acc;
10723 },
10724 {
10725 primaryActions: [],
10726 regularActions: []
10727 }
10728 );
10729 }, [actions]);
10730 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10731 MenuItemTrigger,
10732 {
10733 action,
10734 onClick: () => {
10735 if ("RenderModal" in action) {
10736 setActiveModalAction(action);
10737 return;
10738 }
10739 action.callback([item], { registry });
10740 },
10741 items: [item]
10742 },
10743 action.id
10744 ));
10745 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu.Group, { children: [
10746 renderActionGroup(primaryActions),
10747 renderActionGroup(regularActions)
10748 ] });
10749 }
10750 function ItemActions({
10751 item,
10752 actions,
10753 isCompact
10754 }) {
10755 const registry = (0, import_data.useRegistry)();
10756 const { primaryActions, eligibleActions } = (0, import_element28.useMemo)(() => {
10757 const _eligibleActions = actions.filter(
10758 (action) => !action.isEligible || action.isEligible(item)
10759 );
10760 const _primaryActions = _eligibleActions.filter(
10761 (action) => action.isPrimary
10762 );
10763 return {
10764 primaryActions: _primaryActions,
10765 eligibleActions: _eligibleActions
10766 };
10767 }, [actions, item]);
10768 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10769 if (isCompact) {
10770 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10771 CompactItemActions,
10772 {
10773 item,
10774 actions: eligibleActions,
10775 isSmall: true,
10776 registry
10777 }
10778 );
10779 }
10780 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
10781 Stack,
10782 {
10783 direction: "row",
10784 justify: "flex-end",
10785 className: "dataviews-item-actions",
10786 style: {
10787 flexShrink: 0,
10788 width: "auto"
10789 },
10790 children: [
10791 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10792 PrimaryActions,
10793 {
10794 item,
10795 actions: primaryActions,
10796 registry
10797 }
10798 ),
10799 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10800 // there if there are any actions at all.
10801 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10802 CompactItemActions,
10803 {
10804 item,
10805 actions: eligibleActions,
10806 registry
10807 }
10808 )
10809 ]
10810 }
10811 );
10812 }
10813 function CompactItemActions({
10814 item,
10815 actions,
10816 isSmall,
10817 registry
10818 }) {
10819 const [activeModalAction, setActiveModalAction] = (0, import_element28.useState)(
10820 null
10821 );
10822 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10823 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Menu, { placement: "bottom-end", children: [
10824 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10825 Menu.TriggerButton,
10826 {
10827 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10828 import_components2.Button,
10829 {
10830 size: isSmall ? "small" : "compact",
10831 icon: more_vertical_default,
10832 label: (0, import_i18n4.__)("Actions"),
10833 accessibleWhenDisabled: true,
10834 disabled: !actions.length,
10835 className: "dataviews-all-actions-button"
10836 }
10837 )
10838 }
10839 ),
10840 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10841 ActionsMenuGroup,
10842 {
10843 actions,
10844 item,
10845 registry,
10846 setActiveModalAction
10847 }
10848 ) })
10849 ] }),
10850 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10851 ActionModal,
10852 {
10853 action: activeModalAction,
10854 items: [item],
10855 closeModal: () => setActiveModalAction(null)
10856 }
10857 )
10858 ] });
10859 }
10860 function PrimaryActions({
10861 item,
10862 actions,
10863 registry,
10864 buttonVariant
10865 }) {
10866 const [activeModalAction, setActiveModalAction] = (0, import_element28.useState)(null);
10867 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10868 if (isMobileViewport) {
10869 return null;
10870 }
10871 if (!Array.isArray(actions) || actions.length === 0) {
10872 return null;
10873 }
10874 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
10875 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10876 ButtonTrigger,
10877 {
10878 action,
10879 onClick: () => {
10880 if ("RenderModal" in action) {
10881 setActiveModalAction(action);
10882 return;
10883 }
10884 action.callback([item], { registry });
10885 },
10886 items: [item],
10887 variant: buttonVariant
10888 },
10889 action.id
10890 )),
10891 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
10892 ActionModal,
10893 {
10894 action: activeModalAction,
10895 items: [item],
10896 closeModal: () => setActiveModalAction(null)
10897 }
10898 )
10899 ] });
10900 }
10901
10902 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10903 var import_components3 = __toESM(require_components(), 1);
10904 var import_i18n6 = __toESM(require_i18n(), 1);
10905 var import_element29 = __toESM(require_element(), 1);
10906 var import_data2 = __toESM(require_data(), 1);
10907 var import_compose2 = __toESM(require_compose(), 1);
10908
10909 // packages/dataviews/build-module/utils/get-footer-message.mjs
10910 var import_i18n5 = __toESM(require_i18n(), 1);
10911 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10912 if (selectionCount > 0) {
10913 return (0, import_i18n5.sprintf)(
10914 /* translators: %d: number of items. */
10915 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
10916 selectionCount
10917 );
10918 }
10919 if (onlyTotalCount || totalItems <= itemsCount) {
10920 return (0, import_i18n5.sprintf)(
10921 /* translators: %d: number of items. */
10922 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
10923 totalItems
10924 );
10925 }
10926 return (0, import_i18n5.sprintf)(
10927 /* translators: %1$d: number of items. %2$d: total number of items. */
10928 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10929 itemsCount,
10930 totalItems
10931 );
10932 }
10933
10934 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10935 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
10936 function ActionWithModal({
10937 action,
10938 items,
10939 ActionTriggerComponent
10940 }) {
10941 const [isModalOpen, setIsModalOpen] = (0, import_element29.useState)(false);
10942 const actionTriggerProps = {
10943 action,
10944 onClick: () => {
10945 setIsModalOpen(true);
10946 },
10947 items
10948 };
10949 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
10950 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10951 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10952 ActionModal,
10953 {
10954 action,
10955 items,
10956 closeModal: () => setIsModalOpen(false)
10957 }
10958 )
10959 ] });
10960 }
10961 function useHasAPossibleBulkAction(actions, item) {
10962 return (0, import_element29.useMemo)(() => {
10963 return actions.some((action) => {
10964 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10965 });
10966 }, [actions, item]);
10967 }
10968 function useSomeItemHasAPossibleBulkAction(actions, data) {
10969 return (0, import_element29.useMemo)(() => {
10970 return data.some((item) => {
10971 return actions.some((action) => {
10972 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10973 });
10974 });
10975 }, [actions, data]);
10976 }
10977 function BulkSelectionCheckbox({
10978 selection,
10979 onChangeSelection,
10980 data,
10981 actions,
10982 getItemId,
10983 disableSelectAll = false
10984 }) {
10985 const selectableItems = (0, import_element29.useMemo)(() => {
10986 return data.filter((item) => {
10987 return actions.some(
10988 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10989 );
10990 });
10991 }, [data, actions]);
10992 const selectedItems = data.filter(
10993 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10994 );
10995 const hasSelection = selection.length > 0;
10996 const areAllSelected = selectedItems.length === selectableItems.length;
10997 if (disableSelectAll) {
10998 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10999 import_components3.CheckboxControl,
11000 {
11001 className: "dataviews-view-table-selection-checkbox",
11002 checked: hasSelection,
11003 disabled: !hasSelection,
11004 onChange: () => {
11005 onChangeSelection([]);
11006 },
11007 "aria-label": (0, import_i18n6.__)("Deselect all")
11008 }
11009 );
11010 }
11011 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11012 import_components3.CheckboxControl,
11013 {
11014 className: "dataviews-view-table-selection-checkbox",
11015 checked: areAllSelected,
11016 indeterminate: !areAllSelected && !!selectedItems.length,
11017 onChange: () => {
11018 if (areAllSelected) {
11019 onChangeSelection([]);
11020 } else {
11021 onChangeSelection(
11022 selectableItems.map((item) => getItemId(item))
11023 );
11024 }
11025 },
11026 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
11027 }
11028 );
11029 }
11030 function ActionTrigger({
11031 action,
11032 onClick,
11033 isBusy,
11034 items
11035 }) {
11036 const label = typeof action.label === "string" ? action.label : action.label(items);
11037 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11038 if (isMobile) {
11039 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11040 import_components3.Button,
11041 {
11042 disabled: isBusy,
11043 accessibleWhenDisabled: true,
11044 label,
11045 icon: action.icon,
11046 size: "compact",
11047 onClick,
11048 isBusy
11049 }
11050 );
11051 }
11052 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11053 import_components3.Button,
11054 {
11055 disabled: isBusy,
11056 accessibleWhenDisabled: true,
11057 size: "compact",
11058 onClick,
11059 isBusy,
11060 children: label
11061 }
11062 );
11063 }
11064 var EMPTY_ARRAY2 = [];
11065 function ActionButton({
11066 action,
11067 selectedItems,
11068 actionInProgress,
11069 setActionInProgress
11070 }) {
11071 const registry = (0, import_data2.useRegistry)();
11072 const selectedEligibleItems = (0, import_element29.useMemo)(() => {
11073 return selectedItems.filter((item) => {
11074 return !action.isEligible || action.isEligible(item);
11075 });
11076 }, [action, selectedItems]);
11077 if ("RenderModal" in action) {
11078 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11079 ActionWithModal,
11080 {
11081 action,
11082 items: selectedEligibleItems,
11083 ActionTriggerComponent: ActionTrigger
11084 },
11085 action.id
11086 );
11087 }
11088 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11089 ActionTrigger,
11090 {
11091 action,
11092 onClick: async () => {
11093 setActionInProgress(action.id);
11094 await action.callback(selectedItems, {
11095 registry
11096 });
11097 setActionInProgress(null);
11098 },
11099 items: selectedEligibleItems,
11100 isBusy: actionInProgress === action.id
11101 },
11102 action.id
11103 );
11104 }
11105 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
11106 const message2 = getFooterMessage(
11107 selection.length,
11108 data.length,
11109 paginationInfo.totalItems,
11110 isInfiniteScroll
11111 );
11112 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
11113 Stack,
11114 {
11115 direction: "row",
11116 className: "dataviews-bulk-actions-footer__container",
11117 gap: "md",
11118 align: "center",
11119 children: [
11120 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11121 BulkSelectionCheckbox,
11122 {
11123 selection,
11124 onChangeSelection,
11125 data,
11126 actions,
11127 getItemId,
11128 disableSelectAll: isInfiniteScroll
11129 }
11130 ),
11131 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
11132 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
11133 Stack,
11134 {
11135 direction: "row",
11136 className: "dataviews-bulk-actions-footer__action-buttons",
11137 gap: "xs",
11138 children: [
11139 actionsToShow.map((action) => {
11140 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11141 ActionButton,
11142 {
11143 action,
11144 selectedItems,
11145 actionInProgress,
11146 setActionInProgress
11147 },
11148 action.id
11149 );
11150 }),
11151 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11152 import_components3.Button,
11153 {
11154 icon: close_small_default,
11155 showTooltip: true,
11156 tooltipPosition: "top",
11157 size: "compact",
11158 label: (0, import_i18n6.__)("Cancel"),
11159 disabled: !!actionInProgress,
11160 accessibleWhenDisabled: false,
11161 onClick: () => {
11162 onChangeSelection(EMPTY_ARRAY2);
11163 }
11164 }
11165 )
11166 ]
11167 }
11168 )
11169 ]
11170 }
11171 );
11172 }
11173 function FooterContent({
11174 selection,
11175 actions,
11176 onChangeSelection,
11177 data,
11178 getItemId,
11179 isInfiniteScroll,
11180 paginationInfo
11181 }) {
11182 const [actionInProgress, setActionInProgress] = (0, import_element29.useState)(
11183 null
11184 );
11185 const footerContentRef = (0, import_element29.useRef)(void 0);
11186 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
11187 const bulkActions = (0, import_element29.useMemo)(
11188 () => actions.filter((action) => action.supportsBulk),
11189 [actions]
11190 );
11191 const selectableItems = (0, import_element29.useMemo)(() => {
11192 return data.filter((item) => {
11193 return bulkActions.some(
11194 (action) => !action.isEligible || action.isEligible(item)
11195 );
11196 });
11197 }, [data, bulkActions]);
11198 const selectedItems = (0, import_element29.useMemo)(() => {
11199 return data.filter(
11200 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
11201 );
11202 }, [selection, data, getItemId, selectableItems]);
11203 const actionsToShow = (0, import_element29.useMemo)(
11204 () => actions.filter((action) => {
11205 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
11206 (item) => !action.isEligible || action.isEligible(item)
11207 );
11208 }),
11209 [actions, selectedItems, isMobile]
11210 );
11211 if (!actionInProgress) {
11212 if (footerContentRef.current) {
11213 footerContentRef.current = void 0;
11214 }
11215 return renderFooterContent(
11216 data,
11217 actions,
11218 getItemId,
11219 isInfiniteScroll,
11220 selection,
11221 actionsToShow,
11222 selectedItems,
11223 actionInProgress,
11224 setActionInProgress,
11225 onChangeSelection,
11226 paginationInfo
11227 );
11228 } else if (!footerContentRef.current) {
11229 footerContentRef.current = renderFooterContent(
11230 data,
11231 actions,
11232 getItemId,
11233 isInfiniteScroll,
11234 selection,
11235 actionsToShow,
11236 selectedItems,
11237 actionInProgress,
11238 setActionInProgress,
11239 onChangeSelection,
11240 paginationInfo
11241 );
11242 }
11243 return footerContentRef.current;
11244 }
11245 function BulkActionsFooter() {
11246 const {
11247 data,
11248 selection,
11249 actions = EMPTY_ARRAY2,
11250 onChangeSelection,
11251 getItemId,
11252 paginationInfo,
11253 view
11254 } = (0, import_element29.useContext)(dataviews_context_default);
11255 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11256 FooterContent,
11257 {
11258 selection,
11259 onChangeSelection,
11260 data,
11261 actions,
11262 getItemId,
11263 isInfiniteScroll: !!view.infiniteScrollEnabled,
11264 paginationInfo
11265 }
11266 );
11267 }
11268
11269 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11270 var import_i18n7 = __toESM(require_i18n(), 1);
11271 var import_components4 = __toESM(require_components(), 1);
11272 var import_element30 = __toESM(require_element(), 1);
11273
11274 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
11275 function getHideableFields(view, fields) {
11276 const togglableFields = [
11277 view?.titleField,
11278 view?.mediaField,
11279 view?.descriptionField
11280 ].filter(Boolean);
11281 return fields.filter(
11282 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
11283 );
11284 }
11285
11286 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
11287 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11288 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
11289 function WithMenuSeparators({ children }) {
11290 return import_element30.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_element30.Fragment, { children: [
11291 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Separator, {}),
11292 child
11293 ] }, i2));
11294 }
11295 var _HeaderMenu = (0, import_element30.forwardRef)(function HeaderMenu({
11296 fieldId,
11297 view,
11298 fields,
11299 onChangeView,
11300 onHide,
11301 setOpenedFilter,
11302 canMove = true,
11303 canInsertLeft = true,
11304 canInsertRight = true
11305 }, ref) {
11306 const visibleFieldIds = view.fields ?? [];
11307 const index2 = visibleFieldIds?.indexOf(fieldId);
11308 const isSorted = view.sort?.field === fieldId;
11309 let isHidable = false;
11310 let isSortable = false;
11311 let canAddFilter = false;
11312 let operators = [];
11313 const field = fields.find((f2) => f2.id === fieldId);
11314 const { setIsShowingFilter } = (0, import_element30.useContext)(dataviews_context_default);
11315 if (!field) {
11316 return null;
11317 }
11318 isHidable = field.enableHiding !== false;
11319 isSortable = field.enableSorting !== false;
11320 const header = field.header;
11321 operators = !!field.filterBy && field.filterBy?.operators || [];
11322 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
11323 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
11324 return header;
11325 }
11326 const hiddenFields = getHideableFields(view, fields).filter(
11327 (f2) => !visibleFieldIds.includes(f2.id)
11328 );
11329 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
11330 const isRtl = (0, import_i18n7.isRTL)();
11331 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11332 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11333 Menu2.TriggerButton,
11334 {
11335 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11336 import_components4.Button,
11337 {
11338 size: "compact",
11339 className: "dataviews-view-table-header-button",
11340 ref,
11341 variant: "tertiary"
11342 }
11343 ),
11344 children: [
11345 header,
11346 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
11347 ]
11348 }
11349 ),
11350 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(WithMenuSeparators, { children: [
11351 isSortable && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
11352 (direction) => {
11353 const isChecked = view.sort && isSorted && view.sort.direction === direction;
11354 const value = `${fieldId}-${direction}`;
11355 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11356 Menu2.RadioItem,
11357 {
11358 name: "view-table-sorting",
11359 value,
11360 checked: isChecked,
11361 onChange: () => {
11362 onChangeView({
11363 ...view,
11364 sort: {
11365 field: fieldId,
11366 direction
11367 },
11368 showLevels: false
11369 });
11370 },
11371 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
11372 },
11373 value
11374 );
11375 }
11376 ) }),
11377 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11378 Menu2.Item,
11379 {
11380 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: funnel_default }),
11381 onClick: () => {
11382 setOpenedFilter(fieldId);
11383 setIsShowingFilter(true);
11384 onChangeView({
11385 ...view,
11386 page: 1,
11387 filters: [
11388 ...view.filters || [],
11389 {
11390 field: fieldId,
11391 value: void 0,
11392 operator: operators[0]
11393 }
11394 ]
11395 });
11396 },
11397 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
11398 }
11399 ) }),
11400 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2.Group, { children: [
11401 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11402 Menu2.Item,
11403 {
11404 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_left_default }),
11405 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
11406 onClick: () => {
11407 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
11408 const newFields = [
11409 ...visibleFieldIds
11410 ];
11411 newFields.splice(index2, 1);
11412 newFields.splice(
11413 targetIndex,
11414 0,
11415 fieldId
11416 );
11417 onChangeView({
11418 ...view,
11419 fields: newFields
11420 });
11421 },
11422 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
11423 }
11424 ),
11425 canMove && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11426 Menu2.Item,
11427 {
11428 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: arrow_right_default }),
11429 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
11430 onClick: () => {
11431 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
11432 const newFields = [
11433 ...visibleFieldIds
11434 ];
11435 newFields.splice(index2, 1);
11436 newFields.splice(
11437 targetIndex,
11438 0,
11439 fieldId
11440 );
11441 onChangeView({
11442 ...view,
11443 fields: newFields
11444 });
11445 },
11446 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
11447 }
11448 ),
11449 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11450 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
11451 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11452 const insertIndex = isRtl ? index2 + 1 : index2;
11453 return /* @__PURE__ */ (0, import_jsx_runtime50.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_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11472 },
11473 hiddenField.id
11474 );
11475 }) })
11476 ] }),
11477 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Menu2, { children: [
11478 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
11479 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11480 const insertIndex = isRtl ? index2 : index2 + 1;
11481 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11482 Menu2.Item,
11483 {
11484 onClick: () => {
11485 onChangeView({
11486 ...view,
11487 fields: [
11488 ...visibleFieldIds.slice(
11489 0,
11490 insertIndex
11491 ),
11492 hiddenField.id,
11493 ...visibleFieldIds.slice(
11494 insertIndex
11495 )
11496 ]
11497 });
11498 },
11499 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11500 },
11501 hiddenField.id
11502 );
11503 }) })
11504 ] }),
11505 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11506 Menu2.Item,
11507 {
11508 prefix: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components4.Icon, { icon: unseen_default }),
11509 onClick: () => {
11510 onHide(field);
11511 onChangeView({
11512 ...view,
11513 fields: visibleFieldIds.filter(
11514 (id) => id !== fieldId
11515 )
11516 });
11517 },
11518 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
11519 }
11520 )
11521 ] })
11522 ] }) })
11523 ] });
11524 });
11525 var ColumnHeaderMenu = _HeaderMenu;
11526 var column_header_menu_default = ColumnHeaderMenu;
11527
11528 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11529 var import_element31 = __toESM(require_element(), 1);
11530 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
11531 function getClickableItemProps({
11532 item,
11533 isItemClickable,
11534 onClickItem,
11535 className
11536 }) {
11537 if (!isItemClickable(item) || !onClickItem) {
11538 return { className };
11539 }
11540 return {
11541 className: className ? `${className} ${className}--clickable` : void 0,
11542 role: "button",
11543 tabIndex: 0,
11544 onClick: (event) => {
11545 event.stopPropagation();
11546 onClickItem(item);
11547 },
11548 onKeyDown: (event) => {
11549 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11550 event.stopPropagation();
11551 onClickItem(item);
11552 }
11553 }
11554 };
11555 }
11556 function ItemClickWrapper({
11557 item,
11558 isItemClickable,
11559 onClickItem,
11560 renderItemLink,
11561 className,
11562 children,
11563 ...extraProps
11564 }) {
11565 if (!isItemClickable(item)) {
11566 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className, ...extraProps, children });
11567 }
11568 if (renderItemLink) {
11569 const renderedElement = renderItemLink({
11570 item,
11571 className: `${className} ${className}--clickable`,
11572 ...extraProps,
11573 children
11574 });
11575 return (0, import_element31.cloneElement)(renderedElement, {
11576 onClick: (event) => {
11577 event.stopPropagation();
11578 if (renderedElement.props.onClick) {
11579 renderedElement.props.onClick(event);
11580 }
11581 },
11582 onKeyDown: (event) => {
11583 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11584 event.stopPropagation();
11585 if (renderedElement.props.onKeyDown) {
11586 renderedElement.props.onKeyDown(event);
11587 }
11588 }
11589 }
11590 });
11591 }
11592 const clickProps = getClickableItemProps({
11593 item,
11594 isItemClickable,
11595 onClickItem,
11596 className
11597 });
11598 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { ...clickProps, ...extraProps, children });
11599 }
11600
11601 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11602 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
11603 function ColumnPrimary({
11604 item,
11605 level,
11606 titleField,
11607 mediaField,
11608 descriptionField,
11609 onClickItem,
11610 renderItemLink,
11611 isItemClickable
11612 }) {
11613 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11614 mediaField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11615 ItemClickWrapper,
11616 {
11617 item,
11618 isItemClickable,
11619 onClickItem,
11620 renderItemLink,
11621 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11622 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11623 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11624 mediaField.render,
11625 {
11626 item,
11627 field: mediaField,
11628 config: { sizes: "32px" }
11629 }
11630 )
11631 }
11632 ),
11633 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11634 Stack,
11635 {
11636 direction: "column",
11637 align: "flex-start",
11638 className: "dataviews-view-table__primary-column-content",
11639 children: [
11640 titleField && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
11641 ItemClickWrapper,
11642 {
11643 item,
11644 isItemClickable,
11645 onClickItem,
11646 renderItemLink,
11647 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11648 children: [
11649 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { className: "dataviews-view-table__level", children: [
11650 Array(level).fill("\u2014").join(" "),
11651 "\xA0"
11652 ] }),
11653 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField })
11654 ]
11655 }
11656 ),
11657 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11658 descriptionField.render,
11659 {
11660 item,
11661 field: descriptionField
11662 }
11663 )
11664 ]
11665 }
11666 )
11667 ] });
11668 }
11669 var column_primary_default = ColumnPrimary;
11670
11671 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11672 var import_element32 = __toESM(require_element(), 1);
11673 var import_i18n8 = __toESM(require_i18n(), 1);
11674 var isScrolledToEnd = (element) => {
11675 if ((0, import_i18n8.isRTL)()) {
11676 const scrollLeft = Math.abs(element.scrollLeft);
11677 return scrollLeft <= 1;
11678 }
11679 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11680 };
11681 function useScrollState({
11682 scrollContainerRef,
11683 enabledHorizontal = false
11684 }) {
11685 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element32.useState)(false);
11686 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element32.useState)(false);
11687 const handleScroll = (0, import_element32.useCallback)(() => {
11688 const scrollContainer = scrollContainerRef.current;
11689 if (!scrollContainer) {
11690 return;
11691 }
11692 if (enabledHorizontal) {
11693 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11694 }
11695 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11696 }, [scrollContainerRef, enabledHorizontal]);
11697 (0, import_element32.useEffect)(() => {
11698 if (typeof window === "undefined" || !scrollContainerRef.current) {
11699 return () => {
11700 };
11701 }
11702 const scrollContainer = scrollContainerRef.current;
11703 handleScroll();
11704 scrollContainer.addEventListener("scroll", handleScroll);
11705 window.addEventListener("resize", handleScroll);
11706 return () => {
11707 scrollContainer.removeEventListener("scroll", handleScroll);
11708 window.removeEventListener("resize", handleScroll);
11709 };
11710 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11711 return { isHorizontalScrollEnd, isVerticallyScrolled };
11712 }
11713
11714 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11715 function getDataByGroup(data, groupByField) {
11716 return data.reduce((groups, item) => {
11717 const groupName = groupByField.getValue({ item });
11718 if (!groups.has(groupName)) {
11719 groups.set(groupName, []);
11720 }
11721 groups.get(groupName)?.push(item);
11722 return groups;
11723 }, /* @__PURE__ */ new Map());
11724 }
11725
11726 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11727 var import_components5 = __toESM(require_components(), 1);
11728 var import_i18n9 = __toESM(require_i18n(), 1);
11729 var import_element33 = __toESM(require_element(), 1);
11730 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
11731 function FieldItem({
11732 field,
11733 isVisible: isVisible2,
11734 onToggleVisibility
11735 }) {
11736 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11737 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.Icon, { icon: check_default }) }),
11738 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11739 ] }) });
11740 }
11741 function isDefined(item) {
11742 return !!item;
11743 }
11744 function PropertiesSection({
11745 showLabel = true
11746 }) {
11747 const { view, fields, onChangeView } = (0, import_element33.useContext)(dataviews_context_default);
11748 const regularFields = getHideableFields(view, fields);
11749 if (!regularFields?.length) {
11750 return null;
11751 }
11752 const titleField = fields.find((f2) => f2.id === view.titleField);
11753 const previewField = fields.find((f2) => f2.id === view.mediaField);
11754 const descriptionField = fields.find(
11755 (f2) => f2.id === view.descriptionField
11756 );
11757 const lockedFields = [
11758 {
11759 field: titleField,
11760 isVisibleFlag: "showTitle"
11761 },
11762 {
11763 field: previewField,
11764 isVisibleFlag: "showMedia"
11765 },
11766 {
11767 field: descriptionField,
11768 isVisibleFlag: "showDescription"
11769 }
11770 ].filter(({ field }) => isDefined(field));
11771 const visibleFieldIds = view.fields ?? [];
11772 const visibleRegularFieldsCount = regularFields.filter(
11773 (f2) => visibleFieldIds.includes(f2.id)
11774 ).length;
11775 const visibleLockedFields = lockedFields.filter(
11776 ({ isVisibleFlag }) => (
11777 // @ts-expect-error
11778 view[isVisibleFlag] ?? true
11779 )
11780 );
11781 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11782 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11783 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11784 showLabel && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
11785 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11786 Stack,
11787 {
11788 direction: "column",
11789 className: "dataviews-view-config__properties",
11790 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11791 lockedFields.map(({ field, isVisibleFlag }) => {
11792 const isVisible2 = view[isVisibleFlag] ?? true;
11793 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11794 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11795 FieldItem,
11796 {
11797 field: fieldToRender,
11798 isVisible: isVisible2,
11799 onToggleVisibility: () => {
11800 onChangeView({
11801 ...view,
11802 [isVisibleFlag]: !isVisible2
11803 });
11804 }
11805 },
11806 field.id
11807 );
11808 }),
11809 regularFields.map((field) => {
11810 const isVisible2 = visibleFieldIds.includes(field.id);
11811 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11812 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
11813 FieldItem,
11814 {
11815 field: fieldToRender,
11816 isVisible: isVisible2,
11817 onToggleVisibility: () => {
11818 onChangeView({
11819 ...view,
11820 fields: isVisible2 ? visibleFieldIds.filter(
11821 (fieldId) => fieldId !== field.id
11822 ) : [...visibleFieldIds, field.id]
11823 });
11824 }
11825 },
11826 field.id
11827 );
11828 })
11829 ] })
11830 }
11831 )
11832 ] });
11833 }
11834
11835 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11836 var import_element34 = __toESM(require_element(), 1);
11837 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11838 const [showLoader, setShowLoader] = (0, import_element34.useState)(false);
11839 (0, import_element34.useEffect)(() => {
11840 if (!isLoading) {
11841 return;
11842 }
11843 const timeout = setTimeout(() => {
11844 setShowLoader(true);
11845 }, options.delay);
11846 return () => {
11847 clearTimeout(timeout);
11848 setShowLoader(false);
11849 };
11850 }, [isLoading, options.delay]);
11851 return showLoader;
11852 }
11853
11854 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11855 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
11856 function getEffectiveAlign(explicitAlign, fieldType) {
11857 if (explicitAlign) {
11858 return explicitAlign;
11859 }
11860 if (fieldType === "integer" || fieldType === "number") {
11861 return "end";
11862 }
11863 return void 0;
11864 }
11865 function TableColumnField({
11866 item,
11867 fields,
11868 column,
11869 align
11870 }) {
11871 const field = fields.find((f2) => f2.id === column);
11872 if (!field) {
11873 return null;
11874 }
11875 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11876 "dataviews-view-table__cell-align-end": align === "end",
11877 "dataviews-view-table__cell-align-center": align === "center"
11878 });
11879 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(field.render, { item, field }) });
11880 }
11881 function TableRow({
11882 hasBulkActions,
11883 item,
11884 level,
11885 actions,
11886 fields,
11887 id,
11888 view,
11889 titleField,
11890 mediaField,
11891 descriptionField,
11892 selection,
11893 getItemId,
11894 isItemClickable,
11895 onClickItem,
11896 renderItemLink,
11897 onChangeSelection,
11898 isActionsColumnSticky,
11899 posinset
11900 }) {
11901 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
11902 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11903 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11904 const {
11905 showTitle = true,
11906 showMedia = true,
11907 showDescription = true,
11908 infiniteScrollEnabled
11909 } = view;
11910 const isTouchDeviceRef = (0, import_element35.useRef)(false);
11911 const columns = view.fields ?? [];
11912 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11913 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
11914 "tr",
11915 {
11916 className: clsx_default("dataviews-view-table__row", {
11917 "is-selected": hasPossibleBulkAction && isSelected2,
11918 "has-bulk-actions": hasPossibleBulkAction
11919 }),
11920 onTouchStart: () => {
11921 isTouchDeviceRef.current = true;
11922 },
11923 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11924 "aria-posinset": posinset,
11925 role: infiniteScrollEnabled ? "article" : void 0,
11926 onMouseDown: (event) => {
11927 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11928 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11929 event?.preventDefault();
11930 }
11931 },
11932 onClick: (event) => {
11933 if (!hasPossibleBulkAction) {
11934 return;
11935 }
11936 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11937 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11938 onChangeSelection(
11939 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11940 );
11941 }
11942 },
11943 children: [
11944 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11945 DataViewsSelectionCheckbox,
11946 {
11947 item,
11948 selection,
11949 onChangeSelection,
11950 getItemId,
11951 titleField,
11952 disabled: !hasPossibleBulkAction
11953 }
11954 ) }) }),
11955 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11956 column_primary_default,
11957 {
11958 item,
11959 level,
11960 titleField: showTitle ? titleField : void 0,
11961 mediaField: showMedia ? mediaField : void 0,
11962 descriptionField: showDescription ? descriptionField : void 0,
11963 isItemClickable,
11964 onClickItem,
11965 renderItemLink
11966 }
11967 ) }),
11968 columns.map((column) => {
11969 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11970 const field = fields.find((f2) => f2.id === column);
11971 const effectiveAlign = getEffectiveAlign(align, field?.type);
11972 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11973 "td",
11974 {
11975 style: {
11976 width,
11977 maxWidth,
11978 minWidth
11979 },
11980 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11981 TableColumnField,
11982 {
11983 fields,
11984 item,
11985 column,
11986 align: effectiveAlign
11987 }
11988 )
11989 },
11990 column
11991 );
11992 }),
11993 !!actions?.length && // Disable reason: we are not making the element interactive,
11994 // but preventing any click events from bubbling up to the
11995 // table row. This allows us to add a click handler to the row
11996 // itself (to toggle row selection) without erroneously
11997 // intercepting click events from ItemActions.
11998 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
11999 "td",
12000 {
12001 className: clsx_default("dataviews-view-table__actions-column", {
12002 "dataviews-view-table__actions-column--sticky": true,
12003 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
12004 }),
12005 onClick: (e2) => e2.stopPropagation(),
12006 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ItemActions, { item, actions })
12007 }
12008 )
12009 ]
12010 }
12011 );
12012 }
12013 function ViewTable({
12014 actions,
12015 data,
12016 fields,
12017 getItemId,
12018 getItemLevel,
12019 isLoading = false,
12020 onChangeView,
12021 onChangeSelection,
12022 selection,
12023 setOpenedFilter,
12024 onClickItem,
12025 isItemClickable,
12026 renderItemLink,
12027 view,
12028 className,
12029 empty
12030 }) {
12031 const { containerRef } = (0, import_element35.useContext)(dataviews_context_default);
12032 const isDelayedLoading = useDelayedLoading(isLoading);
12033 const headerMenuRefs = (0, import_element35.useRef)(/* @__PURE__ */ new Map());
12034 const headerMenuToFocusRef = (0, import_element35.useRef)(void 0);
12035 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element35.useState)();
12036 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element35.useState)(null);
12037 (0, import_element35.useEffect)(() => {
12038 if (headerMenuToFocusRef.current) {
12039 headerMenuToFocusRef.current.focus();
12040 headerMenuToFocusRef.current = void 0;
12041 }
12042 });
12043 const tableNoticeId = (0, import_element35.useId)();
12044 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
12045 scrollContainerRef: containerRef,
12046 enabledHorizontal: !!actions?.length
12047 });
12048 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12049 if (nextHeaderMenuToFocus) {
12050 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
12051 setNextHeaderMenuToFocus(void 0);
12052 return;
12053 }
12054 const onHide = (field) => {
12055 const hidden = headerMenuRefs.current.get(field.id);
12056 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
12057 setNextHeaderMenuToFocus(fallback?.node);
12058 };
12059 const handleHeaderContextMenu = (event) => {
12060 event.preventDefault();
12061 event.stopPropagation();
12062 const virtualAnchor = {
12063 getBoundingClientRect: () => ({
12064 x: event.clientX,
12065 y: event.clientY,
12066 top: event.clientY,
12067 left: event.clientX,
12068 right: event.clientX,
12069 bottom: event.clientY,
12070 width: 0,
12071 height: 0,
12072 toJSON: () => ({})
12073 })
12074 };
12075 window.requestAnimationFrame(() => {
12076 setContextMenuAnchor(virtualAnchor);
12077 });
12078 };
12079 const hasData = !!data?.length;
12080 const titleField = fields.find((field) => field.id === view.titleField);
12081 const mediaField = fields.find((field) => field.id === view.mediaField);
12082 const descriptionField = fields.find(
12083 (field) => field.id === view.descriptionField
12084 );
12085 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12086 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12087 const { showTitle = true, showMedia = true, showDescription = true } = view;
12088 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
12089 const columns = view.fields ?? [];
12090 const headerMenuRef = (column, index2) => (node) => {
12091 if (node) {
12092 headerMenuRefs.current.set(column, {
12093 node,
12094 fallback: columns[index2 > 0 ? index2 - 1 : 1]
12095 });
12096 } else {
12097 headerMenuRefs.current.delete(column);
12098 }
12099 };
12100 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12101 const isRtl = (0, import_i18n10.isRTL)();
12102 if (!hasData) {
12103 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12104 "div",
12105 {
12106 className: clsx_default("dataviews-no-results", {
12107 "is-refreshing": isDelayedLoading
12108 }),
12109 id: tableNoticeId,
12110 children: empty
12111 }
12112 );
12113 }
12114 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
12115 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
12116 "table",
12117 {
12118 className: clsx_default("dataviews-view-table", className, {
12119 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12120 view.layout.density
12121 ),
12122 "has-bulk-actions": hasBulkActions,
12123 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12124 }),
12125 "aria-busy": isLoading,
12126 "aria-describedby": tableNoticeId,
12127 role: isInfiniteScroll ? "feed" : void 0,
12128 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
12129 children: [
12130 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("colgroup", { children: [
12131 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
12132 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
12133 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12134 "col",
12135 {
12136 className: clsx_default(
12137 `dataviews-view-table__col-${column}`,
12138 {
12139 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
12140 }
12141 )
12142 },
12143 `col-${column}`
12144 )),
12145 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("col", { className: "dataviews-view-table__col-actions" })
12146 ] }),
12147 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12148 import_components6.Popover,
12149 {
12150 anchor: contextMenuAnchor,
12151 onClose: () => setContextMenuAnchor(null),
12152 placement: "bottom-start",
12153 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(PropertiesSection, { showLabel: false })
12154 }
12155 ),
12156 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12157 "thead",
12158 {
12159 className: clsx_default({
12160 "dataviews-view-table__thead--stuck": isVerticallyScrolled
12161 }),
12162 onContextMenu: handleHeaderContextMenu,
12163 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tr", { className: "dataviews-view-table__row", children: [
12164 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12165 "th",
12166 {
12167 className: "dataviews-view-table__checkbox-column",
12168 scope: "col",
12169 onContextMenu: handleHeaderContextMenu,
12170 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12171 BulkSelectionCheckbox,
12172 {
12173 selection,
12174 onChangeSelection,
12175 data,
12176 actions,
12177 getItemId
12178 }
12179 )
12180 }
12181 ),
12182 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12183 column_header_menu_default,
12184 {
12185 ref: headerMenuRef(
12186 titleField.id,
12187 0
12188 ),
12189 fieldId: titleField.id,
12190 view,
12191 fields,
12192 onChangeView,
12193 onHide,
12194 setOpenedFilter,
12195 canMove: false,
12196 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
12197 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
12198 }
12199 ) }),
12200 columns.map((column, index2) => {
12201 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
12202 const field = fields.find(
12203 (f2) => f2.id === column
12204 );
12205 const effectiveAlign = getEffectiveAlign(
12206 align,
12207 field?.type
12208 );
12209 const canInsertOrMove = view.layout?.enableMoving ?? true;
12210 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12211 "th",
12212 {
12213 style: {
12214 width,
12215 maxWidth,
12216 minWidth,
12217 textAlign: effectiveAlign
12218 },
12219 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
12220 scope: "col",
12221 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12222 column_header_menu_default,
12223 {
12224 ref: headerMenuRef(column, index2),
12225 fieldId: column,
12226 view,
12227 fields,
12228 onChangeView,
12229 onHide,
12230 setOpenedFilter,
12231 canMove: canInsertOrMove,
12232 canInsertLeft: canInsertOrMove,
12233 canInsertRight: canInsertOrMove
12234 }
12235 )
12236 },
12237 column
12238 );
12239 }),
12240 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12241 "th",
12242 {
12243 className: clsx_default(
12244 "dataviews-view-table__actions-column",
12245 {
12246 "dataviews-view-table__actions-column--sticky": true,
12247 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
12248 }
12249 ),
12250 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
12251 }
12252 )
12253 ] })
12254 }
12255 ),
12256 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
12257 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("tbody", { children: [
12258 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12259 "td",
12260 {
12261 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
12262 className: "dataviews-view-table__group-header-cell",
12263 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
12264 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12265 (0, import_i18n10.__)("%1$s: %2$s"),
12266 groupField.label,
12267 groupName
12268 )
12269 }
12270 ) }),
12271 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12272 TableRow,
12273 {
12274 item,
12275 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12276 hasBulkActions,
12277 actions,
12278 fields,
12279 id: getItemId(item) || index2.toString(),
12280 view,
12281 titleField,
12282 mediaField,
12283 descriptionField,
12284 selection,
12285 getItemId,
12286 onChangeSelection,
12287 onClickItem,
12288 renderItemLink,
12289 isItemClickable,
12290 isActionsColumnSticky: !isHorizontalScrollEnd
12291 },
12292 getItemId(item)
12293 ))
12294 ] }, `group-${groupName}`)
12295 ) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12296 TableRow,
12297 {
12298 item,
12299 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
12300 hasBulkActions,
12301 actions,
12302 fields,
12303 id: getItemId(item) || index2.toString(),
12304 view,
12305 titleField,
12306 mediaField,
12307 descriptionField,
12308 selection,
12309 getItemId,
12310 onChangeSelection,
12311 onClickItem,
12312 renderItemLink,
12313 isItemClickable,
12314 isActionsColumnSticky: !isHorizontalScrollEnd,
12315 posinset: isInfiniteScroll ? index2 + 1 : void 0
12316 },
12317 getItemId(item)
12318 )) })
12319 ]
12320 }
12321 ),
12322 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components6.Spinner, {}) }) })
12323 ] });
12324 }
12325 var table_default = ViewTable;
12326
12327 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12328 var import_components9 = __toESM(require_components(), 1);
12329 var import_i18n13 = __toESM(require_i18n(), 1);
12330
12331 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12332 var import_components8 = __toESM(require_components(), 1);
12333 var import_i18n12 = __toESM(require_i18n(), 1);
12334 var import_compose3 = __toESM(require_compose(), 1);
12335 var import_keycodes2 = __toESM(require_keycodes(), 1);
12336 var import_element39 = __toESM(require_element(), 1);
12337
12338 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
12339 var import_components7 = __toESM(require_components(), 1);
12340 var import_i18n11 = __toESM(require_i18n(), 1);
12341 var import_element36 = __toESM(require_element(), 1);
12342 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
12343 var imageSizes = [
12344 {
12345 value: 120,
12346 breakpoint: 1
12347 },
12348 {
12349 value: 170,
12350 breakpoint: 1
12351 },
12352 {
12353 value: 230,
12354 breakpoint: 1
12355 },
12356 {
12357 value: 290,
12358 breakpoint: 1112
12359 // at minimum image width, 4 images display at this container size
12360 },
12361 {
12362 value: 350,
12363 breakpoint: 1636
12364 // at minimum image width, 6 images display at this container size
12365 },
12366 {
12367 value: 430,
12368 breakpoint: 588
12369 // at minimum image width, 2 images display at this container size
12370 }
12371 ];
12372 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
12373 function useGridColumns() {
12374 const context = (0, import_element36.useContext)(dataviews_context_default);
12375 const view = context.view;
12376 return (0, import_element36.useMemo)(() => {
12377 const containerWidth = context.containerWidth;
12378 const gap = 32;
12379 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
12380 const columns = Math.floor(
12381 (containerWidth + gap) / (previewSize + gap)
12382 );
12383 return Math.max(1, columns);
12384 }, [context.containerWidth, view.layout?.previewSize]);
12385 }
12386
12387 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
12388 var import_element37 = __toESM(require_element(), 1);
12389 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
12390 var GridItems = (0, import_element37.forwardRef)(({ className, previewSize, ...props }, ref) => {
12391 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
12392 "div",
12393 {
12394 ref,
12395 className: clsx_default("dataviews-view-grid-items", className),
12396 style: {
12397 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
12398 },
12399 ...props
12400 }
12401 );
12402 });
12403
12404 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
12405 var import_element38 = __toESM(require_element(), 1);
12406 function useIntersectionObserver(elementRef, posinset) {
12407 const { intersectionObserver } = (0, import_element38.useContext)(dataviews_context_default);
12408 (0, import_element38.useEffect)(() => {
12409 const element = elementRef.current;
12410 if (!element || posinset === void 0 || !intersectionObserver) {
12411 return;
12412 }
12413 intersectionObserver.observe(element);
12414 return () => {
12415 intersectionObserver.unobserve(element);
12416 };
12417 }, [elementRef, intersectionObserver, posinset]);
12418 }
12419 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
12420 const hasData = !!data?.length;
12421 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
12422 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
12423 }
12424
12425 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
12426 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12427 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
12428 function chunk(array, size4) {
12429 const chunks = [];
12430 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
12431 chunks.push(array.slice(i2, i2 + size4));
12432 }
12433 return chunks;
12434 }
12435 var GridItem = (0, import_element39.forwardRef)(
12436 function GridItem2({
12437 view,
12438 selection,
12439 onChangeSelection,
12440 onClickItem,
12441 isItemClickable,
12442 renderItemLink,
12443 getItemId,
12444 item,
12445 actions,
12446 mediaField,
12447 titleField,
12448 descriptionField,
12449 regularFields,
12450 badgeFields,
12451 hasBulkActions,
12452 config,
12453 posinset,
12454 setsize,
12455 ...props
12456 }, forwardedRef) {
12457 const {
12458 showTitle = true,
12459 showMedia = true,
12460 showDescription = true
12461 } = view;
12462 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
12463 const id = getItemId(item);
12464 const elementRef = (0, import_element39.useRef)(null);
12465 const setRefs = (0, import_element39.useCallback)(
12466 (node) => {
12467 elementRef.current = node;
12468 if (typeof forwardedRef === "function") {
12469 forwardedRef(node);
12470 } else if (forwardedRef) {
12471 forwardedRef.current = node;
12472 }
12473 },
12474 [forwardedRef]
12475 );
12476 useIntersectionObserver(elementRef, posinset);
12477 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12478 const isSelected2 = selection.includes(id);
12479 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12480 const rendersMediaField = showMedia && mediaField?.render;
12481 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12482 mediaField.render,
12483 {
12484 item,
12485 field: mediaField,
12486 config
12487 }
12488 ) : mediaPlaceholder;
12489 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
12490 let mediaA11yProps;
12491 let titleA11yProps;
12492 if (isItemClickable(item) && onClickItem) {
12493 if (renderedTitleField) {
12494 mediaA11yProps = {
12495 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12496 };
12497 titleA11yProps = {
12498 id: `dataviews-view-grid__title-field-${instanceId}`
12499 };
12500 } else {
12501 mediaA11yProps = {
12502 "aria-label": (0, import_i18n12.__)("Navigate to item")
12503 };
12504 }
12505 }
12506 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12507 Stack,
12508 {
12509 direction: "column",
12510 ...props,
12511 ref: setRefs,
12512 "aria-setsize": setsize,
12513 "aria-posinset": posinset,
12514 className: clsx_default(
12515 props.className,
12516 "dataviews-view-grid__row__gridcell",
12517 "dataviews-view-grid__card",
12518 {
12519 "is-selected": hasBulkAction && isSelected2
12520 }
12521 ),
12522 onClickCapture: (event) => {
12523 props.onClickCapture?.(event);
12524 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12525 event.stopPropagation();
12526 event.preventDefault();
12527 if (!hasBulkAction) {
12528 return;
12529 }
12530 onChangeSelection(
12531 isSelected2 ? selection.filter(
12532 (itemId) => id !== itemId
12533 ) : [...selection, id]
12534 );
12535 }
12536 },
12537 children: [
12538 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12539 ItemClickWrapper,
12540 {
12541 item,
12542 isItemClickable,
12543 onClickItem,
12544 renderItemLink,
12545 className: clsx_default("dataviews-view-grid__media", {
12546 "dataviews-view-grid__media--placeholder": !rendersMediaField
12547 }),
12548 ...mediaA11yProps,
12549 children: renderedMediaField
12550 }
12551 ),
12552 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12553 DataViewsSelectionCheckbox,
12554 {
12555 item,
12556 selection,
12557 onChangeSelection,
12558 getItemId,
12559 titleField,
12560 disabled: !hasBulkAction
12561 }
12562 ),
12563 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12564 ItemActions,
12565 {
12566 item,
12567 actions,
12568 isCompact: true
12569 }
12570 ) }),
12571 showTitle && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12572 ItemClickWrapper,
12573 {
12574 item,
12575 isItemClickable,
12576 onClickItem,
12577 renderItemLink,
12578 className: "dataviews-view-grid__title-field dataviews-title-field",
12579 ...titleA11yProps,
12580 title: titleField?.getValueFormatted({
12581 item,
12582 field: titleField
12583 }) || void 0,
12584 children: renderedTitleField
12585 }
12586 ) }),
12587 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12588 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12589 descriptionField.render,
12590 {
12591 item,
12592 field: descriptionField
12593 }
12594 ),
12595 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12596 Stack,
12597 {
12598 direction: "row",
12599 className: "dataviews-view-grid__badge-fields",
12600 gap: "sm",
12601 wrap: "wrap",
12602 align: "top",
12603 justify: "flex-start",
12604 children: badgeFields.map((field) => {
12605 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12606 WCBadge,
12607 {
12608 className: "dataviews-view-grid__field-value",
12609 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12610 field.render,
12611 {
12612 item,
12613 field
12614 }
12615 )
12616 },
12617 field.id
12618 );
12619 })
12620 }
12621 ),
12622 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12623 Stack,
12624 {
12625 direction: "column",
12626 className: "dataviews-view-grid__fields",
12627 gap: "xs",
12628 children: regularFields.map((field) => {
12629 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12630 import_components8.Flex,
12631 {
12632 className: "dataviews-view-grid__field",
12633 gap: 1,
12634 justify: "flex-start",
12635 expanded: true,
12636 style: { height: "auto" },
12637 direction: "row",
12638 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
12639 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(tooltip_exports.Root, { children: [
12640 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12641 tooltip_exports.Trigger,
12642 {
12643 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12644 }
12645 ),
12646 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(tooltip_exports.Popup, { children: field.label })
12647 ] }),
12648 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12649 import_components8.FlexItem,
12650 {
12651 className: "dataviews-view-grid__field-value",
12652 style: { maxHeight: "none" },
12653 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12654 field.render,
12655 {
12656 item,
12657 field
12658 }
12659 )
12660 }
12661 )
12662 ] })
12663 },
12664 field.id
12665 );
12666 })
12667 }
12668 )
12669 ] })
12670 ]
12671 }
12672 );
12673 }
12674 );
12675 function CompositeGrid({
12676 data,
12677 isInfiniteScroll,
12678 className,
12679 inert,
12680 isLoading,
12681 view,
12682 fields,
12683 selection,
12684 onChangeSelection,
12685 onClickItem,
12686 isItemClickable,
12687 renderItemLink,
12688 getItemId,
12689 actions
12690 }) {
12691 const { paginationInfo, resizeObserverRef } = (0, import_element39.useContext)(dataviews_context_default);
12692 const gridColumns = useGridColumns();
12693 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12694 const titleField = fields.find(
12695 (field) => field.id === view?.titleField
12696 );
12697 const mediaField = fields.find(
12698 (field) => field.id === view?.mediaField
12699 );
12700 const descriptionField = fields.find(
12701 (field) => field.id === view?.descriptionField
12702 );
12703 const otherFields = view.fields ?? [];
12704 const { regularFields, badgeFields } = otherFields.reduce(
12705 (accumulator, fieldId) => {
12706 const field = fields.find((f2) => f2.id === fieldId);
12707 if (!field) {
12708 return accumulator;
12709 }
12710 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12711 accumulator[key].push(field);
12712 return accumulator;
12713 },
12714 { regularFields: [], badgeFields: [] }
12715 );
12716 const size4 = "900px";
12717 const totalRows = Math.ceil(data.length / gridColumns);
12718 const placeholdersNeeded = usePlaceholdersNeeded(
12719 data,
12720 isInfiniteScroll,
12721 gridColumns
12722 );
12723 return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, {
12724 // Render infinite scroll layout (no rows, feed semantics)
12725 children: [
12726 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
12727 import_components8.Composite,
12728 {
12729 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12730 GridItems,
12731 {
12732 className: clsx_default(
12733 "dataviews-view-grid-infinite-scroll",
12734 className,
12735 {
12736 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12737 "compact",
12738 "comfortable"
12739 ].includes(view.layout.density)
12740 }
12741 ),
12742 previewSize: view.layout?.previewSize,
12743 "aria-busy": isLoading,
12744 ref: resizeObserverRef
12745 }
12746 ),
12747 role: "feed",
12748 focusWrap: true,
12749 inert,
12750 children: [
12751 Array.from({ length: placeholdersNeeded }).map(
12752 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12753 import_components8.Composite.Item,
12754 {
12755 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12756 Stack,
12757 {
12758 ...props,
12759 direction: "column",
12760 role: "article",
12761 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12762 }
12763 ),
12764 "aria-hidden": true,
12765 tabIndex: -1
12766 },
12767 `placeholder-${index2}`
12768 )
12769 ),
12770 data.map((item) => {
12771 const itemId = getItemId(item);
12772 const stablePosition = item.position;
12773 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12774 import_components8.Composite.Item,
12775 {
12776 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12777 GridItem,
12778 {
12779 ...props,
12780 id: itemId,
12781 role: "article",
12782 view,
12783 selection,
12784 onChangeSelection,
12785 onClickItem,
12786 isItemClickable,
12787 renderItemLink,
12788 getItemId,
12789 item,
12790 actions,
12791 mediaField,
12792 titleField,
12793 descriptionField,
12794 regularFields,
12795 badgeFields,
12796 hasBulkActions,
12797 posinset: stablePosition,
12798 setsize: paginationInfo.totalItems,
12799 config: {
12800 sizes: size4
12801 }
12802 }
12803 )
12804 },
12805 itemId
12806 );
12807 })
12808 ]
12809 }
12810 ),
12811 // Render standard grid layout (with rows, grid semantics)
12812 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12813 import_components8.Composite,
12814 {
12815 role: "grid",
12816 className: clsx_default("dataviews-view-grid", className, {
12817 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12818 view.layout.density
12819 )
12820 }),
12821 focusWrap: true,
12822 "aria-busy": isLoading,
12823 "aria-rowcount": totalRows,
12824 ref: resizeObserverRef,
12825 inert,
12826 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12827 import_components8.Composite.Row,
12828 {
12829 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12830 "div",
12831 {
12832 role: "row",
12833 "aria-rowindex": i2 + 1,
12834 "aria-label": (0, import_i18n12.sprintf)(
12835 /* translators: %d: The row number in the grid */
12836 (0, import_i18n12.__)("Row %d"),
12837 i2 + 1
12838 ),
12839 className: "dataviews-view-grid__row",
12840 style: {
12841 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12842 }
12843 }
12844 ),
12845 children: row.map((item) => {
12846 const itemId = getItemId(item);
12847 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12848 import_components8.Composite.Item,
12849 {
12850 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
12851 GridItem,
12852 {
12853 ...props,
12854 id: itemId,
12855 role: "gridcell",
12856 view,
12857 selection,
12858 onChangeSelection,
12859 onClickItem,
12860 isItemClickable,
12861 renderItemLink,
12862 getItemId,
12863 item,
12864 actions,
12865 mediaField,
12866 titleField,
12867 descriptionField,
12868 regularFields,
12869 badgeFields,
12870 hasBulkActions,
12871 config: {
12872 sizes: size4
12873 }
12874 }
12875 )
12876 },
12877 itemId
12878 );
12879 })
12880 },
12881 i2
12882 ))
12883 }
12884 )
12885 ]
12886 });
12887 }
12888
12889 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12890 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12891 function ViewGrid({
12892 actions,
12893 data,
12894 fields,
12895 getItemId,
12896 isLoading,
12897 onChangeSelection,
12898 onClickItem,
12899 isItemClickable,
12900 renderItemLink,
12901 selection,
12902 view,
12903 className,
12904 empty
12905 }) {
12906 const isDelayedLoading = useDelayedLoading(!!isLoading);
12907 const hasData = !!data?.length;
12908 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12909 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12910 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12911 if (!hasData) {
12912 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12913 "div",
12914 {
12915 className: clsx_default("dataviews-no-results", {
12916 "is-refreshing": isDelayedLoading
12917 }),
12918 children: empty
12919 }
12920 );
12921 }
12922 const gridProps = {
12923 className: clsx_default(className, {
12924 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12925 }),
12926 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12927 isLoading,
12928 view,
12929 fields,
12930 selection,
12931 onChangeSelection,
12932 onClickItem,
12933 isItemClickable,
12934 renderItemLink,
12935 getItemId,
12936 actions
12937 };
12938 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
12939 // Render multiple groups.
12940 children: [
12941 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12942 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12943 Stack,
12944 {
12945 direction: "column",
12946 gap: "sm",
12947 children: [
12948 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12949 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12950 (0, import_i18n13.__)("%1$s: %2$s"),
12951 groupField.label,
12952 groupName
12953 ) }),
12954 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12955 CompositeGrid,
12956 {
12957 ...gridProps,
12958 data: groupItems,
12959 isInfiniteScroll: false
12960 }
12961 )
12962 ]
12963 },
12964 groupName
12965 )
12966 ) }),
12967 // Render a single grid with all data.
12968 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12969 CompositeGrid,
12970 {
12971 ...gridProps,
12972 data,
12973 isInfiniteScroll: !!isInfiniteScroll
12974 }
12975 ),
12976 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components9.Spinner, {}) })
12977 ]
12978 });
12979 }
12980 var grid_default = ViewGrid;
12981
12982 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12983 var import_compose4 = __toESM(require_compose(), 1);
12984 var import_components10 = __toESM(require_components(), 1);
12985 var import_element40 = __toESM(require_element(), 1);
12986 var import_i18n14 = __toESM(require_i18n(), 1);
12987 var import_data3 = __toESM(require_data(), 1);
12988 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
12989 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
12990 function generateItemWrapperCompositeId(idPrefix) {
12991 return `${idPrefix}-item-wrapper`;
12992 }
12993 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12994 return `${idPrefix}-primary-action-${primaryActionId}`;
12995 }
12996 function generateDropdownTriggerCompositeId(idPrefix) {
12997 return `${idPrefix}-dropdown`;
12998 }
12999 function PrimaryActionGridCell({
13000 idPrefix,
13001 primaryAction,
13002 item
13003 }) {
13004 const registry = (0, import_data3.useRegistry)();
13005 const [isModalOpen, setIsModalOpen] = (0, import_element40.useState)(false);
13006 const compositeItemId = generatePrimaryActionCompositeId(
13007 idPrefix,
13008 primaryAction.id
13009 );
13010 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
13011 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13012 import_components10.Composite.Item,
13013 {
13014 id: compositeItemId,
13015 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13016 import_components10.Button,
13017 {
13018 disabled: !!primaryAction.disabled,
13019 accessibleWhenDisabled: true,
13020 text: label,
13021 size: "small",
13022 onClick: () => setIsModalOpen(true)
13023 }
13024 ),
13025 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13026 ActionModal,
13027 {
13028 action: primaryAction,
13029 items: [item],
13030 closeModal: () => setIsModalOpen(false)
13031 }
13032 )
13033 }
13034 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13035 import_components10.Composite.Item,
13036 {
13037 id: compositeItemId,
13038 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13039 import_components10.Button,
13040 {
13041 disabled: !!primaryAction.disabled,
13042 accessibleWhenDisabled: true,
13043 size: "small",
13044 onClick: () => {
13045 primaryAction.callback([item], { registry });
13046 },
13047 children: label
13048 }
13049 )
13050 }
13051 ) }, primaryAction.id);
13052 }
13053 function ListItem({
13054 view,
13055 actions,
13056 idPrefix,
13057 isSelected: isSelected2,
13058 item,
13059 titleField,
13060 mediaField,
13061 descriptionField,
13062 onSelect,
13063 otherFields,
13064 onDropdownTriggerKeyDown,
13065 posinset
13066 }) {
13067 const {
13068 showTitle = true,
13069 showMedia = true,
13070 showDescription = true,
13071 infiniteScrollEnabled
13072 } = view;
13073 const itemRef = (0, import_element40.useRef)(null);
13074 const labelId = `${idPrefix}-label`;
13075 const descriptionId = `${idPrefix}-description`;
13076 const registry = (0, import_data3.useRegistry)();
13077 const [isHovered, setIsHovered] = (0, import_element40.useState)(false);
13078 const [activeModalAction, setActiveModalAction] = (0, import_element40.useState)(
13079 null
13080 );
13081 const handleHover = ({ type }) => {
13082 const isHover = type === "mouseenter";
13083 setIsHovered(isHover);
13084 };
13085 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
13086 (0, import_element40.useEffect)(() => {
13087 if (isSelected2) {
13088 itemRef.current?.scrollIntoView({
13089 behavior: "auto",
13090 block: "nearest",
13091 inline: "nearest"
13092 });
13093 }
13094 }, [isSelected2]);
13095 const { primaryAction, eligibleActions } = (0, import_element40.useMemo)(() => {
13096 const _eligibleActions = actions.filter(
13097 (action) => !action.isEligible || action.isEligible(item)
13098 );
13099 const _primaryActions = _eligibleActions.filter(
13100 (action) => action.isPrimary
13101 );
13102 return {
13103 primaryAction: _primaryActions[0],
13104 eligibleActions: _eligibleActions
13105 };
13106 }, [actions, item]);
13107 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
13108 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13109 mediaField.render,
13110 {
13111 item,
13112 field: mediaField,
13113 config: { sizes: "52px" }
13114 }
13115 ) }) : null;
13116 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(titleField.render, { item, field: titleField }) : null;
13117 const renderDescription = showDescription && descriptionField?.render;
13118 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
13119 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13120 Stack,
13121 {
13122 direction: "row",
13123 gap: "md",
13124 className: "dataviews-view-list__item-actions",
13125 children: [
13126 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13127 PrimaryActionGridCell,
13128 {
13129 idPrefix,
13130 primaryAction,
13131 item
13132 }
13133 ),
13134 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { role: "gridcell", children: [
13135 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu3, { placement: "bottom-end", children: [
13136 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13137 Menu3.TriggerButton,
13138 {
13139 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13140 import_components10.Composite.Item,
13141 {
13142 id: generateDropdownTriggerCompositeId(
13143 idPrefix
13144 ),
13145 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13146 import_components10.Button,
13147 {
13148 size: "small",
13149 icon: more_vertical_default,
13150 label: (0, import_i18n14.__)("Actions"),
13151 accessibleWhenDisabled: true,
13152 disabled: !actions.length,
13153 onKeyDown: onDropdownTriggerKeyDown
13154 }
13155 )
13156 }
13157 )
13158 }
13159 ),
13160 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13161 ActionsMenuGroup,
13162 {
13163 actions: eligibleActions,
13164 item,
13165 registry,
13166 setActiveModalAction
13167 }
13168 ) })
13169 ] }),
13170 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13171 ActionModal,
13172 {
13173 action: activeModalAction,
13174 items: [item],
13175 closeModal: () => setActiveModalAction(null)
13176 }
13177 )
13178 ] })
13179 ]
13180 }
13181 );
13182 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13183 import_components10.Composite.Row,
13184 {
13185 ref: itemRef,
13186 render: (
13187 /* aria-posinset breaks Composite.Row if passed to it directly. */
13188 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13189 "div",
13190 {
13191 "aria-posinset": posinset,
13192 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
13193 }
13194 )
13195 ),
13196 role: infiniteScrollEnabled ? "article" : "row",
13197 className: clsx_default({
13198 "is-selected": isSelected2,
13199 "is-hovered": isHovered
13200 }),
13201 onMouseEnter: handleHover,
13202 onMouseLeave: handleHover,
13203 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13204 Stack,
13205 {
13206 direction: "row",
13207 className: "dataviews-view-list__item-wrapper",
13208 children: [
13209 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13210 import_components10.Composite.Item,
13211 {
13212 id: generateItemWrapperCompositeId(idPrefix),
13213 "aria-pressed": isSelected2,
13214 "aria-labelledby": labelId,
13215 "aria-describedby": descriptionId,
13216 className: "dataviews-view-list__item",
13217 onClick: () => onSelect(item)
13218 }
13219 ) }),
13220 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13221 Stack,
13222 {
13223 direction: "row",
13224 gap: "md",
13225 justify: "start",
13226 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
13227 style: { flex: 1, minWidth: 0 },
13228 children: [
13229 renderedMediaField,
13230 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13231 Stack,
13232 {
13233 direction: "column",
13234 gap: "xs",
13235 className: "dataviews-view-list__field-wrapper",
13236 children: [
13237 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", align: "center", children: [
13238 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13239 "div",
13240 {
13241 className: "dataviews-title-field dataviews-view-list__title-field",
13242 id: labelId,
13243 children: renderedTitleField
13244 }
13245 ),
13246 usedActions
13247 ] }),
13248 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13249 descriptionField.render,
13250 {
13251 item,
13252 field: descriptionField
13253 }
13254 ) }),
13255 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13256 "div",
13257 {
13258 className: "dataviews-view-list__fields",
13259 id: descriptionId,
13260 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13261 "div",
13262 {
13263 className: "dataviews-view-list__field",
13264 children: [
13265 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13266 VisuallyHidden,
13267 {
13268 className: "dataviews-view-list__field-label",
13269 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", {}),
13270 children: field.label
13271 }
13272 ),
13273 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13274 field.render,
13275 {
13276 item,
13277 field
13278 }
13279 ) })
13280 ]
13281 },
13282 field.id
13283 ))
13284 }
13285 )
13286 ]
13287 }
13288 )
13289 ]
13290 }
13291 )
13292 ]
13293 }
13294 )
13295 }
13296 );
13297 }
13298 function isDefined2(item) {
13299 return !!item;
13300 }
13301 function ViewList(props) {
13302 const {
13303 actions,
13304 data,
13305 fields,
13306 getItemId,
13307 isLoading,
13308 onChangeSelection,
13309 selection,
13310 view,
13311 className,
13312 empty
13313 } = props;
13314 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
13315 const isDelayedLoading = useDelayedLoading(!!isLoading);
13316 const selectedItem = data?.findLast(
13317 (item) => selection.includes(getItemId(item))
13318 );
13319 const titleField = fields.find((field) => field.id === view.titleField);
13320 const mediaField = fields.find((field) => field.id === view.mediaField);
13321 const descriptionField = fields.find(
13322 (field) => field.id === view.descriptionField
13323 );
13324 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
13325 const onSelect = (item) => onChangeSelection([getItemId(item)]);
13326 const generateCompositeItemIdPrefix = (0, import_element40.useCallback)(
13327 (item) => `${baseId}-${getItemId(item)}`,
13328 [baseId, getItemId]
13329 );
13330 const isActiveCompositeItem = (0, import_element40.useCallback)(
13331 (item, idToCheck) => {
13332 return idToCheck.startsWith(
13333 generateCompositeItemIdPrefix(item)
13334 );
13335 },
13336 [generateCompositeItemIdPrefix]
13337 );
13338 const [activeCompositeId, setActiveCompositeId] = (0, import_element40.useState)(void 0);
13339 const compositeRef = (0, import_element40.useRef)(null);
13340 (0, import_element40.useEffect)(() => {
13341 if (selectedItem) {
13342 setActiveCompositeId(
13343 generateItemWrapperCompositeId(
13344 generateCompositeItemIdPrefix(selectedItem)
13345 )
13346 );
13347 }
13348 }, [selectedItem, generateCompositeItemIdPrefix]);
13349 const activeItemIndex = data.findIndex(
13350 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
13351 );
13352 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
13353 const isActiveIdInList = activeItemIndex !== -1;
13354 const selectCompositeItem = (0, import_element40.useCallback)(
13355 (targetIndex, generateCompositeId) => {
13356 const clampedIndex = Math.min(
13357 data.length - 1,
13358 Math.max(0, targetIndex)
13359 );
13360 if (!data[clampedIndex]) {
13361 return;
13362 }
13363 const itemIdPrefix = generateCompositeItemIdPrefix(
13364 data[clampedIndex]
13365 );
13366 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
13367 setActiveCompositeId(targetCompositeItemId);
13368 if (compositeRef.current?.contains(
13369 compositeRef.current.ownerDocument.activeElement
13370 )) {
13371 document.getElementById(targetCompositeItemId)?.focus();
13372 }
13373 },
13374 [data, generateCompositeItemIdPrefix]
13375 );
13376 (0, import_element40.useEffect)(() => {
13377 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
13378 if (!isActiveIdInList && wasActiveIdInList) {
13379 selectCompositeItem(
13380 previousActiveItemIndex,
13381 generateItemWrapperCompositeId
13382 );
13383 }
13384 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
13385 const onDropdownTriggerKeyDown = (0, import_element40.useCallback)(
13386 (event) => {
13387 if (event.key === "ArrowDown") {
13388 event.preventDefault();
13389 selectCompositeItem(
13390 activeItemIndex + 1,
13391 generateDropdownTriggerCompositeId
13392 );
13393 }
13394 if (event.key === "ArrowUp") {
13395 event.preventDefault();
13396 selectCompositeItem(
13397 activeItemIndex - 1,
13398 generateDropdownTriggerCompositeId
13399 );
13400 }
13401 },
13402 [selectCompositeItem, activeItemIndex]
13403 );
13404 const hasData = !!data?.length;
13405 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13406 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13407 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13408 if (!hasData) {
13409 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13410 "div",
13411 {
13412 className: clsx_default("dataviews-no-results", {
13413 "is-refreshing": isDelayedLoading
13414 }),
13415 children: empty
13416 }
13417 );
13418 }
13419 if (hasData && groupField && dataByGroup) {
13420 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13421 import_components10.Composite,
13422 {
13423 ref: compositeRef,
13424 id: `${baseId}`,
13425 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13426 className: "dataviews-view-list__group",
13427 role: "grid",
13428 activeId: activeCompositeId,
13429 setActiveId: setActiveCompositeId,
13430 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13431 Stack,
13432 {
13433 direction: "column",
13434 gap: "lg",
13435 className: clsx_default("dataviews-view-list", className),
13436 children: Array.from(dataByGroup.entries()).map(
13437 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13438 Stack,
13439 {
13440 direction: "column",
13441 gap: "sm",
13442 children: [
13443 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
13444 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13445 (0, import_i18n14.__)("%1$s: %2$s"),
13446 groupField.label,
13447 groupName
13448 ) }),
13449 groupItems.map((item) => {
13450 const id = generateCompositeItemIdPrefix(item);
13451 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13452 ListItem,
13453 {
13454 view,
13455 idPrefix: id,
13456 actions,
13457 item,
13458 isSelected: item === selectedItem,
13459 onSelect,
13460 mediaField,
13461 titleField,
13462 descriptionField,
13463 otherFields,
13464 onDropdownTriggerKeyDown
13465 },
13466 id
13467 );
13468 })
13469 ]
13470 },
13471 groupName
13472 )
13473 )
13474 }
13475 )
13476 }
13477 );
13478 }
13479 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
13480 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13481 import_components10.Composite,
13482 {
13483 ref: compositeRef,
13484 id: baseId,
13485 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", {}),
13486 className: clsx_default("dataviews-view-list", className, {
13487 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13488 view.layout.density
13489 ),
13490 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13491 }),
13492 role: view.infiniteScrollEnabled ? "feed" : "grid",
13493 activeId: activeCompositeId,
13494 setActiveId: setActiveCompositeId,
13495 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13496 children: data.map((item, index2) => {
13497 const id = generateCompositeItemIdPrefix(item);
13498 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13499 ListItem,
13500 {
13501 view,
13502 idPrefix: id,
13503 actions,
13504 item,
13505 isSelected: item === selectedItem,
13506 onSelect,
13507 mediaField,
13508 titleField,
13509 descriptionField,
13510 otherFields,
13511 onDropdownTriggerKeyDown,
13512 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13513 },
13514 id
13515 );
13516 })
13517 }
13518 ),
13519 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components10.Spinner, {}) })
13520 ] });
13521 }
13522
13523 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13524 var import_components11 = __toESM(require_components(), 1);
13525
13526 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13527 var import_i18n15 = __toESM(require_i18n(), 1);
13528 var import_element41 = __toESM(require_element(), 1);
13529 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13530 function ActivityGroup({
13531 groupName,
13532 groupData,
13533 groupField,
13534 showLabel = true,
13535 children
13536 }) {
13537 const groupHeader = showLabel ? (0, import_element41.createInterpolateElement)(
13538 // translators: %s: The label of the field e.g. "Status".
13539 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
13540 {
13541 groupName: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13542 groupField.render,
13543 {
13544 item: groupData[0],
13545 field: groupField
13546 }
13547 )
13548 }
13549 ) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(groupField.render, { item: groupData[0], field: groupField });
13550 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
13551 Stack,
13552 {
13553 direction: "column",
13554 className: "dataviews-view-activity__group",
13555 children: [
13556 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13557 children
13558 ]
13559 },
13560 groupName
13561 );
13562 }
13563
13564 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13565 var import_element42 = __toESM(require_element(), 1);
13566 var import_data4 = __toESM(require_data(), 1);
13567 var import_compose5 = __toESM(require_compose(), 1);
13568 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13569 function ActivityItem(props) {
13570 const {
13571 view,
13572 actions,
13573 item,
13574 titleField,
13575 mediaField,
13576 descriptionField,
13577 otherFields,
13578 posinset,
13579 onClickItem,
13580 renderItemLink,
13581 isItemClickable
13582 } = props;
13583 const {
13584 showTitle = true,
13585 showMedia = true,
13586 showDescription = true,
13587 infiniteScrollEnabled
13588 } = view;
13589 const itemRef = (0, import_element42.useRef)(null);
13590 const registry = (0, import_data4.useRegistry)();
13591 const { paginationInfo } = (0, import_element42.useContext)(dataviews_context_default);
13592 const { primaryActions, eligibleActions } = (0, import_element42.useMemo)(() => {
13593 const _eligibleActions = actions.filter(
13594 (action) => !action.isEligible || action.isEligible(item)
13595 );
13596 const _primaryActions = _eligibleActions.filter(
13597 (action) => action.isPrimary
13598 );
13599 return {
13600 primaryActions: _primaryActions,
13601 eligibleActions: _eligibleActions
13602 };
13603 }, [actions, item]);
13604 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13605 const density = view.layout?.density ?? "balanced";
13606 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13607 mediaField.render,
13608 {
13609 item,
13610 field: mediaField,
13611 config: {
13612 sizes: density === "comfortable" ? "32px" : "24px"
13613 }
13614 }
13615 ) : null;
13616 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13617 "span",
13618 {
13619 className: "dataviews-view-activity__item-bullet",
13620 "aria-hidden": "true"
13621 }
13622 ) });
13623 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
13624 const verticalGap = (0, import_element42.useMemo)(() => {
13625 switch (density) {
13626 case "comfortable":
13627 return "md";
13628 default:
13629 return "sm";
13630 }
13631 }, [density]);
13632 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13633 "div",
13634 {
13635 ref: itemRef,
13636 role: infiniteScrollEnabled ? "article" : void 0,
13637 "aria-posinset": posinset,
13638 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13639 className: clsx_default(
13640 "dataviews-view-activity__item",
13641 density === "compact" && "is-compact",
13642 density === "balanced" && "is-balanced",
13643 density === "comfortable" && "is-comfortable"
13644 ),
13645 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13646 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13647 Stack,
13648 {
13649 direction: "column",
13650 gap: "xs",
13651 align: "center",
13652 className: "dataviews-view-activity__item-type",
13653 children: renderedMediaField
13654 }
13655 ),
13656 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13657 Stack,
13658 {
13659 direction: "column",
13660 gap: verticalGap,
13661 align: "flex-start",
13662 className: "dataviews-view-activity__item-content",
13663 children: [
13664 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13665 ItemClickWrapper,
13666 {
13667 item,
13668 isItemClickable,
13669 onClickItem,
13670 renderItemLink,
13671 className: "dataviews-view-activity__item-title",
13672 children: renderedTitleField
13673 }
13674 ),
13675 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13676 descriptionField.render,
13677 {
13678 item,
13679 field: descriptionField
13680 }
13681 ) }),
13682 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
13683 "div",
13684 {
13685 className: "dataviews-view-activity__item-field",
13686 children: [
13687 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13688 VisuallyHidden,
13689 {
13690 className: "dataviews-view-activity__item-field-label",
13691 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", {}),
13692 children: field.label
13693 }
13694 ),
13695 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13696 field.render,
13697 {
13698 item,
13699 field
13700 }
13701 ) })
13702 ]
13703 },
13704 field.id
13705 )) }),
13706 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13707 PrimaryActions,
13708 {
13709 item,
13710 actions: primaryActions,
13711 registry,
13712 buttonVariant: "secondary"
13713 }
13714 )
13715 ]
13716 }
13717 ),
13718 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13719 // there if there are any actions at all.
13720 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13721 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13722 ItemActions,
13723 {
13724 item,
13725 actions: eligibleActions,
13726 isCompact: true
13727 }
13728 ) })
13729 ] })
13730 }
13731 );
13732 }
13733 var activity_item_default = ActivityItem;
13734
13735 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13736 var import_react10 = __toESM(require_react(), 1);
13737 function isDefined3(item) {
13738 return !!item;
13739 }
13740 function ActivityItems(props) {
13741 const { data, fields, getItemId, view } = props;
13742 const titleField = fields.find((field) => field.id === view.titleField);
13743 const mediaField = fields.find((field) => field.id === view.mediaField);
13744 const descriptionField = fields.find(
13745 (field) => field.id === view.descriptionField
13746 );
13747 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13748 return data.map((item, index2) => {
13749 return /* @__PURE__ */ (0, import_react10.createElement)(
13750 activity_item_default,
13751 {
13752 ...props,
13753 key: getItemId(item),
13754 item,
13755 mediaField,
13756 titleField,
13757 descriptionField,
13758 otherFields,
13759 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13760 }
13761 );
13762 });
13763 }
13764
13765 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13766 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13767 function ViewActivity(props) {
13768 const { empty, data, fields, isLoading, view, className } = props;
13769 const isDelayedLoading = useDelayedLoading(!!isLoading);
13770 const hasData = !!data?.length;
13771 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13772 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13773 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13774 if (!hasData) {
13775 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13776 "div",
13777 {
13778 className: clsx_default("dataviews-no-results", {
13779 "is-refreshing": isDelayedLoading
13780 }),
13781 children: empty
13782 }
13783 );
13784 }
13785 const isInert = !isInfiniteScroll && !!isLoading;
13786 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13787 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13788 });
13789 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13790 if (hasData && groupField && dataByGroup) {
13791 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13792 Stack,
13793 {
13794 direction: "column",
13795 gap: "sm",
13796 className: wrapperClassName,
13797 inert: isInert ? "true" : void 0,
13798 children: groupedEntries.map(
13799 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13800 ActivityGroup,
13801 {
13802 groupName,
13803 groupData,
13804 groupField,
13805 showLabel: view.groupBy?.showLabel !== false,
13806 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13807 ActivityItems,
13808 {
13809 ...props,
13810 data: groupData
13811 }
13812 )
13813 },
13814 groupName
13815 )
13816 )
13817 }
13818 );
13819 }
13820 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
13821 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13822 "div",
13823 {
13824 className: wrapperClassName,
13825 role: view.infiniteScrollEnabled ? "feed" : void 0,
13826 inert: isInert ? "true" : void 0,
13827 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(ActivityItems, { ...props })
13828 }
13829 ),
13830 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components11.Spinner, {}) })
13831 ] });
13832 }
13833
13834 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13835 var import_components14 = __toESM(require_components(), 1);
13836 var import_i18n18 = __toESM(require_i18n(), 1);
13837 var import_compose6 = __toESM(require_compose(), 1);
13838 var import_element45 = __toESM(require_element(), 1);
13839
13840 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13841 var import_components13 = __toESM(require_components(), 1);
13842 var import_data5 = __toESM(require_data(), 1);
13843 var import_element44 = __toESM(require_element(), 1);
13844 var import_i18n17 = __toESM(require_i18n(), 1);
13845
13846 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13847 var import_components12 = __toESM(require_components(), 1);
13848 var import_element43 = __toESM(require_element(), 1);
13849 var import_i18n16 = __toESM(require_i18n(), 1);
13850 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13851 function DataViewsPagination() {
13852 const {
13853 view,
13854 onChangeView,
13855 paginationInfo: { totalItems = 0, totalPages }
13856 } = (0, import_element43.useContext)(dataviews_context_default);
13857 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13858 return null;
13859 }
13860 const currentPage = view.page ?? 1;
13861 const pageSelectOptions = Array.from(Array(totalPages)).map(
13862 (_, i2) => {
13863 const page = i2 + 1;
13864 return {
13865 value: page.toString(),
13866 label: page.toString(),
13867 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
13868 // translators: 1: current page number. 2: total number of pages.
13869 (0, import_i18n16.__)("Page %1$d of %2$d"),
13870 currentPage,
13871 totalPages
13872 ) : page.toString()
13873 };
13874 }
13875 );
13876 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
13877 Stack,
13878 {
13879 direction: "row",
13880 className: "dataviews-pagination",
13881 justify: "end",
13882 align: "center",
13883 gap: "xl",
13884 children: [
13885 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13886 Stack,
13887 {
13888 direction: "row",
13889 justify: "flex-start",
13890 align: "center",
13891 gap: "xs",
13892 className: "dataviews-pagination__page-select",
13893 children: (0, import_element43.createInterpolateElement)(
13894 (0, import_i18n16.sprintf)(
13895 // translators: 1: Current page number, 2: Total number of pages.
13896 (0, import_i18n16._x)(
13897 "<div>Page</div>%1$s<div>of %2$d</div>",
13898 "paging"
13899 ),
13900 "<CurrentPage />",
13901 totalPages
13902 ),
13903 {
13904 div: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { "aria-hidden": true }),
13905 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13906 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13907 import_components12.SelectControl,
13908 {
13909 "aria-label": (0, import_i18n16.__)("Current page"),
13910 value: currentPage.toString(),
13911 options: pageSelectOptions,
13912 onChange: (newValue) => {
13913 onChangeView({
13914 ...view,
13915 page: +newValue
13916 });
13917 },
13918 size: "small",
13919 variant: "minimal"
13920 }
13921 )
13922 }
13923 )
13924 }
13925 ),
13926 /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13927 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13928 import_components12.Button,
13929 {
13930 onClick: () => onChangeView({
13931 ...view,
13932 page: currentPage - 1
13933 }),
13934 disabled: currentPage === 1,
13935 accessibleWhenDisabled: true,
13936 label: (0, import_i18n16.__)("Previous page"),
13937 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
13938 showTooltip: true,
13939 size: "compact",
13940 tooltipPosition: "top"
13941 }
13942 ),
13943 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13944 import_components12.Button,
13945 {
13946 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13947 disabled: currentPage >= totalPages,
13948 accessibleWhenDisabled: true,
13949 label: (0, import_i18n16.__)("Next page"),
13950 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
13951 showTooltip: true,
13952 size: "compact",
13953 tooltipPosition: "top"
13954 }
13955 )
13956 ] })
13957 ]
13958 }
13959 );
13960 }
13961 var dataviews_pagination_default = (0, import_element43.memo)(DataViewsPagination);
13962
13963 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13964 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13965 function useIsMultiselectPicker(actions) {
13966 return (0, import_element44.useMemo)(() => {
13967 return actions?.every((action) => action.supportsBulk);
13968 }, [actions]);
13969 }
13970
13971 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13972 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13973 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
13974 function GridItem3({
13975 view,
13976 multiselect,
13977 selection,
13978 onChangeSelection,
13979 getItemId,
13980 item,
13981 mediaField,
13982 titleField,
13983 descriptionField,
13984 regularFields,
13985 badgeFields,
13986 config,
13987 posinset,
13988 setsize
13989 }) {
13990 const { showTitle = true, showMedia = true, showDescription = true } = view;
13991 const id = getItemId(item);
13992 const elementRef = (0, import_element45.useRef)(null);
13993 const isSelected2 = selection.includes(id);
13994 useIntersectionObserver(elementRef, posinset);
13995 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13996 mediaField.render,
13997 {
13998 item,
13999 field: mediaField,
14000 config
14001 }
14002 ) : null;
14003 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(titleField.render, { item, field: titleField }) : null;
14004 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14005 import_components14.Composite.Item,
14006 {
14007 ref: elementRef,
14008 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
14009 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Stack, { direction: "column", children, ...props }),
14010 role: "option",
14011 "aria-posinset": posinset,
14012 "aria-setsize": setsize,
14013 className: clsx_default("dataviews-view-picker-grid__card", {
14014 "is-selected": isSelected2
14015 }),
14016 "aria-selected": isSelected2,
14017 onClick: () => {
14018 if (isSelected2) {
14019 onChangeSelection(
14020 selection.filter((itemId) => id !== itemId)
14021 );
14022 } else {
14023 const newSelection = multiselect ? [...selection, id] : [id];
14024 onChangeSelection(newSelection);
14025 }
14026 },
14027 children: [
14028 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
14029 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14030 DataViewsSelectionCheckbox,
14031 {
14032 item,
14033 selection,
14034 onChangeSelection,
14035 getItemId,
14036 titleField,
14037 disabled: false,
14038 "aria-hidden": true,
14039 tabIndex: -1
14040 }
14041 ),
14042 showTitle && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14043 Stack,
14044 {
14045 direction: "row",
14046 justify: "space-between",
14047 className: "dataviews-view-picker-grid__title-actions",
14048 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
14049 }
14050 ),
14051 /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(Stack, { direction: "column", gap: "xs", children: [
14052 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14053 descriptionField.render,
14054 {
14055 item,
14056 field: descriptionField
14057 }
14058 ),
14059 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14060 Stack,
14061 {
14062 direction: "row",
14063 className: "dataviews-view-picker-grid__badge-fields",
14064 gap: "sm",
14065 wrap: "wrap",
14066 align: "top",
14067 justify: "flex-start",
14068 children: badgeFields.map((field) => {
14069 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14070 WCBadge2,
14071 {
14072 className: "dataviews-view-picker-grid__field-value",
14073 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14074 field.render,
14075 {
14076 item,
14077 field
14078 }
14079 )
14080 },
14081 field.id
14082 );
14083 })
14084 }
14085 ),
14086 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14087 Stack,
14088 {
14089 direction: "column",
14090 className: "dataviews-view-picker-grid__fields",
14091 gap: "xs",
14092 children: regularFields.map((field) => {
14093 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14094 import_components14.Flex,
14095 {
14096 className: "dataviews-view-picker-grid__field",
14097 gap: 1,
14098 justify: "flex-start",
14099 expanded: true,
14100 style: { height: "auto" },
14101 direction: "row",
14102 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
14103 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
14104 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14105 import_components14.FlexItem,
14106 {
14107 className: "dataviews-view-picker-grid__field-value",
14108 style: { maxHeight: "none" },
14109 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14110 field.render,
14111 {
14112 item,
14113 field
14114 }
14115 )
14116 }
14117 )
14118 ] })
14119 },
14120 field.id
14121 );
14122 })
14123 }
14124 )
14125 ] })
14126 ]
14127 },
14128 id
14129 );
14130 }
14131 function GridGroup({
14132 groupName,
14133 groupField,
14134 showLabel = true,
14135 children
14136 }) {
14137 const headerId = (0, import_compose6.useInstanceId)(
14138 GridGroup,
14139 "dataviews-view-picker-grid-group__header"
14140 );
14141 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14142 Stack,
14143 {
14144 direction: "column",
14145 gap: "sm",
14146 role: "group",
14147 "aria-labelledby": headerId,
14148 children: [
14149 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14150 "h3",
14151 {
14152 className: "dataviews-view-picker-grid-group__header",
14153 id: headerId,
14154 children: showLabel ? (0, import_i18n18.sprintf)(
14155 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14156 (0, import_i18n18.__)("%1$s: %2$s"),
14157 groupField.label,
14158 groupName
14159 ) : groupName
14160 }
14161 ),
14162 children
14163 ]
14164 },
14165 groupName
14166 );
14167 }
14168 function ViewPickerGrid({
14169 actions,
14170 data,
14171 fields,
14172 getItemId,
14173 isLoading,
14174 onChangeSelection,
14175 selection,
14176 view,
14177 className,
14178 empty
14179 }) {
14180 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element45.useContext)(dataviews_context_default);
14181 const titleField = fields.find(
14182 (field) => field.id === view?.titleField
14183 );
14184 const mediaField = fields.find(
14185 (field) => field.id === view?.mediaField
14186 );
14187 const descriptionField = fields.find(
14188 (field) => field.id === view?.descriptionField
14189 );
14190 const otherFields = view.fields ?? [];
14191 const { regularFields, badgeFields } = otherFields.reduce(
14192 (accumulator, fieldId) => {
14193 const field = fields.find((f2) => f2.id === fieldId);
14194 if (!field) {
14195 return accumulator;
14196 }
14197 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
14198 accumulator[key].push(field);
14199 return accumulator;
14200 },
14201 { regularFields: [], badgeFields: [] }
14202 );
14203 const hasData = !!data?.length;
14204 const usedPreviewSize = view.layout?.previewSize;
14205 const isMultiselect = useIsMultiselectPicker(actions);
14206 const size4 = "900px";
14207 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14208 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14209 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14210 const currentPage = view?.page ?? 1;
14211 const perPage = view?.perPage ?? 0;
14212 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14213 const gridColumns = useGridColumns();
14214 const placeholdersNeeded = usePlaceholdersNeeded(
14215 data,
14216 isInfiniteScroll,
14217 gridColumns
14218 );
14219 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, {
14220 // Render multiple groups.
14221 children: [
14222 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14223 import_components14.Composite,
14224 {
14225 virtualFocus: true,
14226 orientation: "horizontal",
14227 role: "listbox",
14228 "aria-multiselectable": isMultiselect,
14229 className: clsx_default(
14230 "dataviews-view-picker-grid",
14231 className,
14232 {
14233 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14234 view.layout.density
14235 )
14236 }
14237 ),
14238 "aria-label": itemListLabel,
14239 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14240 Stack,
14241 {
14242 direction: "column",
14243 gap: "lg",
14244 children,
14245 ...props
14246 }
14247 ),
14248 children: Array.from(dataByGroup.entries()).map(
14249 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14250 GridGroup,
14251 {
14252 groupName,
14253 groupField,
14254 showLabel: view.groupBy?.showLabel !== false,
14255 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14256 GridItems,
14257 {
14258 previewSize: usedPreviewSize,
14259 style: {
14260 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
14261 },
14262 "aria-busy": isLoading,
14263 ref: resizeObserverRef,
14264 children: groupItems.map((item) => {
14265 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
14266 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14267 GridItem3,
14268 {
14269 view,
14270 multiselect: isMultiselect,
14271 selection,
14272 onChangeSelection,
14273 getItemId,
14274 item,
14275 mediaField,
14276 titleField,
14277 descriptionField,
14278 regularFields,
14279 badgeFields,
14280 config: {
14281 sizes: size4
14282 },
14283 posinset: posInSet,
14284 setsize: setSize
14285 },
14286 getItemId(item)
14287 );
14288 })
14289 }
14290 )
14291 },
14292 groupName
14293 )
14294 )
14295 }
14296 ),
14297 // Render a single grid with all data.
14298 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
14299 import_components14.Composite,
14300 {
14301 render: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14302 GridItems,
14303 {
14304 className: clsx_default(
14305 "dataviews-view-picker-grid",
14306 className,
14307 {
14308 [`has-${view.layout?.density}-density`]: view.layout?.density && [
14309 "compact",
14310 "comfortable"
14311 ].includes(view.layout.density)
14312 }
14313 ),
14314 previewSize: usedPreviewSize,
14315 "aria-busy": isLoading,
14316 ref: resizeObserverRef
14317 }
14318 ),
14319 virtualFocus: true,
14320 orientation: "horizontal",
14321 role: "listbox",
14322 "aria-multiselectable": isMultiselect,
14323 "aria-label": itemListLabel,
14324 children: [
14325 Array.from({ length: placeholdersNeeded }).map(
14326 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14327 import_components14.Composite.Item,
14328 {
14329 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14330 Stack,
14331 {
14332 direction: "column",
14333 children,
14334 ...props
14335 }
14336 ),
14337 role: "option",
14338 "aria-hidden": true,
14339 tabIndex: -1,
14340 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
14341 },
14342 `placeholder-${index2}`
14343 )
14344 ),
14345 data.map((item) => {
14346 const posinset = item.position;
14347 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14348 GridItem3,
14349 {
14350 view,
14351 multiselect: isMultiselect,
14352 selection,
14353 onChangeSelection,
14354 getItemId,
14355 item,
14356 mediaField,
14357 titleField,
14358 descriptionField,
14359 regularFields,
14360 badgeFields,
14361 config: {
14362 sizes: size4
14363 },
14364 posinset,
14365 setsize: setSize
14366 },
14367 getItemId(item)
14368 );
14369 })
14370 ]
14371 }
14372 ),
14373 // Render empty state.
14374 !hasData && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
14375 "div",
14376 {
14377 className: clsx_default({
14378 "dataviews-loading": isLoading,
14379 "dataviews-no-results": !isLoading
14380 }),
14381 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) }) : empty
14382 }
14383 ),
14384 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_components14.Spinner, {}) })
14385 ]
14386 });
14387 }
14388 var picker_grid_default = ViewPickerGrid;
14389
14390 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
14391 var import_i18n19 = __toESM(require_i18n(), 1);
14392 var import_components15 = __toESM(require_components(), 1);
14393 var import_element46 = __toESM(require_element(), 1);
14394 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
14395 function TableColumnField2({
14396 item,
14397 fields,
14398 column,
14399 align
14400 }) {
14401 const field = fields.find((f2) => f2.id === column);
14402 if (!field) {
14403 return null;
14404 }
14405 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
14406 "dataviews-view-table__cell-align-end": align === "end",
14407 "dataviews-view-table__cell-align-center": align === "center"
14408 });
14409 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(field.render, { item, field }) });
14410 }
14411 function TableRow2({
14412 item,
14413 fields,
14414 id,
14415 view,
14416 titleField,
14417 mediaField,
14418 descriptionField,
14419 selection,
14420 getItemId,
14421 onChangeSelection,
14422 multiselect,
14423 posinset
14424 }) {
14425 const { paginationInfo } = (0, import_element46.useContext)(dataviews_context_default);
14426 const isSelected2 = selection.includes(id);
14427 const [isHovered, setIsHovered] = (0, import_element46.useState)(false);
14428 const elementRef = (0, import_element46.useRef)(null);
14429 useIntersectionObserver(elementRef, posinset);
14430 const {
14431 showTitle = true,
14432 showMedia = true,
14433 showDescription = true,
14434 infiniteScrollEnabled
14435 } = view;
14436 const handleMouseEnter = () => {
14437 setIsHovered(true);
14438 };
14439 const handleMouseLeave = () => {
14440 setIsHovered(false);
14441 };
14442 const columns = view.fields ?? [];
14443 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14444 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14445 import_components15.Composite.Item,
14446 {
14447 ref: elementRef,
14448 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14449 "tr",
14450 {
14451 className: clsx_default("dataviews-view-table__row", {
14452 "is-selected": isSelected2,
14453 "is-hovered": isHovered
14454 }),
14455 onMouseEnter: handleMouseEnter,
14456 onMouseLeave: handleMouseLeave,
14457 children,
14458 ...props
14459 }
14460 ),
14461 "aria-selected": isSelected2,
14462 "aria-setsize": paginationInfo.totalItems || void 0,
14463 "aria-posinset": posinset,
14464 role: infiniteScrollEnabled ? "article" : "option",
14465 onMouseDown: (event) => {
14466 if (event.button !== 0) {
14467 return;
14468 }
14469 event.currentTarget.parentElement?.focus({
14470 preventScroll: true
14471 });
14472 },
14473 onClick: () => {
14474 if (isSelected2) {
14475 onChangeSelection(
14476 selection.filter((itemId) => id !== itemId)
14477 );
14478 } else {
14479 const newSelection = multiselect ? [...selection, id] : [id];
14480 onChangeSelection(newSelection);
14481 }
14482 },
14483 children: [
14484 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14485 "td",
14486 {
14487 className: "dataviews-view-table__checkbox-column",
14488 role: "presentation",
14489 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14490 DataViewsSelectionCheckbox,
14491 {
14492 item,
14493 selection,
14494 onChangeSelection,
14495 getItemId,
14496 titleField,
14497 disabled: false,
14498 "aria-hidden": true,
14499 tabIndex: -1
14500 }
14501 ) })
14502 }
14503 ),
14504 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14505 "td",
14506 {
14507 role: "presentation",
14508 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14509 column_primary_default,
14510 {
14511 item,
14512 titleField: showTitle ? titleField : void 0,
14513 mediaField: showMedia ? mediaField : void 0,
14514 descriptionField: showDescription ? descriptionField : void 0,
14515 isItemClickable: () => false
14516 }
14517 )
14518 }
14519 ),
14520 columns.map((column) => {
14521 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14522 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14523 "td",
14524 {
14525 style: {
14526 width,
14527 maxWidth,
14528 minWidth
14529 },
14530 role: "presentation",
14531 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14532 TableColumnField2,
14533 {
14534 fields,
14535 item,
14536 column,
14537 align
14538 }
14539 )
14540 },
14541 column
14542 );
14543 })
14544 ]
14545 },
14546 id
14547 );
14548 }
14549 function ViewPickerTable({
14550 actions,
14551 data,
14552 fields,
14553 getItemId,
14554 isLoading = false,
14555 onChangeView,
14556 onChangeSelection,
14557 selection,
14558 setOpenedFilter,
14559 view,
14560 className,
14561 empty
14562 }) {
14563 const headerMenuRefs = (0, import_element46.useRef)(/* @__PURE__ */ new Map());
14564 const headerMenuToFocusRef = (0, import_element46.useRef)(void 0);
14565 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element46.useState)();
14566 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14567 (0, import_element46.useEffect)(() => {
14568 if (headerMenuToFocusRef.current) {
14569 headerMenuToFocusRef.current.focus();
14570 headerMenuToFocusRef.current = void 0;
14571 }
14572 });
14573 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14574 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14575 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14576 const tableNoticeId = (0, import_element46.useId)();
14577 if (nextHeaderMenuToFocus) {
14578 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14579 setNextHeaderMenuToFocus(void 0);
14580 return;
14581 }
14582 const onHide = (field) => {
14583 const hidden = headerMenuRefs.current.get(field.id);
14584 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14585 setNextHeaderMenuToFocus(fallback?.node);
14586 };
14587 const hasData = !!data?.length;
14588 const titleField = fields.find((field) => field.id === view.titleField);
14589 const mediaField = fields.find((field) => field.id === view.mediaField);
14590 const descriptionField = fields.find(
14591 (field) => field.id === view.descriptionField
14592 );
14593 const { showTitle = true, showMedia = true, showDescription = true } = view;
14594 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14595 const columns = view.fields ?? [];
14596 const headerMenuRef = (column, index2) => (node) => {
14597 if (node) {
14598 headerMenuRefs.current.set(column, {
14599 node,
14600 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14601 });
14602 } else {
14603 headerMenuRefs.current.delete(column);
14604 }
14605 };
14606 return /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(import_jsx_runtime66.Fragment, { children: [
14607 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14608 "table",
14609 {
14610 className: clsx_default(
14611 "dataviews-view-table",
14612 "dataviews-view-picker-table",
14613 className,
14614 {
14615 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14616 view.layout.density
14617 )
14618 }
14619 ),
14620 "aria-busy": isLoading,
14621 "aria-describedby": tableNoticeId,
14622 role: isInfiniteScroll ? "feed" : "listbox",
14623 children: [
14624 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14625 "tr",
14626 {
14627 className: "dataviews-view-table__row",
14628 role: "presentation",
14629 children: [
14630 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14631 BulkSelectionCheckbox,
14632 {
14633 selection,
14634 onChangeSelection,
14635 data,
14636 actions,
14637 getItemId,
14638 disableSelectAll: isInfiniteScroll
14639 }
14640 ) }),
14641 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14642 column_header_menu_default,
14643 {
14644 ref: headerMenuRef(
14645 titleField.id,
14646 0
14647 ),
14648 fieldId: titleField.id,
14649 view,
14650 fields,
14651 onChangeView,
14652 onHide,
14653 setOpenedFilter,
14654 canMove: false
14655 }
14656 ) }),
14657 columns.map((column, index2) => {
14658 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14659 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14660 "th",
14661 {
14662 style: {
14663 width,
14664 maxWidth,
14665 minWidth,
14666 textAlign: align
14667 },
14668 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14669 scope: "col",
14670 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14671 column_header_menu_default,
14672 {
14673 ref: headerMenuRef(column, index2),
14674 fieldId: column,
14675 view,
14676 fields,
14677 onChangeView,
14678 onHide,
14679 setOpenedFilter,
14680 canMove: view.layout?.enableMoving ?? true
14681 }
14682 )
14683 },
14684 column
14685 );
14686 })
14687 ]
14688 }
14689 ) }),
14690 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14691 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14692 import_components15.Composite,
14693 {
14694 virtualFocus: true,
14695 orientation: "vertical",
14696 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "group" }),
14697 children: [
14698 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14699 "tr",
14700 {
14701 className: "dataviews-view-table__group-header-row",
14702 role: "presentation",
14703 children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14704 "td",
14705 {
14706 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14707 className: "dataviews-view-table__group-header-cell",
14708 role: "presentation",
14709 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
14710 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14711 (0, import_i18n19.__)("%1$s: %2$s"),
14712 groupField.label,
14713 groupName
14714 )
14715 }
14716 )
14717 }
14718 ),
14719 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14720 TableRow2,
14721 {
14722 item,
14723 fields,
14724 id: getItemId(item) || index2.toString(),
14725 view,
14726 titleField,
14727 mediaField,
14728 descriptionField,
14729 selection,
14730 getItemId,
14731 onChangeSelection,
14732 multiselect: isMultiselect
14733 },
14734 getItemId(item)
14735 ))
14736 ]
14737 },
14738 `group-${groupName}`
14739 )
14740 ) : /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14741 import_components15.Composite,
14742 {
14743 render: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("tbody", { role: "presentation" }),
14744 virtualFocus: true,
14745 orientation: "vertical",
14746 children: hasData && data.map((item, index2) => {
14747 const itemId = getItemId(item);
14748 const posinset = item.position;
14749 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
14750 TableRow2,
14751 {
14752 item,
14753 fields,
14754 id: itemId || index2.toString(),
14755 view,
14756 titleField,
14757 mediaField,
14758 descriptionField,
14759 selection,
14760 getItemId,
14761 onChangeSelection,
14762 multiselect: isMultiselect,
14763 posinset
14764 },
14765 itemId
14766 );
14767 })
14768 }
14769 )
14770 ]
14771 }
14772 ),
14773 /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)(
14774 "div",
14775 {
14776 className: clsx_default({
14777 "dataviews-loading": isLoading,
14778 "dataviews-no-results": !hasData && !isLoading
14779 }),
14780 id: tableNoticeId,
14781 children: [
14782 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) }) : empty),
14783 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_components15.Spinner, {}) })
14784 ]
14785 }
14786 )
14787 ] });
14788 }
14789 var picker_table_default = ViewPickerTable;
14790
14791 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14792 var import_components16 = __toESM(require_components(), 1);
14793 var import_element47 = __toESM(require_element(), 1);
14794 var import_compose7 = __toESM(require_compose(), 1);
14795 var import_i18n20 = __toESM(require_i18n(), 1);
14796 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
14797 function isDefined4(item) {
14798 return !!item;
14799 }
14800 function PickerActivityItem({
14801 view,
14802 multiselect,
14803 selection,
14804 onChangeSelection,
14805 getItemId,
14806 item,
14807 titleField,
14808 mediaField,
14809 descriptionField,
14810 otherFields,
14811 posinset,
14812 setsize
14813 }) {
14814 const elementRef = (0, import_element47.useRef)(null);
14815 useIntersectionObserver(elementRef, posinset);
14816 const { showTitle = true, showMedia = true, showDescription = true } = view;
14817 const id = getItemId(item);
14818 const isSelected2 = selection.includes(id);
14819 const density = view.layout?.density ?? "balanced";
14820 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14821 mediaField.render,
14822 {
14823 item,
14824 field: mediaField,
14825 config: {
14826 sizes: density === "comfortable" ? "32px" : "24px"
14827 }
14828 }
14829 ) : null;
14830 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14831 "span",
14832 {
14833 className: "dataviews-view-picker-activity__item-bullet",
14834 "aria-hidden": "true"
14835 }
14836 ) });
14837 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(titleField.render, { item, field: titleField }) : null;
14838 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14839 const verticalGap = (0, import_element47.useMemo)(() => {
14840 switch (density) {
14841 case "comfortable":
14842 return "md";
14843 default:
14844 return "sm";
14845 }
14846 }, [density]);
14847 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14848 import_components16.Composite.Item,
14849 {
14850 ref: elementRef,
14851 role: "option",
14852 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14853 "aria-posinset": posinset,
14854 "aria-setsize": setsize,
14855 "aria-selected": isSelected2,
14856 className: clsx_default(
14857 "dataviews-view-picker-activity__item",
14858 density === "compact" && "is-compact",
14859 density === "balanced" && "is-balanced",
14860 density === "comfortable" && "is-comfortable",
14861 isSelected2 && "is-selected"
14862 ),
14863 onClick: () => {
14864 if (isSelected2) {
14865 onChangeSelection(
14866 selection.filter((itemId) => id !== itemId)
14867 );
14868 } else {
14869 const newSelection = multiselect ? [...selection, id] : [id];
14870 onChangeSelection(newSelection);
14871 }
14872 },
14873 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", {}),
14874 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14875 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14876 Stack,
14877 {
14878 direction: "column",
14879 gap: "xs",
14880 align: "center",
14881 className: "dataviews-view-picker-activity__item-type",
14882 children: renderedMediaField
14883 }
14884 ),
14885 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14886 Stack,
14887 {
14888 direction: "column",
14889 gap: verticalGap,
14890 align: "flex-start",
14891 className: "dataviews-view-picker-activity__item-content",
14892 children: [
14893 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14894 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14895 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14896 "div",
14897 {
14898 className: "dataviews-view-picker-activity__item-field",
14899 children: [
14900 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14901 VisuallyHidden,
14902 {
14903 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", {}),
14904 className: "dataviews-view-picker-activity__item-field-label",
14905 children: field.label
14906 }
14907 ),
14908 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14909 field.render,
14910 {
14911 item,
14912 field
14913 }
14914 ) })
14915 ]
14916 },
14917 field.id
14918 )) })
14919 ]
14920 }
14921 )
14922 ] })
14923 }
14924 );
14925 }
14926 function PickerActivityGroup({
14927 groupName,
14928 groupField,
14929 showLabel = true,
14930 children
14931 }) {
14932 const headerId = (0, import_compose7.useInstanceId)(
14933 PickerActivityGroup,
14934 "dataviews-view-picker-activity-group__header"
14935 );
14936 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
14937 Stack,
14938 {
14939 direction: "column",
14940 role: "group",
14941 "aria-labelledby": headerId,
14942 className: "dataviews-view-picker-activity-group",
14943 children: [
14944 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14945 "h3",
14946 {
14947 className: "dataviews-view-picker-activity-group__header",
14948 id: headerId,
14949 children: showLabel ? (0, import_i18n20.sprintf)(
14950 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14951 (0, import_i18n20.__)("%1$s: %2$s"),
14952 groupField.label,
14953 groupName
14954 ) : groupName
14955 }
14956 ),
14957 children
14958 ]
14959 }
14960 );
14961 }
14962 function ViewPickerActivity({
14963 data,
14964 fields,
14965 getItemId,
14966 isLoading,
14967 onChangeSelection,
14968 selection,
14969 view,
14970 actions,
14971 className,
14972 empty
14973 }) {
14974 const { itemListLabel, paginationInfo } = (0, import_element47.useContext)(dataviews_context_default);
14975 const isMultiselect = useIsMultiselectPicker(actions);
14976 const titleField = fields.find(
14977 (field) => field.id === view?.titleField
14978 );
14979 const mediaField = fields.find(
14980 (field) => field.id === view?.mediaField
14981 );
14982 const descriptionField = fields.find(
14983 (field) => field.id === view?.descriptionField
14984 );
14985 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
14986 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14987 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14988 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14989 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14990 const hasData = !!data?.length;
14991 const isGrouped = !!(groupField && dataByGroup);
14992 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
14993 PickerActivityItem,
14994 {
14995 view,
14996 multiselect: isMultiselect,
14997 selection,
14998 onChangeSelection,
14999 getItemId,
15000 item,
15001 titleField,
15002 mediaField,
15003 descriptionField,
15004 otherFields,
15005 posinset: item.position,
15006 setsize
15007 },
15008 getItemId(item)
15009 );
15010 if (!hasData) {
15011 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15012 "div",
15013 {
15014 className: clsx_default({
15015 "dataviews-loading": isLoading,
15016 "dataviews-no-results": !isLoading
15017 }),
15018 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components16.Spinner, {}) }) : empty
15019 }
15020 );
15021 }
15022 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
15023 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15024 import_components16.Composite,
15025 {
15026 virtualFocus: true,
15027 orientation: "vertical",
15028 role: "listbox",
15029 "aria-multiselectable": isMultiselect,
15030 "aria-label": itemListLabel,
15031 "aria-busy": isLoading,
15032 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
15033 className: clsx_default(
15034 "dataviews-view-picker-activity",
15035 className
15036 ),
15037 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
15038 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
15039 PickerActivityGroup,
15040 {
15041 groupName,
15042 groupField,
15043 showLabel: view.groupBy?.showLabel !== false,
15044 children: groupItems.map(renderItem)
15045 },
15046 groupName
15047 )
15048 ) : data.map(renderItem)
15049 }
15050 ),
15051 isLoading && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components16.Spinner, {}) })
15052 ] });
15053 }
15054
15055 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
15056 var import_components17 = __toESM(require_components(), 1);
15057 var import_i18n21 = __toESM(require_i18n(), 1);
15058 var import_element48 = __toESM(require_element(), 1);
15059 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
15060 function DensityPicker() {
15061 const context = (0, import_element48.useContext)(dataviews_context_default);
15062 const view = context.view;
15063 return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
15064 import_components17.__experimentalToggleGroupControl,
15065 {
15066 size: "__unstable-large",
15067 label: (0, import_i18n21.__)("Density"),
15068 value: view.layout?.density || "balanced",
15069 onChange: (value) => {
15070 context.onChangeView({
15071 ...view,
15072 layout: {
15073 ...view.layout,
15074 density: value
15075 }
15076 });
15077 },
15078 isBlock: true,
15079 children: [
15080 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15081 import_components17.__experimentalToggleGroupControlOption,
15082 {
15083 value: "comfortable",
15084 label: (0, import_i18n21._x)(
15085 "Comfortable",
15086 "Density option for DataView layout"
15087 )
15088 },
15089 "comfortable"
15090 ),
15091 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15092 import_components17.__experimentalToggleGroupControlOption,
15093 {
15094 value: "balanced",
15095 label: (0, import_i18n21._x)("Balanced", "Density option for DataView layout")
15096 },
15097 "balanced"
15098 ),
15099 /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
15100 import_components17.__experimentalToggleGroupControlOption,
15101 {
15102 value: "compact",
15103 label: (0, import_i18n21._x)("Compact", "Density option for DataView layout")
15104 },
15105 "compact"
15106 )
15107 ]
15108 }
15109 );
15110 }
15111
15112 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
15113 var import_components18 = __toESM(require_components(), 1);
15114 var import_i18n22 = __toESM(require_i18n(), 1);
15115 var import_element49 = __toESM(require_element(), 1);
15116 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
15117 var imageSizes2 = [
15118 {
15119 value: 120,
15120 breakpoint: 1
15121 },
15122 {
15123 value: 170,
15124 breakpoint: 1
15125 },
15126 {
15127 value: 230,
15128 breakpoint: 1
15129 },
15130 {
15131 value: 290,
15132 breakpoint: 1112
15133 // at minimum image width, 4 images display at this container size
15134 },
15135 {
15136 value: 350,
15137 breakpoint: 1636
15138 // at minimum image width, 6 images display at this container size
15139 },
15140 {
15141 value: 430,
15142 breakpoint: 588
15143 // at minimum image width, 2 images display at this container size
15144 }
15145 ];
15146 function PreviewSizePicker() {
15147 const context = (0, import_element49.useContext)(dataviews_context_default);
15148 const view = context.view;
15149 const breakValues = imageSizes2.filter((size4) => {
15150 return context.containerWidth >= size4.breakpoint;
15151 });
15152 const layoutPreviewSize = view.layout?.previewSize ?? 230;
15153 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
15154 const marks = breakValues.map((size4, index2) => {
15155 return {
15156 value: index2
15157 };
15158 });
15159 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
15160 import_components18.RangeControl,
15161 {
15162 __next40pxDefaultSize: true,
15163 showTooltip: false,
15164 label: (0, import_i18n22.__)("Preview size"),
15165 value: previewSizeToUse,
15166 min: 0,
15167 max: breakValues.length - 1,
15168 withInputField: false,
15169 onChange: (value = 0) => {
15170 context.onChangeView({
15171 ...view,
15172 layout: {
15173 ...view.layout,
15174 previewSize: breakValues[value].value
15175 }
15176 });
15177 },
15178 step: 1,
15179 marks
15180 }
15181 );
15182 }
15183
15184 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
15185 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
15186 function GridConfigOptions() {
15187 return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
15188 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(DensityPicker, {}),
15189 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(PreviewSizePicker, {})
15190 ] });
15191 }
15192
15193 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
15194 var VIEW_LAYOUTS = [
15195 {
15196 type: LAYOUT_TABLE,
15197 label: (0, import_i18n23.__)("Table"),
15198 component: table_default,
15199 icon: block_table_default,
15200 viewConfigOptions: DensityPicker
15201 },
15202 {
15203 type: LAYOUT_GRID,
15204 label: (0, import_i18n23.__)("Grid"),
15205 component: grid_default,
15206 icon: category_default,
15207 viewConfigOptions: GridConfigOptions
15208 },
15209 {
15210 type: LAYOUT_LIST,
15211 label: (0, import_i18n23.__)("List"),
15212 component: ViewList,
15213 icon: (0, import_i18n23.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
15214 viewConfigOptions: DensityPicker
15215 },
15216 {
15217 type: LAYOUT_ACTIVITY,
15218 label: (0, import_i18n23.__)("Activity"),
15219 component: ViewActivity,
15220 icon: scheduled_default,
15221 viewConfigOptions: DensityPicker
15222 },
15223 {
15224 type: LAYOUT_PICKER_GRID,
15225 label: (0, import_i18n23.__)("Grid"),
15226 component: picker_grid_default,
15227 icon: category_default,
15228 viewConfigOptions: GridConfigOptions,
15229 isPicker: true
15230 },
15231 {
15232 type: LAYOUT_PICKER_TABLE,
15233 label: (0, import_i18n23.__)("Table"),
15234 component: picker_table_default,
15235 icon: block_table_default,
15236 viewConfigOptions: DensityPicker,
15237 isPicker: true
15238 },
15239 {
15240 type: LAYOUT_PICKER_ACTIVITY,
15241 label: (0, import_i18n23.__)("Activity"),
15242 component: ViewPickerActivity,
15243 icon: scheduled_default,
15244 viewConfigOptions: DensityPicker,
15245 isPicker: true
15246 }
15247 ];
15248
15249 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15250 var import_element57 = __toESM(require_element(), 1);
15251
15252 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15253 var import_components21 = __toESM(require_components(), 1);
15254 var import_i18n26 = __toESM(require_i18n(), 1);
15255 var import_element54 = __toESM(require_element(), 1);
15256
15257 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
15258 function noop4(..._) {
15259 }
15260 function applyState(argument, currentValue) {
15261 if (isUpdater(argument)) {
15262 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
15263 return argument(value);
15264 }
15265 return argument;
15266 }
15267 function isUpdater(argument) {
15268 return typeof argument === "function";
15269 }
15270 function isLazyValue(value) {
15271 return typeof value === "function";
15272 }
15273 function hasOwnProperty(object, prop) {
15274 if (typeof Object.hasOwn === "function") {
15275 return Object.hasOwn(object, prop);
15276 }
15277 return Object.prototype.hasOwnProperty.call(object, prop);
15278 }
15279 function chain(...fns) {
15280 return (...args) => {
15281 for (const fn of fns) {
15282 if (typeof fn === "function") {
15283 fn(...args);
15284 }
15285 }
15286 };
15287 }
15288 function normalizeString(str) {
15289 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
15290 }
15291 function omit(object, keys) {
15292 const result = { ...object };
15293 for (const key of keys) {
15294 if (hasOwnProperty(result, key)) {
15295 delete result[key];
15296 }
15297 }
15298 return result;
15299 }
15300 function pick(object, paths) {
15301 const result = {};
15302 for (const key of paths) {
15303 if (hasOwnProperty(object, key)) {
15304 result[key] = object[key];
15305 }
15306 }
15307 return result;
15308 }
15309 function identity(value) {
15310 return value;
15311 }
15312 function invariant(condition, message2) {
15313 if (condition) return;
15314 if (typeof message2 !== "string") throw new Error("Invariant failed");
15315 throw new Error(message2);
15316 }
15317 function getKeys(obj) {
15318 return Object.keys(obj);
15319 }
15320 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
15321 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
15322 if (result == null) return false;
15323 return !result;
15324 }
15325 function disabledFromProps(props) {
15326 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
15327 }
15328 function removeUndefinedValues(obj) {
15329 const result = {};
15330 for (const key in obj) {
15331 if (obj[key] !== void 0) {
15332 result[key] = obj[key];
15333 }
15334 }
15335 return result;
15336 }
15337 function defaultValue(...values) {
15338 for (const value of values) {
15339 if (value !== void 0) return value;
15340 }
15341 return void 0;
15342 }
15343
15344 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
15345 var import_react11 = __toESM(require_react(), 1);
15346 function setRef(ref, value) {
15347 if (typeof ref === "function") {
15348 ref(value);
15349 } else if (ref) {
15350 ref.current = value;
15351 }
15352 }
15353 function isValidElementWithRef(element) {
15354 if (!element) return false;
15355 if (!(0, import_react11.isValidElement)(element)) return false;
15356 if ("ref" in element.props) return true;
15357 if ("ref" in element) return true;
15358 return false;
15359 }
15360 function getRefProperty(element) {
15361 if (!isValidElementWithRef(element)) return null;
15362 const props = { ...element.props };
15363 return props.ref || element.ref;
15364 }
15365 function mergeProps2(base, overrides) {
15366 const props = { ...base };
15367 for (const key in overrides) {
15368 if (!hasOwnProperty(overrides, key)) continue;
15369 if (key === "className") {
15370 const prop = "className";
15371 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
15372 continue;
15373 }
15374 if (key === "style") {
15375 const prop = "style";
15376 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
15377 continue;
15378 }
15379 const overrideValue = overrides[key];
15380 if (typeof overrideValue === "function" && key.startsWith("on")) {
15381 const baseValue = base[key];
15382 if (typeof baseValue === "function") {
15383 props[key] = (...args) => {
15384 overrideValue(...args);
15385 baseValue(...args);
15386 };
15387 continue;
15388 }
15389 }
15390 props[key] = overrideValue;
15391 }
15392 return props;
15393 }
15394
15395 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
15396 var canUseDOM = checkIsBrowser();
15397 function checkIsBrowser() {
15398 var _a;
15399 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
15400 }
15401 function getDocument(node) {
15402 if (!node) return document;
15403 if ("self" in node) return node.document;
15404 return node.ownerDocument || document;
15405 }
15406 function getActiveElement(node, activeDescendant = false) {
15407 var _a;
15408 const { activeElement: activeElement2 } = getDocument(node);
15409 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
15410 return null;
15411 }
15412 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
15413 return getActiveElement(
15414 activeElement2.contentDocument.body,
15415 activeDescendant
15416 );
15417 }
15418 if (activeDescendant) {
15419 const id = activeElement2.getAttribute("aria-activedescendant");
15420 if (id) {
15421 const element = getDocument(activeElement2).getElementById(id);
15422 if (element) {
15423 return element;
15424 }
15425 }
15426 }
15427 return activeElement2;
15428 }
15429 function contains2(parent, child) {
15430 return parent === child || parent.contains(child);
15431 }
15432 function isFrame(element) {
15433 return element.tagName === "IFRAME";
15434 }
15435 function isButton(element) {
15436 const tagName = element.tagName.toLowerCase();
15437 if (tagName === "button") return true;
15438 if (tagName === "input" && element.type) {
15439 return buttonInputTypes.indexOf(element.type) !== -1;
15440 }
15441 return false;
15442 }
15443 var buttonInputTypes = [
15444 "button",
15445 "color",
15446 "file",
15447 "image",
15448 "reset",
15449 "submit"
15450 ];
15451 function isVisible(element) {
15452 if (typeof element.checkVisibility === "function") {
15453 return element.checkVisibility();
15454 }
15455 const htmlElement = element;
15456 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
15457 }
15458 function isTextField(element) {
15459 try {
15460 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
15461 const isTextArea = element.tagName === "TEXTAREA";
15462 return isTextInput || isTextArea || false;
15463 } catch (_error) {
15464 return false;
15465 }
15466 }
15467 function isTextbox(element) {
15468 return element.isContentEditable || isTextField(element);
15469 }
15470 function getTextboxValue(element) {
15471 if (isTextField(element)) {
15472 return element.value;
15473 }
15474 if (element.isContentEditable) {
15475 const range = getDocument(element).createRange();
15476 range.selectNodeContents(element);
15477 return range.toString();
15478 }
15479 return "";
15480 }
15481 function getTextboxSelection(element) {
15482 let start = 0;
15483 let end = 0;
15484 if (isTextField(element)) {
15485 start = element.selectionStart || 0;
15486 end = element.selectionEnd || 0;
15487 } else if (element.isContentEditable) {
15488 const selection = getDocument(element).getSelection();
15489 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15490 const range = selection.getRangeAt(0);
15491 const nextRange = range.cloneRange();
15492 nextRange.selectNodeContents(element);
15493 nextRange.setEnd(range.startContainer, range.startOffset);
15494 start = nextRange.toString().length;
15495 nextRange.setEnd(range.endContainer, range.endOffset);
15496 end = nextRange.toString().length;
15497 }
15498 }
15499 return { start, end };
15500 }
15501 function getPopupRole(element, fallback) {
15502 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
15503 const role = element == null ? void 0 : element.getAttribute("role");
15504 if (role && allowedPopupRoles.indexOf(role) !== -1) {
15505 return role;
15506 }
15507 return fallback;
15508 }
15509 function getScrollingElement(element) {
15510 if (!element) return null;
15511 const isScrollableOverflow = (overflow) => {
15512 if (overflow === "auto") return true;
15513 if (overflow === "scroll") return true;
15514 return false;
15515 };
15516 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15517 const { overflowY } = getComputedStyle(element);
15518 if (isScrollableOverflow(overflowY)) return element;
15519 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15520 const { overflowX } = getComputedStyle(element);
15521 if (isScrollableOverflow(overflowX)) return element;
15522 }
15523 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15524 }
15525 function setSelectionRange(element, ...args) {
15526 if (/text|search|password|tel|url/i.test(element.type)) {
15527 element.setSelectionRange(...args);
15528 }
15529 }
15530 function sortBasedOnDOMPosition(items, getElement) {
15531 const pairs = items.map((item, index2) => [index2, item]);
15532 let isOrderDifferent = false;
15533 pairs.sort(([indexA, a2], [indexB, b2]) => {
15534 const elementA = getElement(a2);
15535 const elementB = getElement(b2);
15536 if (elementA === elementB) return 0;
15537 if (!elementA || !elementB) return 0;
15538 if (isElementPreceding(elementA, elementB)) {
15539 if (indexA > indexB) {
15540 isOrderDifferent = true;
15541 }
15542 return -1;
15543 }
15544 if (indexA < indexB) {
15545 isOrderDifferent = true;
15546 }
15547 return 1;
15548 });
15549 if (isOrderDifferent) {
15550 return pairs.map(([_, item]) => item);
15551 }
15552 return items;
15553 }
15554 function isElementPreceding(a2, b2) {
15555 return Boolean(
15556 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
15557 );
15558 }
15559
15560 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
15561 function isTouchDevice() {
15562 return canUseDOM && !!navigator.maxTouchPoints;
15563 }
15564 function isApple() {
15565 if (!canUseDOM) return false;
15566 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15567 }
15568 function isSafari2() {
15569 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15570 }
15571 function isFirefox2() {
15572 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15573 }
15574
15575 // node_modules/@ariakit/core/esm/utils/events.js
15576 function isPortalEvent(event) {
15577 return Boolean(
15578 event.currentTarget && !contains2(event.currentTarget, event.target)
15579 );
15580 }
15581 function isSelfTarget(event) {
15582 return event.target === event.currentTarget;
15583 }
15584 function isOpeningInNewTab(event) {
15585 const element = event.currentTarget;
15586 if (!element) return false;
15587 const isAppleDevice = isApple();
15588 if (isAppleDevice && !event.metaKey) return false;
15589 if (!isAppleDevice && !event.ctrlKey) return false;
15590 const tagName = element.tagName.toLowerCase();
15591 if (tagName === "a") return true;
15592 if (tagName === "button" && element.type === "submit") return true;
15593 if (tagName === "input" && element.type === "submit") return true;
15594 return false;
15595 }
15596 function isDownloading(event) {
15597 const element = event.currentTarget;
15598 if (!element) return false;
15599 const tagName = element.tagName.toLowerCase();
15600 if (!event.altKey) return false;
15601 if (tagName === "a") return true;
15602 if (tagName === "button" && element.type === "submit") return true;
15603 if (tagName === "input" && element.type === "submit") return true;
15604 return false;
15605 }
15606 function fireBlurEvent(element, eventInit) {
15607 const event = new FocusEvent("blur", eventInit);
15608 const defaultAllowed = element.dispatchEvent(event);
15609 const bubbleInit = { ...eventInit, bubbles: true };
15610 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15611 return defaultAllowed;
15612 }
15613 function fireKeyboardEvent(element, type, eventInit) {
15614 const event = new KeyboardEvent(type, eventInit);
15615 return element.dispatchEvent(event);
15616 }
15617 function fireClickEvent(element, eventInit) {
15618 const event = new MouseEvent("click", eventInit);
15619 return element.dispatchEvent(event);
15620 }
15621 function isFocusEventOutside(event, container) {
15622 const containerElement = container || event.currentTarget;
15623 const relatedTarget = event.relatedTarget;
15624 return !relatedTarget || !contains2(containerElement, relatedTarget);
15625 }
15626 function queueBeforeEvent(element, type, callback, timeout) {
15627 const createTimer = (callback2) => {
15628 if (timeout) {
15629 const timerId2 = setTimeout(callback2, timeout);
15630 return () => clearTimeout(timerId2);
15631 }
15632 const timerId = requestAnimationFrame(callback2);
15633 return () => cancelAnimationFrame(timerId);
15634 };
15635 const cancelTimer = createTimer(() => {
15636 element.removeEventListener(type, callSync, true);
15637 callback();
15638 });
15639 const callSync = () => {
15640 cancelTimer();
15641 callback();
15642 };
15643 element.addEventListener(type, callSync, { once: true, capture: true });
15644 return cancelTimer;
15645 }
15646 function addGlobalEventListener(type, listener, options, scope = window) {
15647 const children = [];
15648 try {
15649 scope.document.addEventListener(type, listener, options);
15650 for (const frame of Array.from(scope.frames)) {
15651 children.push(addGlobalEventListener(type, listener, options, frame));
15652 }
15653 } catch (e2) {
15654 }
15655 const removeEventListener = () => {
15656 try {
15657 scope.document.removeEventListener(type, listener, options);
15658 } catch (e2) {
15659 }
15660 for (const remove of children) {
15661 remove();
15662 }
15663 };
15664 return removeEventListener;
15665 }
15666
15667 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15668 var React47 = __toESM(require_react(), 1);
15669 var import_react12 = __toESM(require_react(), 1);
15670 var _React = { ...React47 };
15671 var useReactId = _React.useId;
15672 var useReactDeferredValue = _React.useDeferredValue;
15673 var useReactInsertionEffect = _React.useInsertionEffect;
15674 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
15675 function useInitialValue(value) {
15676 const [initialValue] = (0, import_react12.useState)(value);
15677 return initialValue;
15678 }
15679 function useLiveRef(value) {
15680 const ref = (0, import_react12.useRef)(value);
15681 useSafeLayoutEffect(() => {
15682 ref.current = value;
15683 });
15684 return ref;
15685 }
15686 function useEvent(callback) {
15687 const ref = (0, import_react12.useRef)(() => {
15688 throw new Error("Cannot call an event handler while rendering.");
15689 });
15690 if (useReactInsertionEffect) {
15691 useReactInsertionEffect(() => {
15692 ref.current = callback;
15693 });
15694 } else {
15695 ref.current = callback;
15696 }
15697 return (0, import_react12.useCallback)((...args) => {
15698 var _a;
15699 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15700 }, []);
15701 }
15702 function useTransactionState(callback) {
15703 const [state, setState] = (0, import_react12.useState)(null);
15704 useSafeLayoutEffect(() => {
15705 if (state == null) return;
15706 if (!callback) return;
15707 let prevState = null;
15708 callback((prev) => {
15709 prevState = prev;
15710 return state;
15711 });
15712 return () => {
15713 callback(prevState);
15714 };
15715 }, [state, callback]);
15716 return [state, setState];
15717 }
15718 function useMergeRefs(...refs) {
15719 return (0, import_react12.useMemo)(() => {
15720 if (!refs.some(Boolean)) return;
15721 return (value) => {
15722 for (const ref of refs) {
15723 setRef(ref, value);
15724 }
15725 };
15726 }, refs);
15727 }
15728 function useId4(defaultId) {
15729 if (useReactId) {
15730 const reactId = useReactId();
15731 if (defaultId) return defaultId;
15732 return reactId;
15733 }
15734 const [id, setId] = (0, import_react12.useState)(defaultId);
15735 useSafeLayoutEffect(() => {
15736 if (defaultId || id) return;
15737 const random = Math.random().toString(36).slice(2, 8);
15738 setId(`id-${random}`);
15739 }, [defaultId, id]);
15740 return defaultId || id;
15741 }
15742 function useTagName(refOrElement, type) {
15743 const stringOrUndefined = (type2) => {
15744 if (typeof type2 !== "string") return;
15745 return type2;
15746 };
15747 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
15748 useSafeLayoutEffect(() => {
15749 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15750 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15751 }, [refOrElement, type]);
15752 return tagName;
15753 }
15754 function useAttribute(refOrElement, attributeName, defaultValue2) {
15755 const initialValue = useInitialValue(defaultValue2);
15756 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
15757 (0, import_react12.useEffect)(() => {
15758 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15759 if (!element) return;
15760 const callback = () => {
15761 const value = element.getAttribute(attributeName);
15762 setAttribute(value == null ? initialValue : value);
15763 };
15764 const observer = new MutationObserver(callback);
15765 observer.observe(element, { attributeFilter: [attributeName] });
15766 callback();
15767 return () => observer.disconnect();
15768 }, [refOrElement, attributeName, initialValue]);
15769 return attribute;
15770 }
15771 function useUpdateEffect(effect, deps) {
15772 const mounted = (0, import_react12.useRef)(false);
15773 (0, import_react12.useEffect)(() => {
15774 if (mounted.current) {
15775 return effect();
15776 }
15777 mounted.current = true;
15778 }, deps);
15779 (0, import_react12.useEffect)(
15780 () => () => {
15781 mounted.current = false;
15782 },
15783 []
15784 );
15785 }
15786 function useUpdateLayoutEffect(effect, deps) {
15787 const mounted = (0, import_react12.useRef)(false);
15788 useSafeLayoutEffect(() => {
15789 if (mounted.current) {
15790 return effect();
15791 }
15792 mounted.current = true;
15793 }, deps);
15794 useSafeLayoutEffect(
15795 () => () => {
15796 mounted.current = false;
15797 },
15798 []
15799 );
15800 }
15801 function useForceUpdate() {
15802 return (0, import_react12.useReducer)(() => [], []);
15803 }
15804 function useBooleanEvent(booleanOrCallback) {
15805 return useEvent(
15806 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15807 );
15808 }
15809 function useWrapElement(props, callback, deps = []) {
15810 const wrapElement = (0, import_react12.useCallback)(
15811 (element) => {
15812 if (props.wrapElement) {
15813 element = props.wrapElement(element);
15814 }
15815 return callback(element);
15816 },
15817 [...deps, props.wrapElement]
15818 );
15819 return { ...props, wrapElement };
15820 }
15821 function useMetadataProps(props, key, value) {
15822 const parent = props.onLoadedMetadataCapture;
15823 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
15824 return Object.assign(() => {
15825 }, { ...parent, [key]: value });
15826 }, [parent, key, value]);
15827 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15828 }
15829 var hasInstalledGlobalEventListeners = false;
15830 function useIsMouseMoving() {
15831 (0, import_react12.useEffect)(() => {
15832 if (hasInstalledGlobalEventListeners) return;
15833 addGlobalEventListener("mousemove", setMouseMoving, true);
15834 addGlobalEventListener("mousedown", resetMouseMoving, true);
15835 addGlobalEventListener("mouseup", resetMouseMoving, true);
15836 addGlobalEventListener("keydown", resetMouseMoving, true);
15837 addGlobalEventListener("scroll", resetMouseMoving, true);
15838 hasInstalledGlobalEventListeners = true;
15839 }, []);
15840 const isMouseMoving = useEvent(() => mouseMoving);
15841 return isMouseMoving;
15842 }
15843 var mouseMoving = false;
15844 var previousScreenX = 0;
15845 var previousScreenY = 0;
15846 function hasMouseMovement(event) {
15847 const movementX = event.movementX || event.screenX - previousScreenX;
15848 const movementY = event.movementY || event.screenY - previousScreenY;
15849 previousScreenX = event.screenX;
15850 previousScreenY = event.screenY;
15851 return movementX || movementY || false;
15852 }
15853 function setMouseMoving(event) {
15854 if (!hasMouseMovement(event)) return;
15855 mouseMoving = true;
15856 }
15857 function resetMouseMoving() {
15858 mouseMoving = false;
15859 }
15860
15861 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15862 var React48 = __toESM(require_react(), 1);
15863 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
15864 function forwardRef210(render4) {
15865 const Role = React48.forwardRef(
15866 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15867 (props, ref) => render4({ ...props, ref })
15868 );
15869 Role.displayName = render4.displayName || render4.name;
15870 return Role;
15871 }
15872 function memo22(Component, propsAreEqual) {
15873 return React48.memo(Component, propsAreEqual);
15874 }
15875 function createElement3(Type, props) {
15876 const { wrapElement, render: render4, ...rest } = props;
15877 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15878 let element;
15879 if (React48.isValidElement(render4)) {
15880 const renderProps = {
15881 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15882 ...render4.props,
15883 ref: mergedRef
15884 };
15885 element = React48.cloneElement(render4, mergeProps2(rest, renderProps));
15886 } else if (render4) {
15887 element = render4(rest);
15888 } else {
15889 element = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Type, { ...rest });
15890 }
15891 if (wrapElement) {
15892 return wrapElement(element);
15893 }
15894 return element;
15895 }
15896 function createHook(useProps) {
15897 const useRole = (props = {}) => {
15898 return useProps(props);
15899 };
15900 useRole.displayName = useProps.name;
15901 return useRole;
15902 }
15903 function createStoreContext(providers = [], scopedProviders = []) {
15904 const context = React48.createContext(void 0);
15905 const scopedContext = React48.createContext(void 0);
15906 const useContext210 = () => React48.useContext(context);
15907 const useScopedContext = (onlyScoped = false) => {
15908 const scoped = React48.useContext(scopedContext);
15909 const store = useContext210();
15910 if (onlyScoped) return scoped;
15911 return scoped || store;
15912 };
15913 const useProviderContext = () => {
15914 const scoped = React48.useContext(scopedContext);
15915 const store = useContext210();
15916 if (scoped && scoped === store) return;
15917 return store;
15918 };
15919 const ContextProvider = (props) => {
15920 return providers.reduceRight(
15921 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }),
15922 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(context.Provider, { ...props })
15923 );
15924 };
15925 const ScopedContextProvider = (props) => {
15926 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15927 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Provider2, { ...props, children }),
15928 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(scopedContext.Provider, { ...props })
15929 ) });
15930 };
15931 return {
15932 context,
15933 scopedContext,
15934 useContext: useContext210,
15935 useScopedContext,
15936 useProviderContext,
15937 ContextProvider,
15938 ScopedContextProvider
15939 };
15940 }
15941
15942 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15943 var ctx = createStoreContext();
15944 var useCollectionContext = ctx.useContext;
15945 var useCollectionScopedContext = ctx.useScopedContext;
15946 var useCollectionProviderContext = ctx.useProviderContext;
15947 var CollectionContextProvider = ctx.ContextProvider;
15948 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15949
15950 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15951 var import_react13 = __toESM(require_react(), 1);
15952 var ctx2 = createStoreContext(
15953 [CollectionContextProvider],
15954 [CollectionScopedContextProvider]
15955 );
15956 var useCompositeContext = ctx2.useContext;
15957 var useCompositeScopedContext = ctx2.useScopedContext;
15958 var useCompositeProviderContext = ctx2.useProviderContext;
15959 var CompositeContextProvider = ctx2.ContextProvider;
15960 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15961 var CompositeItemContext = (0, import_react13.createContext)(
15962 void 0
15963 );
15964 var CompositeRowContext = (0, import_react13.createContext)(
15965 void 0
15966 );
15967
15968 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15969 function findFirstEnabledItem(items, excludeId) {
15970 return items.find((item) => {
15971 if (excludeId) {
15972 return !item.disabled && item.id !== excludeId;
15973 }
15974 return !item.disabled;
15975 });
15976 }
15977 function getEnabledItem(store, id) {
15978 if (!id) return null;
15979 return store.item(id) || null;
15980 }
15981 function groupItemsByRows(items) {
15982 const rows = [];
15983 for (const item of items) {
15984 const row = rows.find((currentRow) => {
15985 var _a;
15986 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15987 });
15988 if (row) {
15989 row.push(item);
15990 } else {
15991 rows.push([item]);
15992 }
15993 }
15994 return rows;
15995 }
15996 function selectTextField(element, collapseToEnd = false) {
15997 if (isTextField(element)) {
15998 element.setSelectionRange(
15999 collapseToEnd ? element.value.length : 0,
16000 element.value.length
16001 );
16002 } else if (element.isContentEditable) {
16003 const selection = getDocument(element).getSelection();
16004 selection == null ? void 0 : selection.selectAllChildren(element);
16005 if (collapseToEnd) {
16006 selection == null ? void 0 : selection.collapseToEnd();
16007 }
16008 }
16009 }
16010 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
16011 function focusSilently(element) {
16012 element[FOCUS_SILENTLY] = true;
16013 element.focus({ preventScroll: true });
16014 }
16015 function silentlyFocused(element) {
16016 const isSilentlyFocused = element[FOCUS_SILENTLY];
16017 delete element[FOCUS_SILENTLY];
16018 return isSilentlyFocused;
16019 }
16020 function isItem(store, element, exclude) {
16021 if (!element) return false;
16022 if (element === exclude) return false;
16023 const item = store.item(element.id);
16024 if (!item) return false;
16025 if (exclude && item.element === exclude) return false;
16026 return true;
16027 }
16028
16029 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
16030 var import_react14 = __toESM(require_react(), 1);
16031 var TagName = "div";
16032 var useCollectionItem = createHook(
16033 function useCollectionItem2({
16034 store,
16035 shouldRegisterItem = true,
16036 getItem = identity,
16037 // @ts-expect-error This prop may come from a collection renderer.
16038 element,
16039 ...props
16040 }) {
16041 const context = useCollectionContext();
16042 store = store || context;
16043 const id = useId4(props.id);
16044 const ref = (0, import_react14.useRef)(element);
16045 (0, import_react14.useEffect)(() => {
16046 const element2 = ref.current;
16047 if (!id) return;
16048 if (!element2) return;
16049 if (!shouldRegisterItem) return;
16050 const item = getItem({ id, element: element2 });
16051 return store == null ? void 0 : store.renderItem(item);
16052 }, [id, shouldRegisterItem, getItem, store]);
16053 props = {
16054 ...props,
16055 ref: useMergeRefs(ref, props.ref)
16056 };
16057 return removeUndefinedValues(props);
16058 }
16059 );
16060 var CollectionItem = forwardRef210(function CollectionItem2(props) {
16061 const htmlProps = useCollectionItem(props);
16062 return createElement3(TagName, htmlProps);
16063 });
16064
16065 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
16066 var import_react15 = __toESM(require_react(), 1);
16067 var FocusableContext = (0, import_react15.createContext)(true);
16068
16069 // node_modules/@ariakit/core/esm/utils/focus.js
16070 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'])";
16071 function isFocusable(element) {
16072 if (!element.matches(selector)) return false;
16073 if (!isVisible(element)) return false;
16074 if (element.closest("[inert]")) return false;
16075 return true;
16076 }
16077 function getClosestFocusable(element) {
16078 while (element && !isFocusable(element)) {
16079 element = element.closest(selector);
16080 }
16081 return element || null;
16082 }
16083 function hasFocus(element) {
16084 const activeElement2 = getActiveElement(element);
16085 if (!activeElement2) return false;
16086 if (activeElement2 === element) return true;
16087 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
16088 if (!activeDescendant) return false;
16089 return activeDescendant === element.id;
16090 }
16091 function hasFocusWithin(element) {
16092 const activeElement2 = getActiveElement(element);
16093 if (!activeElement2) return false;
16094 if (contains2(element, activeElement2)) return true;
16095 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
16096 if (!activeDescendant) return false;
16097 if (!("id" in element)) return false;
16098 if (activeDescendant === element.id) return true;
16099 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
16100 }
16101 function focusIfNeeded(element) {
16102 if (!hasFocusWithin(element) && isFocusable(element)) {
16103 element.focus();
16104 }
16105 }
16106 function focusIntoView(element, options) {
16107 if (!("scrollIntoView" in element)) {
16108 element.focus();
16109 } else {
16110 element.focus({ preventScroll: true });
16111 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
16112 }
16113 }
16114
16115 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
16116 var import_react16 = __toESM(require_react(), 1);
16117 var TagName2 = "div";
16118 var isSafariBrowser = isSafari2();
16119 var alwaysFocusVisibleInputTypes = [
16120 "text",
16121 "search",
16122 "url",
16123 "tel",
16124 "email",
16125 "password",
16126 "number",
16127 "date",
16128 "month",
16129 "week",
16130 "time",
16131 "datetime",
16132 "datetime-local"
16133 ];
16134 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
16135 function markSafariFocusAncestor(element, value) {
16136 if (!element) return;
16137 element[safariFocusAncestorSymbol] = value;
16138 }
16139 function isAlwaysFocusVisible(element) {
16140 const { tagName, readOnly, type } = element;
16141 if (tagName === "TEXTAREA" && !readOnly) return true;
16142 if (tagName === "SELECT" && !readOnly) return true;
16143 if (tagName === "INPUT" && !readOnly) {
16144 return alwaysFocusVisibleInputTypes.includes(type);
16145 }
16146 if (element.isContentEditable) return true;
16147 const role = element.getAttribute("role");
16148 if (role === "combobox" && element.dataset.name) {
16149 return true;
16150 }
16151 return false;
16152 }
16153 function getLabels(element) {
16154 if ("labels" in element) {
16155 return element.labels;
16156 }
16157 return null;
16158 }
16159 function isNativeCheckboxOrRadio(element) {
16160 const tagName = element.tagName.toLowerCase();
16161 if (tagName === "input" && element.type) {
16162 return element.type === "radio" || element.type === "checkbox";
16163 }
16164 return false;
16165 }
16166 function isNativeTabbable(tagName) {
16167 if (!tagName) return true;
16168 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
16169 }
16170 function supportsDisabledAttribute(tagName) {
16171 if (!tagName) return true;
16172 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
16173 }
16174 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
16175 if (!focusable2) {
16176 return tabIndexProp;
16177 }
16178 if (trulyDisabled) {
16179 if (nativeTabbable && !supportsDisabled) {
16180 return -1;
16181 }
16182 return;
16183 }
16184 if (nativeTabbable) {
16185 return tabIndexProp;
16186 }
16187 return tabIndexProp || 0;
16188 }
16189 function useDisableEvent(onEvent, disabled2) {
16190 return useEvent((event) => {
16191 onEvent == null ? void 0 : onEvent(event);
16192 if (event.defaultPrevented) return;
16193 if (disabled2) {
16194 event.stopPropagation();
16195 event.preventDefault();
16196 }
16197 });
16198 }
16199 var hasInstalledGlobalEventListeners2 = false;
16200 var isKeyboardModality = true;
16201 function onGlobalMouseDown(event) {
16202 const target = event.target;
16203 if (target && "hasAttribute" in target) {
16204 if (!target.hasAttribute("data-focus-visible")) {
16205 isKeyboardModality = false;
16206 }
16207 }
16208 }
16209 function onGlobalKeyDown(event) {
16210 if (event.metaKey) return;
16211 if (event.ctrlKey) return;
16212 if (event.altKey) return;
16213 isKeyboardModality = true;
16214 }
16215 var useFocusable = createHook(
16216 function useFocusable2({
16217 focusable: focusable2 = true,
16218 accessibleWhenDisabled,
16219 autoFocus,
16220 onFocusVisible,
16221 ...props
16222 }) {
16223 const ref = (0, import_react16.useRef)(null);
16224 (0, import_react16.useEffect)(() => {
16225 if (!focusable2) return;
16226 if (hasInstalledGlobalEventListeners2) return;
16227 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
16228 addGlobalEventListener("keydown", onGlobalKeyDown, true);
16229 hasInstalledGlobalEventListeners2 = true;
16230 }, [focusable2]);
16231 if (isSafariBrowser) {
16232 (0, import_react16.useEffect)(() => {
16233 if (!focusable2) return;
16234 const element = ref.current;
16235 if (!element) return;
16236 if (!isNativeCheckboxOrRadio(element)) return;
16237 const labels = getLabels(element);
16238 if (!labels) return;
16239 const onMouseUp = () => queueMicrotask(() => element.focus());
16240 for (const label of labels) {
16241 label.addEventListener("mouseup", onMouseUp);
16242 }
16243 return () => {
16244 for (const label of labels) {
16245 label.removeEventListener("mouseup", onMouseUp);
16246 }
16247 };
16248 }, [focusable2]);
16249 }
16250 const disabled2 = focusable2 && disabledFromProps(props);
16251 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
16252 const [focusVisible, setFocusVisible] = (0, import_react16.useState)(false);
16253 (0, import_react16.useEffect)(() => {
16254 if (!focusable2) return;
16255 if (trulyDisabled && focusVisible) {
16256 setFocusVisible(false);
16257 }
16258 }, [focusable2, trulyDisabled, focusVisible]);
16259 (0, import_react16.useEffect)(() => {
16260 if (!focusable2) return;
16261 if (!focusVisible) return;
16262 const element = ref.current;
16263 if (!element) return;
16264 if (typeof IntersectionObserver === "undefined") return;
16265 const observer = new IntersectionObserver(() => {
16266 if (!isFocusable(element)) {
16267 setFocusVisible(false);
16268 }
16269 });
16270 observer.observe(element);
16271 return () => observer.disconnect();
16272 }, [focusable2, focusVisible]);
16273 const onKeyPressCapture = useDisableEvent(
16274 props.onKeyPressCapture,
16275 disabled2
16276 );
16277 const onMouseDownCapture = useDisableEvent(
16278 props.onMouseDownCapture,
16279 disabled2
16280 );
16281 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
16282 const onMouseDownProp = props.onMouseDown;
16283 const onMouseDown = useEvent((event) => {
16284 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
16285 if (event.defaultPrevented) return;
16286 if (!focusable2) return;
16287 const element = event.currentTarget;
16288 if (!isSafariBrowser) return;
16289 if (isPortalEvent(event)) return;
16290 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
16291 let receivedFocus = false;
16292 const onFocus = () => {
16293 receivedFocus = true;
16294 };
16295 const options = { capture: true, once: true };
16296 element.addEventListener("focusin", onFocus, options);
16297 const focusableContainer = getClosestFocusable(element.parentElement);
16298 markSafariFocusAncestor(focusableContainer, true);
16299 queueBeforeEvent(element, "mouseup", () => {
16300 element.removeEventListener("focusin", onFocus, true);
16301 markSafariFocusAncestor(focusableContainer, false);
16302 if (receivedFocus) return;
16303 focusIfNeeded(element);
16304 });
16305 });
16306 const handleFocusVisible = (event, currentTarget) => {
16307 if (currentTarget) {
16308 event.currentTarget = currentTarget;
16309 }
16310 if (!focusable2) return;
16311 const element = event.currentTarget;
16312 if (!element) return;
16313 if (!hasFocus(element)) return;
16314 onFocusVisible == null ? void 0 : onFocusVisible(event);
16315 if (event.defaultPrevented) return;
16316 element.dataset.focusVisible = "true";
16317 setFocusVisible(true);
16318 };
16319 const onKeyDownCaptureProp = props.onKeyDownCapture;
16320 const onKeyDownCapture = useEvent((event) => {
16321 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
16322 if (event.defaultPrevented) return;
16323 if (!focusable2) return;
16324 if (focusVisible) return;
16325 if (event.metaKey) return;
16326 if (event.altKey) return;
16327 if (event.ctrlKey) return;
16328 if (!isSelfTarget(event)) return;
16329 const element = event.currentTarget;
16330 const applyFocusVisible = () => handleFocusVisible(event, element);
16331 queueBeforeEvent(element, "focusout", applyFocusVisible);
16332 });
16333 const onFocusCaptureProp = props.onFocusCapture;
16334 const onFocusCapture = useEvent((event) => {
16335 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16336 if (event.defaultPrevented) return;
16337 if (!focusable2) return;
16338 if (!isSelfTarget(event)) {
16339 setFocusVisible(false);
16340 return;
16341 }
16342 const element = event.currentTarget;
16343 const applyFocusVisible = () => handleFocusVisible(event, element);
16344 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
16345 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
16346 } else {
16347 setFocusVisible(false);
16348 }
16349 });
16350 const onBlurProp = props.onBlur;
16351 const onBlur = useEvent((event) => {
16352 onBlurProp == null ? void 0 : onBlurProp(event);
16353 if (!focusable2) return;
16354 if (!isFocusEventOutside(event)) return;
16355 event.currentTarget.removeAttribute("data-focus-visible");
16356 setFocusVisible(false);
16357 });
16358 const autoFocusOnShow = (0, import_react16.useContext)(FocusableContext);
16359 const autoFocusRef = useEvent((element) => {
16360 if (!focusable2) return;
16361 if (!autoFocus) return;
16362 if (!element) return;
16363 if (!autoFocusOnShow) return;
16364 queueMicrotask(() => {
16365 if (hasFocus(element)) return;
16366 if (!isFocusable(element)) return;
16367 element.focus();
16368 });
16369 });
16370 const tagName = useTagName(ref);
16371 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
16372 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
16373 const styleProp = props.style;
16374 const style = (0, import_react16.useMemo)(() => {
16375 if (trulyDisabled) {
16376 return { pointerEvents: "none", ...styleProp };
16377 }
16378 return styleProp;
16379 }, [trulyDisabled, styleProp]);
16380 props = {
16381 "data-focus-visible": focusable2 && focusVisible || void 0,
16382 "data-autofocus": autoFocus || void 0,
16383 "aria-disabled": disabled2 || void 0,
16384 ...props,
16385 ref: useMergeRefs(ref, autoFocusRef, props.ref),
16386 style,
16387 tabIndex: getTabIndex2(
16388 focusable2,
16389 trulyDisabled,
16390 nativeTabbable,
16391 supportsDisabled,
16392 props.tabIndex
16393 ),
16394 disabled: supportsDisabled && trulyDisabled ? true : void 0,
16395 // TODO: Test Focusable contentEditable.
16396 contentEditable: disabled2 ? void 0 : props.contentEditable,
16397 onKeyPressCapture,
16398 onClickCapture,
16399 onMouseDownCapture,
16400 onMouseDown,
16401 onKeyDownCapture,
16402 onFocusCapture,
16403 onBlur
16404 };
16405 return removeUndefinedValues(props);
16406 }
16407 );
16408 var Focusable = forwardRef210(function Focusable2(props) {
16409 const htmlProps = useFocusable(props);
16410 return createElement3(TagName2, htmlProps);
16411 });
16412
16413 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
16414 var import_react17 = __toESM(require_react(), 1);
16415 var TagName3 = "button";
16416 function isNativeClick(event) {
16417 if (!event.isTrusted) return false;
16418 const element = event.currentTarget;
16419 if (event.key === "Enter") {
16420 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
16421 }
16422 if (event.key === " ") {
16423 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
16424 }
16425 return false;
16426 }
16427 var symbol = /* @__PURE__ */ Symbol("command");
16428 var useCommand = createHook(
16429 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
16430 const ref = (0, import_react17.useRef)(null);
16431 const [isNativeButton, setIsNativeButton] = (0, import_react17.useState)(false);
16432 (0, import_react17.useEffect)(() => {
16433 if (!ref.current) return;
16434 setIsNativeButton(isButton(ref.current));
16435 }, []);
16436 const [active, setActive] = (0, import_react17.useState)(false);
16437 const activeRef = (0, import_react17.useRef)(false);
16438 const disabled2 = disabledFromProps(props);
16439 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
16440 const onKeyDownProp = props.onKeyDown;
16441 const onKeyDown = useEvent((event) => {
16442 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16443 const element = event.currentTarget;
16444 if (event.defaultPrevented) return;
16445 if (isDuplicate) return;
16446 if (disabled2) return;
16447 if (!isSelfTarget(event)) return;
16448 if (isTextField(element)) return;
16449 if (element.isContentEditable) return;
16450 const isEnter = clickOnEnter && event.key === "Enter";
16451 const isSpace = clickOnSpace && event.key === " ";
16452 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
16453 const shouldPreventSpace = event.key === " " && !clickOnSpace;
16454 if (shouldPreventEnter || shouldPreventSpace) {
16455 event.preventDefault();
16456 return;
16457 }
16458 if (isEnter || isSpace) {
16459 const nativeClick = isNativeClick(event);
16460 if (isEnter) {
16461 if (!nativeClick) {
16462 event.preventDefault();
16463 const { view, ...eventInit } = event;
16464 const click = () => fireClickEvent(element, eventInit);
16465 if (isFirefox2()) {
16466 queueBeforeEvent(element, "keyup", click);
16467 } else {
16468 queueMicrotask(click);
16469 }
16470 }
16471 } else if (isSpace) {
16472 activeRef.current = true;
16473 if (!nativeClick) {
16474 event.preventDefault();
16475 setActive(true);
16476 }
16477 }
16478 }
16479 });
16480 const onKeyUpProp = props.onKeyUp;
16481 const onKeyUp = useEvent((event) => {
16482 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
16483 if (event.defaultPrevented) return;
16484 if (isDuplicate) return;
16485 if (disabled2) return;
16486 if (event.metaKey) return;
16487 const isSpace = clickOnSpace && event.key === " ";
16488 if (activeRef.current && isSpace) {
16489 activeRef.current = false;
16490 if (!isNativeClick(event)) {
16491 event.preventDefault();
16492 setActive(false);
16493 const element = event.currentTarget;
16494 const { view, ...eventInit } = event;
16495 queueMicrotask(() => fireClickEvent(element, eventInit));
16496 }
16497 }
16498 });
16499 props = {
16500 "data-active": active || void 0,
16501 type: isNativeButton ? "button" : void 0,
16502 ...metadataProps,
16503 ...props,
16504 ref: useMergeRefs(ref, props.ref),
16505 onKeyDown,
16506 onKeyUp
16507 };
16508 props = useFocusable(props);
16509 return props;
16510 }
16511 );
16512 var Command = forwardRef210(function Command2(props) {
16513 const htmlProps = useCommand(props);
16514 return createElement3(TagName3, htmlProps);
16515 });
16516
16517 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
16518 function getInternal(store, key) {
16519 const internals = store.__unstableInternals;
16520 invariant(internals, "Invalid store");
16521 return internals[key];
16522 }
16523 function createStore(initialState, ...stores) {
16524 let state = initialState;
16525 let prevStateBatch = state;
16526 let lastUpdate = /* @__PURE__ */ Symbol();
16527 let destroy = noop4;
16528 const instances = /* @__PURE__ */ new Set();
16529 const updatedKeys = /* @__PURE__ */ new Set();
16530 const setups = /* @__PURE__ */ new Set();
16531 const listeners = /* @__PURE__ */ new Set();
16532 const batchListeners = /* @__PURE__ */ new Set();
16533 const disposables = /* @__PURE__ */ new WeakMap();
16534 const listenerKeys = /* @__PURE__ */ new WeakMap();
16535 const storeSetup = (callback) => {
16536 setups.add(callback);
16537 return () => setups.delete(callback);
16538 };
16539 const storeInit = () => {
16540 const initialized = instances.size;
16541 const instance = /* @__PURE__ */ Symbol();
16542 instances.add(instance);
16543 const maybeDestroy = () => {
16544 instances.delete(instance);
16545 if (instances.size) return;
16546 destroy();
16547 };
16548 if (initialized) return maybeDestroy;
16549 const desyncs = getKeys(state).map(
16550 (key) => chain(
16551 ...stores.map((store) => {
16552 var _a;
16553 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
16554 if (!storeState) return;
16555 if (!hasOwnProperty(storeState, key)) return;
16556 return sync(store, [key], (state2) => {
16557 setState(
16558 key,
16559 state2[key],
16560 // @ts-expect-error - Not public API. This is just to prevent
16561 // infinite loops.
16562 true
16563 );
16564 });
16565 })
16566 )
16567 );
16568 const teardowns = [];
16569 for (const setup2 of setups) {
16570 teardowns.push(setup2());
16571 }
16572 const cleanups = stores.map(init);
16573 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16574 return maybeDestroy;
16575 };
16576 const sub = (keys, listener, set2 = listeners) => {
16577 set2.add(listener);
16578 listenerKeys.set(listener, keys);
16579 return () => {
16580 var _a;
16581 (_a = disposables.get(listener)) == null ? void 0 : _a();
16582 disposables.delete(listener);
16583 listenerKeys.delete(listener);
16584 set2.delete(listener);
16585 };
16586 };
16587 const storeSubscribe = (keys, listener) => sub(keys, listener);
16588 const storeSync = (keys, listener) => {
16589 disposables.set(listener, listener(state, state));
16590 return sub(keys, listener);
16591 };
16592 const storeBatch = (keys, listener) => {
16593 disposables.set(listener, listener(state, prevStateBatch));
16594 return sub(keys, listener, batchListeners);
16595 };
16596 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16597 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
16598 const getState = () => state;
16599 const setState = (key, value, fromStores = false) => {
16600 var _a;
16601 if (!hasOwnProperty(state, key)) return;
16602 const nextValue = applyState(value, state[key]);
16603 if (nextValue === state[key]) return;
16604 if (!fromStores) {
16605 for (const store of stores) {
16606 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
16607 }
16608 }
16609 const prevState = state;
16610 state = { ...state, [key]: nextValue };
16611 const thisUpdate = /* @__PURE__ */ Symbol();
16612 lastUpdate = thisUpdate;
16613 updatedKeys.add(key);
16614 const run = (listener, prev, uKeys) => {
16615 var _a2;
16616 const keys = listenerKeys.get(listener);
16617 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
16618 if (!keys || keys.some(updated)) {
16619 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
16620 disposables.set(listener, listener(state, prev));
16621 }
16622 };
16623 for (const listener of listeners) {
16624 run(listener, prevState);
16625 }
16626 queueMicrotask(() => {
16627 if (lastUpdate !== thisUpdate) return;
16628 const snapshot = state;
16629 for (const listener of batchListeners) {
16630 run(listener, prevStateBatch, updatedKeys);
16631 }
16632 prevStateBatch = snapshot;
16633 updatedKeys.clear();
16634 });
16635 };
16636 const finalStore = {
16637 getState,
16638 setState,
16639 __unstableInternals: {
16640 setup: storeSetup,
16641 init: storeInit,
16642 subscribe: storeSubscribe,
16643 sync: storeSync,
16644 batch: storeBatch,
16645 pick: storePick,
16646 omit: storeOmit
16647 }
16648 };
16649 return finalStore;
16650 }
16651 function setup(store, ...args) {
16652 if (!store) return;
16653 return getInternal(store, "setup")(...args);
16654 }
16655 function init(store, ...args) {
16656 if (!store) return;
16657 return getInternal(store, "init")(...args);
16658 }
16659 function subscribe(store, ...args) {
16660 if (!store) return;
16661 return getInternal(store, "subscribe")(...args);
16662 }
16663 function sync(store, ...args) {
16664 if (!store) return;
16665 return getInternal(store, "sync")(...args);
16666 }
16667 function batch(store, ...args) {
16668 if (!store) return;
16669 return getInternal(store, "batch")(...args);
16670 }
16671 function omit2(store, ...args) {
16672 if (!store) return;
16673 return getInternal(store, "omit")(...args);
16674 }
16675 function pick2(store, ...args) {
16676 if (!store) return;
16677 return getInternal(store, "pick")(...args);
16678 }
16679 function mergeStore(...stores) {
16680 var _a;
16681 const initialState = {};
16682 for (const store2 of stores) {
16683 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16684 if (nextState) {
16685 Object.assign(initialState, nextState);
16686 }
16687 }
16688 const store = createStore(initialState, ...stores);
16689 return Object.assign({}, ...stores, store);
16690 }
16691 function throwOnConflictingProps(props, store) {
16692 if (false) return;
16693 if (!store) return;
16694 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16695 var _a;
16696 const stateKey = key.replace("default", "");
16697 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16698 });
16699 if (!defaultKeys.length) return;
16700 const storeState = store.getState();
16701 const conflictingProps = defaultKeys.filter(
16702 (key) => hasOwnProperty(storeState, key)
16703 );
16704 if (!conflictingProps.length) return;
16705 throw new Error(
16706 `Passing a store prop in conjunction with a default state is not supported.
16707
16708 const store = useSelectStore();
16709 <SelectProvider store={store} defaultValue="Apple" />
16710 ^ ^
16711
16712 Instead, pass the default state to the topmost store:
16713
16714 const store = useSelectStore({ defaultValue: "Apple" });
16715 <SelectProvider store={store} />
16716
16717 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16718
16719 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16720 `
16721 );
16722 }
16723
16724 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16725 var React49 = __toESM(require_react(), 1);
16726 var import_shim2 = __toESM(require_shim(), 1);
16727 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16728 var noopSubscribe = () => () => {
16729 };
16730 function useStoreState(store, keyOrSelector = identity) {
16731 const storeSubscribe = React49.useCallback(
16732 (callback) => {
16733 if (!store) return noopSubscribe();
16734 return subscribe(store, null, callback);
16735 },
16736 [store]
16737 );
16738 const getSnapshot = () => {
16739 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16740 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16741 const state = store == null ? void 0 : store.getState();
16742 if (selector2) return selector2(state);
16743 if (!state) return;
16744 if (!key) return;
16745 if (!hasOwnProperty(state, key)) return;
16746 return state[key];
16747 };
16748 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16749 }
16750 function useStoreStateObject(store, object) {
16751 const objRef = React49.useRef(
16752 {}
16753 );
16754 const storeSubscribe = React49.useCallback(
16755 (callback) => {
16756 if (!store) return noopSubscribe();
16757 return subscribe(store, null, callback);
16758 },
16759 [store]
16760 );
16761 const getSnapshot = () => {
16762 const state = store == null ? void 0 : store.getState();
16763 let updated = false;
16764 const obj = objRef.current;
16765 for (const prop in object) {
16766 const keyOrSelector = object[prop];
16767 if (typeof keyOrSelector === "function") {
16768 const value = keyOrSelector(state);
16769 if (value !== obj[prop]) {
16770 obj[prop] = value;
16771 updated = true;
16772 }
16773 }
16774 if (typeof keyOrSelector === "string") {
16775 if (!state) continue;
16776 if (!hasOwnProperty(state, keyOrSelector)) continue;
16777 const value = state[keyOrSelector];
16778 if (value !== obj[prop]) {
16779 obj[prop] = value;
16780 updated = true;
16781 }
16782 }
16783 }
16784 if (updated) {
16785 objRef.current = { ...obj };
16786 }
16787 return objRef.current;
16788 };
16789 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16790 }
16791 function useStoreProps(store, props, key, setKey) {
16792 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16793 const setValue = setKey ? props[setKey] : void 0;
16794 const propsRef = useLiveRef({ value, setValue });
16795 useSafeLayoutEffect(() => {
16796 return sync(store, [key], (state, prev) => {
16797 const { value: value2, setValue: setValue2 } = propsRef.current;
16798 if (!setValue2) return;
16799 if (state[key] === prev[key]) return;
16800 if (state[key] === value2) return;
16801 setValue2(state[key]);
16802 });
16803 }, [store, key]);
16804 useSafeLayoutEffect(() => {
16805 if (value === void 0) return;
16806 store.setState(key, value);
16807 return batch(store, [key], () => {
16808 if (value === void 0) return;
16809 store.setState(key, value);
16810 });
16811 });
16812 }
16813 function useStore2(createStore2, props) {
16814 const [store, setStore] = React49.useState(() => createStore2(props));
16815 useSafeLayoutEffect(() => init(store), [store]);
16816 const useState210 = React49.useCallback(
16817 (keyOrSelector) => useStoreState(store, keyOrSelector),
16818 [store]
16819 );
16820 const memoizedStore = React49.useMemo(
16821 () => ({ ...store, useState: useState210 }),
16822 [store, useState210]
16823 );
16824 const updateStore = useEvent(() => {
16825 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16826 });
16827 return [memoizedStore, updateStore];
16828 }
16829
16830 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16831 var import_react18 = __toESM(require_react(), 1);
16832 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
16833 var TagName4 = "button";
16834 function isEditableElement(element) {
16835 if (isTextbox(element)) return true;
16836 return element.tagName === "INPUT" && !isButton(element);
16837 }
16838 function getNextPageOffset(scrollingElement, pageUp = false) {
16839 const height = scrollingElement.clientHeight;
16840 const { top } = scrollingElement.getBoundingClientRect();
16841 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16842 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16843 if (scrollingElement.tagName === "HTML") {
16844 return pageOffset + scrollingElement.scrollTop;
16845 }
16846 return pageOffset;
16847 }
16848 function getItemOffset(itemElement, pageUp = false) {
16849 const { top } = itemElement.getBoundingClientRect();
16850 if (pageUp) {
16851 return top + itemElement.clientHeight;
16852 }
16853 return top;
16854 }
16855 function findNextPageItemId(element, store, next, pageUp = false) {
16856 var _a;
16857 if (!store) return;
16858 if (!next) return;
16859 const { renderedItems } = store.getState();
16860 const scrollingElement = getScrollingElement(element);
16861 if (!scrollingElement) return;
16862 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16863 let id;
16864 let prevDifference;
16865 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16866 const previousId = id;
16867 id = next(i2);
16868 if (!id) break;
16869 if (id === previousId) continue;
16870 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16871 if (!itemElement) continue;
16872 const itemOffset = getItemOffset(itemElement, pageUp);
16873 const difference = itemOffset - nextPageOffset;
16874 const absDifference = Math.abs(difference);
16875 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16876 if (prevDifference !== void 0 && prevDifference < absDifference) {
16877 id = previousId;
16878 }
16879 break;
16880 }
16881 prevDifference = absDifference;
16882 }
16883 return id;
16884 }
16885 function targetIsAnotherItem(event, store) {
16886 if (isSelfTarget(event)) return false;
16887 return isItem(store, event.target);
16888 }
16889 var useCompositeItem = createHook(
16890 function useCompositeItem2({
16891 store,
16892 rowId: rowIdProp,
16893 preventScrollOnKeyDown = false,
16894 moveOnKeyPress = true,
16895 tabbable: tabbable2 = false,
16896 getItem: getItemProp,
16897 "aria-setsize": ariaSetSizeProp,
16898 "aria-posinset": ariaPosInSetProp,
16899 ...props
16900 }) {
16901 const context = useCompositeContext();
16902 store = store || context;
16903 const id = useId4(props.id);
16904 const ref = (0, import_react18.useRef)(null);
16905 const row = (0, import_react18.useContext)(CompositeRowContext);
16906 const disabled2 = disabledFromProps(props);
16907 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16908 const {
16909 rowId,
16910 baseElement,
16911 isActiveItem,
16912 ariaSetSize,
16913 ariaPosInSet,
16914 isTabbable
16915 } = useStoreStateObject(store, {
16916 rowId(state) {
16917 if (rowIdProp) return rowIdProp;
16918 if (!state) return;
16919 if (!(row == null ? void 0 : row.baseElement)) return;
16920 if (row.baseElement !== state.baseElement) return;
16921 return row.id;
16922 },
16923 baseElement(state) {
16924 return (state == null ? void 0 : state.baseElement) || void 0;
16925 },
16926 isActiveItem(state) {
16927 return !!state && state.activeId === id;
16928 },
16929 ariaSetSize(state) {
16930 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16931 if (!state) return;
16932 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16933 if (row.baseElement !== state.baseElement) return;
16934 return row.ariaSetSize;
16935 },
16936 ariaPosInSet(state) {
16937 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16938 if (!state) return;
16939 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16940 if (row.baseElement !== state.baseElement) return;
16941 const itemsInRow = state.renderedItems.filter(
16942 (item) => item.rowId === rowId
16943 );
16944 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16945 },
16946 isTabbable(state) {
16947 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16948 if (state.virtualFocus) return false;
16949 if (tabbable2) return true;
16950 if (state.activeId === null) return false;
16951 const item = store == null ? void 0 : store.item(state.activeId);
16952 if (item == null ? void 0 : item.disabled) return true;
16953 if (!(item == null ? void 0 : item.element)) return true;
16954 return state.activeId === id;
16955 }
16956 });
16957 const getItem = (0, import_react18.useCallback)(
16958 (item) => {
16959 var _a;
16960 const nextItem = {
16961 ...item,
16962 id: id || item.id,
16963 rowId,
16964 disabled: !!trulyDisabled,
16965 children: (_a = item.element) == null ? void 0 : _a.textContent
16966 };
16967 if (getItemProp) {
16968 return getItemProp(nextItem);
16969 }
16970 return nextItem;
16971 },
16972 [id, rowId, trulyDisabled, getItemProp]
16973 );
16974 const onFocusProp = props.onFocus;
16975 const hasFocusedComposite = (0, import_react18.useRef)(false);
16976 const onFocus = useEvent((event) => {
16977 onFocusProp == null ? void 0 : onFocusProp(event);
16978 if (event.defaultPrevented) return;
16979 if (isPortalEvent(event)) return;
16980 if (!id) return;
16981 if (!store) return;
16982 if (targetIsAnotherItem(event, store)) return;
16983 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16984 store.setActiveId(id);
16985 if (isTextbox(event.currentTarget)) {
16986 selectTextField(event.currentTarget);
16987 }
16988 if (!virtualFocus) return;
16989 if (!isSelfTarget(event)) return;
16990 if (isEditableElement(event.currentTarget)) return;
16991 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16992 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16993 event.currentTarget.scrollIntoView({
16994 block: "nearest",
16995 inline: "nearest"
16996 });
16997 }
16998 hasFocusedComposite.current = true;
16999 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
17000 if (fromComposite) {
17001 focusSilently(baseElement2);
17002 } else {
17003 baseElement2.focus();
17004 }
17005 });
17006 const onBlurCaptureProp = props.onBlurCapture;
17007 const onBlurCapture = useEvent((event) => {
17008 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
17009 if (event.defaultPrevented) return;
17010 const state = store == null ? void 0 : store.getState();
17011 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
17012 hasFocusedComposite.current = false;
17013 event.preventDefault();
17014 event.stopPropagation();
17015 }
17016 });
17017 const onKeyDownProp = props.onKeyDown;
17018 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
17019 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17020 const onKeyDown = useEvent((event) => {
17021 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17022 if (event.defaultPrevented) return;
17023 if (!isSelfTarget(event)) return;
17024 if (!store) return;
17025 const { currentTarget } = event;
17026 const state = store.getState();
17027 const item = store.item(id);
17028 const isGrid2 = !!(item == null ? void 0 : item.rowId);
17029 const isVertical = state.orientation !== "horizontal";
17030 const isHorizontal = state.orientation !== "vertical";
17031 const canHomeEnd = () => {
17032 if (isGrid2) return true;
17033 if (isHorizontal) return true;
17034 if (!state.baseElement) return true;
17035 if (!isTextField(state.baseElement)) return true;
17036 return false;
17037 };
17038 const keyMap = {
17039 ArrowUp: (isGrid2 || isVertical) && store.up,
17040 ArrowRight: (isGrid2 || isHorizontal) && store.next,
17041 ArrowDown: (isGrid2 || isVertical) && store.down,
17042 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
17043 Home: () => {
17044 if (!canHomeEnd()) return;
17045 if (!isGrid2 || event.ctrlKey) {
17046 return store == null ? void 0 : store.first();
17047 }
17048 return store == null ? void 0 : store.previous(-1);
17049 },
17050 End: () => {
17051 if (!canHomeEnd()) return;
17052 if (!isGrid2 || event.ctrlKey) {
17053 return store == null ? void 0 : store.last();
17054 }
17055 return store == null ? void 0 : store.next(-1);
17056 },
17057 PageUp: () => {
17058 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
17059 },
17060 PageDown: () => {
17061 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
17062 }
17063 };
17064 const action = keyMap[event.key];
17065 if (action) {
17066 if (isTextbox(currentTarget)) {
17067 const selection = getTextboxSelection(currentTarget);
17068 const isLeft = isHorizontal && event.key === "ArrowLeft";
17069 const isRight = isHorizontal && event.key === "ArrowRight";
17070 const isUp = isVertical && event.key === "ArrowUp";
17071 const isDown = isVertical && event.key === "ArrowDown";
17072 if (isRight || isDown) {
17073 const { length: valueLength } = getTextboxValue(currentTarget);
17074 if (selection.end !== valueLength) return;
17075 } else if ((isLeft || isUp) && selection.start !== 0) return;
17076 }
17077 const nextId = action();
17078 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
17079 if (!moveOnKeyPressProp(event)) return;
17080 event.preventDefault();
17081 store.move(nextId);
17082 }
17083 }
17084 });
17085 const providerValue = (0, import_react18.useMemo)(
17086 () => ({ id, baseElement }),
17087 [id, baseElement]
17088 );
17089 props = useWrapElement(
17090 props,
17091 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
17092 [providerValue]
17093 );
17094 props = {
17095 id,
17096 "data-active-item": isActiveItem || void 0,
17097 ...props,
17098 ref: useMergeRefs(ref, props.ref),
17099 tabIndex: isTabbable ? props.tabIndex : -1,
17100 onFocus,
17101 onBlurCapture,
17102 onKeyDown
17103 };
17104 props = useCommand(props);
17105 props = useCollectionItem({
17106 store,
17107 ...props,
17108 getItem,
17109 shouldRegisterItem: id ? props.shouldRegisterItem : false
17110 });
17111 return removeUndefinedValues({
17112 ...props,
17113 "aria-setsize": ariaSetSize,
17114 "aria-posinset": ariaPosInSet
17115 });
17116 }
17117 );
17118 var CompositeItem = memo22(
17119 forwardRef210(function CompositeItem2(props) {
17120 const htmlProps = useCompositeItem(props);
17121 return createElement3(TagName4, htmlProps);
17122 })
17123 );
17124
17125 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
17126 function toArray(arg) {
17127 if (Array.isArray(arg)) {
17128 return arg;
17129 }
17130 return typeof arg !== "undefined" ? [arg] : [];
17131 }
17132 function flatten2DArray(array) {
17133 const flattened = [];
17134 for (const row of array) {
17135 flattened.push(...row);
17136 }
17137 return flattened;
17138 }
17139 function reverseArray(array) {
17140 return array.slice().reverse();
17141 }
17142
17143 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
17144 var import_react19 = __toESM(require_react(), 1);
17145 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
17146 var TagName5 = "div";
17147 function isGrid(items) {
17148 return items.some((item) => !!item.rowId);
17149 }
17150 function isPrintableKey(event) {
17151 const target = event.target;
17152 if (target && !isTextField(target)) return false;
17153 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
17154 }
17155 function isModifierKey(event) {
17156 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
17157 }
17158 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
17159 return useEvent((event) => {
17160 var _a;
17161 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
17162 if (event.defaultPrevented) return;
17163 if (event.isPropagationStopped()) return;
17164 if (!isSelfTarget(event)) return;
17165 if (isModifierKey(event)) return;
17166 if (isPrintableKey(event)) return;
17167 const state = store.getState();
17168 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
17169 if (!activeElement2) return;
17170 const { view, ...eventInit } = event;
17171 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
17172 if (activeElement2 !== previousElement) {
17173 activeElement2.focus();
17174 }
17175 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
17176 event.preventDefault();
17177 }
17178 if (event.currentTarget.contains(activeElement2)) {
17179 event.stopPropagation();
17180 }
17181 });
17182 }
17183 function findFirstEnabledItemInTheLastRow(items) {
17184 return findFirstEnabledItem(
17185 flatten2DArray(reverseArray(groupItemsByRows(items)))
17186 );
17187 }
17188 function useScheduleFocus(store) {
17189 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
17190 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
17191 const activeItem = store.useState(
17192 (state) => getEnabledItem(store, state.activeId)
17193 );
17194 (0, import_react19.useEffect)(() => {
17195 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
17196 if (!scheduled) return;
17197 if (!activeElement2) return;
17198 setScheduled(false);
17199 activeElement2.focus({ preventScroll: true });
17200 }, [activeItem, scheduled]);
17201 return schedule;
17202 }
17203 var useComposite = createHook(
17204 function useComposite2({
17205 store,
17206 composite = true,
17207 focusOnMove = composite,
17208 moveOnKeyPress = true,
17209 ...props
17210 }) {
17211 const context = useCompositeProviderContext();
17212 store = store || context;
17213 invariant(
17214 store,
17215 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
17216 );
17217 const ref = (0, import_react19.useRef)(null);
17218 const previousElementRef = (0, import_react19.useRef)(null);
17219 const scheduleFocus = useScheduleFocus(store);
17220 const moves = store.useState("moves");
17221 const [, setBaseElement] = useTransactionState(
17222 composite ? store.setBaseElement : null
17223 );
17224 (0, import_react19.useEffect)(() => {
17225 var _a;
17226 if (!store) return;
17227 if (!moves) return;
17228 if (!composite) return;
17229 if (!focusOnMove) return;
17230 const { activeId: activeId2 } = store.getState();
17231 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
17232 if (!itemElement) return;
17233 focusIntoView(itemElement);
17234 }, [store, moves, composite, focusOnMove]);
17235 useSafeLayoutEffect(() => {
17236 if (!store) return;
17237 if (!moves) return;
17238 if (!composite) return;
17239 const { baseElement, activeId: activeId2 } = store.getState();
17240 const isSelfAcive = activeId2 === null;
17241 if (!isSelfAcive) return;
17242 if (!baseElement) return;
17243 const previousElement = previousElementRef.current;
17244 previousElementRef.current = null;
17245 if (previousElement) {
17246 fireBlurEvent(previousElement, { relatedTarget: baseElement });
17247 }
17248 if (!hasFocus(baseElement)) {
17249 baseElement.focus();
17250 }
17251 }, [store, moves, composite]);
17252 const activeId = store.useState("activeId");
17253 const virtualFocus = store.useState("virtualFocus");
17254 useSafeLayoutEffect(() => {
17255 var _a;
17256 if (!store) return;
17257 if (!composite) return;
17258 if (!virtualFocus) return;
17259 const previousElement = previousElementRef.current;
17260 previousElementRef.current = null;
17261 if (!previousElement) return;
17262 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
17263 const relatedTarget = activeElement2 || getActiveElement(previousElement);
17264 if (relatedTarget === previousElement) return;
17265 fireBlurEvent(previousElement, { relatedTarget });
17266 }, [store, activeId, virtualFocus, composite]);
17267 const onKeyDownCapture = useKeyboardEventProxy(
17268 store,
17269 props.onKeyDownCapture,
17270 previousElementRef
17271 );
17272 const onKeyUpCapture = useKeyboardEventProxy(
17273 store,
17274 props.onKeyUpCapture,
17275 previousElementRef
17276 );
17277 const onFocusCaptureProp = props.onFocusCapture;
17278 const onFocusCapture = useEvent((event) => {
17279 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
17280 if (event.defaultPrevented) return;
17281 if (!store) return;
17282 const { virtualFocus: virtualFocus2 } = store.getState();
17283 if (!virtualFocus2) return;
17284 const previousActiveElement = event.relatedTarget;
17285 const isSilentlyFocused = silentlyFocused(event.currentTarget);
17286 if (isSelfTarget(event) && isSilentlyFocused) {
17287 event.stopPropagation();
17288 previousElementRef.current = previousActiveElement;
17289 }
17290 });
17291 const onFocusProp = props.onFocus;
17292 const onFocus = useEvent((event) => {
17293 onFocusProp == null ? void 0 : onFocusProp(event);
17294 if (event.defaultPrevented) return;
17295 if (!composite) return;
17296 if (!store) return;
17297 const { relatedTarget } = event;
17298 const { virtualFocus: virtualFocus2 } = store.getState();
17299 if (virtualFocus2) {
17300 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
17301 queueMicrotask(scheduleFocus);
17302 }
17303 } else if (isSelfTarget(event)) {
17304 store.setActiveId(null);
17305 }
17306 });
17307 const onBlurCaptureProp = props.onBlurCapture;
17308 const onBlurCapture = useEvent((event) => {
17309 var _a;
17310 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
17311 if (event.defaultPrevented) return;
17312 if (!store) return;
17313 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
17314 if (!virtualFocus2) return;
17315 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
17316 const nextActiveElement = event.relatedTarget;
17317 const nextActiveElementIsItem = isItem(store, nextActiveElement);
17318 const previousElement = previousElementRef.current;
17319 previousElementRef.current = null;
17320 if (isSelfTarget(event) && nextActiveElementIsItem) {
17321 if (nextActiveElement === activeElement2) {
17322 if (previousElement && previousElement !== nextActiveElement) {
17323 fireBlurEvent(previousElement, event);
17324 }
17325 } else if (activeElement2) {
17326 fireBlurEvent(activeElement2, event);
17327 } else if (previousElement) {
17328 fireBlurEvent(previousElement, event);
17329 }
17330 event.stopPropagation();
17331 } else {
17332 const targetIsItem = isItem(store, event.target);
17333 if (!targetIsItem && activeElement2) {
17334 fireBlurEvent(activeElement2, event);
17335 }
17336 }
17337 });
17338 const onKeyDownProp = props.onKeyDown;
17339 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17340 const onKeyDown = useEvent((event) => {
17341 var _a;
17342 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17343 if (event.nativeEvent.isComposing) return;
17344 if (event.defaultPrevented) return;
17345 if (!store) return;
17346 if (!isSelfTarget(event)) return;
17347 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
17348 const activeItem = getEnabledItem(store, activeId2);
17349 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
17350 const isVertical = orientation !== "horizontal";
17351 const isHorizontal = orientation !== "vertical";
17352 const grid = isGrid(renderedItems);
17353 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
17354 if (isHorizontalKey && isTextField(event.currentTarget)) return;
17355 const up = () => {
17356 if (grid) {
17357 const item = findFirstEnabledItemInTheLastRow(renderedItems);
17358 return item == null ? void 0 : item.id;
17359 }
17360 return store == null ? void 0 : store.last();
17361 };
17362 const keyMap = {
17363 ArrowUp: (grid || isVertical) && up,
17364 ArrowRight: (grid || isHorizontal) && store.first,
17365 ArrowDown: (grid || isVertical) && store.first,
17366 ArrowLeft: (grid || isHorizontal) && store.last,
17367 Home: store.first,
17368 End: store.last,
17369 PageUp: store.first,
17370 PageDown: store.last
17371 };
17372 const action = keyMap[event.key];
17373 if (action) {
17374 const id = action();
17375 if (id !== void 0) {
17376 if (!moveOnKeyPressProp(event)) return;
17377 event.preventDefault();
17378 store.move(id);
17379 }
17380 }
17381 });
17382 props = useWrapElement(
17383 props,
17384 (element) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(CompositeContextProvider, { value: store, children: element }),
17385 [store]
17386 );
17387 const activeDescendant = store.useState((state) => {
17388 var _a;
17389 if (!store) return;
17390 if (!composite) return;
17391 if (!state.virtualFocus) return;
17392 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
17393 });
17394 props = {
17395 "aria-activedescendant": activeDescendant,
17396 ...props,
17397 ref: useMergeRefs(ref, setBaseElement, props.ref),
17398 onKeyDownCapture,
17399 onKeyUpCapture,
17400 onFocusCapture,
17401 onFocus,
17402 onBlurCapture,
17403 onKeyDown
17404 };
17405 const focusable2 = store.useState(
17406 (state) => composite && (state.virtualFocus || state.activeId === null)
17407 );
17408 props = useFocusable({ focusable: focusable2, ...props });
17409 return props;
17410 }
17411 );
17412 var Composite6 = forwardRef210(function Composite22(props) {
17413 const htmlProps = useComposite(props);
17414 return createElement3(TagName5, htmlProps);
17415 });
17416
17417 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
17418 var ctx3 = createStoreContext();
17419 var useDisclosureContext = ctx3.useContext;
17420 var useDisclosureScopedContext = ctx3.useScopedContext;
17421 var useDisclosureProviderContext = ctx3.useProviderContext;
17422 var DisclosureContextProvider = ctx3.ContextProvider;
17423 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
17424
17425 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
17426 var import_react20 = __toESM(require_react(), 1);
17427 var ctx4 = createStoreContext(
17428 [DisclosureContextProvider],
17429 [DisclosureScopedContextProvider]
17430 );
17431 var useDialogContext = ctx4.useContext;
17432 var useDialogScopedContext = ctx4.useScopedContext;
17433 var useDialogProviderContext = ctx4.useProviderContext;
17434 var DialogContextProvider = ctx4.ContextProvider;
17435 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
17436 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
17437 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
17438
17439 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
17440 var import_react21 = __toESM(require_react(), 1);
17441 var import_react_dom4 = __toESM(require_react_dom(), 1);
17442 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
17443 var TagName6 = "div";
17444 function afterTimeout(timeoutMs, cb) {
17445 const timeoutId = setTimeout(cb, timeoutMs);
17446 return () => clearTimeout(timeoutId);
17447 }
17448 function afterPaint2(cb) {
17449 let raf = requestAnimationFrame(() => {
17450 raf = requestAnimationFrame(cb);
17451 });
17452 return () => cancelAnimationFrame(raf);
17453 }
17454 function parseCSSTime(...times) {
17455 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
17456 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
17457 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
17458 if (currentTime > longestTime) return currentTime;
17459 return longestTime;
17460 }, 0);
17461 }
17462 function isHidden(mounted, hidden, alwaysVisible) {
17463 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
17464 }
17465 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
17466 const context = useDisclosureProviderContext();
17467 store = store || context;
17468 invariant(
17469 store,
17470 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
17471 );
17472 const ref = (0, import_react21.useRef)(null);
17473 const id = useId4(props.id);
17474 const [transition, setTransition] = (0, import_react21.useState)(null);
17475 const open = store.useState("open");
17476 const mounted = store.useState("mounted");
17477 const animated = store.useState("animated");
17478 const contentElement = store.useState("contentElement");
17479 const otherElement = useStoreState(store.disclosure, "contentElement");
17480 useSafeLayoutEffect(() => {
17481 if (!ref.current) return;
17482 store == null ? void 0 : store.setContentElement(ref.current);
17483 }, [store]);
17484 useSafeLayoutEffect(() => {
17485 let previousAnimated;
17486 store == null ? void 0 : store.setState("animated", (animated2) => {
17487 previousAnimated = animated2;
17488 return true;
17489 });
17490 return () => {
17491 if (previousAnimated === void 0) return;
17492 store == null ? void 0 : store.setState("animated", previousAnimated);
17493 };
17494 }, [store]);
17495 useSafeLayoutEffect(() => {
17496 if (!animated) return;
17497 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
17498 setTransition(null);
17499 return;
17500 }
17501 return afterPaint2(() => {
17502 setTransition(open ? "enter" : mounted ? "leave" : null);
17503 });
17504 }, [animated, contentElement, open, mounted]);
17505 useSafeLayoutEffect(() => {
17506 if (!store) return;
17507 if (!animated) return;
17508 if (!transition) return;
17509 if (!contentElement) return;
17510 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
17511 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17512 if (transition === "leave" && open) return;
17513 if (transition === "enter" && !open) return;
17514 if (typeof animated === "number") {
17515 const timeout2 = animated;
17516 return afterTimeout(timeout2, stopAnimationSync);
17517 }
17518 const {
17519 transitionDuration,
17520 animationDuration,
17521 transitionDelay,
17522 animationDelay
17523 } = getComputedStyle(contentElement);
17524 const {
17525 transitionDuration: transitionDuration2 = "0",
17526 animationDuration: animationDuration2 = "0",
17527 transitionDelay: transitionDelay2 = "0",
17528 animationDelay: animationDelay2 = "0"
17529 } = otherElement ? getComputedStyle(otherElement) : {};
17530 const delay = parseCSSTime(
17531 transitionDelay,
17532 animationDelay,
17533 transitionDelay2,
17534 animationDelay2
17535 );
17536 const duration = parseCSSTime(
17537 transitionDuration,
17538 animationDuration,
17539 transitionDuration2,
17540 animationDuration2
17541 );
17542 const timeout = delay + duration;
17543 if (!timeout) {
17544 if (transition === "enter") {
17545 store.setState("animated", false);
17546 }
17547 stopAnimation();
17548 return;
17549 }
17550 const frameRate = 1e3 / 60;
17551 const maxTimeout = Math.max(timeout - frameRate, 0);
17552 return afterTimeout(maxTimeout, stopAnimationSync);
17553 }, [store, animated, contentElement, otherElement, open, transition]);
17554 props = useWrapElement(
17555 props,
17556 (element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DialogScopedContextProvider, { value: store, children: element }),
17557 [store]
17558 );
17559 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17560 const styleProp = props.style;
17561 const style = (0, import_react21.useMemo)(() => {
17562 if (hidden) {
17563 return { ...styleProp, display: "none" };
17564 }
17565 return styleProp;
17566 }, [hidden, styleProp]);
17567 props = {
17568 id,
17569 "data-open": open || void 0,
17570 "data-enter": transition === "enter" || void 0,
17571 "data-leave": transition === "leave" || void 0,
17572 hidden,
17573 ...props,
17574 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17575 style
17576 };
17577 return removeUndefinedValues(props);
17578 });
17579 var DisclosureContentImpl = forwardRef210(function DisclosureContentImpl2(props) {
17580 const htmlProps = useDisclosureContent(props);
17581 return createElement3(TagName6, htmlProps);
17582 });
17583 var DisclosureContent = forwardRef210(function DisclosureContent2({
17584 unmountOnHide,
17585 ...props
17586 }) {
17587 const context = useDisclosureProviderContext();
17588 const store = props.store || context;
17589 const mounted = useStoreState(
17590 store,
17591 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
17592 );
17593 if (mounted === false) return null;
17594 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(DisclosureContentImpl, { ...props });
17595 });
17596
17597 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
17598 function createDisclosureStore(props = {}) {
17599 const store = mergeStore(
17600 props.store,
17601 omit2(props.disclosure, ["contentElement", "disclosureElement"])
17602 );
17603 throwOnConflictingProps(props, store);
17604 const syncState = store == null ? void 0 : store.getState();
17605 const open = defaultValue(
17606 props.open,
17607 syncState == null ? void 0 : syncState.open,
17608 props.defaultOpen,
17609 false
17610 );
17611 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
17612 const initialState = {
17613 open,
17614 animated,
17615 animating: !!animated && open,
17616 mounted: open,
17617 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
17618 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
17619 };
17620 const disclosure = createStore(initialState, store);
17621 setup(
17622 disclosure,
17623 () => sync(disclosure, ["animated", "animating"], (state) => {
17624 if (state.animated) return;
17625 disclosure.setState("animating", false);
17626 })
17627 );
17628 setup(
17629 disclosure,
17630 () => subscribe(disclosure, ["open"], () => {
17631 if (!disclosure.getState().animated) return;
17632 disclosure.setState("animating", true);
17633 })
17634 );
17635 setup(
17636 disclosure,
17637 () => sync(disclosure, ["open", "animating"], (state) => {
17638 disclosure.setState("mounted", state.open || state.animating);
17639 })
17640 );
17641 return {
17642 ...disclosure,
17643 disclosure: props.disclosure,
17644 setOpen: (value) => disclosure.setState("open", value),
17645 show: () => disclosure.setState("open", true),
17646 hide: () => disclosure.setState("open", false),
17647 toggle: () => disclosure.setState("open", (open2) => !open2),
17648 stopAnimation: () => disclosure.setState("animating", false),
17649 setContentElement: (value) => disclosure.setState("contentElement", value),
17650 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17651 };
17652 }
17653
17654 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17655 function useDisclosureStoreProps(store, update2, props) {
17656 useUpdateEffect(update2, [props.store, props.disclosure]);
17657 useStoreProps(store, props, "open", "setOpen");
17658 useStoreProps(store, props, "mounted", "setMounted");
17659 useStoreProps(store, props, "animated");
17660 return Object.assign(store, { disclosure: props.disclosure });
17661 }
17662
17663 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17664 var ctx5 = createStoreContext(
17665 [DialogContextProvider],
17666 [DialogScopedContextProvider]
17667 );
17668 var usePopoverContext = ctx5.useContext;
17669 var usePopoverScopedContext = ctx5.useScopedContext;
17670 var usePopoverProviderContext = ctx5.useProviderContext;
17671 var PopoverContextProvider = ctx5.ContextProvider;
17672 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17673
17674 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17675 function getCommonParent(items) {
17676 var _a;
17677 const firstItem = items.find((item) => !!item.element);
17678 const lastItem = [...items].reverse().find((item) => !!item.element);
17679 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17680 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17681 const parent = parentElement;
17682 if (lastItem && parent.contains(lastItem.element)) {
17683 return parentElement;
17684 }
17685 parentElement = parentElement.parentElement;
17686 }
17687 return getDocument(parentElement).body;
17688 }
17689 function getPrivateStore(store) {
17690 return store == null ? void 0 : store.__unstablePrivateStore;
17691 }
17692 function createCollectionStore(props = {}) {
17693 var _a;
17694 throwOnConflictingProps(props, props.store);
17695 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17696 const items = defaultValue(
17697 props.items,
17698 syncState == null ? void 0 : syncState.items,
17699 props.defaultItems,
17700 []
17701 );
17702 const itemsMap = new Map(items.map((item) => [item.id, item]));
17703 const initialState = {
17704 items,
17705 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17706 };
17707 const syncPrivateStore = getPrivateStore(props.store);
17708 const privateStore = createStore(
17709 { items, renderedItems: initialState.renderedItems },
17710 syncPrivateStore
17711 );
17712 const collection = createStore(initialState, props.store);
17713 const sortItems = (renderedItems) => {
17714 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17715 privateStore.setState("renderedItems", sortedItems);
17716 collection.setState("renderedItems", sortedItems);
17717 };
17718 setup(collection, () => init(privateStore));
17719 setup(privateStore, () => {
17720 return batch(privateStore, ["items"], (state) => {
17721 collection.setState("items", state.items);
17722 });
17723 });
17724 setup(privateStore, () => {
17725 return batch(privateStore, ["renderedItems"], (state) => {
17726 let firstRun = true;
17727 let raf = requestAnimationFrame(() => {
17728 const { renderedItems } = collection.getState();
17729 if (state.renderedItems === renderedItems) return;
17730 sortItems(state.renderedItems);
17731 });
17732 if (typeof IntersectionObserver !== "function") {
17733 return () => cancelAnimationFrame(raf);
17734 }
17735 const ioCallback = () => {
17736 if (firstRun) {
17737 firstRun = false;
17738 return;
17739 }
17740 cancelAnimationFrame(raf);
17741 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17742 };
17743 const root = getCommonParent(state.renderedItems);
17744 const observer = new IntersectionObserver(ioCallback, { root });
17745 for (const item of state.renderedItems) {
17746 if (!item.element) continue;
17747 observer.observe(item.element);
17748 }
17749 return () => {
17750 cancelAnimationFrame(raf);
17751 observer.disconnect();
17752 };
17753 });
17754 });
17755 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17756 let prevItem;
17757 setItems((items2) => {
17758 const index2 = items2.findIndex(({ id }) => id === item.id);
17759 const nextItems = items2.slice();
17760 if (index2 !== -1) {
17761 prevItem = items2[index2];
17762 const nextItem = { ...prevItem, ...item };
17763 nextItems[index2] = nextItem;
17764 itemsMap.set(item.id, nextItem);
17765 } else {
17766 nextItems.push(item);
17767 itemsMap.set(item.id, item);
17768 }
17769 return nextItems;
17770 });
17771 const unmergeItem = () => {
17772 setItems((items2) => {
17773 if (!prevItem) {
17774 if (canDeleteFromMap) {
17775 itemsMap.delete(item.id);
17776 }
17777 return items2.filter(({ id }) => id !== item.id);
17778 }
17779 const index2 = items2.findIndex(({ id }) => id === item.id);
17780 if (index2 === -1) return items2;
17781 const nextItems = items2.slice();
17782 nextItems[index2] = prevItem;
17783 itemsMap.set(item.id, prevItem);
17784 return nextItems;
17785 });
17786 };
17787 return unmergeItem;
17788 };
17789 const registerItem = (item) => mergeItem(
17790 item,
17791 (getItems) => privateStore.setState("items", getItems),
17792 true
17793 );
17794 return {
17795 ...collection,
17796 registerItem,
17797 renderItem: (item) => chain(
17798 registerItem(item),
17799 mergeItem(
17800 item,
17801 (getItems) => privateStore.setState("renderedItems", getItems)
17802 )
17803 ),
17804 item: (id) => {
17805 if (!id) return null;
17806 let item = itemsMap.get(id);
17807 if (!item) {
17808 const { items: items2 } = privateStore.getState();
17809 item = items2.find((item2) => item2.id === id);
17810 if (item) {
17811 itemsMap.set(id, item);
17812 }
17813 }
17814 return item || null;
17815 },
17816 // @ts-expect-error Internal
17817 __unstablePrivateStore: privateStore
17818 };
17819 }
17820
17821 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17822 function useCollectionStoreProps(store, update2, props) {
17823 useUpdateEffect(update2, [props.store]);
17824 useStoreProps(store, props, "items", "setItems");
17825 return store;
17826 }
17827
17828 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17829 var NULL_ITEM = { id: null };
17830 function findFirstEnabledItem2(items, excludeId) {
17831 return items.find((item) => {
17832 if (excludeId) {
17833 return !item.disabled && item.id !== excludeId;
17834 }
17835 return !item.disabled;
17836 });
17837 }
17838 function getEnabledItems(items, excludeId) {
17839 return items.filter((item) => {
17840 if (excludeId) {
17841 return !item.disabled && item.id !== excludeId;
17842 }
17843 return !item.disabled;
17844 });
17845 }
17846 function getItemsInRow(items, rowId) {
17847 return items.filter((item) => item.rowId === rowId);
17848 }
17849 function flipItems(items, activeId, shouldInsertNullItem = false) {
17850 const index2 = items.findIndex((item) => item.id === activeId);
17851 return [
17852 ...items.slice(index2 + 1),
17853 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17854 ...items.slice(0, index2)
17855 ];
17856 }
17857 function groupItemsByRows2(items) {
17858 const rows = [];
17859 for (const item of items) {
17860 const row = rows.find((currentRow) => {
17861 var _a;
17862 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17863 });
17864 if (row) {
17865 row.push(item);
17866 } else {
17867 rows.push([item]);
17868 }
17869 }
17870 return rows;
17871 }
17872 function getMaxRowLength(array) {
17873 let maxLength = 0;
17874 for (const { length } of array) {
17875 if (length > maxLength) {
17876 maxLength = length;
17877 }
17878 }
17879 return maxLength;
17880 }
17881 function createEmptyItem(rowId) {
17882 return {
17883 id: "__EMPTY_ITEM__",
17884 disabled: true,
17885 rowId
17886 };
17887 }
17888 function normalizeRows(rows, activeId, focusShift) {
17889 const maxLength = getMaxRowLength(rows);
17890 for (const row of rows) {
17891 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17892 const item = row[i2];
17893 if (!item || focusShift && item.disabled) {
17894 const isFirst = i2 === 0;
17895 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17896 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17897 }
17898 }
17899 }
17900 return rows;
17901 }
17902 function verticalizeItems(items) {
17903 const rows = groupItemsByRows2(items);
17904 const maxLength = getMaxRowLength(rows);
17905 const verticalized = [];
17906 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17907 for (const row of rows) {
17908 const item = row[i2];
17909 if (item) {
17910 verticalized.push({
17911 ...item,
17912 // If there's no rowId, it means that it's not a grid composite, but
17913 // a single row instead. So, instead of verticalizing it, that is,
17914 // assigning a different rowId based on the column index, we keep it
17915 // undefined so they will be part of the same row. This is useful
17916 // when using up/down on one-dimensional composites.
17917 rowId: item.rowId ? `${i2}` : void 0
17918 });
17919 }
17920 }
17921 }
17922 return verticalized;
17923 }
17924 function createCompositeStore(props = {}) {
17925 var _a;
17926 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17927 const collection = createCollectionStore(props);
17928 const activeId = defaultValue(
17929 props.activeId,
17930 syncState == null ? void 0 : syncState.activeId,
17931 props.defaultActiveId
17932 );
17933 const initialState = {
17934 ...collection.getState(),
17935 id: defaultValue(
17936 props.id,
17937 syncState == null ? void 0 : syncState.id,
17938 `id-${Math.random().toString(36).slice(2, 8)}`
17939 ),
17940 activeId,
17941 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17942 includesBaseElement: defaultValue(
17943 props.includesBaseElement,
17944 syncState == null ? void 0 : syncState.includesBaseElement,
17945 activeId === null
17946 ),
17947 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17948 orientation: defaultValue(
17949 props.orientation,
17950 syncState == null ? void 0 : syncState.orientation,
17951 "both"
17952 ),
17953 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17954 virtualFocus: defaultValue(
17955 props.virtualFocus,
17956 syncState == null ? void 0 : syncState.virtualFocus,
17957 false
17958 ),
17959 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17960 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17961 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17962 };
17963 const composite = createStore(initialState, collection, props.store);
17964 setup(
17965 composite,
17966 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17967 composite.setState("activeId", (activeId2) => {
17968 var _a2;
17969 if (activeId2 !== void 0) return activeId2;
17970 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17971 });
17972 })
17973 );
17974 const getNextId = (direction = "next", options = {}) => {
17975 var _a2, _b;
17976 const defaultState = composite.getState();
17977 const {
17978 skip = 0,
17979 activeId: activeId2 = defaultState.activeId,
17980 focusShift = defaultState.focusShift,
17981 focusLoop = defaultState.focusLoop,
17982 focusWrap = defaultState.focusWrap,
17983 includesBaseElement = defaultState.includesBaseElement,
17984 renderedItems = defaultState.renderedItems,
17985 rtl = defaultState.rtl
17986 } = options;
17987 const isVerticalDirection = direction === "up" || direction === "down";
17988 const isNextDirection = direction === "next" || direction === "down";
17989 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17990 const canShift = focusShift && !skip;
17991 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17992 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17993 );
17994 items = canReverse ? reverseArray(items) : items;
17995 items = isVerticalDirection ? verticalizeItems(items) : items;
17996 if (activeId2 == null) {
17997 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17998 }
17999 const activeItem = items.find((item) => item.id === activeId2);
18000 if (!activeItem) {
18001 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
18002 }
18003 const isGrid2 = items.some((item) => item.rowId);
18004 const activeIndex = items.indexOf(activeItem);
18005 const nextItems = items.slice(activeIndex + 1);
18006 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
18007 if (skip) {
18008 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
18009 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
18010 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
18011 return nextItem2 == null ? void 0 : nextItem2.id;
18012 }
18013 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
18014 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
18015 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
18016 if (canLoop) {
18017 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
18018 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
18019 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
18020 return nextItem2 == null ? void 0 : nextItem2.id;
18021 }
18022 if (canWrap) {
18023 const nextItem2 = findFirstEnabledItem2(
18024 // We can use nextItems, which contains all the next items, including
18025 // items from other rows, to wrap between rows. However, if there is a
18026 // null item (the composite container), we'll only use the next items in
18027 // the row. So moving next from the last item will focus on the
18028 // composite container. On grid composites, horizontal navigation never
18029 // focuses on the composite container, only vertical.
18030 hasNullItem ? nextItemsInRow : nextItems,
18031 activeId2
18032 );
18033 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
18034 return nextId;
18035 }
18036 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
18037 if (!nextItem && hasNullItem) {
18038 return null;
18039 }
18040 return nextItem == null ? void 0 : nextItem.id;
18041 };
18042 return {
18043 ...collection,
18044 ...composite,
18045 setBaseElement: (element) => composite.setState("baseElement", element),
18046 setActiveId: (id) => composite.setState("activeId", id),
18047 move: (id) => {
18048 if (id === void 0) return;
18049 composite.setState("activeId", id);
18050 composite.setState("moves", (moves) => moves + 1);
18051 },
18052 first: () => {
18053 var _a2;
18054 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
18055 },
18056 last: () => {
18057 var _a2;
18058 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
18059 },
18060 next: (options) => {
18061 if (options !== void 0 && typeof options === "number") {
18062 options = { skip: options };
18063 }
18064 return getNextId("next", options);
18065 },
18066 previous: (options) => {
18067 if (options !== void 0 && typeof options === "number") {
18068 options = { skip: options };
18069 }
18070 return getNextId("previous", options);
18071 },
18072 down: (options) => {
18073 if (options !== void 0 && typeof options === "number") {
18074 options = { skip: options };
18075 }
18076 return getNextId("down", options);
18077 },
18078 up: (options) => {
18079 if (options !== void 0 && typeof options === "number") {
18080 options = { skip: options };
18081 }
18082 return getNextId("up", options);
18083 }
18084 };
18085 }
18086
18087 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
18088 function useCompositeStoreOptions(props) {
18089 const id = useId4(props.id);
18090 return { id, ...props };
18091 }
18092 function useCompositeStoreProps(store, update2, props) {
18093 store = useCollectionStoreProps(store, update2, props);
18094 useStoreProps(store, props, "activeId", "setActiveId");
18095 useStoreProps(store, props, "includesBaseElement");
18096 useStoreProps(store, props, "virtualFocus");
18097 useStoreProps(store, props, "orientation");
18098 useStoreProps(store, props, "rtl");
18099 useStoreProps(store, props, "focusLoop");
18100 useStoreProps(store, props, "focusWrap");
18101 useStoreProps(store, props, "focusShift");
18102 return store;
18103 }
18104
18105 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
18106 var import_react22 = __toESM(require_react(), 1);
18107 var ComboboxListRoleContext = (0, import_react22.createContext)(
18108 void 0
18109 );
18110 var ctx6 = createStoreContext(
18111 [PopoverContextProvider, CompositeContextProvider],
18112 [PopoverScopedContextProvider, CompositeScopedContextProvider]
18113 );
18114 var useComboboxContext = ctx6.useContext;
18115 var useComboboxScopedContext = ctx6.useScopedContext;
18116 var useComboboxProviderContext = ctx6.useProviderContext;
18117 var ComboboxContextProvider = ctx6.ContextProvider;
18118 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
18119 var ComboboxItemValueContext = (0, import_react22.createContext)(
18120 void 0
18121 );
18122 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
18123
18124 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
18125 function createDialogStore(props = {}) {
18126 return createDisclosureStore(props);
18127 }
18128
18129 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
18130 function useDialogStoreProps(store, update2, props) {
18131 return useDisclosureStoreProps(store, update2, props);
18132 }
18133
18134 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
18135 function createPopoverStore({
18136 popover: otherPopover,
18137 ...props
18138 } = {}) {
18139 const store = mergeStore(
18140 props.store,
18141 omit2(otherPopover, [
18142 "arrowElement",
18143 "anchorElement",
18144 "contentElement",
18145 "popoverElement",
18146 "disclosureElement"
18147 ])
18148 );
18149 throwOnConflictingProps(props, store);
18150 const syncState = store == null ? void 0 : store.getState();
18151 const dialog = createDialogStore({ ...props, store });
18152 const placement = defaultValue(
18153 props.placement,
18154 syncState == null ? void 0 : syncState.placement,
18155 "bottom"
18156 );
18157 const initialState = {
18158 ...dialog.getState(),
18159 placement,
18160 currentPlacement: placement,
18161 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
18162 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
18163 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
18164 rendered: /* @__PURE__ */ Symbol("rendered")
18165 };
18166 const popover = createStore(initialState, dialog, store);
18167 return {
18168 ...dialog,
18169 ...popover,
18170 setAnchorElement: (element) => popover.setState("anchorElement", element),
18171 setPopoverElement: (element) => popover.setState("popoverElement", element),
18172 setArrowElement: (element) => popover.setState("arrowElement", element),
18173 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
18174 };
18175 }
18176
18177 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
18178 function usePopoverStoreProps(store, update2, props) {
18179 useUpdateEffect(update2, [props.popover]);
18180 useStoreProps(store, props, "placement");
18181 return useDialogStoreProps(store, update2, props);
18182 }
18183
18184 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
18185 var TagName7 = "div";
18186 var usePopoverAnchor = createHook(
18187 function usePopoverAnchor2({ store, ...props }) {
18188 const context = usePopoverProviderContext();
18189 store = store || context;
18190 props = {
18191 ...props,
18192 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
18193 };
18194 return props;
18195 }
18196 );
18197 var PopoverAnchor = forwardRef210(function PopoverAnchor2(props) {
18198 const htmlProps = usePopoverAnchor(props);
18199 return createElement3(TagName7, htmlProps);
18200 });
18201
18202 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
18203 var import_react23 = __toESM(require_react(), 1);
18204 var TagName8 = "div";
18205 function getMouseDestination(event) {
18206 const relatedTarget = event.relatedTarget;
18207 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
18208 return relatedTarget;
18209 }
18210 return null;
18211 }
18212 function hoveringInside(event) {
18213 const nextElement = getMouseDestination(event);
18214 if (!nextElement) return false;
18215 return contains2(event.currentTarget, nextElement);
18216 }
18217 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
18218 function movingToAnotherItem(event) {
18219 let dest = getMouseDestination(event);
18220 if (!dest) return false;
18221 do {
18222 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
18223 dest = dest.parentElement;
18224 } while (dest);
18225 return false;
18226 }
18227 var useCompositeHover = createHook(
18228 function useCompositeHover2({
18229 store,
18230 focusOnHover = true,
18231 blurOnHoverEnd = !!focusOnHover,
18232 ...props
18233 }) {
18234 const context = useCompositeContext();
18235 store = store || context;
18236 invariant(
18237 store,
18238 "CompositeHover must be wrapped in a Composite component."
18239 );
18240 const isMouseMoving = useIsMouseMoving();
18241 const onMouseMoveProp = props.onMouseMove;
18242 const focusOnHoverProp = useBooleanEvent(focusOnHover);
18243 const onMouseMove = useEvent((event) => {
18244 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
18245 if (event.defaultPrevented) return;
18246 if (!isMouseMoving()) return;
18247 if (!focusOnHoverProp(event)) return;
18248 if (!hasFocusWithin(event.currentTarget)) {
18249 const baseElement = store == null ? void 0 : store.getState().baseElement;
18250 if (baseElement && !hasFocus(baseElement)) {
18251 baseElement.focus();
18252 }
18253 }
18254 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
18255 });
18256 const onMouseLeaveProp = props.onMouseLeave;
18257 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
18258 const onMouseLeave = useEvent((event) => {
18259 var _a;
18260 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
18261 if (event.defaultPrevented) return;
18262 if (!isMouseMoving()) return;
18263 if (hoveringInside(event)) return;
18264 if (movingToAnotherItem(event)) return;
18265 if (!focusOnHoverProp(event)) return;
18266 if (!blurOnHoverEndProp(event)) return;
18267 store == null ? void 0 : store.setActiveId(null);
18268 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
18269 });
18270 const ref = (0, import_react23.useCallback)((element) => {
18271 if (!element) return;
18272 element[symbol2] = true;
18273 }, []);
18274 props = {
18275 ...props,
18276 ref: useMergeRefs(ref, props.ref),
18277 onMouseMove,
18278 onMouseLeave
18279 };
18280 return removeUndefinedValues(props);
18281 }
18282 );
18283 var CompositeHover = memo22(
18284 forwardRef210(function CompositeHover2(props) {
18285 const htmlProps = useCompositeHover(props);
18286 return createElement3(TagName8, htmlProps);
18287 })
18288 );
18289
18290 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
18291 var import_react24 = __toESM(require_react(), 1);
18292 var TagName9 = "input";
18293 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
18294 if (!autoSelect) return false;
18295 const firstItem = items.find((item) => !item.disabled && item.value);
18296 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
18297 }
18298 function hasCompletionString(value, activeValue) {
18299 if (!activeValue) return false;
18300 if (value == null) return false;
18301 value = normalizeString(value);
18302 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
18303 }
18304 function isInputEvent(event) {
18305 return event.type === "input";
18306 }
18307 function isAriaAutoCompleteValue(value) {
18308 return value === "inline" || value === "list" || value === "both" || value === "none";
18309 }
18310 function getDefaultAutoSelectId(items) {
18311 const item = items.find((item2) => {
18312 var _a;
18313 if (item2.disabled) return false;
18314 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
18315 });
18316 return item == null ? void 0 : item.id;
18317 }
18318 var useCombobox = createHook(
18319 function useCombobox2({
18320 store,
18321 focusable: focusable2 = true,
18322 autoSelect: autoSelectProp = false,
18323 getAutoSelectId,
18324 setValueOnChange,
18325 showMinLength = 0,
18326 showOnChange,
18327 showOnMouseDown,
18328 showOnClick = showOnMouseDown,
18329 showOnKeyDown,
18330 showOnKeyPress = showOnKeyDown,
18331 blurActiveItemOnClick,
18332 setValueOnClick = true,
18333 moveOnKeyPress = true,
18334 autoComplete = "list",
18335 ...props
18336 }) {
18337 const context = useComboboxProviderContext();
18338 store = store || context;
18339 invariant(
18340 store,
18341 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
18342 );
18343 const ref = (0, import_react24.useRef)(null);
18344 const [valueUpdated, forceValueUpdate] = useForceUpdate();
18345 const canAutoSelectRef = (0, import_react24.useRef)(false);
18346 const composingRef = (0, import_react24.useRef)(false);
18347 const autoSelect = store.useState(
18348 (state) => state.virtualFocus && autoSelectProp
18349 );
18350 const inline4 = autoComplete === "inline" || autoComplete === "both";
18351 const [canInline, setCanInline] = (0, import_react24.useState)(inline4);
18352 useUpdateLayoutEffect(() => {
18353 if (!inline4) return;
18354 setCanInline(true);
18355 }, [inline4]);
18356 const storeValue = store.useState("value");
18357 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
18358 (0, import_react24.useEffect)(() => {
18359 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
18360 prevSelectedValueRef.current = prev.selectedValue;
18361 });
18362 }, []);
18363 const inlineActiveValue = store.useState((state) => {
18364 var _a;
18365 if (!inline4) return;
18366 if (!canInline) return;
18367 if (state.activeValue && Array.isArray(state.selectedValue)) {
18368 if (state.selectedValue.includes(state.activeValue)) return;
18369 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
18370 }
18371 return state.activeValue;
18372 });
18373 const items = store.useState("renderedItems");
18374 const open = store.useState("open");
18375 const contentElement = store.useState("contentElement");
18376 const value = (0, import_react24.useMemo)(() => {
18377 if (!inline4) return storeValue;
18378 if (!canInline) return storeValue;
18379 const firstItemAutoSelected = isFirstItemAutoSelected(
18380 items,
18381 inlineActiveValue,
18382 autoSelect
18383 );
18384 if (firstItemAutoSelected) {
18385 if (hasCompletionString(storeValue, inlineActiveValue)) {
18386 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
18387 return storeValue + slice;
18388 }
18389 return storeValue;
18390 }
18391 return inlineActiveValue || storeValue;
18392 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
18393 (0, import_react24.useEffect)(() => {
18394 const element = ref.current;
18395 if (!element) return;
18396 const onCompositeItemMove = () => setCanInline(true);
18397 element.addEventListener("combobox-item-move", onCompositeItemMove);
18398 return () => {
18399 element.removeEventListener("combobox-item-move", onCompositeItemMove);
18400 };
18401 }, []);
18402 (0, import_react24.useEffect)(() => {
18403 if (!inline4) return;
18404 if (!canInline) return;
18405 if (!inlineActiveValue) return;
18406 const firstItemAutoSelected = isFirstItemAutoSelected(
18407 items,
18408 inlineActiveValue,
18409 autoSelect
18410 );
18411 if (!firstItemAutoSelected) return;
18412 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
18413 let cleanup = noop4;
18414 queueMicrotask(() => {
18415 const element = ref.current;
18416 if (!element) return;
18417 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
18418 const nextStart = storeValue.length;
18419 const nextEnd = inlineActiveValue.length;
18420 setSelectionRange(element, nextStart, nextEnd);
18421 cleanup = () => {
18422 if (!hasFocus(element)) return;
18423 const { start, end } = getTextboxSelection(element);
18424 if (start !== nextStart) return;
18425 if (end !== nextEnd) return;
18426 setSelectionRange(element, prevStart, prevEnd);
18427 };
18428 });
18429 return () => cleanup();
18430 }, [
18431 valueUpdated,
18432 inline4,
18433 canInline,
18434 inlineActiveValue,
18435 items,
18436 autoSelect,
18437 storeValue
18438 ]);
18439 const scrollingElementRef = (0, import_react24.useRef)(null);
18440 const getAutoSelectIdProp = useEvent(getAutoSelectId);
18441 const autoSelectIdRef = (0, import_react24.useRef)(null);
18442 (0, import_react24.useEffect)(() => {
18443 if (!open) return;
18444 if (!contentElement) return;
18445 const scrollingElement = getScrollingElement(contentElement);
18446 if (!scrollingElement) return;
18447 scrollingElementRef.current = scrollingElement;
18448 const onUserScroll = () => {
18449 canAutoSelectRef.current = false;
18450 };
18451 const onScroll = () => {
18452 if (!store) return;
18453 if (!canAutoSelectRef.current) return;
18454 const { activeId } = store.getState();
18455 if (activeId === null) return;
18456 if (activeId === autoSelectIdRef.current) return;
18457 canAutoSelectRef.current = false;
18458 };
18459 const options = { passive: true, capture: true };
18460 scrollingElement.addEventListener("wheel", onUserScroll, options);
18461 scrollingElement.addEventListener("touchmove", onUserScroll, options);
18462 scrollingElement.addEventListener("scroll", onScroll, options);
18463 return () => {
18464 scrollingElement.removeEventListener("wheel", onUserScroll, true);
18465 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
18466 scrollingElement.removeEventListener("scroll", onScroll, true);
18467 };
18468 }, [open, contentElement, store]);
18469 useSafeLayoutEffect(() => {
18470 if (!storeValue) return;
18471 if (composingRef.current) return;
18472 canAutoSelectRef.current = true;
18473 }, [storeValue]);
18474 useSafeLayoutEffect(() => {
18475 if (autoSelect !== "always" && open) return;
18476 canAutoSelectRef.current = open;
18477 }, [autoSelect, open]);
18478 const resetValueOnSelect = store.useState("resetValueOnSelect");
18479 useUpdateEffect(() => {
18480 var _a, _b;
18481 const canAutoSelect = canAutoSelectRef.current;
18482 if (!store) return;
18483 if (!open) return;
18484 if (!canAutoSelect && !resetValueOnSelect) return;
18485 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18486 if (baseElement && !hasFocus(baseElement)) return;
18487 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
18488 const observer = new MutationObserver(forceValueUpdate);
18489 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18490 return () => observer.disconnect();
18491 }
18492 if (autoSelect && canAutoSelect) {
18493 const userAutoSelectId = getAutoSelectIdProp(items);
18494 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
18495 autoSelectIdRef.current = autoSelectId;
18496 store.move(autoSelectId != null ? autoSelectId : null);
18497 } else {
18498 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
18499 if (element && "scrollIntoView" in element) {
18500 element.scrollIntoView({ block: "nearest", inline: "nearest" });
18501 }
18502 }
18503 return;
18504 }, [
18505 store,
18506 open,
18507 valueUpdated,
18508 storeValue,
18509 autoSelect,
18510 resetValueOnSelect,
18511 getAutoSelectIdProp,
18512 items
18513 ]);
18514 (0, import_react24.useEffect)(() => {
18515 if (!inline4) return;
18516 const combobox = ref.current;
18517 if (!combobox) return;
18518 const elements = [combobox, contentElement].filter(
18519 (value2) => !!value2
18520 );
18521 const onBlur2 = (event) => {
18522 if (elements.every((el) => isFocusEventOutside(event, el))) {
18523 store == null ? void 0 : store.setValue(value);
18524 }
18525 };
18526 for (const element of elements) {
18527 element.addEventListener("focusout", onBlur2);
18528 }
18529 return () => {
18530 for (const element of elements) {
18531 element.removeEventListener("focusout", onBlur2);
18532 }
18533 };
18534 }, [inline4, contentElement, store, value]);
18535 const canShow = (event) => {
18536 const currentTarget = event.currentTarget;
18537 return currentTarget.value.length >= showMinLength;
18538 };
18539 const onChangeProp = props.onChange;
18540 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
18541 const setValueOnChangeProp = useBooleanEvent(
18542 // If the combobox is combined with tags, the value will be set by the tag
18543 // input component.
18544 setValueOnChange != null ? setValueOnChange : !store.tag
18545 );
18546 const onChange = useEvent((event) => {
18547 onChangeProp == null ? void 0 : onChangeProp(event);
18548 if (event.defaultPrevented) return;
18549 if (!store) return;
18550 const currentTarget = event.currentTarget;
18551 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18552 const nativeEvent = event.nativeEvent;
18553 canAutoSelectRef.current = true;
18554 if (isInputEvent(nativeEvent)) {
18555 if (nativeEvent.isComposing) {
18556 canAutoSelectRef.current = false;
18557 composingRef.current = true;
18558 }
18559 if (inline4) {
18560 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18561 const caretAtEnd = selectionStart === value2.length;
18562 setCanInline(textInserted && caretAtEnd);
18563 }
18564 }
18565 if (setValueOnChangeProp(event)) {
18566 const isSameValue = value2 === store.getState().value;
18567 store.setValue(value2);
18568 queueMicrotask(() => {
18569 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18570 });
18571 if (inline4 && autoSelect && isSameValue) {
18572 forceValueUpdate();
18573 }
18574 }
18575 if (showOnChangeProp(event)) {
18576 store.show();
18577 }
18578 if (!autoSelect || !canAutoSelectRef.current) {
18579 store.setActiveId(null);
18580 }
18581 });
18582 const onCompositionEndProp = props.onCompositionEnd;
18583 const onCompositionEnd = useEvent((event) => {
18584 canAutoSelectRef.current = true;
18585 composingRef.current = false;
18586 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
18587 if (event.defaultPrevented) return;
18588 if (!autoSelect) return;
18589 forceValueUpdate();
18590 });
18591 const onMouseDownProp = props.onMouseDown;
18592 const blurActiveItemOnClickProp = useBooleanEvent(
18593 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
18594 );
18595 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18596 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
18597 const onMouseDown = useEvent((event) => {
18598 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18599 if (event.defaultPrevented) return;
18600 if (event.button) return;
18601 if (event.ctrlKey) return;
18602 if (!store) return;
18603 if (blurActiveItemOnClickProp(event)) {
18604 store.setActiveId(null);
18605 }
18606 if (setValueOnClickProp(event)) {
18607 store.setValue(value);
18608 }
18609 if (showOnClickProp(event)) {
18610 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18611 }
18612 });
18613 const onKeyDownProp = props.onKeyDown;
18614 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
18615 const onKeyDown = useEvent((event) => {
18616 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18617 if (!event.repeat) {
18618 canAutoSelectRef.current = false;
18619 }
18620 if (event.defaultPrevented) return;
18621 if (event.ctrlKey) return;
18622 if (event.altKey) return;
18623 if (event.shiftKey) return;
18624 if (event.metaKey) return;
18625 if (!store) return;
18626 const { open: open2 } = store.getState();
18627 if (open2) return;
18628 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18629 if (showOnKeyPressProp(event)) {
18630 event.preventDefault();
18631 store.show();
18632 }
18633 }
18634 });
18635 const onBlurProp = props.onBlur;
18636 const onBlur = useEvent((event) => {
18637 canAutoSelectRef.current = false;
18638 onBlurProp == null ? void 0 : onBlurProp(event);
18639 if (event.defaultPrevented) return;
18640 });
18641 const id = useId4(props.id);
18642 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18643 const isActiveItem = store.useState((state) => state.activeId === null);
18644 props = {
18645 id,
18646 role: "combobox",
18647 "aria-autocomplete": ariaAutoComplete,
18648 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18649 "aria-expanded": open,
18650 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18651 "data-active-item": isActiveItem || void 0,
18652 value,
18653 ...props,
18654 ref: useMergeRefs(ref, props.ref),
18655 onChange,
18656 onCompositionEnd,
18657 onMouseDown,
18658 onKeyDown,
18659 onBlur
18660 };
18661 props = useComposite({
18662 store,
18663 focusable: focusable2,
18664 ...props,
18665 // Enable inline autocomplete when the user moves from the combobox input
18666 // to an item.
18667 moveOnKeyPress: (event) => {
18668 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18669 if (inline4) setCanInline(true);
18670 return true;
18671 }
18672 });
18673 props = usePopoverAnchor({ store, ...props });
18674 return { autoComplete: "off", ...props };
18675 }
18676 );
18677 var Combobox = forwardRef210(function Combobox2(props) {
18678 const htmlProps = useCombobox(props);
18679 return createElement3(TagName9, htmlProps);
18680 });
18681
18682 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18683 var import_react25 = __toESM(require_react(), 1);
18684 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
18685 var TagName10 = "div";
18686 function isSelected(storeValue, itemValue) {
18687 if (itemValue == null) return;
18688 if (storeValue == null) return false;
18689 if (Array.isArray(storeValue)) {
18690 return storeValue.includes(itemValue);
18691 }
18692 return storeValue === itemValue;
18693 }
18694 function getItemRole(popupRole) {
18695 var _a;
18696 const itemRoleByPopupRole = {
18697 menu: "menuitem",
18698 listbox: "option",
18699 tree: "treeitem"
18700 };
18701 const key = popupRole;
18702 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18703 }
18704 var useComboboxItem = createHook(
18705 function useComboboxItem2({
18706 store,
18707 value,
18708 hideOnClick,
18709 setValueOnClick,
18710 selectValueOnClick = true,
18711 resetValueOnSelect,
18712 focusOnHover = false,
18713 moveOnKeyPress = true,
18714 getItem: getItemProp,
18715 ...props
18716 }) {
18717 var _a;
18718 const context = useComboboxScopedContext();
18719 store = store || context;
18720 invariant(
18721 store,
18722 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18723 );
18724 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18725 resetValueOnSelectState: "resetValueOnSelect",
18726 multiSelectable(state) {
18727 return Array.isArray(state.selectedValue);
18728 },
18729 selected(state) {
18730 return isSelected(state.selectedValue, value);
18731 }
18732 });
18733 const getItem = (0, import_react25.useCallback)(
18734 (item) => {
18735 const nextItem = { ...item, value };
18736 if (getItemProp) {
18737 return getItemProp(nextItem);
18738 }
18739 return nextItem;
18740 },
18741 [value, getItemProp]
18742 );
18743 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18744 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18745 const onClickProp = props.onClick;
18746 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18747 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18748 const resetValueOnSelectProp = useBooleanEvent(
18749 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18750 );
18751 const hideOnClickProp = useBooleanEvent(hideOnClick);
18752 const onClick = useEvent((event) => {
18753 onClickProp == null ? void 0 : onClickProp(event);
18754 if (event.defaultPrevented) return;
18755 if (isDownloading(event)) return;
18756 if (isOpeningInNewTab(event)) return;
18757 if (value != null) {
18758 if (selectValueOnClickProp(event)) {
18759 if (resetValueOnSelectProp(event)) {
18760 store == null ? void 0 : store.resetValue();
18761 }
18762 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18763 if (!Array.isArray(prevValue)) return value;
18764 if (prevValue.includes(value)) {
18765 return prevValue.filter((v2) => v2 !== value);
18766 }
18767 return [...prevValue, value];
18768 });
18769 }
18770 if (setValueOnClickProp(event)) {
18771 store == null ? void 0 : store.setValue(value);
18772 }
18773 }
18774 if (hideOnClickProp(event)) {
18775 store == null ? void 0 : store.hide();
18776 }
18777 });
18778 const onKeyDownProp = props.onKeyDown;
18779 const onKeyDown = useEvent((event) => {
18780 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18781 if (event.defaultPrevented) return;
18782 const baseElement = store == null ? void 0 : store.getState().baseElement;
18783 if (!baseElement) return;
18784 if (hasFocus(baseElement)) return;
18785 const printable = event.key.length === 1;
18786 if (printable || event.key === "Backspace" || event.key === "Delete") {
18787 queueMicrotask(() => baseElement.focus());
18788 if (isTextField(baseElement)) {
18789 store == null ? void 0 : store.setValue(baseElement.value);
18790 }
18791 }
18792 });
18793 if (multiSelectable && selected != null) {
18794 props = {
18795 "aria-selected": selected,
18796 ...props
18797 };
18798 }
18799 props = useWrapElement(
18800 props,
18801 (element) => /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
18802 [value, selected]
18803 );
18804 const popupRole = (0, import_react25.useContext)(ComboboxListRoleContext);
18805 props = {
18806 role: getItemRole(popupRole),
18807 children: value,
18808 ...props,
18809 onClick,
18810 onKeyDown
18811 };
18812 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18813 props = useCompositeItem({
18814 store,
18815 ...props,
18816 getItem,
18817 // Dispatch a custom event on the combobox input when moving to an item
18818 // with the keyboard so the Combobox component can enable inline
18819 // autocompletion.
18820 moveOnKeyPress: (event) => {
18821 if (!moveOnKeyPressProp(event)) return false;
18822 const moveEvent = new Event("combobox-item-move");
18823 const baseElement = store == null ? void 0 : store.getState().baseElement;
18824 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18825 return true;
18826 }
18827 });
18828 props = useCompositeHover({ store, focusOnHover, ...props });
18829 return props;
18830 }
18831 );
18832 var ComboboxItem = memo22(
18833 forwardRef210(function ComboboxItem2(props) {
18834 const htmlProps = useComboboxItem(props);
18835 return createElement3(TagName10, htmlProps);
18836 })
18837 );
18838
18839 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18840 var import_react26 = __toESM(require_react(), 1);
18841 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
18842 var TagName11 = "span";
18843 function normalizeValue(value) {
18844 return normalizeString(value).toLowerCase();
18845 }
18846 function getOffsets(string, values) {
18847 const offsets = [];
18848 for (const value of values) {
18849 let pos = 0;
18850 const length = value.length;
18851 while (string.indexOf(value, pos) !== -1) {
18852 const index2 = string.indexOf(value, pos);
18853 if (index2 !== -1) {
18854 offsets.push([index2, length]);
18855 }
18856 pos = index2 + 1;
18857 }
18858 }
18859 return offsets;
18860 }
18861 function filterOverlappingOffsets(offsets) {
18862 return offsets.filter(([offset4, length], i2, arr) => {
18863 return !arr.some(
18864 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18865 );
18866 });
18867 }
18868 function sortOffsets(offsets) {
18869 return offsets.sort(([a2], [b2]) => a2 - b2);
18870 }
18871 function splitValue(itemValue, userValue) {
18872 if (!itemValue) return itemValue;
18873 if (!userValue) return itemValue;
18874 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18875 const parts = [];
18876 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
18877 "span",
18878 {
18879 "data-autocomplete-value": autocomplete ? "" : void 0,
18880 "data-user-value": autocomplete ? void 0 : "",
18881 children: value
18882 },
18883 parts.length
18884 );
18885 const offsets = sortOffsets(
18886 filterOverlappingOffsets(
18887 // Convert userValues into a set to avoid duplicates
18888 getOffsets(normalizeValue(itemValue), new Set(userValues))
18889 )
18890 );
18891 if (!offsets.length) {
18892 parts.push(span(itemValue, true));
18893 return parts;
18894 }
18895 const [firstOffset] = offsets[0];
18896 const values = [
18897 itemValue.slice(0, firstOffset),
18898 ...offsets.flatMap(([offset4, length], i2) => {
18899 var _a;
18900 const value = itemValue.slice(offset4, offset4 + length);
18901 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18902 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18903 return [value, nextValue];
18904 })
18905 ];
18906 values.forEach((value, i2) => {
18907 if (!value) return;
18908 parts.push(span(value, i2 % 2 === 0));
18909 });
18910 return parts;
18911 }
18912 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18913 const context = useComboboxScopedContext();
18914 store = store || context;
18915 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
18916 const itemValue = value != null ? value : itemContext;
18917 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18918 const children = (0, import_react26.useMemo)(() => {
18919 if (!itemValue) return;
18920 if (!inputValue) return itemValue;
18921 return splitValue(itemValue, inputValue);
18922 }, [itemValue, inputValue]);
18923 props = {
18924 children,
18925 ...props
18926 };
18927 return removeUndefinedValues(props);
18928 });
18929 var ComboboxItemValue = forwardRef210(function ComboboxItemValue2(props) {
18930 const htmlProps = useComboboxItemValue(props);
18931 return createElement3(TagName11, htmlProps);
18932 });
18933
18934 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18935 var TagName12 = "label";
18936 var useComboboxLabel = createHook(
18937 function useComboboxLabel2({ store, ...props }) {
18938 const context = useComboboxProviderContext();
18939 store = store || context;
18940 invariant(
18941 store,
18942 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18943 );
18944 const comboboxId = store.useState((state) => {
18945 var _a;
18946 return (_a = state.baseElement) == null ? void 0 : _a.id;
18947 });
18948 props = {
18949 htmlFor: comboboxId,
18950 ...props
18951 };
18952 return removeUndefinedValues(props);
18953 }
18954 );
18955 var ComboboxLabel = memo22(
18956 forwardRef210(function ComboboxLabel2(props) {
18957 const htmlProps = useComboboxLabel(props);
18958 return createElement3(TagName12, htmlProps);
18959 })
18960 );
18961
18962 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18963 var import_react27 = __toESM(require_react(), 1);
18964 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
18965 var TagName13 = "div";
18966 var useComboboxList = createHook(
18967 function useComboboxList2({ store, alwaysVisible, ...props }) {
18968 const scopedContext = useComboboxScopedContext(true);
18969 const context = useComboboxContext();
18970 store = store || context;
18971 const scopedContextSameStore = !!store && store === scopedContext;
18972 invariant(
18973 store,
18974 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18975 );
18976 const ref = (0, import_react27.useRef)(null);
18977 const id = useId4(props.id);
18978 const mounted = store.useState("mounted");
18979 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18980 const style = hidden ? { ...props.style, display: "none" } : props.style;
18981 const multiSelectable = store.useState(
18982 (state) => Array.isArray(state.selectedValue)
18983 );
18984 const role = useAttribute(ref, "role", props.role);
18985 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18986 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18987 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
18988 const contentElement = store.useState("contentElement");
18989 useSafeLayoutEffect(() => {
18990 if (!mounted) return;
18991 const element = ref.current;
18992 if (!element) return;
18993 if (contentElement !== element) return;
18994 const callback = () => {
18995 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18996 };
18997 const observer = new MutationObserver(callback);
18998 observer.observe(element, {
18999 subtree: true,
19000 childList: true,
19001 attributeFilter: ["role"]
19002 });
19003 callback();
19004 return () => observer.disconnect();
19005 }, [mounted, contentElement]);
19006 if (!hasListboxInside) {
19007 props = {
19008 role: "listbox",
19009 "aria-multiselectable": ariaMultiSelectable,
19010 ...props
19011 };
19012 }
19013 props = useWrapElement(
19014 props,
19015 (element) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
19016 [store, role]
19017 );
19018 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
19019 props = {
19020 id,
19021 hidden,
19022 ...props,
19023 ref: useMergeRefs(setContentElement, ref, props.ref),
19024 style
19025 };
19026 return removeUndefinedValues(props);
19027 }
19028 );
19029 var ComboboxList = forwardRef210(function ComboboxList2(props) {
19030 const htmlProps = useComboboxList(props);
19031 return createElement3(TagName13, htmlProps);
19032 });
19033
19034 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
19035 var import_react28 = __toESM(require_react(), 1);
19036 var TagValueContext = (0, import_react28.createContext)(null);
19037 var TagRemoveIdContext = (0, import_react28.createContext)(
19038 null
19039 );
19040 var ctx7 = createStoreContext(
19041 [CompositeContextProvider],
19042 [CompositeScopedContextProvider]
19043 );
19044 var useTagContext = ctx7.useContext;
19045 var useTagScopedContext = ctx7.useScopedContext;
19046 var useTagProviderContext = ctx7.useProviderContext;
19047 var TagContextProvider = ctx7.ContextProvider;
19048 var TagScopedContextProvider = ctx7.ScopedContextProvider;
19049
19050 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
19051 var isTouchSafari = isSafari2() && isTouchDevice();
19052 function createComboboxStore({
19053 tag,
19054 ...props
19055 } = {}) {
19056 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
19057 throwOnConflictingProps(props, store);
19058 const tagState = tag == null ? void 0 : tag.getState();
19059 const syncState = store == null ? void 0 : store.getState();
19060 const activeId = defaultValue(
19061 props.activeId,
19062 syncState == null ? void 0 : syncState.activeId,
19063 props.defaultActiveId,
19064 null
19065 );
19066 const composite = createCompositeStore({
19067 ...props,
19068 activeId,
19069 includesBaseElement: defaultValue(
19070 props.includesBaseElement,
19071 syncState == null ? void 0 : syncState.includesBaseElement,
19072 true
19073 ),
19074 orientation: defaultValue(
19075 props.orientation,
19076 syncState == null ? void 0 : syncState.orientation,
19077 "vertical"
19078 ),
19079 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
19080 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
19081 virtualFocus: defaultValue(
19082 props.virtualFocus,
19083 syncState == null ? void 0 : syncState.virtualFocus,
19084 true
19085 )
19086 });
19087 const popover = createPopoverStore({
19088 ...props,
19089 placement: defaultValue(
19090 props.placement,
19091 syncState == null ? void 0 : syncState.placement,
19092 "bottom-start"
19093 )
19094 });
19095 const value = defaultValue(
19096 props.value,
19097 syncState == null ? void 0 : syncState.value,
19098 props.defaultValue,
19099 ""
19100 );
19101 const selectedValue = defaultValue(
19102 props.selectedValue,
19103 syncState == null ? void 0 : syncState.selectedValue,
19104 tagState == null ? void 0 : tagState.values,
19105 props.defaultSelectedValue,
19106 ""
19107 );
19108 const multiSelectable = Array.isArray(selectedValue);
19109 const initialState = {
19110 ...composite.getState(),
19111 ...popover.getState(),
19112 value,
19113 selectedValue,
19114 resetValueOnSelect: defaultValue(
19115 props.resetValueOnSelect,
19116 syncState == null ? void 0 : syncState.resetValueOnSelect,
19117 multiSelectable
19118 ),
19119 resetValueOnHide: defaultValue(
19120 props.resetValueOnHide,
19121 syncState == null ? void 0 : syncState.resetValueOnHide,
19122 multiSelectable && !tag
19123 ),
19124 activeValue: syncState == null ? void 0 : syncState.activeValue
19125 };
19126 const combobox = createStore(initialState, composite, popover, store);
19127 if (isTouchSafari) {
19128 setup(
19129 combobox,
19130 () => sync(combobox, ["virtualFocus"], () => {
19131 combobox.setState("virtualFocus", false);
19132 })
19133 );
19134 }
19135 setup(combobox, () => {
19136 if (!tag) return;
19137 return chain(
19138 sync(combobox, ["selectedValue"], (state) => {
19139 if (!Array.isArray(state.selectedValue)) return;
19140 tag.setValues(state.selectedValue);
19141 }),
19142 sync(tag, ["values"], (state) => {
19143 combobox.setState("selectedValue", state.values);
19144 })
19145 );
19146 });
19147 setup(
19148 combobox,
19149 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
19150 if (!state.resetValueOnHide) return;
19151 if (state.mounted) return;
19152 combobox.setState("value", value);
19153 })
19154 );
19155 setup(
19156 combobox,
19157 () => sync(combobox, ["open"], (state) => {
19158 if (state.open) return;
19159 combobox.setState("activeId", activeId);
19160 combobox.setState("moves", 0);
19161 })
19162 );
19163 setup(
19164 combobox,
19165 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
19166 if (state.moves === prevState.moves) {
19167 combobox.setState("activeValue", void 0);
19168 }
19169 })
19170 );
19171 setup(
19172 combobox,
19173 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
19174 if (state.moves === prev.moves) return;
19175 const { activeId: activeId2 } = combobox.getState();
19176 const activeItem = composite.item(activeId2);
19177 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
19178 })
19179 );
19180 return {
19181 ...popover,
19182 ...composite,
19183 ...combobox,
19184 tag,
19185 setValue: (value2) => combobox.setState("value", value2),
19186 resetValue: () => combobox.setState("value", initialState.value),
19187 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
19188 };
19189 }
19190
19191 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
19192 function useComboboxStoreOptions(props) {
19193 const tag = useTagContext();
19194 props = {
19195 ...props,
19196 tag: props.tag !== void 0 ? props.tag : tag
19197 };
19198 return useCompositeStoreOptions(props);
19199 }
19200 function useComboboxStoreProps(store, update2, props) {
19201 useUpdateEffect(update2, [props.tag]);
19202 useStoreProps(store, props, "value", "setValue");
19203 useStoreProps(store, props, "selectedValue", "setSelectedValue");
19204 useStoreProps(store, props, "resetValueOnHide");
19205 useStoreProps(store, props, "resetValueOnSelect");
19206 return Object.assign(
19207 useCompositeStoreProps(
19208 usePopoverStoreProps(store, update2, props),
19209 update2,
19210 props
19211 ),
19212 { tag: props.tag }
19213 );
19214 }
19215 function useComboboxStore(props = {}) {
19216 props = useComboboxStoreOptions(props);
19217 const [store, update2] = useStore2(createComboboxStore, props);
19218 return useComboboxStoreProps(store, update2, props);
19219 }
19220
19221 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
19222 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
19223 function ComboboxProvider(props = {}) {
19224 const store = useComboboxStore(props);
19225 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(ComboboxContextProvider, { value: store, children: props.children });
19226 }
19227
19228 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19229 var import_remove_accents = __toESM(require_remove_accents(), 1);
19230 var import_compose8 = __toESM(require_compose(), 1);
19231 var import_i18n24 = __toESM(require_i18n(), 1);
19232 var import_element51 = __toESM(require_element(), 1);
19233 var import_components19 = __toESM(require_components(), 1);
19234
19235 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
19236 var EMPTY_ARRAY3 = [];
19237 var getCurrentValue = (filterDefinition, currentFilter) => {
19238 if (filterDefinition.singleSelection) {
19239 return currentFilter?.value;
19240 }
19241 if (Array.isArray(currentFilter?.value)) {
19242 return currentFilter.value;
19243 }
19244 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
19245 return [currentFilter.value];
19246 }
19247 return EMPTY_ARRAY3;
19248 };
19249
19250 // packages/dataviews/build-module/hooks/use-elements.mjs
19251 var import_element50 = __toESM(require_element(), 1);
19252 var EMPTY_ARRAY4 = [];
19253 function useElements({
19254 elements,
19255 getElements
19256 }) {
19257 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
19258 const [records, setRecords] = (0, import_element50.useState)(staticElements);
19259 const [isLoading, setIsLoading] = (0, import_element50.useState)(false);
19260 (0, import_element50.useEffect)(() => {
19261 if (!getElements) {
19262 setRecords(staticElements);
19263 return;
19264 }
19265 let cancelled = false;
19266 setIsLoading(true);
19267 getElements().then((fetchedElements) => {
19268 if (!cancelled) {
19269 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
19270 setRecords(dynamicElements);
19271 }
19272 }).catch(() => {
19273 if (!cancelled) {
19274 setRecords(staticElements);
19275 }
19276 }).finally(() => {
19277 if (!cancelled) {
19278 setIsLoading(false);
19279 }
19280 });
19281 return () => {
19282 cancelled = true;
19283 };
19284 }, [getElements, staticElements]);
19285 return {
19286 elements: records,
19287 isLoading
19288 };
19289 }
19290
19291 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
19292 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
19293 function normalizeSearchInput(input = "") {
19294 return (0, import_remove_accents.default)(input.trim().toLowerCase());
19295 }
19296 var getNewValue = (filterDefinition, currentFilter, value) => {
19297 if (filterDefinition.singleSelection) {
19298 return value;
19299 }
19300 if (Array.isArray(currentFilter?.value)) {
19301 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
19302 }
19303 return [value];
19304 };
19305 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
19306 return `${prefix}-${filterElementValue}`;
19307 }
19308 var MultiSelectionOption = ({ selected }) => {
19309 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19310 "span",
19311 {
19312 className: clsx_default(
19313 "dataviews-filters__search-widget-listitem-multi-selection",
19314 { "is-selected": selected }
19315 ),
19316 children: selected && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Icon, { icon: check_default })
19317 }
19318 );
19319 };
19320 var SingleSelectionOption = ({ selected }) => {
19321 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19322 "span",
19323 {
19324 className: clsx_default(
19325 "dataviews-filters__search-widget-listitem-single-selection",
19326 { "is-selected": selected }
19327 )
19328 }
19329 );
19330 };
19331 function ListBox({ view, filter, onChangeView }) {
19332 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
19333 const [activeCompositeId, setActiveCompositeId] = (0, import_element51.useState)(
19334 // When there are one or less operators, the first item is set as active
19335 // (by setting the initial `activeId` to `undefined`).
19336 // With 2 or more operators, the focus is moved on the operators control
19337 // (by setting the initial `activeId` to `null`), meaning that there won't
19338 // be an active item initially. Focus is then managed via the
19339 // `onFocusVisible` callback.
19340 filter.operators?.length === 1 ? void 0 : null
19341 );
19342 const currentFilter = view.filters?.find(
19343 (f2) => f2.field === filter.field
19344 );
19345 const currentValue = getCurrentValue(filter, currentFilter);
19346 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19347 import_components19.Composite,
19348 {
19349 virtualFocus: true,
19350 focusLoop: true,
19351 activeId: activeCompositeId,
19352 setActiveId: setActiveCompositeId,
19353 role: "listbox",
19354 className: "dataviews-filters__search-widget-listbox",
19355 "aria-label": (0, import_i18n24.sprintf)(
19356 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
19357 (0, import_i18n24.__)("List of: %1$s"),
19358 filter.name
19359 ),
19360 onFocusVisible: () => {
19361 if (!activeCompositeId && filter.elements.length) {
19362 setActiveCompositeId(
19363 generateFilterElementCompositeItemId(
19364 baseId,
19365 filter.elements[0].value
19366 )
19367 );
19368 }
19369 },
19370 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Composite.Typeahead, {}),
19371 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19372 import_components19.Composite.Hover,
19373 {
19374 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19375 import_components19.Composite.Item,
19376 {
19377 id: generateFilterElementCompositeItemId(
19378 baseId,
19379 element.value
19380 ),
19381 render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19382 "div",
19383 {
19384 "aria-label": element.label,
19385 role: "option",
19386 className: "dataviews-filters__search-widget-listitem"
19387 }
19388 ),
19389 onClick: () => {
19390 const newFilters = currentFilter ? [
19391 ...(view.filters ?? []).map(
19392 (_filter) => {
19393 if (_filter.field === filter.field) {
19394 return {
19395 ..._filter,
19396 operator: currentFilter.operator || filter.operators[0],
19397 value: getNewValue(
19398 filter,
19399 currentFilter,
19400 element.value
19401 )
19402 };
19403 }
19404 return _filter;
19405 }
19406 )
19407 ] : [
19408 ...view.filters ?? [],
19409 {
19410 field: filter.field,
19411 operator: filter.operators[0],
19412 value: getNewValue(
19413 filter,
19414 currentFilter,
19415 element.value
19416 )
19417 }
19418 ];
19419 onChangeView({
19420 ...view,
19421 page: 1,
19422 filters: newFilters
19423 });
19424 }
19425 }
19426 ),
19427 children: [
19428 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19429 SingleSelectionOption,
19430 {
19431 selected: currentValue === element.value
19432 }
19433 ),
19434 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19435 MultiSelectionOption,
19436 {
19437 selected: currentValue.includes(element.value)
19438 }
19439 ),
19440 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19441 "span",
19442 {
19443 className: "dataviews-filters__search-widget-listitem-value",
19444 title: element.label,
19445 children: element.label
19446 }
19447 )
19448 ]
19449 },
19450 element.value
19451 ))
19452 }
19453 );
19454 }
19455 function ComboboxList22({ view, filter, onChangeView }) {
19456 const [searchValue, setSearchValue] = (0, import_element51.useState)("");
19457 const deferredSearchValue = (0, import_element51.useDeferredValue)(searchValue);
19458 const currentFilter = view.filters?.find(
19459 (_filter) => _filter.field === filter.field
19460 );
19461 const currentValue = getCurrentValue(filter, currentFilter);
19462 const matches = (0, import_element51.useMemo)(() => {
19463 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
19464 return filter.elements.filter(
19465 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
19466 );
19467 }, [filter.elements, deferredSearchValue]);
19468 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19469 ComboboxProvider,
19470 {
19471 selectedValue: currentValue,
19472 setSelectedValue: (value) => {
19473 const newFilters = currentFilter ? [
19474 ...(view.filters ?? []).map((_filter) => {
19475 if (_filter.field === filter.field) {
19476 return {
19477 ..._filter,
19478 operator: currentFilter.operator || filter.operators[0],
19479 value
19480 };
19481 }
19482 return _filter;
19483 })
19484 ] : [
19485 ...view.filters ?? [],
19486 {
19487 field: filter.field,
19488 operator: filter.operators[0],
19489 value
19490 }
19491 ];
19492 onChangeView({
19493 ...view,
19494 page: 1,
19495 filters: newFilters
19496 });
19497 },
19498 setValue: setSearchValue,
19499 children: [
19500 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19501 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(ComboboxLabel, {}), children: (0, import_i18n24.__)("Search items") }),
19502 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19503 Combobox,
19504 {
19505 autoSelect: "always",
19506 placeholder: (0, import_i18n24.__)("Search"),
19507 className: "dataviews-filters__search-widget-filter-combobox__input"
19508 }
19509 ),
19510 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Icon, { icon: search_default }) })
19511 ] }),
19512 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19513 ComboboxList,
19514 {
19515 className: "dataviews-filters__search-widget-filter-combobox-list",
19516 alwaysVisible: true,
19517 children: [
19518 matches.map((element) => {
19519 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19520 ComboboxItem,
19521 {
19522 resetValueOnSelect: false,
19523 value: element.value,
19524 className: "dataviews-filters__search-widget-listitem",
19525 hideOnClick: false,
19526 setValueOnClick: false,
19527 focusOnHover: true,
19528 children: [
19529 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19530 SingleSelectionOption,
19531 {
19532 selected: currentValue === element.value
19533 }
19534 ),
19535 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19536 MultiSelectionOption,
19537 {
19538 selected: currentValue.includes(
19539 element.value
19540 )
19541 }
19542 ),
19543 /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(
19544 "span",
19545 {
19546 className: "dataviews-filters__search-widget-listitem-value",
19547 title: element.label,
19548 children: [
19549 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
19550 ComboboxItemValue,
19551 {
19552 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19553 value: element.label
19554 }
19555 ),
19556 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19557 ]
19558 }
19559 )
19560 ]
19561 },
19562 element.value
19563 );
19564 }),
19565 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { children: (0, import_i18n24.__)("No results found") })
19566 ]
19567 }
19568 )
19569 ]
19570 }
19571 );
19572 }
19573 function SearchWidget(props) {
19574 const { elements, isLoading } = useElements({
19575 elements: props.filter.elements,
19576 getElements: props.filter.getElements
19577 });
19578 if (isLoading) {
19579 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components19.Spinner, {}) });
19580 }
19581 if (elements.length === 0) {
19582 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n24.__)("No elements found") });
19583 }
19584 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19585 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19586 }
19587
19588 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19589 var import_es6 = __toESM(require_es6(), 1);
19590 var import_compose9 = __toESM(require_compose(), 1);
19591 var import_element52 = __toESM(require_element(), 1);
19592 var import_components20 = __toESM(require_components(), 1);
19593 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
19594 function InputWidget({
19595 filter,
19596 view,
19597 onChangeView,
19598 fields
19599 }) {
19600 const currentFilter = view.filters?.find(
19601 (f2) => f2.field === filter.field
19602 );
19603 const currentValue = getCurrentValue(filter, currentFilter);
19604 const field = (0, import_element52.useMemo)(() => {
19605 const currentField = fields.find((f2) => f2.id === filter.field);
19606 if (currentField) {
19607 return {
19608 ...currentField,
19609 // Deactivate validation for filters.
19610 isValid: {},
19611 // Filter controls are always enabled.
19612 isDisabled: () => false,
19613 // Filter controls are always visible.
19614 isVisible: () => true,
19615 // Configure getValue/setValue as if Item was a plain object.
19616 getValue: ({ item }) => item[currentField.id],
19617 setValue: ({ value }) => ({
19618 [currentField.id]: value
19619 })
19620 };
19621 }
19622 return currentField;
19623 }, [fields, filter.field]);
19624 const data = (0, import_element52.useMemo)(() => {
19625 return (view.filters ?? []).reduce(
19626 (acc, activeFilter) => {
19627 acc[activeFilter.field] = activeFilter.value;
19628 return acc;
19629 },
19630 {}
19631 );
19632 }, [view.filters]);
19633 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19634 if (!field || !currentFilter) {
19635 return;
19636 }
19637 const nextValue = field.getValue({ item: updatedData });
19638 if ((0, import_es6.default)(nextValue, currentValue)) {
19639 return;
19640 }
19641 onChangeView({
19642 ...view,
19643 filters: (view.filters ?? []).map(
19644 (_filter) => _filter.field === filter.field ? {
19645 ..._filter,
19646 operator: currentFilter.operator || filter.operators[0],
19647 // Consider empty strings as undefined:
19648 //
19649 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19650 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19651 //
19652 // In practice, this means the filter will not be able to find an empty string as the value.
19653 value: nextValue === "" ? void 0 : nextValue
19654 } : _filter
19655 )
19656 });
19657 });
19658 if (!field || !field.Edit || !currentFilter) {
19659 return null;
19660 }
19661 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19662 import_components20.Flex,
19663 {
19664 className: "dataviews-filters__user-input-widget",
19665 gap: 2.5,
19666 direction: "column",
19667 children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
19668 field.Edit,
19669 {
19670 hideLabelFromVision: true,
19671 data,
19672 field,
19673 operator: currentFilter.operator,
19674 onChange: handleChange
19675 }
19676 )
19677 }
19678 );
19679 }
19680
19681 // node_modules/date-fns/constants.js
19682 var daysInYear = 365.2425;
19683 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19684 var minTime = -maxTime;
19685 var millisecondsInWeek = 6048e5;
19686 var millisecondsInDay = 864e5;
19687 var secondsInHour = 3600;
19688 var secondsInDay = secondsInHour * 24;
19689 var secondsInWeek = secondsInDay * 7;
19690 var secondsInYear = secondsInDay * daysInYear;
19691 var secondsInMonth = secondsInYear / 12;
19692 var secondsInQuarter = secondsInMonth * 3;
19693 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19694
19695 // node_modules/date-fns/constructFrom.js
19696 function constructFrom(date, value) {
19697 if (typeof date === "function") return date(value);
19698 if (date && typeof date === "object" && constructFromSymbol in date)
19699 return date[constructFromSymbol](value);
19700 if (date instanceof Date) return new date.constructor(value);
19701 return new Date(value);
19702 }
19703
19704 // node_modules/date-fns/toDate.js
19705 function toDate(argument, context) {
19706 return constructFrom(context || argument, argument);
19707 }
19708
19709 // node_modules/date-fns/addDays.js
19710 function addDays(date, amount, options) {
19711 const _date = toDate(date, options?.in);
19712 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19713 if (!amount) return _date;
19714 _date.setDate(_date.getDate() + amount);
19715 return _date;
19716 }
19717
19718 // node_modules/date-fns/addMonths.js
19719 function addMonths(date, amount, options) {
19720 const _date = toDate(date, options?.in);
19721 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19722 if (!amount) {
19723 return _date;
19724 }
19725 const dayOfMonth = _date.getDate();
19726 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19727 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19728 const daysInMonth = endOfDesiredMonth.getDate();
19729 if (dayOfMonth >= daysInMonth) {
19730 return endOfDesiredMonth;
19731 } else {
19732 _date.setFullYear(
19733 endOfDesiredMonth.getFullYear(),
19734 endOfDesiredMonth.getMonth(),
19735 dayOfMonth
19736 );
19737 return _date;
19738 }
19739 }
19740
19741 // node_modules/date-fns/_lib/defaultOptions.js
19742 var defaultOptions = {};
19743 function getDefaultOptions() {
19744 return defaultOptions;
19745 }
19746
19747 // node_modules/date-fns/startOfWeek.js
19748 function startOfWeek(date, options) {
19749 const defaultOptions2 = getDefaultOptions();
19750 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19751 const _date = toDate(date, options?.in);
19752 const day = _date.getDay();
19753 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19754 _date.setDate(_date.getDate() - diff);
19755 _date.setHours(0, 0, 0, 0);
19756 return _date;
19757 }
19758
19759 // node_modules/date-fns/startOfISOWeek.js
19760 function startOfISOWeek(date, options) {
19761 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19762 }
19763
19764 // node_modules/date-fns/getISOWeekYear.js
19765 function getISOWeekYear(date, options) {
19766 const _date = toDate(date, options?.in);
19767 const year = _date.getFullYear();
19768 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19769 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19770 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19771 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19772 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19773 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19774 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19775 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19776 if (_date.getTime() >= startOfNextYear.getTime()) {
19777 return year + 1;
19778 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19779 return year;
19780 } else {
19781 return year - 1;
19782 }
19783 }
19784
19785 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19786 function getTimezoneOffsetInMilliseconds(date) {
19787 const _date = toDate(date);
19788 const utcDate = new Date(
19789 Date.UTC(
19790 _date.getFullYear(),
19791 _date.getMonth(),
19792 _date.getDate(),
19793 _date.getHours(),
19794 _date.getMinutes(),
19795 _date.getSeconds(),
19796 _date.getMilliseconds()
19797 )
19798 );
19799 utcDate.setUTCFullYear(_date.getFullYear());
19800 return +date - +utcDate;
19801 }
19802
19803 // node_modules/date-fns/_lib/normalizeDates.js
19804 function normalizeDates(context, ...dates) {
19805 const normalize = constructFrom.bind(
19806 null,
19807 context || dates.find((date) => typeof date === "object")
19808 );
19809 return dates.map(normalize);
19810 }
19811
19812 // node_modules/date-fns/startOfDay.js
19813 function startOfDay(date, options) {
19814 const _date = toDate(date, options?.in);
19815 _date.setHours(0, 0, 0, 0);
19816 return _date;
19817 }
19818
19819 // node_modules/date-fns/differenceInCalendarDays.js
19820 function differenceInCalendarDays(laterDate, earlierDate, options) {
19821 const [laterDate_, earlierDate_] = normalizeDates(
19822 options?.in,
19823 laterDate,
19824 earlierDate
19825 );
19826 const laterStartOfDay = startOfDay(laterDate_);
19827 const earlierStartOfDay = startOfDay(earlierDate_);
19828 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19829 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19830 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19831 }
19832
19833 // node_modules/date-fns/startOfISOWeekYear.js
19834 function startOfISOWeekYear(date, options) {
19835 const year = getISOWeekYear(date, options);
19836 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19837 fourthOfJanuary.setFullYear(year, 0, 4);
19838 fourthOfJanuary.setHours(0, 0, 0, 0);
19839 return startOfISOWeek(fourthOfJanuary);
19840 }
19841
19842 // node_modules/date-fns/addWeeks.js
19843 function addWeeks(date, amount, options) {
19844 return addDays(date, amount * 7, options);
19845 }
19846
19847 // node_modules/date-fns/addYears.js
19848 function addYears(date, amount, options) {
19849 return addMonths(date, amount * 12, options);
19850 }
19851
19852 // node_modules/date-fns/isDate.js
19853 function isDate(value) {
19854 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19855 }
19856
19857 // node_modules/date-fns/isValid.js
19858 function isValid(date) {
19859 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19860 }
19861
19862 // node_modules/date-fns/startOfMonth.js
19863 function startOfMonth(date, options) {
19864 const _date = toDate(date, options?.in);
19865 _date.setDate(1);
19866 _date.setHours(0, 0, 0, 0);
19867 return _date;
19868 }
19869
19870 // node_modules/date-fns/startOfYear.js
19871 function startOfYear(date, options) {
19872 const date_ = toDate(date, options?.in);
19873 date_.setFullYear(date_.getFullYear(), 0, 1);
19874 date_.setHours(0, 0, 0, 0);
19875 return date_;
19876 }
19877
19878 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19879 var formatDistanceLocale = {
19880 lessThanXSeconds: {
19881 one: "less than a second",
19882 other: "less than {{count}} seconds"
19883 },
19884 xSeconds: {
19885 one: "1 second",
19886 other: "{{count}} seconds"
19887 },
19888 halfAMinute: "half a minute",
19889 lessThanXMinutes: {
19890 one: "less than a minute",
19891 other: "less than {{count}} minutes"
19892 },
19893 xMinutes: {
19894 one: "1 minute",
19895 other: "{{count}} minutes"
19896 },
19897 aboutXHours: {
19898 one: "about 1 hour",
19899 other: "about {{count}} hours"
19900 },
19901 xHours: {
19902 one: "1 hour",
19903 other: "{{count}} hours"
19904 },
19905 xDays: {
19906 one: "1 day",
19907 other: "{{count}} days"
19908 },
19909 aboutXWeeks: {
19910 one: "about 1 week",
19911 other: "about {{count}} weeks"
19912 },
19913 xWeeks: {
19914 one: "1 week",
19915 other: "{{count}} weeks"
19916 },
19917 aboutXMonths: {
19918 one: "about 1 month",
19919 other: "about {{count}} months"
19920 },
19921 xMonths: {
19922 one: "1 month",
19923 other: "{{count}} months"
19924 },
19925 aboutXYears: {
19926 one: "about 1 year",
19927 other: "about {{count}} years"
19928 },
19929 xYears: {
19930 one: "1 year",
19931 other: "{{count}} years"
19932 },
19933 overXYears: {
19934 one: "over 1 year",
19935 other: "over {{count}} years"
19936 },
19937 almostXYears: {
19938 one: "almost 1 year",
19939 other: "almost {{count}} years"
19940 }
19941 };
19942 var formatDistance = (token, count, options) => {
19943 let result;
19944 const tokenValue = formatDistanceLocale[token];
19945 if (typeof tokenValue === "string") {
19946 result = tokenValue;
19947 } else if (count === 1) {
19948 result = tokenValue.one;
19949 } else {
19950 result = tokenValue.other.replace("{{count}}", count.toString());
19951 }
19952 if (options?.addSuffix) {
19953 if (options.comparison && options.comparison > 0) {
19954 return "in " + result;
19955 } else {
19956 return result + " ago";
19957 }
19958 }
19959 return result;
19960 };
19961
19962 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19963 function buildFormatLongFn(args) {
19964 return (options = {}) => {
19965 const width = options.width ? String(options.width) : args.defaultWidth;
19966 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19967 return format6;
19968 };
19969 }
19970
19971 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19972 var dateFormats = {
19973 full: "EEEE, MMMM do, y",
19974 long: "MMMM do, y",
19975 medium: "MMM d, y",
19976 short: "MM/dd/yyyy"
19977 };
19978 var timeFormats = {
19979 full: "h:mm:ss a zzzz",
19980 long: "h:mm:ss a z",
19981 medium: "h:mm:ss a",
19982 short: "h:mm a"
19983 };
19984 var dateTimeFormats = {
19985 full: "{{date}} 'at' {{time}}",
19986 long: "{{date}} 'at' {{time}}",
19987 medium: "{{date}}, {{time}}",
19988 short: "{{date}}, {{time}}"
19989 };
19990 var formatLong = {
19991 date: buildFormatLongFn({
19992 formats: dateFormats,
19993 defaultWidth: "full"
19994 }),
19995 time: buildFormatLongFn({
19996 formats: timeFormats,
19997 defaultWidth: "full"
19998 }),
19999 dateTime: buildFormatLongFn({
20000 formats: dateTimeFormats,
20001 defaultWidth: "full"
20002 })
20003 };
20004
20005 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
20006 var formatRelativeLocale = {
20007 lastWeek: "'last' eeee 'at' p",
20008 yesterday: "'yesterday at' p",
20009 today: "'today at' p",
20010 tomorrow: "'tomorrow at' p",
20011 nextWeek: "eeee 'at' p",
20012 other: "P"
20013 };
20014 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
20015
20016 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
20017 function buildLocalizeFn(args) {
20018 return (value, options) => {
20019 const context = options?.context ? String(options.context) : "standalone";
20020 let valuesArray;
20021 if (context === "formatting" && args.formattingValues) {
20022 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
20023 const width = options?.width ? String(options.width) : defaultWidth;
20024 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
20025 } else {
20026 const defaultWidth = args.defaultWidth;
20027 const width = options?.width ? String(options.width) : args.defaultWidth;
20028 valuesArray = args.values[width] || args.values[defaultWidth];
20029 }
20030 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
20031 return valuesArray[index2];
20032 };
20033 }
20034
20035 // node_modules/date-fns/locale/en-US/_lib/localize.js
20036 var eraValues = {
20037 narrow: ["B", "A"],
20038 abbreviated: ["BC", "AD"],
20039 wide: ["Before Christ", "Anno Domini"]
20040 };
20041 var quarterValues = {
20042 narrow: ["1", "2", "3", "4"],
20043 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
20044 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
20045 };
20046 var monthValues = {
20047 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
20048 abbreviated: [
20049 "Jan",
20050 "Feb",
20051 "Mar",
20052 "Apr",
20053 "May",
20054 "Jun",
20055 "Jul",
20056 "Aug",
20057 "Sep",
20058 "Oct",
20059 "Nov",
20060 "Dec"
20061 ],
20062 wide: [
20063 "January",
20064 "February",
20065 "March",
20066 "April",
20067 "May",
20068 "June",
20069 "July",
20070 "August",
20071 "September",
20072 "October",
20073 "November",
20074 "December"
20075 ]
20076 };
20077 var dayValues = {
20078 narrow: ["S", "M", "T", "W", "T", "F", "S"],
20079 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
20080 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
20081 wide: [
20082 "Sunday",
20083 "Monday",
20084 "Tuesday",
20085 "Wednesday",
20086 "Thursday",
20087 "Friday",
20088 "Saturday"
20089 ]
20090 };
20091 var dayPeriodValues = {
20092 narrow: {
20093 am: "a",
20094 pm: "p",
20095 midnight: "mi",
20096 noon: "n",
20097 morning: "morning",
20098 afternoon: "afternoon",
20099 evening: "evening",
20100 night: "night"
20101 },
20102 abbreviated: {
20103 am: "AM",
20104 pm: "PM",
20105 midnight: "midnight",
20106 noon: "noon",
20107 morning: "morning",
20108 afternoon: "afternoon",
20109 evening: "evening",
20110 night: "night"
20111 },
20112 wide: {
20113 am: "a.m.",
20114 pm: "p.m.",
20115 midnight: "midnight",
20116 noon: "noon",
20117 morning: "morning",
20118 afternoon: "afternoon",
20119 evening: "evening",
20120 night: "night"
20121 }
20122 };
20123 var formattingDayPeriodValues = {
20124 narrow: {
20125 am: "a",
20126 pm: "p",
20127 midnight: "mi",
20128 noon: "n",
20129 morning: "in the morning",
20130 afternoon: "in the afternoon",
20131 evening: "in the evening",
20132 night: "at night"
20133 },
20134 abbreviated: {
20135 am: "AM",
20136 pm: "PM",
20137 midnight: "midnight",
20138 noon: "noon",
20139 morning: "in the morning",
20140 afternoon: "in the afternoon",
20141 evening: "in the evening",
20142 night: "at night"
20143 },
20144 wide: {
20145 am: "a.m.",
20146 pm: "p.m.",
20147 midnight: "midnight",
20148 noon: "noon",
20149 morning: "in the morning",
20150 afternoon: "in the afternoon",
20151 evening: "in the evening",
20152 night: "at night"
20153 }
20154 };
20155 var ordinalNumber = (dirtyNumber, _options) => {
20156 const number = Number(dirtyNumber);
20157 const rem100 = number % 100;
20158 if (rem100 > 20 || rem100 < 10) {
20159 switch (rem100 % 10) {
20160 case 1:
20161 return number + "st";
20162 case 2:
20163 return number + "nd";
20164 case 3:
20165 return number + "rd";
20166 }
20167 }
20168 return number + "th";
20169 };
20170 var localize = {
20171 ordinalNumber,
20172 era: buildLocalizeFn({
20173 values: eraValues,
20174 defaultWidth: "wide"
20175 }),
20176 quarter: buildLocalizeFn({
20177 values: quarterValues,
20178 defaultWidth: "wide",
20179 argumentCallback: (quarter) => quarter - 1
20180 }),
20181 month: buildLocalizeFn({
20182 values: monthValues,
20183 defaultWidth: "wide"
20184 }),
20185 day: buildLocalizeFn({
20186 values: dayValues,
20187 defaultWidth: "wide"
20188 }),
20189 dayPeriod: buildLocalizeFn({
20190 values: dayPeriodValues,
20191 defaultWidth: "wide",
20192 formattingValues: formattingDayPeriodValues,
20193 defaultFormattingWidth: "wide"
20194 })
20195 };
20196
20197 // node_modules/date-fns/locale/_lib/buildMatchFn.js
20198 function buildMatchFn(args) {
20199 return (string, options = {}) => {
20200 const width = options.width;
20201 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
20202 const matchResult = string.match(matchPattern);
20203 if (!matchResult) {
20204 return null;
20205 }
20206 const matchedString = matchResult[0];
20207 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
20208 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
20209 // [TODO] -- I challenge you to fix the type
20210 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
20211 );
20212 let value;
20213 value = args.valueCallback ? args.valueCallback(key) : key;
20214 value = options.valueCallback ? (
20215 // [TODO] -- I challenge you to fix the type
20216 options.valueCallback(value)
20217 ) : value;
20218 const rest = string.slice(matchedString.length);
20219 return { value, rest };
20220 };
20221 }
20222 function findKey(object, predicate) {
20223 for (const key in object) {
20224 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
20225 return key;
20226 }
20227 }
20228 return void 0;
20229 }
20230 function findIndex(array, predicate) {
20231 for (let key = 0; key < array.length; key++) {
20232 if (predicate(array[key])) {
20233 return key;
20234 }
20235 }
20236 return void 0;
20237 }
20238
20239 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
20240 function buildMatchPatternFn(args) {
20241 return (string, options = {}) => {
20242 const matchResult = string.match(args.matchPattern);
20243 if (!matchResult) return null;
20244 const matchedString = matchResult[0];
20245 const parseResult = string.match(args.parsePattern);
20246 if (!parseResult) return null;
20247 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
20248 value = options.valueCallback ? options.valueCallback(value) : value;
20249 const rest = string.slice(matchedString.length);
20250 return { value, rest };
20251 };
20252 }
20253
20254 // node_modules/date-fns/locale/en-US/_lib/match.js
20255 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
20256 var parseOrdinalNumberPattern = /\d+/i;
20257 var matchEraPatterns = {
20258 narrow: /^(b|a)/i,
20259 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
20260 wide: /^(before christ|before common era|anno domini|common era)/i
20261 };
20262 var parseEraPatterns = {
20263 any: [/^b/i, /^(a|c)/i]
20264 };
20265 var matchQuarterPatterns = {
20266 narrow: /^[1234]/i,
20267 abbreviated: /^q[1234]/i,
20268 wide: /^[1234](th|st|nd|rd)? quarter/i
20269 };
20270 var parseQuarterPatterns = {
20271 any: [/1/i, /2/i, /3/i, /4/i]
20272 };
20273 var matchMonthPatterns = {
20274 narrow: /^[jfmasond]/i,
20275 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
20276 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
20277 };
20278 var parseMonthPatterns = {
20279 narrow: [
20280 /^j/i,
20281 /^f/i,
20282 /^m/i,
20283 /^a/i,
20284 /^m/i,
20285 /^j/i,
20286 /^j/i,
20287 /^a/i,
20288 /^s/i,
20289 /^o/i,
20290 /^n/i,
20291 /^d/i
20292 ],
20293 any: [
20294 /^ja/i,
20295 /^f/i,
20296 /^mar/i,
20297 /^ap/i,
20298 /^may/i,
20299 /^jun/i,
20300 /^jul/i,
20301 /^au/i,
20302 /^s/i,
20303 /^o/i,
20304 /^n/i,
20305 /^d/i
20306 ]
20307 };
20308 var matchDayPatterns = {
20309 narrow: /^[smtwf]/i,
20310 short: /^(su|mo|tu|we|th|fr|sa)/i,
20311 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
20312 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
20313 };
20314 var parseDayPatterns = {
20315 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
20316 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
20317 };
20318 var matchDayPeriodPatterns = {
20319 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
20320 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
20321 };
20322 var parseDayPeriodPatterns = {
20323 any: {
20324 am: /^a/i,
20325 pm: /^p/i,
20326 midnight: /^mi/i,
20327 noon: /^no/i,
20328 morning: /morning/i,
20329 afternoon: /afternoon/i,
20330 evening: /evening/i,
20331 night: /night/i
20332 }
20333 };
20334 var match = {
20335 ordinalNumber: buildMatchPatternFn({
20336 matchPattern: matchOrdinalNumberPattern,
20337 parsePattern: parseOrdinalNumberPattern,
20338 valueCallback: (value) => parseInt(value, 10)
20339 }),
20340 era: buildMatchFn({
20341 matchPatterns: matchEraPatterns,
20342 defaultMatchWidth: "wide",
20343 parsePatterns: parseEraPatterns,
20344 defaultParseWidth: "any"
20345 }),
20346 quarter: buildMatchFn({
20347 matchPatterns: matchQuarterPatterns,
20348 defaultMatchWidth: "wide",
20349 parsePatterns: parseQuarterPatterns,
20350 defaultParseWidth: "any",
20351 valueCallback: (index2) => index2 + 1
20352 }),
20353 month: buildMatchFn({
20354 matchPatterns: matchMonthPatterns,
20355 defaultMatchWidth: "wide",
20356 parsePatterns: parseMonthPatterns,
20357 defaultParseWidth: "any"
20358 }),
20359 day: buildMatchFn({
20360 matchPatterns: matchDayPatterns,
20361 defaultMatchWidth: "wide",
20362 parsePatterns: parseDayPatterns,
20363 defaultParseWidth: "any"
20364 }),
20365 dayPeriod: buildMatchFn({
20366 matchPatterns: matchDayPeriodPatterns,
20367 defaultMatchWidth: "any",
20368 parsePatterns: parseDayPeriodPatterns,
20369 defaultParseWidth: "any"
20370 })
20371 };
20372
20373 // node_modules/date-fns/locale/en-US.js
20374 var enUS = {
20375 code: "en-US",
20376 formatDistance,
20377 formatLong,
20378 formatRelative,
20379 localize,
20380 match,
20381 options: {
20382 weekStartsOn: 0,
20383 firstWeekContainsDate: 1
20384 }
20385 };
20386
20387 // node_modules/date-fns/getDayOfYear.js
20388 function getDayOfYear(date, options) {
20389 const _date = toDate(date, options?.in);
20390 const diff = differenceInCalendarDays(_date, startOfYear(_date));
20391 const dayOfYear = diff + 1;
20392 return dayOfYear;
20393 }
20394
20395 // node_modules/date-fns/getISOWeek.js
20396 function getISOWeek(date, options) {
20397 const _date = toDate(date, options?.in);
20398 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
20399 return Math.round(diff / millisecondsInWeek) + 1;
20400 }
20401
20402 // node_modules/date-fns/getWeekYear.js
20403 function getWeekYear(date, options) {
20404 const _date = toDate(date, options?.in);
20405 const year = _date.getFullYear();
20406 const defaultOptions2 = getDefaultOptions();
20407 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20408 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
20409 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
20410 firstWeekOfNextYear.setHours(0, 0, 0, 0);
20411 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
20412 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
20413 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
20414 firstWeekOfThisYear.setHours(0, 0, 0, 0);
20415 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
20416 if (+_date >= +startOfNextYear) {
20417 return year + 1;
20418 } else if (+_date >= +startOfThisYear) {
20419 return year;
20420 } else {
20421 return year - 1;
20422 }
20423 }
20424
20425 // node_modules/date-fns/startOfWeekYear.js
20426 function startOfWeekYear(date, options) {
20427 const defaultOptions2 = getDefaultOptions();
20428 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20429 const year = getWeekYear(date, options);
20430 const firstWeek = constructFrom(options?.in || date, 0);
20431 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
20432 firstWeek.setHours(0, 0, 0, 0);
20433 const _date = startOfWeek(firstWeek, options);
20434 return _date;
20435 }
20436
20437 // node_modules/date-fns/getWeek.js
20438 function getWeek(date, options) {
20439 const _date = toDate(date, options?.in);
20440 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
20441 return Math.round(diff / millisecondsInWeek) + 1;
20442 }
20443
20444 // node_modules/date-fns/_lib/addLeadingZeros.js
20445 function addLeadingZeros(number, targetLength) {
20446 const sign = number < 0 ? "-" : "";
20447 const output = Math.abs(number).toString().padStart(targetLength, "0");
20448 return sign + output;
20449 }
20450
20451 // node_modules/date-fns/_lib/format/lightFormatters.js
20452 var lightFormatters = {
20453 // Year
20454 y(date, token) {
20455 const signedYear = date.getFullYear();
20456 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20457 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
20458 },
20459 // Month
20460 M(date, token) {
20461 const month = date.getMonth();
20462 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
20463 },
20464 // Day of the month
20465 d(date, token) {
20466 return addLeadingZeros(date.getDate(), token.length);
20467 },
20468 // AM or PM
20469 a(date, token) {
20470 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20471 switch (token) {
20472 case "a":
20473 case "aa":
20474 return dayPeriodEnumValue.toUpperCase();
20475 case "aaa":
20476 return dayPeriodEnumValue;
20477 case "aaaaa":
20478 return dayPeriodEnumValue[0];
20479 case "aaaa":
20480 default:
20481 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20482 }
20483 },
20484 // Hour [1-12]
20485 h(date, token) {
20486 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20487 },
20488 // Hour [0-23]
20489 H(date, token) {
20490 return addLeadingZeros(date.getHours(), token.length);
20491 },
20492 // Minute
20493 m(date, token) {
20494 return addLeadingZeros(date.getMinutes(), token.length);
20495 },
20496 // Second
20497 s(date, token) {
20498 return addLeadingZeros(date.getSeconds(), token.length);
20499 },
20500 // Fraction of second
20501 S(date, token) {
20502 const numberOfDigits = token.length;
20503 const milliseconds = date.getMilliseconds();
20504 const fractionalSeconds = Math.trunc(
20505 milliseconds * Math.pow(10, numberOfDigits - 3)
20506 );
20507 return addLeadingZeros(fractionalSeconds, token.length);
20508 }
20509 };
20510
20511 // node_modules/date-fns/_lib/format/formatters.js
20512 var dayPeriodEnum = {
20513 am: "am",
20514 pm: "pm",
20515 midnight: "midnight",
20516 noon: "noon",
20517 morning: "morning",
20518 afternoon: "afternoon",
20519 evening: "evening",
20520 night: "night"
20521 };
20522 var formatters = {
20523 // Era
20524 G: function(date, token, localize2) {
20525 const era = date.getFullYear() > 0 ? 1 : 0;
20526 switch (token) {
20527 // AD, BC
20528 case "G":
20529 case "GG":
20530 case "GGG":
20531 return localize2.era(era, { width: "abbreviated" });
20532 // A, B
20533 case "GGGGG":
20534 return localize2.era(era, { width: "narrow" });
20535 // Anno Domini, Before Christ
20536 case "GGGG":
20537 default:
20538 return localize2.era(era, { width: "wide" });
20539 }
20540 },
20541 // Year
20542 y: function(date, token, localize2) {
20543 if (token === "yo") {
20544 const signedYear = date.getFullYear();
20545 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20546 return localize2.ordinalNumber(year, { unit: "year" });
20547 }
20548 return lightFormatters.y(date, token);
20549 },
20550 // Local week-numbering year
20551 Y: function(date, token, localize2, options) {
20552 const signedWeekYear = getWeekYear(date, options);
20553 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20554 if (token === "YY") {
20555 const twoDigitYear = weekYear % 100;
20556 return addLeadingZeros(twoDigitYear, 2);
20557 }
20558 if (token === "Yo") {
20559 return localize2.ordinalNumber(weekYear, { unit: "year" });
20560 }
20561 return addLeadingZeros(weekYear, token.length);
20562 },
20563 // ISO week-numbering year
20564 R: function(date, token) {
20565 const isoWeekYear = getISOWeekYear(date);
20566 return addLeadingZeros(isoWeekYear, token.length);
20567 },
20568 // Extended year. This is a single number designating the year of this calendar system.
20569 // The main difference between `y` and `u` localizers are B.C. years:
20570 // | Year | `y` | `u` |
20571 // |------|-----|-----|
20572 // | AC 1 | 1 | 1 |
20573 // | BC 1 | 1 | 0 |
20574 // | BC 2 | 2 | -1 |
20575 // Also `yy` always returns the last two digits of a year,
20576 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20577 u: function(date, token) {
20578 const year = date.getFullYear();
20579 return addLeadingZeros(year, token.length);
20580 },
20581 // Quarter
20582 Q: function(date, token, localize2) {
20583 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20584 switch (token) {
20585 // 1, 2, 3, 4
20586 case "Q":
20587 return String(quarter);
20588 // 01, 02, 03, 04
20589 case "QQ":
20590 return addLeadingZeros(quarter, 2);
20591 // 1st, 2nd, 3rd, 4th
20592 case "Qo":
20593 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20594 // Q1, Q2, Q3, Q4
20595 case "QQQ":
20596 return localize2.quarter(quarter, {
20597 width: "abbreviated",
20598 context: "formatting"
20599 });
20600 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20601 case "QQQQQ":
20602 return localize2.quarter(quarter, {
20603 width: "narrow",
20604 context: "formatting"
20605 });
20606 // 1st quarter, 2nd quarter, ...
20607 case "QQQQ":
20608 default:
20609 return localize2.quarter(quarter, {
20610 width: "wide",
20611 context: "formatting"
20612 });
20613 }
20614 },
20615 // Stand-alone quarter
20616 q: function(date, token, localize2) {
20617 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20618 switch (token) {
20619 // 1, 2, 3, 4
20620 case "q":
20621 return String(quarter);
20622 // 01, 02, 03, 04
20623 case "qq":
20624 return addLeadingZeros(quarter, 2);
20625 // 1st, 2nd, 3rd, 4th
20626 case "qo":
20627 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20628 // Q1, Q2, Q3, Q4
20629 case "qqq":
20630 return localize2.quarter(quarter, {
20631 width: "abbreviated",
20632 context: "standalone"
20633 });
20634 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20635 case "qqqqq":
20636 return localize2.quarter(quarter, {
20637 width: "narrow",
20638 context: "standalone"
20639 });
20640 // 1st quarter, 2nd quarter, ...
20641 case "qqqq":
20642 default:
20643 return localize2.quarter(quarter, {
20644 width: "wide",
20645 context: "standalone"
20646 });
20647 }
20648 },
20649 // Month
20650 M: function(date, token, localize2) {
20651 const month = date.getMonth();
20652 switch (token) {
20653 case "M":
20654 case "MM":
20655 return lightFormatters.M(date, token);
20656 // 1st, 2nd, ..., 12th
20657 case "Mo":
20658 return localize2.ordinalNumber(month + 1, { unit: "month" });
20659 // Jan, Feb, ..., Dec
20660 case "MMM":
20661 return localize2.month(month, {
20662 width: "abbreviated",
20663 context: "formatting"
20664 });
20665 // J, F, ..., D
20666 case "MMMMM":
20667 return localize2.month(month, {
20668 width: "narrow",
20669 context: "formatting"
20670 });
20671 // January, February, ..., December
20672 case "MMMM":
20673 default:
20674 return localize2.month(month, { width: "wide", context: "formatting" });
20675 }
20676 },
20677 // Stand-alone month
20678 L: function(date, token, localize2) {
20679 const month = date.getMonth();
20680 switch (token) {
20681 // 1, 2, ..., 12
20682 case "L":
20683 return String(month + 1);
20684 // 01, 02, ..., 12
20685 case "LL":
20686 return addLeadingZeros(month + 1, 2);
20687 // 1st, 2nd, ..., 12th
20688 case "Lo":
20689 return localize2.ordinalNumber(month + 1, { unit: "month" });
20690 // Jan, Feb, ..., Dec
20691 case "LLL":
20692 return localize2.month(month, {
20693 width: "abbreviated",
20694 context: "standalone"
20695 });
20696 // J, F, ..., D
20697 case "LLLLL":
20698 return localize2.month(month, {
20699 width: "narrow",
20700 context: "standalone"
20701 });
20702 // January, February, ..., December
20703 case "LLLL":
20704 default:
20705 return localize2.month(month, { width: "wide", context: "standalone" });
20706 }
20707 },
20708 // Local week of year
20709 w: function(date, token, localize2, options) {
20710 const week = getWeek(date, options);
20711 if (token === "wo") {
20712 return localize2.ordinalNumber(week, { unit: "week" });
20713 }
20714 return addLeadingZeros(week, token.length);
20715 },
20716 // ISO week of year
20717 I: function(date, token, localize2) {
20718 const isoWeek = getISOWeek(date);
20719 if (token === "Io") {
20720 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20721 }
20722 return addLeadingZeros(isoWeek, token.length);
20723 },
20724 // Day of the month
20725 d: function(date, token, localize2) {
20726 if (token === "do") {
20727 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20728 }
20729 return lightFormatters.d(date, token);
20730 },
20731 // Day of year
20732 D: function(date, token, localize2) {
20733 const dayOfYear = getDayOfYear(date);
20734 if (token === "Do") {
20735 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20736 }
20737 return addLeadingZeros(dayOfYear, token.length);
20738 },
20739 // Day of week
20740 E: function(date, token, localize2) {
20741 const dayOfWeek = date.getDay();
20742 switch (token) {
20743 // Tue
20744 case "E":
20745 case "EE":
20746 case "EEE":
20747 return localize2.day(dayOfWeek, {
20748 width: "abbreviated",
20749 context: "formatting"
20750 });
20751 // T
20752 case "EEEEE":
20753 return localize2.day(dayOfWeek, {
20754 width: "narrow",
20755 context: "formatting"
20756 });
20757 // Tu
20758 case "EEEEEE":
20759 return localize2.day(dayOfWeek, {
20760 width: "short",
20761 context: "formatting"
20762 });
20763 // Tuesday
20764 case "EEEE":
20765 default:
20766 return localize2.day(dayOfWeek, {
20767 width: "wide",
20768 context: "formatting"
20769 });
20770 }
20771 },
20772 // Local day of week
20773 e: function(date, token, localize2, options) {
20774 const dayOfWeek = date.getDay();
20775 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20776 switch (token) {
20777 // Numerical value (Nth day of week with current locale or weekStartsOn)
20778 case "e":
20779 return String(localDayOfWeek);
20780 // Padded numerical value
20781 case "ee":
20782 return addLeadingZeros(localDayOfWeek, 2);
20783 // 1st, 2nd, ..., 7th
20784 case "eo":
20785 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20786 case "eee":
20787 return localize2.day(dayOfWeek, {
20788 width: "abbreviated",
20789 context: "formatting"
20790 });
20791 // T
20792 case "eeeee":
20793 return localize2.day(dayOfWeek, {
20794 width: "narrow",
20795 context: "formatting"
20796 });
20797 // Tu
20798 case "eeeeee":
20799 return localize2.day(dayOfWeek, {
20800 width: "short",
20801 context: "formatting"
20802 });
20803 // Tuesday
20804 case "eeee":
20805 default:
20806 return localize2.day(dayOfWeek, {
20807 width: "wide",
20808 context: "formatting"
20809 });
20810 }
20811 },
20812 // Stand-alone local day of week
20813 c: function(date, token, localize2, options) {
20814 const dayOfWeek = date.getDay();
20815 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20816 switch (token) {
20817 // Numerical value (same as in `e`)
20818 case "c":
20819 return String(localDayOfWeek);
20820 // Padded numerical value
20821 case "cc":
20822 return addLeadingZeros(localDayOfWeek, token.length);
20823 // 1st, 2nd, ..., 7th
20824 case "co":
20825 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20826 case "ccc":
20827 return localize2.day(dayOfWeek, {
20828 width: "abbreviated",
20829 context: "standalone"
20830 });
20831 // T
20832 case "ccccc":
20833 return localize2.day(dayOfWeek, {
20834 width: "narrow",
20835 context: "standalone"
20836 });
20837 // Tu
20838 case "cccccc":
20839 return localize2.day(dayOfWeek, {
20840 width: "short",
20841 context: "standalone"
20842 });
20843 // Tuesday
20844 case "cccc":
20845 default:
20846 return localize2.day(dayOfWeek, {
20847 width: "wide",
20848 context: "standalone"
20849 });
20850 }
20851 },
20852 // ISO day of week
20853 i: function(date, token, localize2) {
20854 const dayOfWeek = date.getDay();
20855 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20856 switch (token) {
20857 // 2
20858 case "i":
20859 return String(isoDayOfWeek);
20860 // 02
20861 case "ii":
20862 return addLeadingZeros(isoDayOfWeek, token.length);
20863 // 2nd
20864 case "io":
20865 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20866 // Tue
20867 case "iii":
20868 return localize2.day(dayOfWeek, {
20869 width: "abbreviated",
20870 context: "formatting"
20871 });
20872 // T
20873 case "iiiii":
20874 return localize2.day(dayOfWeek, {
20875 width: "narrow",
20876 context: "formatting"
20877 });
20878 // Tu
20879 case "iiiiii":
20880 return localize2.day(dayOfWeek, {
20881 width: "short",
20882 context: "formatting"
20883 });
20884 // Tuesday
20885 case "iiii":
20886 default:
20887 return localize2.day(dayOfWeek, {
20888 width: "wide",
20889 context: "formatting"
20890 });
20891 }
20892 },
20893 // AM or PM
20894 a: function(date, token, localize2) {
20895 const hours = date.getHours();
20896 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20897 switch (token) {
20898 case "a":
20899 case "aa":
20900 return localize2.dayPeriod(dayPeriodEnumValue, {
20901 width: "abbreviated",
20902 context: "formatting"
20903 });
20904 case "aaa":
20905 return localize2.dayPeriod(dayPeriodEnumValue, {
20906 width: "abbreviated",
20907 context: "formatting"
20908 }).toLowerCase();
20909 case "aaaaa":
20910 return localize2.dayPeriod(dayPeriodEnumValue, {
20911 width: "narrow",
20912 context: "formatting"
20913 });
20914 case "aaaa":
20915 default:
20916 return localize2.dayPeriod(dayPeriodEnumValue, {
20917 width: "wide",
20918 context: "formatting"
20919 });
20920 }
20921 },
20922 // AM, PM, midnight, noon
20923 b: function(date, token, localize2) {
20924 const hours = date.getHours();
20925 let dayPeriodEnumValue;
20926 if (hours === 12) {
20927 dayPeriodEnumValue = dayPeriodEnum.noon;
20928 } else if (hours === 0) {
20929 dayPeriodEnumValue = dayPeriodEnum.midnight;
20930 } else {
20931 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20932 }
20933 switch (token) {
20934 case "b":
20935 case "bb":
20936 return localize2.dayPeriod(dayPeriodEnumValue, {
20937 width: "abbreviated",
20938 context: "formatting"
20939 });
20940 case "bbb":
20941 return localize2.dayPeriod(dayPeriodEnumValue, {
20942 width: "abbreviated",
20943 context: "formatting"
20944 }).toLowerCase();
20945 case "bbbbb":
20946 return localize2.dayPeriod(dayPeriodEnumValue, {
20947 width: "narrow",
20948 context: "formatting"
20949 });
20950 case "bbbb":
20951 default:
20952 return localize2.dayPeriod(dayPeriodEnumValue, {
20953 width: "wide",
20954 context: "formatting"
20955 });
20956 }
20957 },
20958 // in the morning, in the afternoon, in the evening, at night
20959 B: function(date, token, localize2) {
20960 const hours = date.getHours();
20961 let dayPeriodEnumValue;
20962 if (hours >= 17) {
20963 dayPeriodEnumValue = dayPeriodEnum.evening;
20964 } else if (hours >= 12) {
20965 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20966 } else if (hours >= 4) {
20967 dayPeriodEnumValue = dayPeriodEnum.morning;
20968 } else {
20969 dayPeriodEnumValue = dayPeriodEnum.night;
20970 }
20971 switch (token) {
20972 case "B":
20973 case "BB":
20974 case "BBB":
20975 return localize2.dayPeriod(dayPeriodEnumValue, {
20976 width: "abbreviated",
20977 context: "formatting"
20978 });
20979 case "BBBBB":
20980 return localize2.dayPeriod(dayPeriodEnumValue, {
20981 width: "narrow",
20982 context: "formatting"
20983 });
20984 case "BBBB":
20985 default:
20986 return localize2.dayPeriod(dayPeriodEnumValue, {
20987 width: "wide",
20988 context: "formatting"
20989 });
20990 }
20991 },
20992 // Hour [1-12]
20993 h: function(date, token, localize2) {
20994 if (token === "ho") {
20995 let hours = date.getHours() % 12;
20996 if (hours === 0) hours = 12;
20997 return localize2.ordinalNumber(hours, { unit: "hour" });
20998 }
20999 return lightFormatters.h(date, token);
21000 },
21001 // Hour [0-23]
21002 H: function(date, token, localize2) {
21003 if (token === "Ho") {
21004 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
21005 }
21006 return lightFormatters.H(date, token);
21007 },
21008 // Hour [0-11]
21009 K: function(date, token, localize2) {
21010 const hours = date.getHours() % 12;
21011 if (token === "Ko") {
21012 return localize2.ordinalNumber(hours, { unit: "hour" });
21013 }
21014 return addLeadingZeros(hours, token.length);
21015 },
21016 // Hour [1-24]
21017 k: function(date, token, localize2) {
21018 let hours = date.getHours();
21019 if (hours === 0) hours = 24;
21020 if (token === "ko") {
21021 return localize2.ordinalNumber(hours, { unit: "hour" });
21022 }
21023 return addLeadingZeros(hours, token.length);
21024 },
21025 // Minute
21026 m: function(date, token, localize2) {
21027 if (token === "mo") {
21028 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
21029 }
21030 return lightFormatters.m(date, token);
21031 },
21032 // Second
21033 s: function(date, token, localize2) {
21034 if (token === "so") {
21035 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
21036 }
21037 return lightFormatters.s(date, token);
21038 },
21039 // Fraction of second
21040 S: function(date, token) {
21041 return lightFormatters.S(date, token);
21042 },
21043 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
21044 X: function(date, token, _localize) {
21045 const timezoneOffset = date.getTimezoneOffset();
21046 if (timezoneOffset === 0) {
21047 return "Z";
21048 }
21049 switch (token) {
21050 // Hours and optional minutes
21051 case "X":
21052 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21053 // Hours, minutes and optional seconds without `:` delimiter
21054 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21055 // so this token always has the same output as `XX`
21056 case "XXXX":
21057 case "XX":
21058 return formatTimezone(timezoneOffset);
21059 // Hours, minutes and optional seconds with `:` delimiter
21060 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21061 // so this token always has the same output as `XXX`
21062 case "XXXXX":
21063 case "XXX":
21064 // Hours and minutes with `:` delimiter
21065 default:
21066 return formatTimezone(timezoneOffset, ":");
21067 }
21068 },
21069 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
21070 x: function(date, token, _localize) {
21071 const timezoneOffset = date.getTimezoneOffset();
21072 switch (token) {
21073 // Hours and optional minutes
21074 case "x":
21075 return formatTimezoneWithOptionalMinutes(timezoneOffset);
21076 // Hours, minutes and optional seconds without `:` delimiter
21077 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21078 // so this token always has the same output as `xx`
21079 case "xxxx":
21080 case "xx":
21081 return formatTimezone(timezoneOffset);
21082 // Hours, minutes and optional seconds with `:` delimiter
21083 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
21084 // so this token always has the same output as `xxx`
21085 case "xxxxx":
21086 case "xxx":
21087 // Hours and minutes with `:` delimiter
21088 default:
21089 return formatTimezone(timezoneOffset, ":");
21090 }
21091 },
21092 // Timezone (GMT)
21093 O: function(date, token, _localize) {
21094 const timezoneOffset = date.getTimezoneOffset();
21095 switch (token) {
21096 // Short
21097 case "O":
21098 case "OO":
21099 case "OOO":
21100 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21101 // Long
21102 case "OOOO":
21103 default:
21104 return "GMT" + formatTimezone(timezoneOffset, ":");
21105 }
21106 },
21107 // Timezone (specific non-location)
21108 z: function(date, token, _localize) {
21109 const timezoneOffset = date.getTimezoneOffset();
21110 switch (token) {
21111 // Short
21112 case "z":
21113 case "zz":
21114 case "zzz":
21115 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
21116 // Long
21117 case "zzzz":
21118 default:
21119 return "GMT" + formatTimezone(timezoneOffset, ":");
21120 }
21121 },
21122 // Seconds timestamp
21123 t: function(date, token, _localize) {
21124 const timestamp = Math.trunc(+date / 1e3);
21125 return addLeadingZeros(timestamp, token.length);
21126 },
21127 // Milliseconds timestamp
21128 T: function(date, token, _localize) {
21129 return addLeadingZeros(+date, token.length);
21130 }
21131 };
21132 function formatTimezoneShort(offset4, delimiter = "") {
21133 const sign = offset4 > 0 ? "-" : "+";
21134 const absOffset = Math.abs(offset4);
21135 const hours = Math.trunc(absOffset / 60);
21136 const minutes = absOffset % 60;
21137 if (minutes === 0) {
21138 return sign + String(hours);
21139 }
21140 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
21141 }
21142 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
21143 if (offset4 % 60 === 0) {
21144 const sign = offset4 > 0 ? "-" : "+";
21145 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
21146 }
21147 return formatTimezone(offset4, delimiter);
21148 }
21149 function formatTimezone(offset4, delimiter = "") {
21150 const sign = offset4 > 0 ? "-" : "+";
21151 const absOffset = Math.abs(offset4);
21152 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
21153 const minutes = addLeadingZeros(absOffset % 60, 2);
21154 return sign + hours + delimiter + minutes;
21155 }
21156
21157 // node_modules/date-fns/_lib/format/longFormatters.js
21158 var dateLongFormatter = (pattern, formatLong2) => {
21159 switch (pattern) {
21160 case "P":
21161 return formatLong2.date({ width: "short" });
21162 case "PP":
21163 return formatLong2.date({ width: "medium" });
21164 case "PPP":
21165 return formatLong2.date({ width: "long" });
21166 case "PPPP":
21167 default:
21168 return formatLong2.date({ width: "full" });
21169 }
21170 };
21171 var timeLongFormatter = (pattern, formatLong2) => {
21172 switch (pattern) {
21173 case "p":
21174 return formatLong2.time({ width: "short" });
21175 case "pp":
21176 return formatLong2.time({ width: "medium" });
21177 case "ppp":
21178 return formatLong2.time({ width: "long" });
21179 case "pppp":
21180 default:
21181 return formatLong2.time({ width: "full" });
21182 }
21183 };
21184 var dateTimeLongFormatter = (pattern, formatLong2) => {
21185 const matchResult = pattern.match(/(P+)(p+)?/) || [];
21186 const datePattern = matchResult[1];
21187 const timePattern = matchResult[2];
21188 if (!timePattern) {
21189 return dateLongFormatter(pattern, formatLong2);
21190 }
21191 let dateTimeFormat;
21192 switch (datePattern) {
21193 case "P":
21194 dateTimeFormat = formatLong2.dateTime({ width: "short" });
21195 break;
21196 case "PP":
21197 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
21198 break;
21199 case "PPP":
21200 dateTimeFormat = formatLong2.dateTime({ width: "long" });
21201 break;
21202 case "PPPP":
21203 default:
21204 dateTimeFormat = formatLong2.dateTime({ width: "full" });
21205 break;
21206 }
21207 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
21208 };
21209 var longFormatters = {
21210 p: timeLongFormatter,
21211 P: dateTimeLongFormatter
21212 };
21213
21214 // node_modules/date-fns/_lib/protectedTokens.js
21215 var dayOfYearTokenRE = /^D+$/;
21216 var weekYearTokenRE = /^Y+$/;
21217 var throwTokens = ["D", "DD", "YY", "YYYY"];
21218 function isProtectedDayOfYearToken(token) {
21219 return dayOfYearTokenRE.test(token);
21220 }
21221 function isProtectedWeekYearToken(token) {
21222 return weekYearTokenRE.test(token);
21223 }
21224 function warnOrThrowProtectedError(token, format6, input) {
21225 const _message = message(token, format6, input);
21226 console.warn(_message);
21227 if (throwTokens.includes(token)) throw new RangeError(_message);
21228 }
21229 function message(token, format6, input) {
21230 const subject = token[0] === "Y" ? "years" : "days of the month";
21231 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`;
21232 }
21233
21234 // node_modules/date-fns/format.js
21235 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
21236 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
21237 var escapedStringRegExp = /^'([^]*?)'?$/;
21238 var doubleQuoteRegExp = /''/g;
21239 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
21240 function format(date, formatStr, options) {
21241 const defaultOptions2 = getDefaultOptions();
21242 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
21243 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
21244 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
21245 const originalDate = toDate(date, options?.in);
21246 if (!isValid(originalDate)) {
21247 throw new RangeError("Invalid time value");
21248 }
21249 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
21250 const firstCharacter = substring[0];
21251 if (firstCharacter === "p" || firstCharacter === "P") {
21252 const longFormatter = longFormatters[firstCharacter];
21253 return longFormatter(substring, locale.formatLong);
21254 }
21255 return substring;
21256 }).join("").match(formattingTokensRegExp).map((substring) => {
21257 if (substring === "''") {
21258 return { isToken: false, value: "'" };
21259 }
21260 const firstCharacter = substring[0];
21261 if (firstCharacter === "'") {
21262 return { isToken: false, value: cleanEscapedString(substring) };
21263 }
21264 if (formatters[firstCharacter]) {
21265 return { isToken: true, value: substring };
21266 }
21267 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
21268 throw new RangeError(
21269 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
21270 );
21271 }
21272 return { isToken: false, value: substring };
21273 });
21274 if (locale.localize.preprocessor) {
21275 parts = locale.localize.preprocessor(originalDate, parts);
21276 }
21277 const formatterOptions = {
21278 firstWeekContainsDate,
21279 weekStartsOn,
21280 locale
21281 };
21282 return parts.map((part) => {
21283 if (!part.isToken) return part.value;
21284 const token = part.value;
21285 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
21286 warnOrThrowProtectedError(token, formatStr, String(date));
21287 }
21288 const formatter = formatters[token[0]];
21289 return formatter(originalDate, token, locale.localize, formatterOptions);
21290 }).join("");
21291 }
21292 function cleanEscapedString(input) {
21293 const matched = input.match(escapedStringRegExp);
21294 if (!matched) {
21295 return input;
21296 }
21297 return matched[1].replace(doubleQuoteRegExp, "'");
21298 }
21299
21300 // node_modules/date-fns/subDays.js
21301 function subDays(date, amount, options) {
21302 return addDays(date, -amount, options);
21303 }
21304
21305 // node_modules/date-fns/subMonths.js
21306 function subMonths(date, amount, options) {
21307 return addMonths(date, -amount, options);
21308 }
21309
21310 // node_modules/date-fns/subWeeks.js
21311 function subWeeks(date, amount, options) {
21312 return addWeeks(date, -amount, options);
21313 }
21314
21315 // node_modules/date-fns/subYears.js
21316 function subYears(date, amount, options) {
21317 return addYears(date, -amount, options);
21318 }
21319
21320 // packages/dataviews/build-module/utils/operators.mjs
21321 var import_i18n25 = __toESM(require_i18n(), 1);
21322 var import_element53 = __toESM(require_element(), 1);
21323 var import_date = __toESM(require_date(), 1);
21324 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
21325 var filterTextWrappers = {
21326 Name: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
21327 Value: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
21328 };
21329 function getRelativeDate(value, unit) {
21330 switch (unit) {
21331 case "days":
21332 return subDays(/* @__PURE__ */ new Date(), value);
21333 case "weeks":
21334 return subWeeks(/* @__PURE__ */ new Date(), value);
21335 case "months":
21336 return subMonths(/* @__PURE__ */ new Date(), value);
21337 case "years":
21338 return subYears(/* @__PURE__ */ new Date(), value);
21339 default:
21340 return /* @__PURE__ */ new Date();
21341 }
21342 }
21343 var isNoneOperatorDefinition = {
21344 /* translators: DataViews operator name */
21345 label: (0, import_i18n25.__)("Is none of"),
21346 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21347 (0, import_i18n25.sprintf)(
21348 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
21349 (0, import_i18n25.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
21350 filter.name,
21351 activeElements.map((element) => element.label).join(", ")
21352 ),
21353 filterTextWrappers
21354 ),
21355 filter: ((item, field, filterValue) => {
21356 if (!filterValue?.length) {
21357 return true;
21358 }
21359 const fieldValue = field.getValue({ item });
21360 if (Array.isArray(fieldValue)) {
21361 return !filterValue.some(
21362 (fv) => fieldValue.includes(fv)
21363 );
21364 } else if (typeof fieldValue === "string") {
21365 return !filterValue.includes(fieldValue);
21366 }
21367 return false;
21368 }),
21369 selection: "multi"
21370 };
21371 var OPERATORS = [
21372 {
21373 name: OPERATOR_IS_ANY,
21374 /* translators: DataViews operator name */
21375 label: (0, import_i18n25.__)("Includes"),
21376 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21377 (0, import_i18n25.sprintf)(
21378 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
21379 (0, import_i18n25.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
21380 filter.name,
21381 activeElements.map((element) => element.label).join(", ")
21382 ),
21383 filterTextWrappers
21384 ),
21385 filter(item, field, filterValue) {
21386 if (!filterValue?.length) {
21387 return true;
21388 }
21389 const fieldValue = field.getValue({ item });
21390 if (Array.isArray(fieldValue)) {
21391 return filterValue.some(
21392 (fv) => fieldValue.includes(fv)
21393 );
21394 } else if (typeof fieldValue === "string") {
21395 return filterValue.includes(fieldValue);
21396 }
21397 return false;
21398 },
21399 selection: "multi"
21400 },
21401 {
21402 name: OPERATOR_IS_NONE,
21403 ...isNoneOperatorDefinition
21404 },
21405 {
21406 name: OPERATOR_IS_ALL,
21407 /* translators: DataViews operator name */
21408 label: (0, import_i18n25.__)("Includes all"),
21409 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21410 (0, import_i18n25.sprintf)(
21411 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
21412 (0, import_i18n25.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
21413 filter.name,
21414 activeElements.map((element) => element.label).join(", ")
21415 ),
21416 filterTextWrappers
21417 ),
21418 filter(item, field, filterValue) {
21419 if (!filterValue?.length) {
21420 return true;
21421 }
21422 return filterValue.every((value) => {
21423 return field.getValue({ item })?.includes(value);
21424 });
21425 },
21426 selection: "multi"
21427 },
21428 {
21429 name: OPERATOR_IS_NOT_ALL,
21430 ...isNoneOperatorDefinition
21431 },
21432 {
21433 name: OPERATOR_BETWEEN,
21434 /* translators: DataViews operator name */
21435 label: (0, import_i18n25.__)("Between (inc)"),
21436 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21437 (0, import_i18n25.sprintf)(
21438 /* 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". */
21439 (0, import_i18n25.__)(
21440 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
21441 ),
21442 filter.name,
21443 activeElements[0].label[0],
21444 activeElements[0].label[1]
21445 ),
21446 filterTextWrappers
21447 ),
21448 filter(item, field, filterValue) {
21449 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
21450 return true;
21451 }
21452 const fieldValue = field.getValue({ item });
21453 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
21454 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
21455 }
21456 return false;
21457 },
21458 selection: "custom"
21459 },
21460 {
21461 name: OPERATOR_IN_THE_PAST,
21462 /* translators: DataViews operator name */
21463 label: (0, import_i18n25.__)("In the past"),
21464 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21465 (0, import_i18n25.sprintf)(
21466 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21467 (0, import_i18n25.__)(
21468 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21469 ),
21470 filter.name,
21471 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21472 ),
21473 filterTextWrappers
21474 ),
21475 filter(item, field, filterValue) {
21476 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21477 return true;
21478 }
21479 const targetDate = getRelativeDate(
21480 filterValue.value,
21481 filterValue.unit
21482 );
21483 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21484 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21485 },
21486 selection: "custom"
21487 },
21488 {
21489 name: OPERATOR_OVER,
21490 /* translators: DataViews operator name */
21491 label: (0, import_i18n25.__)("Over"),
21492 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21493 (0, import_i18n25.sprintf)(
21494 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21495 (0, import_i18n25.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21496 filter.name,
21497 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21498 ),
21499 filterTextWrappers
21500 ),
21501 filter(item, field, filterValue) {
21502 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21503 return true;
21504 }
21505 const targetDate = getRelativeDate(
21506 filterValue.value,
21507 filterValue.unit
21508 );
21509 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21510 return fieldValue < targetDate;
21511 },
21512 selection: "custom"
21513 },
21514 {
21515 name: OPERATOR_IS,
21516 /* translators: DataViews operator name */
21517 label: (0, import_i18n25.__)("Is"),
21518 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21519 (0, import_i18n25.sprintf)(
21520 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21521 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21522 filter.name,
21523 activeElements[0].label
21524 ),
21525 filterTextWrappers
21526 ),
21527 filter(item, field, filterValue) {
21528 return filterValue === field.getValue({ item }) || filterValue === void 0;
21529 },
21530 selection: "single"
21531 },
21532 {
21533 name: OPERATOR_IS_NOT,
21534 /* translators: DataViews operator name */
21535 label: (0, import_i18n25.__)("Is not"),
21536 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21537 (0, import_i18n25.sprintf)(
21538 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21539 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21540 filter.name,
21541 activeElements[0].label
21542 ),
21543 filterTextWrappers
21544 ),
21545 filter(item, field, filterValue) {
21546 return filterValue !== field.getValue({ item });
21547 },
21548 selection: "single"
21549 },
21550 {
21551 name: OPERATOR_LESS_THAN,
21552 /* translators: DataViews operator name */
21553 label: (0, import_i18n25.__)("Less than"),
21554 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21555 (0, import_i18n25.sprintf)(
21556 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21557 (0, import_i18n25.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21558 filter.name,
21559 activeElements[0].label
21560 ),
21561 filterTextWrappers
21562 ),
21563 filter(item, field, filterValue) {
21564 if (filterValue === void 0) {
21565 return true;
21566 }
21567 const fieldValue = field.getValue({ item });
21568 return fieldValue < filterValue;
21569 },
21570 selection: "single"
21571 },
21572 {
21573 name: OPERATOR_GREATER_THAN,
21574 /* translators: DataViews operator name */
21575 label: (0, import_i18n25.__)("Greater than"),
21576 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21577 (0, import_i18n25.sprintf)(
21578 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21579 (0, import_i18n25.__)(
21580 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21581 ),
21582 filter.name,
21583 activeElements[0].label
21584 ),
21585 filterTextWrappers
21586 ),
21587 filter(item, field, filterValue) {
21588 if (filterValue === void 0) {
21589 return true;
21590 }
21591 const fieldValue = field.getValue({ item });
21592 return fieldValue > filterValue;
21593 },
21594 selection: "single"
21595 },
21596 {
21597 name: OPERATOR_LESS_THAN_OR_EQUAL,
21598 /* translators: DataViews operator name */
21599 label: (0, import_i18n25.__)("Less than or equal"),
21600 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21601 (0, import_i18n25.sprintf)(
21602 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21603 (0, import_i18n25.__)(
21604 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21605 ),
21606 filter.name,
21607 activeElements[0].label
21608 ),
21609 filterTextWrappers
21610 ),
21611 filter(item, field, filterValue) {
21612 if (filterValue === void 0) {
21613 return true;
21614 }
21615 const fieldValue = field.getValue({ item });
21616 return fieldValue <= filterValue;
21617 },
21618 selection: "single"
21619 },
21620 {
21621 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21622 /* translators: DataViews operator name */
21623 label: (0, import_i18n25.__)("Greater than or equal"),
21624 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21625 (0, import_i18n25.sprintf)(
21626 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21627 (0, import_i18n25.__)(
21628 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21629 ),
21630 filter.name,
21631 activeElements[0].label
21632 ),
21633 filterTextWrappers
21634 ),
21635 filter(item, field, filterValue) {
21636 if (filterValue === void 0) {
21637 return true;
21638 }
21639 const fieldValue = field.getValue({ item });
21640 return fieldValue >= filterValue;
21641 },
21642 selection: "single"
21643 },
21644 {
21645 name: OPERATOR_BEFORE,
21646 /* translators: DataViews operator name */
21647 label: (0, import_i18n25.__)("Before"),
21648 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21649 (0, import_i18n25.sprintf)(
21650 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21651 (0, import_i18n25.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21652 filter.name,
21653 activeElements[0].label
21654 ),
21655 filterTextWrappers
21656 ),
21657 filter(item, field, filterValue) {
21658 if (filterValue === void 0) {
21659 return true;
21660 }
21661 const filterDate = (0, import_date.getDate)(filterValue);
21662 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21663 return fieldDate < filterDate;
21664 },
21665 selection: "single"
21666 },
21667 {
21668 name: OPERATOR_AFTER,
21669 /* translators: DataViews operator name */
21670 label: (0, import_i18n25.__)("After"),
21671 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21672 (0, import_i18n25.sprintf)(
21673 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21674 (0, import_i18n25.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21675 filter.name,
21676 activeElements[0].label
21677 ),
21678 filterTextWrappers
21679 ),
21680 filter(item, field, filterValue) {
21681 if (filterValue === void 0) {
21682 return true;
21683 }
21684 const filterDate = (0, import_date.getDate)(filterValue);
21685 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21686 return fieldDate > filterDate;
21687 },
21688 selection: "single"
21689 },
21690 {
21691 name: OPERATOR_BEFORE_INC,
21692 /* translators: DataViews operator name */
21693 label: (0, import_i18n25.__)("Before (inc)"),
21694 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21695 (0, import_i18n25.sprintf)(
21696 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21697 (0, import_i18n25.__)(
21698 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21699 ),
21700 filter.name,
21701 activeElements[0].label
21702 ),
21703 filterTextWrappers
21704 ),
21705 filter(item, field, filterValue) {
21706 if (filterValue === void 0) {
21707 return true;
21708 }
21709 const filterDate = (0, import_date.getDate)(filterValue);
21710 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21711 return fieldDate <= filterDate;
21712 },
21713 selection: "single"
21714 },
21715 {
21716 name: OPERATOR_AFTER_INC,
21717 /* translators: DataViews operator name */
21718 label: (0, import_i18n25.__)("After (inc)"),
21719 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21720 (0, import_i18n25.sprintf)(
21721 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21722 (0, import_i18n25.__)(
21723 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21724 ),
21725 filter.name,
21726 activeElements[0].label
21727 ),
21728 filterTextWrappers
21729 ),
21730 filter(item, field, filterValue) {
21731 if (filterValue === void 0) {
21732 return true;
21733 }
21734 const filterDate = (0, import_date.getDate)(filterValue);
21735 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21736 return fieldDate >= filterDate;
21737 },
21738 selection: "single"
21739 },
21740 {
21741 name: OPERATOR_CONTAINS,
21742 /* translators: DataViews operator name */
21743 label: (0, import_i18n25.__)("Contains"),
21744 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21745 (0, import_i18n25.sprintf)(
21746 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21747 (0, import_i18n25.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21748 filter.name,
21749 activeElements[0].label
21750 ),
21751 filterTextWrappers
21752 ),
21753 filter(item, field, filterValue) {
21754 if (filterValue === void 0) {
21755 return true;
21756 }
21757 const fieldValue = field.getValue({ item });
21758 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21759 },
21760 selection: "single"
21761 },
21762 {
21763 name: OPERATOR_NOT_CONTAINS,
21764 /* translators: DataViews operator name */
21765 label: (0, import_i18n25.__)("Doesn't contain"),
21766 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21767 (0, import_i18n25.sprintf)(
21768 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21769 (0, import_i18n25.__)(
21770 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21771 ),
21772 filter.name,
21773 activeElements[0].label
21774 ),
21775 filterTextWrappers
21776 ),
21777 filter(item, field, filterValue) {
21778 if (filterValue === void 0) {
21779 return true;
21780 }
21781 const fieldValue = field.getValue({ item });
21782 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21783 },
21784 selection: "single"
21785 },
21786 {
21787 name: OPERATOR_STARTS_WITH,
21788 /* translators: DataViews operator name */
21789 label: (0, import_i18n25.__)("Starts with"),
21790 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21791 (0, import_i18n25.sprintf)(
21792 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21793 (0, import_i18n25.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21794 filter.name,
21795 activeElements[0].label
21796 ),
21797 filterTextWrappers
21798 ),
21799 filter(item, field, filterValue) {
21800 if (filterValue === void 0) {
21801 return true;
21802 }
21803 const fieldValue = field.getValue({ item });
21804 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21805 },
21806 selection: "single"
21807 },
21808 {
21809 name: OPERATOR_ON,
21810 /* translators: DataViews operator name */
21811 label: (0, import_i18n25.__)("On"),
21812 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21813 (0, import_i18n25.sprintf)(
21814 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21815 (0, import_i18n25.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21816 filter.name,
21817 activeElements[0].label
21818 ),
21819 filterTextWrappers
21820 ),
21821 filter(item, field, filterValue) {
21822 if (filterValue === void 0) {
21823 return true;
21824 }
21825 const filterDate = (0, import_date.getDate)(filterValue);
21826 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21827 return filterDate.getTime() === fieldDate.getTime();
21828 },
21829 selection: "single"
21830 },
21831 {
21832 name: OPERATOR_NOT_ON,
21833 /* translators: DataViews operator name */
21834 label: (0, import_i18n25.__)("Not on"),
21835 filterText: (filter, activeElements) => (0, import_element53.createInterpolateElement)(
21836 (0, import_i18n25.sprintf)(
21837 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21838 (0, import_i18n25.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21839 filter.name,
21840 activeElements[0].label
21841 ),
21842 filterTextWrappers
21843 ),
21844 filter(item, field, filterValue) {
21845 if (filterValue === void 0) {
21846 return true;
21847 }
21848 const filterDate = (0, import_date.getDate)(filterValue);
21849 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21850 return filterDate.getTime() !== fieldDate.getTime();
21851 },
21852 selection: "single"
21853 }
21854 ];
21855 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21856 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21857 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21858 (op) => op.name === name
21859 );
21860 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21861
21862 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21863 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21864 var ENTER = "Enter";
21865 var SPACE = " ";
21866 var FilterText = ({
21867 activeElements,
21868 filterInView,
21869 filter
21870 }) => {
21871 if (activeElements === void 0 || activeElements.length === 0) {
21872 return filter.name;
21873 }
21874 const operator = getOperatorByName(filterInView?.operator);
21875 if (operator !== void 0) {
21876 return operator.filterText(filter, activeElements);
21877 }
21878 return (0, import_i18n26.sprintf)(
21879 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21880 (0, import_i18n26.__)("Unknown status for %1$s"),
21881 filter.name
21882 );
21883 };
21884 function OperatorSelector({
21885 filter,
21886 view,
21887 onChangeView
21888 }) {
21889 const operatorOptions = filter.operators?.map((operator) => ({
21890 value: operator,
21891 label: getOperatorByName(operator)?.label || operator
21892 }));
21893 const currentFilter = view.filters?.find(
21894 (_filter) => _filter.field === filter.field
21895 );
21896 const value = currentFilter?.operator || filter.operators[0];
21897 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
21898 Stack,
21899 {
21900 direction: "row",
21901 gap: "sm",
21902 justify: "flex-start",
21903 className: "dataviews-filters__summary-operators-container",
21904 align: "center",
21905 children: [
21906 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21907 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21908 import_components21.SelectControl,
21909 {
21910 className: "dataviews-filters__summary-operators-filter-select",
21911 label: (0, import_i18n26.__)("Conditions"),
21912 value,
21913 options: operatorOptions,
21914 onChange: (newValue) => {
21915 const newOperator = newValue;
21916 const currentOperator = currentFilter?.operator;
21917 const newFilters = currentFilter ? [
21918 ...(view.filters ?? []).map(
21919 (_filter) => {
21920 if (_filter.field === filter.field) {
21921 const currentOpSelectionModel = getOperatorByName(
21922 currentOperator
21923 )?.selection;
21924 const newOpSelectionModel = getOperatorByName(
21925 newOperator
21926 )?.selection;
21927 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21928 currentOpSelectionModel,
21929 newOpSelectionModel
21930 ].includes("custom");
21931 return {
21932 ..._filter,
21933 value: shouldResetValue ? void 0 : _filter.value,
21934 operator: newOperator
21935 };
21936 }
21937 return _filter;
21938 }
21939 )
21940 ] : [
21941 ...view.filters ?? [],
21942 {
21943 field: filter.field,
21944 operator: newOperator,
21945 value: void 0
21946 }
21947 ];
21948 onChangeView({
21949 ...view,
21950 page: 1,
21951 filters: newFilters
21952 });
21953 },
21954 size: "small",
21955 variant: "minimal",
21956 hideLabelFromVision: true
21957 }
21958 )
21959 ]
21960 }
21961 );
21962 }
21963 function Filter({
21964 addFilterRef,
21965 openedFilter,
21966 fields,
21967 ...commonProps
21968 }) {
21969 const toggleRef = (0, import_element54.useRef)(null);
21970 const { filter, view, onChangeView } = commonProps;
21971 const filterInView = view.filters?.find(
21972 (f2) => f2.field === filter.field
21973 );
21974 let activeElements = [];
21975 const field = (0, import_element54.useMemo)(() => {
21976 const currentField = fields.find((f2) => f2.id === filter.field);
21977 if (currentField) {
21978 return {
21979 ...currentField,
21980 // Configure getValue as if Item was a plain object.
21981 // See related input-widget.tsx
21982 getValue: ({ item }) => item[currentField.id]
21983 };
21984 }
21985 return currentField;
21986 }, [fields, filter.field]);
21987 const { elements } = useElements({
21988 elements: filter.elements,
21989 getElements: filter.getElements
21990 });
21991 if (elements.length > 0) {
21992 activeElements = elements.filter((element) => {
21993 if (filter.singleSelection) {
21994 return element.value === filterInView?.value;
21995 }
21996 return filterInView?.value?.includes(element.value);
21997 });
21998 } else if (Array.isArray(filterInView?.value)) {
21999 const label = filterInView.value.map((v2) => {
22000 const formattedValue = field?.getValueFormatted({
22001 item: { [field.id]: v2 },
22002 field
22003 });
22004 return formattedValue || String(v2);
22005 });
22006 activeElements = [
22007 {
22008 value: filterInView.value,
22009 // @ts-ignore
22010 label
22011 }
22012 ];
22013 } else if (typeof filterInView?.value === "object") {
22014 activeElements = [
22015 { value: filterInView.value, label: filterInView.value }
22016 ];
22017 } else if (filterInView?.value !== void 0) {
22018 const label = field !== void 0 ? field.getValueFormatted({
22019 item: { [field.id]: filterInView.value },
22020 field
22021 }) : String(filterInView.value);
22022 activeElements = [
22023 {
22024 value: filterInView.value,
22025 label
22026 }
22027 ];
22028 }
22029 const isPrimary = filter.isPrimary;
22030 const isLocked = filterInView?.isLocked;
22031 const hasValues = !isLocked && filterInView?.value !== void 0;
22032 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
22033 const resetOrRemoveLabel = isPrimary ? (0, import_i18n26.__)("Reset") : (0, import_i18n26.__)("Remove");
22034 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22035 import_components21.Dropdown,
22036 {
22037 defaultOpen: openedFilter === filter.field,
22038 contentClassName: "dataviews-filters__summary-popover",
22039 popoverProps: { placement: "bottom-start", role: "dialog" },
22040 onClose: () => {
22041 toggleRef.current?.focus();
22042 },
22043 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
22044 /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
22045 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22046 tooltip_exports.Trigger,
22047 {
22048 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22049 "div",
22050 {
22051 className: clsx_default(
22052 "dataviews-filters__summary-chip",
22053 {
22054 "has-reset": canResetOrRemove,
22055 "has-values": hasValues,
22056 "is-not-clickable": isLocked
22057 }
22058 ),
22059 role: "button",
22060 tabIndex: isLocked ? -1 : 0,
22061 onClick: () => {
22062 if (!isLocked) {
22063 onToggle();
22064 }
22065 },
22066 onKeyDown: (event) => {
22067 if (!isLocked && [ENTER, SPACE].includes(
22068 event.key
22069 )) {
22070 onToggle();
22071 event.preventDefault();
22072 }
22073 },
22074 "aria-disabled": isLocked,
22075 "aria-pressed": isOpen,
22076 "aria-expanded": isOpen,
22077 ref: toggleRef,
22078 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22079 FilterText,
22080 {
22081 activeElements,
22082 filterInView,
22083 filter
22084 }
22085 )
22086 }
22087 )
22088 }
22089 ),
22090 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: (0, import_i18n26.sprintf)(
22091 /* translators: 1: Filter name. */
22092 (0, import_i18n26.__)("Filter by: %1$s"),
22093 filter.name.toLowerCase()
22094 ) })
22095 ] }),
22096 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(tooltip_exports.Root, { children: [
22097 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22098 tooltip_exports.Trigger,
22099 {
22100 render: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22101 "button",
22102 {
22103 className: clsx_default(
22104 "dataviews-filters__summary-chip-remove",
22105 { "has-values": hasValues }
22106 ),
22107 "aria-label": resetOrRemoveLabel,
22108 onClick: () => {
22109 onChangeView({
22110 ...view,
22111 page: 1,
22112 filters: view.filters?.filter(
22113 (_filter) => _filter.field !== filter.field
22114 )
22115 });
22116 if (!isPrimary) {
22117 addFilterRef.current?.focus();
22118 } else {
22119 toggleRef.current?.focus();
22120 }
22121 },
22122 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components21.Icon, { icon: close_small_default })
22123 }
22124 )
22125 }
22126 ),
22127 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
22128 ] })
22129 ] }),
22130 renderContent: () => {
22131 return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
22132 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(OperatorSelector, { ...commonProps }),
22133 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22134 SearchWidget,
22135 {
22136 ...commonProps,
22137 filter: {
22138 ...commonProps.filter,
22139 elements
22140 }
22141 }
22142 ) : /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(InputWidget, { ...commonProps, fields })
22143 ] });
22144 }
22145 }
22146 );
22147 }
22148
22149 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
22150 var import_components22 = __toESM(require_components(), 1);
22151 var import_i18n27 = __toESM(require_i18n(), 1);
22152 var import_element55 = __toESM(require_element(), 1);
22153 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
22154 var { Menu: Menu4 } = unlock2(import_components22.privateApis);
22155 function AddFilterMenu({
22156 filters,
22157 view,
22158 onChangeView,
22159 setOpenedFilter,
22160 triggerProps
22161 }) {
22162 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22163 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu4, { children: [
22164 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.TriggerButton, { ...triggerProps }),
22165 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
22166 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22167 Menu4.Item,
22168 {
22169 onClick: () => {
22170 setOpenedFilter(filter.field);
22171 onChangeView({
22172 ...view,
22173 page: 1,
22174 filters: [
22175 ...view.filters || [],
22176 {
22177 field: filter.field,
22178 value: void 0,
22179 operator: filter.operators[0]
22180 }
22181 ]
22182 });
22183 },
22184 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu4.ItemLabel, { children: filter.name })
22185 },
22186 filter.field
22187 );
22188 }) })
22189 ] });
22190 }
22191 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
22192 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
22193 return null;
22194 }
22195 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
22196 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22197 AddFilterMenu,
22198 {
22199 triggerProps: {
22200 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22201 import_components22.Button,
22202 {
22203 accessibleWhenDisabled: true,
22204 size: "compact",
22205 className: "dataviews-filters-button",
22206 variant: "tertiary",
22207 disabled: !inactiveFilters.length,
22208 ref
22209 }
22210 ),
22211 children: (0, import_i18n27.__)("Add filter")
22212 },
22213 ...{ filters, view, onChangeView, setOpenedFilter }
22214 }
22215 );
22216 }
22217 var add_filter_default = (0, import_element55.forwardRef)(AddFilter);
22218
22219 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
22220 var import_components23 = __toESM(require_components(), 1);
22221 var import_i18n28 = __toESM(require_i18n(), 1);
22222 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22223 function ResetFilter({
22224 filters,
22225 view,
22226 onChangeView
22227 }) {
22228 const isPrimary = (field) => filters.some(
22229 (_filter) => _filter.field === field && _filter.isPrimary
22230 );
22231 const isDisabled = !view.search && !view.filters?.some(
22232 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
22233 );
22234 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22235 import_components23.Button,
22236 {
22237 disabled: isDisabled,
22238 accessibleWhenDisabled: true,
22239 size: "compact",
22240 variant: "tertiary",
22241 className: "dataviews-filters__reset-button",
22242 onClick: () => {
22243 onChangeView({
22244 ...view,
22245 page: 1,
22246 search: "",
22247 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
22248 });
22249 },
22250 children: (0, import_i18n28.__)("Reset")
22251 }
22252 );
22253 }
22254
22255 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
22256 var import_element56 = __toESM(require_element(), 1);
22257 function useFilters(fields, view) {
22258 return (0, import_element56.useMemo)(() => {
22259 const filters = [];
22260 fields.forEach((field) => {
22261 if (field.filterBy === false || !field.hasElements && !field.Edit) {
22262 return;
22263 }
22264 const operators = field.filterBy.operators;
22265 const isPrimary = !!field.filterBy?.isPrimary;
22266 const isLocked = view.filters?.some(
22267 (f2) => f2.field === field.id && !!f2.isLocked
22268 ) ?? false;
22269 filters.push({
22270 field: field.id,
22271 name: field.label,
22272 elements: field.elements,
22273 getElements: field.getElements,
22274 hasElements: field.hasElements,
22275 singleSelection: operators.some(
22276 (op) => isSingleSelectionOperator(op)
22277 ),
22278 operators,
22279 isVisible: isLocked || isPrimary || !!view.filters?.some(
22280 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
22281 ),
22282 isPrimary,
22283 isLocked
22284 });
22285 });
22286 filters.sort((a2, b2) => {
22287 if (a2.isLocked && !b2.isLocked) {
22288 return -1;
22289 }
22290 if (!a2.isLocked && b2.isLocked) {
22291 return 1;
22292 }
22293 if (a2.isPrimary && !b2.isPrimary) {
22294 return -1;
22295 }
22296 if (!a2.isPrimary && b2.isPrimary) {
22297 return 1;
22298 }
22299 return a2.name.localeCompare(b2.name);
22300 });
22301 return filters;
22302 }, [fields, view]);
22303 }
22304 var use_filters_default = useFilters;
22305
22306 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
22307 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22308 function Filters({ className }) {
22309 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element57.useContext)(dataviews_context_default);
22310 const addFilterRef = (0, import_element57.useRef)(null);
22311 const filters = use_filters_default(fields, view);
22312 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22313 add_filter_default,
22314 {
22315 filters,
22316 view,
22317 onChangeView,
22318 ref: addFilterRef,
22319 setOpenedFilter
22320 },
22321 "add-filter"
22322 );
22323 const visibleFilters = filters.filter((filter) => filter.isVisible);
22324 if (visibleFilters.length === 0) {
22325 return null;
22326 }
22327 const filterComponents = [
22328 ...visibleFilters.map((filter) => {
22329 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22330 Filter,
22331 {
22332 filter,
22333 view,
22334 fields,
22335 onChangeView,
22336 addFilterRef,
22337 openedFilter
22338 },
22339 filter.field
22340 );
22341 }),
22342 addFilter
22343 ];
22344 filterComponents.push(
22345 /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22346 ResetFilter,
22347 {
22348 filters,
22349 view,
22350 onChangeView
22351 },
22352 "reset-filters"
22353 )
22354 );
22355 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22356 Stack,
22357 {
22358 direction: "row",
22359 justify: "flex-start",
22360 gap: "sm",
22361 style: { width: "fit-content" },
22362 wrap: "wrap",
22363 className,
22364 children: filterComponents
22365 }
22366 );
22367 }
22368 var filters_default = (0, import_element57.memo)(Filters);
22369
22370 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
22371 var import_element58 = __toESM(require_element(), 1);
22372 var import_components24 = __toESM(require_components(), 1);
22373 var import_i18n29 = __toESM(require_i18n(), 1);
22374 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22375 function FiltersToggle() {
22376 const {
22377 filters,
22378 view,
22379 onChangeView,
22380 setOpenedFilter,
22381 isShowingFilter,
22382 setIsShowingFilter
22383 } = (0, import_element58.useContext)(dataviews_context_default);
22384 const buttonRef = (0, import_element58.useRef)(null);
22385 const onChangeViewWithFilterVisibility = (0, import_element58.useCallback)(
22386 (_view) => {
22387 onChangeView(_view);
22388 setIsShowingFilter(true);
22389 },
22390 [onChangeView, setIsShowingFilter]
22391 );
22392 if (filters.length === 0) {
22393 return null;
22394 }
22395 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
22396 const addFilterButtonProps = {
22397 label: (0, import_i18n29.__)("Add filter"),
22398 "aria-expanded": false,
22399 isPressed: false
22400 };
22401 const toggleFiltersButtonProps = {
22402 label: (0, import_i18n29._x)("Filter", "verb"),
22403 "aria-expanded": isShowingFilter,
22404 isPressed: isShowingFilter,
22405 onClick: () => {
22406 if (!isShowingFilter) {
22407 setOpenedFilter(null);
22408 }
22409 setIsShowingFilter(!isShowingFilter);
22410 }
22411 };
22412 const hasPrimaryOrLockedFilters = filters.some(
22413 (filter) => filter.isPrimary || filter.isLocked
22414 );
22415 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22416 import_components24.Button,
22417 {
22418 ref: buttonRef,
22419 className: "dataviews-filters__visibility-toggle",
22420 size: "compact",
22421 icon: funnel_default,
22422 disabled: hasPrimaryOrLockedFilters,
22423 accessibleWhenDisabled: true,
22424 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
22425 }
22426 );
22427 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22428 AddFilterMenu,
22429 {
22430 filters,
22431 view,
22432 onChangeView: onChangeViewWithFilterVisibility,
22433 setOpenedFilter,
22434 triggerProps: { render: buttonComponent }
22435 }
22436 ) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22437 FilterVisibilityToggle,
22438 {
22439 buttonRef,
22440 filtersCount: view.filters?.length,
22441 children: buttonComponent
22442 }
22443 ) });
22444 }
22445 function FilterVisibilityToggle({
22446 buttonRef,
22447 filtersCount,
22448 children
22449 }) {
22450 (0, import_element58.useEffect)(
22451 () => () => {
22452 buttonRef.current?.focus();
22453 },
22454 [buttonRef]
22455 );
22456 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
22457 children,
22458 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
22459 ] });
22460 }
22461 var toggle_default = FiltersToggle;
22462
22463 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
22464 var import_element59 = __toESM(require_element(), 1);
22465 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22466 function FiltersToggled(props) {
22467 const { isShowingFilter } = (0, import_element59.useContext)(dataviews_context_default);
22468 if (!isShowingFilter) {
22469 return null;
22470 }
22471 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(filters_default, { ...props });
22472 }
22473 var filters_toggled_default = FiltersToggled;
22474
22475 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22476 var import_element60 = __toESM(require_element(), 1);
22477 var import_components25 = __toESM(require_components(), 1);
22478 var import_i18n30 = __toESM(require_i18n(), 1);
22479 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22480 function DataViewsLayout({ className }) {
22481 const {
22482 actions = [],
22483 data,
22484 fields,
22485 getItemId,
22486 getItemLevel,
22487 hasInitiallyLoaded,
22488 isLoading,
22489 view,
22490 onChangeView,
22491 selection,
22492 onChangeSelection,
22493 setOpenedFilter,
22494 onClickItem,
22495 isItemClickable,
22496 renderItemLink,
22497 defaultLayouts,
22498 containerRef,
22499 empty = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: (0, import_i18n30.__)("No results") })
22500 } = (0, import_element60.useContext)(dataviews_context_default);
22501 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22502 delay: 200
22503 });
22504 if (!hasInitiallyLoaded) {
22505 if (!isDelayedInitialLoading) {
22506 return null;
22507 }
22508 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components25.Spinner, {}) }) });
22509 }
22510 const ViewComponent = VIEW_LAYOUTS.find(
22511 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22512 )?.component;
22513 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22514 ViewComponent,
22515 {
22516 className,
22517 actions,
22518 data,
22519 fields,
22520 getItemId,
22521 getItemLevel,
22522 isLoading,
22523 onChangeView,
22524 onChangeSelection,
22525 selection,
22526 setOpenedFilter,
22527 onClickItem,
22528 renderItemLink,
22529 isItemClickable,
22530 view,
22531 empty
22532 }
22533 ) });
22534 }
22535
22536 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22537 var import_element61 = __toESM(require_element(), 1);
22538 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22539 var EMPTY_ARRAY5 = [];
22540 function DataViewsFooter() {
22541 const {
22542 view,
22543 paginationInfo: { totalItems = 0, totalPages },
22544 data,
22545 actions = EMPTY_ARRAY5,
22546 isLoading,
22547 hasInitiallyLoaded
22548 } = (0, import_element61.useContext)(dataviews_context_default);
22549 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22550 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22551 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22552 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22553 return null;
22554 }
22555 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
22556 "div",
22557 {
22558 className: "dataviews-footer",
22559 inert: isRefreshing ? "true" : void 0,
22560 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
22561 Stack,
22562 {
22563 direction: "row",
22564 justify: "end",
22565 align: "center",
22566 className: clsx_default("dataviews-footer__content", {
22567 "is-refreshing": isDelayedRefreshing
22568 }),
22569 gap: "sm",
22570 children: [
22571 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(BulkActionsFooter, {}),
22572 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(dataviews_pagination_default, {})
22573 ]
22574 }
22575 )
22576 }
22577 );
22578 }
22579
22580 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22581 var import_i18n31 = __toESM(require_i18n(), 1);
22582 var import_element62 = __toESM(require_element(), 1);
22583 var import_components26 = __toESM(require_components(), 1);
22584 var import_compose10 = __toESM(require_compose(), 1);
22585 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
22586 var DataViewsSearch = (0, import_element62.memo)(function Search({ label }) {
22587 const { view, onChangeView } = (0, import_element62.useContext)(dataviews_context_default);
22588 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22589 view.search
22590 );
22591 (0, import_element62.useEffect)(() => {
22592 if (view.search !== debouncedSearch) {
22593 setSearch(view.search ?? "");
22594 }
22595 }, [view.search, setSearch]);
22596 const onChangeViewRef = (0, import_element62.useRef)(onChangeView);
22597 const viewRef = (0, import_element62.useRef)(view);
22598 (0, import_element62.useEffect)(() => {
22599 onChangeViewRef.current = onChangeView;
22600 viewRef.current = view;
22601 }, [onChangeView, view]);
22602 (0, import_element62.useEffect)(() => {
22603 if (debouncedSearch !== viewRef.current?.search) {
22604 onChangeViewRef.current({
22605 ...viewRef.current,
22606 page: view.page ? 1 : void 0,
22607 startPosition: view.startPosition ? 1 : void 0,
22608 search: debouncedSearch
22609 });
22610 }
22611 }, [debouncedSearch]);
22612 const searchLabel = label || (0, import_i18n31.__)("Search");
22613 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
22614 import_components26.SearchControl,
22615 {
22616 className: "dataviews-search",
22617 onChange: setSearch,
22618 value: search,
22619 label: searchLabel,
22620 placeholder: searchLabel,
22621 size: "compact"
22622 }
22623 );
22624 });
22625 var dataviews_search_default = DataViewsSearch;
22626
22627 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22628 var import_components27 = __toESM(require_components(), 1);
22629 var import_i18n32 = __toESM(require_i18n(), 1);
22630 var import_element63 = __toESM(require_element(), 1);
22631 var import_warning = __toESM(require_warning(), 1);
22632 var import_compose11 = __toESM(require_compose(), 1);
22633 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
22634 var { Menu: Menu5 } = unlock2(import_components27.privateApis);
22635 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22636 className: "dataviews-config__popover",
22637 placement: "bottom-end",
22638 offset: 9
22639 };
22640 function ViewTypeMenu() {
22641 const { view, onChangeView, defaultLayouts } = (0, import_element63.useContext)(dataviews_context_default);
22642 const availableLayouts = Object.keys(defaultLayouts);
22643 if (availableLayouts.length <= 1) {
22644 return null;
22645 }
22646 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22647 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Menu5, { children: [
22648 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22649 Menu5.TriggerButton,
22650 {
22651 render: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22652 import_components27.Button,
22653 {
22654 size: "compact",
22655 icon: activeView?.icon,
22656 label: (0, import_i18n32.__)("Layout")
22657 }
22658 )
22659 }
22660 ),
22661 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22662 const config = VIEW_LAYOUTS.find(
22663 (v2) => v2.type === layout
22664 );
22665 if (!config) {
22666 return null;
22667 }
22668 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22669 Menu5.RadioItem,
22670 {
22671 value: layout,
22672 name: "view-actions-available-view",
22673 checked: layout === view.type,
22674 hideOnClick: true,
22675 onChange: (e2) => {
22676 switch (e2.target.value) {
22677 case "list":
22678 case "grid":
22679 case "table":
22680 case "pickerGrid":
22681 case "pickerTable":
22682 case "pickerActivity":
22683 case "activity":
22684 const viewWithoutLayout = { ...view };
22685 if ("layout" in viewWithoutLayout) {
22686 delete viewWithoutLayout.layout;
22687 }
22688 return onChangeView({
22689 ...viewWithoutLayout,
22690 type: e2.target.value,
22691 ...defaultLayouts[e2.target.value]
22692 });
22693 }
22694 (0, import_warning.default)("Invalid dataview");
22695 },
22696 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Menu5.ItemLabel, { children: config.label })
22697 },
22698 layout
22699 );
22700 }) })
22701 ] });
22702 }
22703 function SortFieldControl() {
22704 const { view, fields, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22705 const orderOptions = (0, import_element63.useMemo)(() => {
22706 const sortableFields = fields.filter(
22707 (field) => field.enableSorting !== false
22708 );
22709 return sortableFields.map((field) => {
22710 return {
22711 label: field.label,
22712 value: field.id
22713 };
22714 });
22715 }, [fields]);
22716 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22717 import_components27.SelectControl,
22718 {
22719 __next40pxDefaultSize: true,
22720 label: (0, import_i18n32.__)("Sort by"),
22721 value: view.sort?.field,
22722 options: orderOptions,
22723 onChange: (value) => {
22724 onChangeView({
22725 ...view,
22726 sort: {
22727 direction: view?.sort?.direction || "desc",
22728 field: value
22729 },
22730 showLevels: false
22731 });
22732 }
22733 }
22734 );
22735 }
22736 function SortDirectionControl() {
22737 const { view, fields, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22738 const sortableFields = fields.filter(
22739 (field) => field.enableSorting !== false
22740 );
22741 if (sortableFields.length === 0) {
22742 return null;
22743 }
22744 let value = view.sort?.direction;
22745 if (!value && view.sort?.field) {
22746 value = "desc";
22747 }
22748 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22749 import_components27.__experimentalToggleGroupControl,
22750 {
22751 className: "dataviews-view-config__sort-direction",
22752 __next40pxDefaultSize: true,
22753 isBlock: true,
22754 label: (0, import_i18n32.__)("Order"),
22755 value,
22756 onChange: (newDirection) => {
22757 if (newDirection === "asc" || newDirection === "desc") {
22758 onChangeView({
22759 ...view,
22760 sort: {
22761 direction: newDirection,
22762 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22763 fields.find(
22764 (field) => field.enableSorting !== false
22765 )?.id || ""
22766 },
22767 showLevels: false
22768 });
22769 return;
22770 }
22771 (0, import_warning.default)("Invalid direction");
22772 },
22773 children: SORTING_DIRECTIONS.map((direction) => {
22774 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22775 import_components27.__experimentalToggleGroupControlOptionIcon,
22776 {
22777 value: direction,
22778 icon: sortIcons[direction],
22779 label: sortLabels[direction]
22780 },
22781 direction
22782 );
22783 })
22784 }
22785 );
22786 }
22787 function ItemsPerPageControl() {
22788 const { view, config, onChangeView } = (0, import_element63.useContext)(dataviews_context_default);
22789 const { infiniteScrollEnabled } = view;
22790 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22791 return null;
22792 }
22793 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22794 import_components27.__experimentalToggleGroupControl,
22795 {
22796 __next40pxDefaultSize: true,
22797 isBlock: true,
22798 label: (0, import_i18n32.__)("Items per page"),
22799 value: view.perPage || 10,
22800 disabled: !view?.sort?.field,
22801 onChange: (newItemsPerPage) => {
22802 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22803 onChangeView({
22804 ...view,
22805 perPage: newItemsPerPageNumber,
22806 page: 1
22807 });
22808 },
22809 children: config.perPageSizes.map((value) => {
22810 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22811 import_components27.__experimentalToggleGroupControlOption,
22812 {
22813 value,
22814 label: value.toString()
22815 },
22816 value
22817 );
22818 })
22819 }
22820 );
22821 }
22822 function ResetViewButton() {
22823 const { onReset } = (0, import_element63.useContext)(dataviews_context_default);
22824 if (onReset === void 0) {
22825 return null;
22826 }
22827 const isDisabled = onReset === false;
22828 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22829 import_components27.Button,
22830 {
22831 variant: "tertiary",
22832 size: "compact",
22833 disabled: isDisabled,
22834 accessibleWhenDisabled: true,
22835 className: "dataviews-view-config__reset-button",
22836 onClick: () => {
22837 if (typeof onReset === "function") {
22838 onReset();
22839 }
22840 },
22841 children: (0, import_i18n32.__)("Reset view")
22842 }
22843 );
22844 }
22845 function DataviewsViewConfigDropdown() {
22846 const { view, onReset } = (0, import_element63.useContext)(dataviews_context_default);
22847 const popoverId = (0, import_compose11.useInstanceId)(
22848 _DataViewsViewConfig,
22849 "dataviews-view-config-dropdown"
22850 );
22851 const activeLayout = VIEW_LAYOUTS.find(
22852 (layout) => layout.type === view.type
22853 );
22854 const isModified = typeof onReset === "function";
22855 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22856 import_components27.Dropdown,
22857 {
22858 expandOnMobile: true,
22859 popoverProps: {
22860 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22861 id: popoverId
22862 },
22863 renderToggle: ({ onToggle, isOpen }) => {
22864 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22865 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22866 import_components27.Button,
22867 {
22868 size: "compact",
22869 icon: cog_default,
22870 label: (0, import_i18n32._x)(
22871 "View options",
22872 "View is used as a noun"
22873 ),
22874 onClick: onToggle,
22875 "aria-expanded": isOpen ? "true" : "false",
22876 "aria-controls": popoverId
22877 }
22878 ),
22879 isModified && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22880 ] });
22881 },
22882 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22883 import_components27.__experimentalDropdownContentWrapper,
22884 {
22885 paddingSize: "medium",
22886 className: "dataviews-config__popover-content-wrapper",
22887 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22888 Stack,
22889 {
22890 direction: "column",
22891 className: "dataviews-view-config",
22892 gap: "xl",
22893 children: [
22894 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22895 Stack,
22896 {
22897 direction: "row",
22898 justify: "space-between",
22899 align: "center",
22900 className: "dataviews-view-config__header",
22901 children: [
22902 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
22903 import_components27.__experimentalHeading,
22904 {
22905 level: 2,
22906 className: "dataviews-settings-section__title",
22907 children: (0, import_i18n32.__)("Appearance")
22908 }
22909 ),
22910 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ResetViewButton, {})
22911 ]
22912 }
22913 ),
22914 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22915 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
22916 Stack,
22917 {
22918 direction: "row",
22919 gap: "sm",
22920 className: "dataviews-view-config__sort-controls",
22921 children: [
22922 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortFieldControl, {}),
22923 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(SortDirectionControl, {})
22924 ]
22925 }
22926 ),
22927 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(activeLayout.viewConfigOptions, {}),
22928 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ItemsPerPageControl, {}),
22929 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(PropertiesSection, {})
22930 ] })
22931 ]
22932 }
22933 )
22934 }
22935 )
22936 }
22937 );
22938 }
22939 function _DataViewsViewConfig() {
22940 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
22941 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ViewTypeMenu, {}),
22942 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(DataviewsViewConfigDropdown, {})
22943 ] });
22944 }
22945 var DataViewsViewConfig = (0, import_element63.memo)(_DataViewsViewConfig);
22946 var dataviews_view_config_default = DataViewsViewConfig;
22947
22948 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22949 var import_components28 = __toESM(require_components(), 1);
22950 var import_element64 = __toESM(require_element(), 1);
22951
22952 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22953 function getCustomValidity(isValid2, validity) {
22954 let customValidity;
22955 if (isValid2?.required && validity?.required) {
22956 customValidity = validity?.required?.message ? validity.required : void 0;
22957 } else if (isValid2?.pattern && validity?.pattern) {
22958 customValidity = validity.pattern;
22959 } else if (isValid2?.min && validity?.min) {
22960 customValidity = validity.min;
22961 } else if (isValid2?.max && validity?.max) {
22962 customValidity = validity.max;
22963 } else if (isValid2?.minLength && validity?.minLength) {
22964 customValidity = validity.minLength;
22965 } else if (isValid2?.maxLength && validity?.maxLength) {
22966 customValidity = validity.maxLength;
22967 } else if (isValid2?.elements && validity?.elements) {
22968 customValidity = validity.elements;
22969 } else if (validity?.custom) {
22970 customValidity = validity.custom;
22971 }
22972 return customValidity;
22973 }
22974
22975 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22976 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
22977 var { ValidatedCheckboxControl } = unlock2(import_components28.privateApis);
22978 function Checkbox({
22979 field,
22980 onChange,
22981 data,
22982 hideLabelFromVision,
22983 markWhenOptional,
22984 validity
22985 }) {
22986 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22987 const disabled2 = field.isDisabled({ item: data, field });
22988 const onChangeControl = (0, import_element64.useCallback)(() => {
22989 onChange(
22990 setValue({ item: data, value: !getValue({ item: data }) })
22991 );
22992 }, [data, getValue, onChange, setValue]);
22993 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
22994 ValidatedCheckboxControl,
22995 {
22996 required: !!field.isValid?.required,
22997 markWhenOptional,
22998 customValidity: getCustomValidity(isValid2, validity),
22999 hidden: hideLabelFromVision,
23000 label,
23001 help: description,
23002 checked: getValue({ item: data }),
23003 onChange: onChangeControl,
23004 disabled: disabled2
23005 }
23006 );
23007 }
23008
23009 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
23010 var import_components29 = __toESM(require_components(), 1);
23011 var import_element65 = __toESM(require_element(), 1);
23012 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23013 var { ValidatedComboboxControl } = unlock2(import_components29.privateApis);
23014 function Combobox3({
23015 data,
23016 field,
23017 onChange,
23018 hideLabelFromVision,
23019 validity
23020 }) {
23021 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
23022 const value = getValue({ item: data }) ?? "";
23023 const onChangeControl = (0, import_element65.useCallback)(
23024 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
23025 [data, onChange, setValue]
23026 );
23027 const { elements, isLoading } = useElements({
23028 elements: field.elements,
23029 getElements: field.getElements
23030 });
23031 if (isLoading) {
23032 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components29.Spinner, {});
23033 }
23034 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23035 ValidatedComboboxControl,
23036 {
23037 required: !!field.isValid?.required,
23038 customValidity: getCustomValidity(isValid2, validity),
23039 label,
23040 value,
23041 help: description,
23042 placeholder,
23043 options: elements,
23044 onChange: onChangeControl,
23045 hideLabelFromVision,
23046 allowReset: true,
23047 expandOnFocus: true
23048 }
23049 );
23050 }
23051
23052 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23053 var import_components31 = __toESM(require_components(), 1);
23054 var import_element68 = __toESM(require_element(), 1);
23055 var import_i18n34 = __toESM(require_i18n(), 1);
23056 var import_date3 = __toESM(require_date(), 1);
23057
23058 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
23059 var import_components30 = __toESM(require_components(), 1);
23060 var import_element66 = __toESM(require_element(), 1);
23061 var import_i18n33 = __toESM(require_i18n(), 1);
23062 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23063 var TIME_UNITS_OPTIONS = {
23064 [OPERATOR_IN_THE_PAST]: [
23065 { value: "days", label: (0, import_i18n33.__)("Days") },
23066 { value: "weeks", label: (0, import_i18n33.__)("Weeks") },
23067 { value: "months", label: (0, import_i18n33.__)("Months") },
23068 { value: "years", label: (0, import_i18n33.__)("Years") }
23069 ],
23070 [OPERATOR_OVER]: [
23071 { value: "days", label: (0, import_i18n33.__)("Days ago") },
23072 { value: "weeks", label: (0, import_i18n33.__)("Weeks ago") },
23073 { value: "months", label: (0, import_i18n33.__)("Months ago") },
23074 { value: "years", label: (0, import_i18n33.__)("Years ago") }
23075 ]
23076 };
23077 function RelativeDateControl({
23078 className,
23079 data,
23080 field,
23081 onChange,
23082 hideLabelFromVision,
23083 operator
23084 }) {
23085 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
23086 const { id, label, description, getValue, setValue } = field;
23087 const disabled2 = field.isDisabled({ item: data, field });
23088 const fieldValue = getValue({ item: data });
23089 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
23090 const onChangeValue = (0, import_element66.useCallback)(
23091 (newValue) => onChange(
23092 setValue({
23093 item: data,
23094 value: { value: Number(newValue), unit }
23095 })
23096 ),
23097 [onChange, setValue, data, unit]
23098 );
23099 const onChangeUnit = (0, import_element66.useCallback)(
23100 (newUnit) => onChange(
23101 setValue({
23102 item: data,
23103 value: { value: relValue, unit: newUnit }
23104 })
23105 ),
23106 [onChange, setValue, data, relValue]
23107 );
23108 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23109 import_components30.BaseControl,
23110 {
23111 id,
23112 className: clsx_default(className, "dataviews-controls__relative-date"),
23113 label,
23114 hideLabelFromVision,
23115 help: description,
23116 children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(Stack, { direction: "row", gap: "sm", children: [
23117 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23118 import_components30.__experimentalNumberControl,
23119 {
23120 __next40pxDefaultSize: true,
23121 className: "dataviews-controls__relative-date-number",
23122 spinControls: "none",
23123 min: 1,
23124 step: 1,
23125 value: relValue,
23126 onChange: onChangeValue,
23127 disabled: disabled2
23128 }
23129 ),
23130 /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23131 import_components30.SelectControl,
23132 {
23133 className: "dataviews-controls__relative-date-unit",
23134 __next40pxDefaultSize: true,
23135 label: (0, import_i18n33.__)("Unit"),
23136 value: unit,
23137 options,
23138 onChange: onChangeUnit,
23139 hideLabelFromVision: true,
23140 disabled: disabled2
23141 }
23142 )
23143 ] })
23144 }
23145 );
23146 }
23147
23148 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
23149 var import_element67 = __toESM(require_element(), 1);
23150 function useDisabledDateMatchers(isValid2, parseDateFn) {
23151 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
23152 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
23153 const disabledMatchers = (0, import_element67.useMemo)(() => {
23154 const matchers = [];
23155 if (minConstraint) {
23156 const minDate = parseDateFn(minConstraint);
23157 if (minDate) {
23158 matchers.push({ before: minDate });
23159 }
23160 }
23161 if (maxConstraint) {
23162 const maxDate = parseDateFn(maxConstraint);
23163 if (maxDate) {
23164 matchers.push({ after: maxDate });
23165 }
23166 }
23167 return matchers.length > 0 ? matchers : void 0;
23168 }, [minConstraint, maxConstraint, parseDateFn]);
23169 return { minConstraint, maxConstraint, disabledMatchers };
23170 }
23171
23172 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
23173 var import_date2 = __toESM(require_date(), 1);
23174 function parseDateTime(dateTimeString) {
23175 if (!dateTimeString) {
23176 return null;
23177 }
23178 const parsed = (0, import_date2.getDate)(dateTimeString);
23179 return parsed && isValid(parsed) ? parsed : null;
23180 }
23181
23182 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
23183 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23184 var { DateCalendar, ValidatedInputControl } = unlock2(import_components31.privateApis);
23185 var formatDateTime = (value) => {
23186 if (!value) {
23187 return "";
23188 }
23189 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
23190 };
23191 function CalendarDateTimeControl({
23192 data,
23193 field,
23194 onChange,
23195 hideLabelFromVision,
23196 markWhenOptional,
23197 validity,
23198 config
23199 }) {
23200 const { compact } = config || {};
23201 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
23202 const disabled2 = field.isDisabled({ item: data, field });
23203 const fieldValue = getValue({ item: data });
23204 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23205 const [calendarMonth, setCalendarMonth] = (0, import_element68.useState)(() => {
23206 const parsedDate = parseDateTime(value);
23207 return parsedDate || /* @__PURE__ */ new Date();
23208 });
23209 const inputControlRef = (0, import_element68.useRef)(null);
23210 const validationTimeoutRef = (0, import_element68.useRef)(void 0);
23211 const previousFocusRef = (0, import_element68.useRef)(null);
23212 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
23213 const onChangeCallback = (0, import_element68.useCallback)(
23214 (newValue) => onChange(setValue({ item: data, value: newValue })),
23215 [data, onChange, setValue]
23216 );
23217 (0, import_element68.useEffect)(() => {
23218 return () => {
23219 if (validationTimeoutRef.current) {
23220 clearTimeout(validationTimeoutRef.current);
23221 }
23222 };
23223 }, []);
23224 const onSelectDate = (0, import_element68.useCallback)(
23225 (newDate) => {
23226 let dateTimeValue;
23227 if (newDate) {
23228 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
23229 let wpTime;
23230 if (value) {
23231 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
23232 } else {
23233 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
23234 }
23235 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
23236 dateTimeValue = finalDateTime.toISOString();
23237 onChangeCallback(dateTimeValue);
23238 if (validationTimeoutRef.current) {
23239 clearTimeout(validationTimeoutRef.current);
23240 }
23241 } else {
23242 onChangeCallback(void 0);
23243 }
23244 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
23245 validationTimeoutRef.current = setTimeout(() => {
23246 if (inputControlRef.current) {
23247 inputControlRef.current.focus();
23248 inputControlRef.current.blur();
23249 onChangeCallback(dateTimeValue);
23250 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
23251 previousFocusRef.current.focus();
23252 }
23253 }
23254 }, 0);
23255 },
23256 [onChangeCallback, value]
23257 );
23258 const handleManualDateTimeChange = (0, import_element68.useCallback)(
23259 (newValue) => {
23260 if (newValue) {
23261 const dateTime = (0, import_date3.getDate)(newValue);
23262 onChangeCallback(dateTime.toISOString());
23263 const parsedDate = parseDateTime(dateTime.toISOString());
23264 if (parsedDate) {
23265 setCalendarMonth(parsedDate);
23266 }
23267 } else {
23268 onChangeCallback(void 0);
23269 }
23270 },
23271 [onChangeCallback]
23272 );
23273 const { format: fieldFormat } = field;
23274 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
23275 const {
23276 timezone: { string: timezoneString }
23277 } = (0, import_date3.getSettings)();
23278 let displayLabel = label;
23279 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
23280 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23281 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
23282 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23283 }
23284 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23285 import_components31.BaseControl,
23286 {
23287 id,
23288 label: displayLabel,
23289 help: description,
23290 hideLabelFromVision,
23291 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23292 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23293 ValidatedInputControl,
23294 {
23295 ref: inputControlRef,
23296 __next40pxDefaultSize: true,
23297 required: !!isValid2?.required,
23298 customValidity: getCustomValidity(isValid2, validity),
23299 type: "datetime-local",
23300 label: (0, import_i18n34.__)("Date time"),
23301 hideLabelFromVision: true,
23302 value: formatDateTime(value),
23303 onChange: handleManualDateTimeChange,
23304 disabled: disabled2,
23305 min: minConstraint ? formatDateTime(minConstraint) : void 0,
23306 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
23307 }
23308 ),
23309 !compact && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23310 DateCalendar,
23311 {
23312 style: { width: "100%" },
23313 selected: value ? parseDateTime(value) || void 0 : void 0,
23314 onSelect: onSelectDate,
23315 month: calendarMonth,
23316 onMonthChange: setCalendarMonth,
23317 timeZone: timezoneString || void 0,
23318 weekStartsOn,
23319 disabled: disabled2 || disabledMatchers
23320 }
23321 )
23322 ] })
23323 }
23324 );
23325 }
23326 function DateTime({
23327 data,
23328 field,
23329 onChange,
23330 hideLabelFromVision,
23331 markWhenOptional,
23332 operator,
23333 validity,
23334 config
23335 }) {
23336 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23337 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23338 RelativeDateControl,
23339 {
23340 className: "dataviews-controls__datetime",
23341 data,
23342 field,
23343 onChange,
23344 hideLabelFromVision,
23345 operator
23346 }
23347 );
23348 }
23349 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23350 CalendarDateTimeControl,
23351 {
23352 data,
23353 field,
23354 onChange,
23355 hideLabelFromVision,
23356 markWhenOptional,
23357 validity,
23358 config
23359 }
23360 );
23361 }
23362
23363 // packages/dataviews/build-module/components/dataform-controls/date.mjs
23364 var import_components32 = __toESM(require_components(), 1);
23365 var import_element69 = __toESM(require_element(), 1);
23366 var import_i18n35 = __toESM(require_i18n(), 1);
23367 var import_date4 = __toESM(require_date(), 1);
23368 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23369 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components32.privateApis);
23370 var DATE_PRESETS = [
23371 {
23372 id: "today",
23373 label: (0, import_i18n35.__)("Today"),
23374 getValue: () => (0, import_date4.getDate)(null)
23375 },
23376 {
23377 id: "yesterday",
23378 label: (0, import_i18n35.__)("Yesterday"),
23379 getValue: () => {
23380 const today = (0, import_date4.getDate)(null);
23381 return subDays(today, 1);
23382 }
23383 },
23384 {
23385 id: "past-week",
23386 label: (0, import_i18n35.__)("Past week"),
23387 getValue: () => {
23388 const today = (0, import_date4.getDate)(null);
23389 return subDays(today, 7);
23390 }
23391 },
23392 {
23393 id: "past-month",
23394 label: (0, import_i18n35.__)("Past month"),
23395 getValue: () => {
23396 const today = (0, import_date4.getDate)(null);
23397 return subMonths(today, 1);
23398 }
23399 }
23400 ];
23401 var DATE_RANGE_PRESETS = [
23402 {
23403 id: "last-7-days",
23404 label: (0, import_i18n35.__)("Last 7 days"),
23405 getValue: () => {
23406 const today = (0, import_date4.getDate)(null);
23407 return [subDays(today, 7), today];
23408 }
23409 },
23410 {
23411 id: "last-30-days",
23412 label: (0, import_i18n35.__)("Last 30 days"),
23413 getValue: () => {
23414 const today = (0, import_date4.getDate)(null);
23415 return [subDays(today, 30), today];
23416 }
23417 },
23418 {
23419 id: "month-to-date",
23420 label: (0, import_i18n35.__)("Month to date"),
23421 getValue: () => {
23422 const today = (0, import_date4.getDate)(null);
23423 return [startOfMonth(today), today];
23424 }
23425 },
23426 {
23427 id: "last-year",
23428 label: (0, import_i18n35.__)("Last year"),
23429 getValue: () => {
23430 const today = (0, import_date4.getDate)(null);
23431 return [subYears(today, 1), today];
23432 }
23433 },
23434 {
23435 id: "year-to-date",
23436 label: (0, import_i18n35.__)("Year to date"),
23437 getValue: () => {
23438 const today = (0, import_date4.getDate)(null);
23439 return [startOfYear(today), today];
23440 }
23441 }
23442 ];
23443 var parseDate = (dateString) => {
23444 if (!dateString) {
23445 return null;
23446 }
23447 const parsed = (0, import_date4.getDate)(dateString);
23448 return parsed && isValid(parsed) ? parsed : null;
23449 };
23450 var formatDate = (date) => {
23451 if (!date) {
23452 return "";
23453 }
23454 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
23455 };
23456 function ValidatedDateControl({
23457 field,
23458 validity,
23459 inputRefs,
23460 isTouched,
23461 setIsTouched,
23462 children
23463 }) {
23464 const { isValid: isValid2 } = field;
23465 const [customValidity, setCustomValidity] = (0, import_element69.useState)(void 0);
23466 const validateRefs = (0, import_element69.useCallback)(() => {
23467 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23468 for (const ref of refs) {
23469 const input = ref.current;
23470 if (input && !input.validity.valid) {
23471 setCustomValidity({
23472 type: "invalid",
23473 message: input.validationMessage
23474 });
23475 return;
23476 }
23477 }
23478 setCustomValidity(void 0);
23479 }, [inputRefs]);
23480 (0, import_element69.useEffect)(() => {
23481 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23482 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23483 for (const ref of refs) {
23484 const input = ref.current;
23485 if (input) {
23486 input.setCustomValidity(
23487 result?.type === "invalid" && result.message ? result.message : ""
23488 );
23489 }
23490 }
23491 }, [inputRefs, isValid2, validity]);
23492 (0, import_element69.useEffect)(() => {
23493 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23494 const handleInvalid = (event) => {
23495 event.preventDefault();
23496 setIsTouched(true);
23497 };
23498 for (const ref of refs) {
23499 ref.current?.addEventListener("invalid", handleInvalid);
23500 }
23501 return () => {
23502 for (const ref of refs) {
23503 ref.current?.removeEventListener("invalid", handleInvalid);
23504 }
23505 };
23506 }, [inputRefs, setIsTouched]);
23507 (0, import_element69.useEffect)(() => {
23508 if (!isTouched) {
23509 return;
23510 }
23511 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23512 if (result) {
23513 setCustomValidity(result);
23514 } else {
23515 validateRefs();
23516 }
23517 }, [isTouched, isValid2, validity, validateRefs]);
23518 const onBlur = (event) => {
23519 if (isTouched) {
23520 return;
23521 }
23522 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23523 setIsTouched(true);
23524 }
23525 };
23526 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { onBlur, children: [
23527 children,
23528 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23529 "p",
23530 {
23531 className: clsx_default(
23532 "components-validated-control__indicator",
23533 customValidity.type === "invalid" ? "is-invalid" : void 0
23534 ),
23535 children: [
23536 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23537 import_components32.Icon,
23538 {
23539 className: "components-validated-control__indicator-icon",
23540 icon: error_default,
23541 size: 16,
23542 fill: "currentColor"
23543 }
23544 ),
23545 customValidity.message
23546 ]
23547 }
23548 ) })
23549 ] });
23550 }
23551 function CalendarDateControl({
23552 data,
23553 field,
23554 onChange,
23555 hideLabelFromVision,
23556 markWhenOptional,
23557 validity
23558 }) {
23559 const {
23560 id,
23561 label,
23562 description,
23563 setValue,
23564 getValue,
23565 isValid: isValid2,
23566 format: fieldFormat
23567 } = field;
23568 const disabled2 = field.isDisabled({ item: data, field });
23569 const [selectedPresetId, setSelectedPresetId] = (0, import_element69.useState)(
23570 null
23571 );
23572 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23573 const fieldValue = getValue({ item: data });
23574 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23575 const [calendarMonth, setCalendarMonth] = (0, import_element69.useState)(() => {
23576 const parsedDate = parseDate(value);
23577 return parsedDate || /* @__PURE__ */ new Date();
23578 });
23579 const [isTouched, setIsTouched] = (0, import_element69.useState)(false);
23580 const validityTargetRef = (0, import_element69.useRef)(null);
23581 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23582 const onChangeCallback = (0, import_element69.useCallback)(
23583 (newValue) => onChange(setValue({ item: data, value: newValue })),
23584 [data, onChange, setValue]
23585 );
23586 const onSelectDate = (0, import_element69.useCallback)(
23587 (newDate) => {
23588 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23589 onChangeCallback(dateValue);
23590 setSelectedPresetId(null);
23591 setIsTouched(true);
23592 },
23593 [onChangeCallback]
23594 );
23595 const handlePresetClick = (0, import_element69.useCallback)(
23596 (preset) => {
23597 const presetDate = preset.getValue();
23598 const dateValue = formatDate(presetDate);
23599 setCalendarMonth(presetDate);
23600 onChangeCallback(dateValue);
23601 setSelectedPresetId(preset.id);
23602 setIsTouched(true);
23603 },
23604 [onChangeCallback]
23605 );
23606 const handleManualDateChange = (0, import_element69.useCallback)(
23607 (newValue) => {
23608 onChangeCallback(newValue);
23609 if (newValue) {
23610 const parsedDate = parseDate(newValue);
23611 if (parsedDate) {
23612 setCalendarMonth(parsedDate);
23613 }
23614 }
23615 setSelectedPresetId(null);
23616 setIsTouched(true);
23617 },
23618 [onChangeCallback]
23619 );
23620 const {
23621 timezone: { string: timezoneString }
23622 } = (0, import_date4.getSettings)();
23623 let displayLabel = label;
23624 if (isValid2?.required && !markWhenOptional) {
23625 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23626 } else if (!isValid2?.required && markWhenOptional) {
23627 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23628 }
23629 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23630 ValidatedDateControl,
23631 {
23632 field,
23633 validity,
23634 inputRefs: validityTargetRef,
23635 isTouched,
23636 setIsTouched,
23637 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23638 import_components32.BaseControl,
23639 {
23640 id,
23641 className: "dataviews-controls__date",
23642 label: displayLabel,
23643 help: description,
23644 hideLabelFromVision,
23645 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23646 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23647 Stack,
23648 {
23649 direction: "row",
23650 gap: "sm",
23651 wrap: "wrap",
23652 justify: "flex-start",
23653 children: [
23654 DATE_PRESETS.map((preset) => {
23655 const isSelected2 = selectedPresetId === preset.id;
23656 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23657 import_components32.Button,
23658 {
23659 className: "dataviews-controls__date-preset",
23660 variant: "tertiary",
23661 isPressed: isSelected2,
23662 size: "small",
23663 disabled: disabled2,
23664 accessibleWhenDisabled: true,
23665 onClick: () => handlePresetClick(preset),
23666 children: preset.label
23667 },
23668 preset.id
23669 );
23670 }),
23671 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23672 import_components32.Button,
23673 {
23674 className: "dataviews-controls__date-preset",
23675 variant: "tertiary",
23676 isPressed: !selectedPresetId,
23677 size: "small",
23678 disabled: !!selectedPresetId || disabled2,
23679 accessibleWhenDisabled: true,
23680 children: (0, import_i18n35.__)("Custom")
23681 }
23682 )
23683 ]
23684 }
23685 ),
23686 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23687 import_components32.__experimentalInputControl,
23688 {
23689 __next40pxDefaultSize: true,
23690 ref: validityTargetRef,
23691 type: "date",
23692 label: (0, import_i18n35.__)("Date"),
23693 hideLabelFromVision: true,
23694 value,
23695 onChange: handleManualDateChange,
23696 required: !!field.isValid?.required,
23697 disabled: disabled2,
23698 min: minConstraint,
23699 max: maxConstraint
23700 }
23701 ),
23702 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23703 DateCalendar2,
23704 {
23705 style: { width: "100%" },
23706 selected: value ? parseDate(value) || void 0 : void 0,
23707 onSelect: onSelectDate,
23708 month: calendarMonth,
23709 onMonthChange: setCalendarMonth,
23710 timeZone: timezoneString || void 0,
23711 weekStartsOn,
23712 disabled: disabled2 || disabledMatchers,
23713 disableNavigation: disabled2
23714 }
23715 )
23716 ] })
23717 }
23718 )
23719 }
23720 );
23721 }
23722 function CalendarDateRangeControl({
23723 data,
23724 field,
23725 onChange,
23726 hideLabelFromVision,
23727 markWhenOptional,
23728 validity
23729 }) {
23730 const {
23731 id,
23732 label,
23733 description,
23734 getValue,
23735 setValue,
23736 isValid: isValid2,
23737 format: fieldFormat
23738 } = field;
23739 const disabled2 = field.isDisabled({ item: data, field });
23740 let value;
23741 const fieldValue = getValue({ item: data });
23742 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23743 value = fieldValue;
23744 }
23745 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23746 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23747 const onChangeCallback = (0, import_element69.useCallback)(
23748 (newValue) => {
23749 onChange(
23750 setValue({
23751 item: data,
23752 value: newValue
23753 })
23754 );
23755 },
23756 [data, onChange, setValue]
23757 );
23758 const [selectedPresetId, setSelectedPresetId] = (0, import_element69.useState)(
23759 null
23760 );
23761 const selectedRange = (0, import_element69.useMemo)(() => {
23762 if (!value) {
23763 return { from: void 0, to: void 0 };
23764 }
23765 const [from, to] = value;
23766 return {
23767 from: parseDate(from) || void 0,
23768 to: parseDate(to) || void 0
23769 };
23770 }, [value]);
23771 const [calendarMonth, setCalendarMonth] = (0, import_element69.useState)(() => {
23772 return selectedRange.from || /* @__PURE__ */ new Date();
23773 });
23774 const [isTouched, setIsTouched] = (0, import_element69.useState)(false);
23775 const fromInputRef = (0, import_element69.useRef)(null);
23776 const toInputRef = (0, import_element69.useRef)(null);
23777 const updateDateRange = (0, import_element69.useCallback)(
23778 (fromDate, toDate2) => {
23779 if (fromDate && toDate2) {
23780 onChangeCallback([
23781 formatDate(fromDate),
23782 formatDate(toDate2)
23783 ]);
23784 } else if (!fromDate && !toDate2) {
23785 onChangeCallback(void 0);
23786 }
23787 },
23788 [onChangeCallback]
23789 );
23790 const onSelectCalendarRange = (0, import_element69.useCallback)(
23791 (newRange) => {
23792 updateDateRange(newRange?.from, newRange?.to);
23793 setSelectedPresetId(null);
23794 setIsTouched(true);
23795 },
23796 [updateDateRange]
23797 );
23798 const handlePresetClick = (0, import_element69.useCallback)(
23799 (preset) => {
23800 const [startDate, endDate] = preset.getValue();
23801 setCalendarMonth(startDate);
23802 updateDateRange(startDate, endDate);
23803 setSelectedPresetId(preset.id);
23804 setIsTouched(true);
23805 },
23806 [updateDateRange]
23807 );
23808 const handleManualDateChange = (0, import_element69.useCallback)(
23809 (fromOrTo, newValue) => {
23810 const [currentFrom, currentTo] = value || [
23811 void 0,
23812 void 0
23813 ];
23814 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23815 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23816 updateDateRange(updatedFrom, updatedTo);
23817 if (newValue) {
23818 const parsedDate = parseDate(newValue);
23819 if (parsedDate) {
23820 setCalendarMonth(parsedDate);
23821 }
23822 }
23823 setSelectedPresetId(null);
23824 setIsTouched(true);
23825 },
23826 [value, updateDateRange]
23827 );
23828 const { timezone } = (0, import_date4.getSettings)();
23829 let displayLabel = label;
23830 if (field.isValid?.required && !markWhenOptional) {
23831 displayLabel = `${label} (${(0, import_i18n35.__)("Required")})`;
23832 } else if (!field.isValid?.required && markWhenOptional) {
23833 displayLabel = `${label} (${(0, import_i18n35.__)("Optional")})`;
23834 }
23835 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23836 ValidatedDateControl,
23837 {
23838 field,
23839 validity,
23840 inputRefs: [fromInputRef, toInputRef],
23841 isTouched,
23842 setIsTouched,
23843 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23844 import_components32.BaseControl,
23845 {
23846 id,
23847 className: "dataviews-controls__date",
23848 label: displayLabel,
23849 help: description,
23850 hideLabelFromVision,
23851 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23852 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23853 Stack,
23854 {
23855 direction: "row",
23856 gap: "sm",
23857 wrap: "wrap",
23858 justify: "flex-start",
23859 children: [
23860 DATE_RANGE_PRESETS.map((preset) => {
23861 const isSelected2 = selectedPresetId === preset.id;
23862 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23863 import_components32.Button,
23864 {
23865 className: "dataviews-controls__date-preset",
23866 variant: "tertiary",
23867 isPressed: isSelected2,
23868 size: "small",
23869 disabled: disabled2,
23870 accessibleWhenDisabled: true,
23871 onClick: () => handlePresetClick(preset),
23872 children: preset.label
23873 },
23874 preset.id
23875 );
23876 }),
23877 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23878 import_components32.Button,
23879 {
23880 className: "dataviews-controls__date-preset",
23881 variant: "tertiary",
23882 isPressed: !selectedPresetId,
23883 size: "small",
23884 accessibleWhenDisabled: true,
23885 disabled: !!selectedPresetId || disabled2,
23886 children: (0, import_i18n35.__)("Custom")
23887 }
23888 )
23889 ]
23890 }
23891 ),
23892 /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
23893 Stack,
23894 {
23895 direction: "row",
23896 gap: "sm",
23897 justify: "space-between",
23898 className: "dataviews-controls__date-range-inputs",
23899 children: [
23900 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23901 import_components32.__experimentalInputControl,
23902 {
23903 __next40pxDefaultSize: true,
23904 ref: fromInputRef,
23905 type: "date",
23906 label: (0, import_i18n35.__)("From"),
23907 hideLabelFromVision: true,
23908 value: value?.[0],
23909 onChange: (newValue) => handleManualDateChange("from", newValue),
23910 required: !!field.isValid?.required,
23911 disabled: disabled2,
23912 min: minConstraint,
23913 max: maxConstraint
23914 }
23915 ),
23916 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23917 import_components32.__experimentalInputControl,
23918 {
23919 __next40pxDefaultSize: true,
23920 ref: toInputRef,
23921 type: "date",
23922 label: (0, import_i18n35.__)("To"),
23923 hideLabelFromVision: true,
23924 value: value?.[1],
23925 onChange: (newValue) => handleManualDateChange("to", newValue),
23926 required: !!field.isValid?.required,
23927 disabled: disabled2,
23928 min: minConstraint,
23929 max: maxConstraint
23930 }
23931 )
23932 ]
23933 }
23934 ),
23935 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23936 DateRangeCalendar,
23937 {
23938 style: { width: "100%" },
23939 selected: selectedRange,
23940 onSelect: onSelectCalendarRange,
23941 month: calendarMonth,
23942 onMonthChange: setCalendarMonth,
23943 timeZone: timezone.string || void 0,
23944 weekStartsOn,
23945 disabled: disabled2 || disabledMatchers
23946 }
23947 )
23948 ] })
23949 }
23950 )
23951 }
23952 );
23953 }
23954 function DateControl({
23955 data,
23956 field,
23957 onChange,
23958 hideLabelFromVision,
23959 markWhenOptional,
23960 operator,
23961 validity
23962 }) {
23963 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23964 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23965 RelativeDateControl,
23966 {
23967 className: "dataviews-controls__date",
23968 data,
23969 field,
23970 onChange,
23971 hideLabelFromVision,
23972 operator
23973 }
23974 );
23975 }
23976 if (operator === OPERATOR_BETWEEN) {
23977 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23978 CalendarDateRangeControl,
23979 {
23980 data,
23981 field,
23982 onChange,
23983 hideLabelFromVision,
23984 markWhenOptional,
23985 validity
23986 }
23987 );
23988 }
23989 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23990 CalendarDateControl,
23991 {
23992 data,
23993 field,
23994 onChange,
23995 hideLabelFromVision,
23996 markWhenOptional,
23997 validity
23998 }
23999 );
24000 }
24001
24002 // packages/dataviews/build-module/components/dataform-controls/select.mjs
24003 var import_components33 = __toESM(require_components(), 1);
24004 var import_element70 = __toESM(require_element(), 1);
24005 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
24006 var { ValidatedSelectControl } = unlock2(import_components33.privateApis);
24007 function Select({
24008 data,
24009 field,
24010 onChange,
24011 hideLabelFromVision,
24012 markWhenOptional,
24013 validity
24014 }) {
24015 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
24016 const disabled2 = field.isDisabled({ item: data, field });
24017 const isMultiple = type === "array";
24018 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
24019 const onChangeControl = (0, import_element70.useCallback)(
24020 (newValue) => onChange(setValue({ item: data, value: newValue })),
24021 [data, onChange, setValue]
24022 );
24023 const { elements, isLoading } = useElements({
24024 elements: field.elements,
24025 getElements: field.getElements
24026 });
24027 if (isLoading) {
24028 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components33.Spinner, {});
24029 }
24030 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
24031 ValidatedSelectControl,
24032 {
24033 required: !!field.isValid?.required,
24034 markWhenOptional,
24035 customValidity: getCustomValidity(isValid2, validity),
24036 label,
24037 value,
24038 help: description,
24039 options: elements,
24040 onChange: onChangeControl,
24041 __next40pxDefaultSize: true,
24042 hideLabelFromVision,
24043 multiple: isMultiple,
24044 disabled: disabled2
24045 }
24046 );
24047 }
24048
24049 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
24050 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
24051 var ELEMENTS_THRESHOLD = 10;
24052 function AdaptiveSelect(props) {
24053 const { field } = props;
24054 const { elements } = useElements({
24055 elements: field.elements,
24056 getElements: field.getElements
24057 });
24058 if (elements.length >= ELEMENTS_THRESHOLD) {
24059 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Combobox3, { ...props });
24060 }
24061 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Select, { ...props });
24062 }
24063
24064 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24065 var import_components35 = __toESM(require_components(), 1);
24066
24067 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
24068 var import_components34 = __toESM(require_components(), 1);
24069 var import_element71 = __toESM(require_element(), 1);
24070 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
24071 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components34.privateApis);
24072 function ValidatedText({
24073 data,
24074 field,
24075 onChange,
24076 hideLabelFromVision,
24077 markWhenOptional,
24078 type,
24079 prefix,
24080 suffix,
24081 validity
24082 }) {
24083 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24084 const value = getValue({ item: data });
24085 const disabled2 = field.isDisabled({ item: data, field });
24086 const onChangeControl = (0, import_element71.useCallback)(
24087 (newValue) => onChange(
24088 setValue({
24089 item: data,
24090 value: newValue
24091 })
24092 ),
24093 [data, setValue, onChange]
24094 );
24095 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
24096 ValidatedInputControl2,
24097 {
24098 required: !!isValid2.required,
24099 markWhenOptional,
24100 customValidity: getCustomValidity(isValid2, validity),
24101 label,
24102 placeholder,
24103 value: value ?? "",
24104 help: description,
24105 onChange: onChangeControl,
24106 hideLabelFromVision,
24107 type,
24108 prefix,
24109 suffix,
24110 disabled: disabled2,
24111 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
24112 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24113 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24114 __next40pxDefaultSize: true
24115 }
24116 );
24117 }
24118
24119 // packages/dataviews/build-module/components/dataform-controls/email.mjs
24120 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
24121 function Email({
24122 data,
24123 field,
24124 onChange,
24125 hideLabelFromVision,
24126 markWhenOptional,
24127 validity
24128 }) {
24129 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
24130 ValidatedText,
24131 {
24132 ...{
24133 data,
24134 field,
24135 onChange,
24136 hideLabelFromVision,
24137 markWhenOptional,
24138 validity,
24139 type: "email",
24140 prefix: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_components35.Icon, { icon: envelope_default }) })
24141 }
24142 }
24143 );
24144 }
24145
24146 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
24147 var import_components36 = __toESM(require_components(), 1);
24148 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
24149 function Telephone({
24150 data,
24151 field,
24152 onChange,
24153 hideLabelFromVision,
24154 markWhenOptional,
24155 validity
24156 }) {
24157 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
24158 ValidatedText,
24159 {
24160 ...{
24161 data,
24162 field,
24163 onChange,
24164 hideLabelFromVision,
24165 markWhenOptional,
24166 validity,
24167 type: "tel",
24168 prefix: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components36.Icon, { icon: mobile_default }) })
24169 }
24170 }
24171 );
24172 }
24173
24174 // packages/dataviews/build-module/components/dataform-controls/url.mjs
24175 var import_components37 = __toESM(require_components(), 1);
24176 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
24177 function Url({
24178 data,
24179 field,
24180 onChange,
24181 hideLabelFromVision,
24182 markWhenOptional,
24183 validity
24184 }) {
24185 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24186 ValidatedText,
24187 {
24188 ...{
24189 data,
24190 field,
24191 onChange,
24192 hideLabelFromVision,
24193 markWhenOptional,
24194 validity,
24195 type: "url",
24196 prefix: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components37.Icon, { icon: link_default }) })
24197 }
24198 }
24199 );
24200 }
24201
24202 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
24203 var import_components38 = __toESM(require_components(), 1);
24204 var import_element72 = __toESM(require_element(), 1);
24205 var import_i18n36 = __toESM(require_i18n(), 1);
24206 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24207 var { ValidatedNumberControl } = unlock2(import_components38.privateApis);
24208 function toNumberOrEmpty(value) {
24209 if (value === "" || value === void 0) {
24210 return "";
24211 }
24212 const number = Number(value);
24213 return Number.isFinite(number) ? number : "";
24214 }
24215 function BetweenControls({
24216 value,
24217 onChange,
24218 hideLabelFromVision,
24219 step
24220 }) {
24221 const [min2 = "", max2 = ""] = value;
24222 const onChangeMin = (0, import_element72.useCallback)(
24223 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
24224 [onChange, max2]
24225 );
24226 const onChangeMax = (0, import_element72.useCallback)(
24227 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
24228 [onChange, min2]
24229 );
24230 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24231 import_components38.BaseControl,
24232 {
24233 help: (0, import_i18n36.__)("The max. value must be greater than the min. value."),
24234 children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
24235 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24236 import_components38.__experimentalNumberControl,
24237 {
24238 label: (0, import_i18n36.__)("Min."),
24239 value: min2,
24240 max: max2 ? Number(max2) - step : void 0,
24241 onChange: onChangeMin,
24242 __next40pxDefaultSize: true,
24243 hideLabelFromVision,
24244 step
24245 }
24246 ),
24247 /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24248 import_components38.__experimentalNumberControl,
24249 {
24250 label: (0, import_i18n36.__)("Max."),
24251 value: max2,
24252 min: min2 ? Number(min2) + step : void 0,
24253 onChange: onChangeMax,
24254 __next40pxDefaultSize: true,
24255 hideLabelFromVision,
24256 step
24257 }
24258 )
24259 ] })
24260 }
24261 );
24262 }
24263 function ValidatedNumber({
24264 data,
24265 field,
24266 onChange,
24267 hideLabelFromVision,
24268 markWhenOptional,
24269 operator,
24270 validity
24271 }) {
24272 const decimals = field.format?.decimals ?? 0;
24273 const step = Math.pow(10, Math.abs(decimals) * -1);
24274 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24275 const value = getValue({ item: data }) ?? "";
24276 const disabled2 = field.isDisabled({ item: data, field });
24277 const onChangeControl = (0, import_element72.useCallback)(
24278 (newValue) => {
24279 onChange(
24280 setValue({
24281 item: data,
24282 // Do not convert an empty string or undefined to a number,
24283 // otherwise there's a mismatch between the UI control (empty)
24284 // and the data relied by onChange (0).
24285 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
24286 })
24287 );
24288 },
24289 [data, onChange, setValue]
24290 );
24291 const onChangeBetweenControls = (0, import_element72.useCallback)(
24292 (newValue) => {
24293 onChange(
24294 setValue({
24295 item: data,
24296 value: newValue
24297 })
24298 );
24299 },
24300 [data, onChange, setValue]
24301 );
24302 if (operator === OPERATOR_BETWEEN) {
24303 let valueBetween = ["", ""];
24304 if (Array.isArray(value) && value.length === 2 && value.every(
24305 (element) => typeof element === "number" || element === ""
24306 )) {
24307 valueBetween = value;
24308 }
24309 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24310 BetweenControls,
24311 {
24312 value: valueBetween,
24313 onChange: onChangeBetweenControls,
24314 hideLabelFromVision,
24315 step
24316 }
24317 );
24318 }
24319 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24320 ValidatedNumberControl,
24321 {
24322 required: !!isValid2.required,
24323 markWhenOptional,
24324 customValidity: getCustomValidity(isValid2, validity),
24325 label,
24326 help: description,
24327 value,
24328 onChange: onChangeControl,
24329 __next40pxDefaultSize: true,
24330 hideLabelFromVision,
24331 step,
24332 min: isValid2.min ? isValid2.min.constraint : void 0,
24333 max: isValid2.max ? isValid2.max.constraint : void 0,
24334 disabled: disabled2
24335 }
24336 );
24337 }
24338
24339 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
24340 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24341 function Integer(props) {
24342 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(ValidatedNumber, { ...props });
24343 }
24344
24345 // packages/dataviews/build-module/components/dataform-controls/number.mjs
24346 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24347 function Number2(props) {
24348 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ValidatedNumber, { ...props });
24349 }
24350
24351 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
24352 var import_components39 = __toESM(require_components(), 1);
24353 var import_element73 = __toESM(require_element(), 1);
24354 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24355 var { ValidatedRadioControl } = unlock2(import_components39.privateApis);
24356 function Radio({
24357 data,
24358 field,
24359 onChange,
24360 hideLabelFromVision,
24361 markWhenOptional,
24362 validity
24363 }) {
24364 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24365 const disabled2 = field.isDisabled({ item: data, field });
24366 const { elements, isLoading } = useElements({
24367 elements: field.elements,
24368 getElements: field.getElements
24369 });
24370 const value = getValue({ item: data });
24371 const onChangeControl = (0, import_element73.useCallback)(
24372 (newValue) => onChange(setValue({ item: data, value: newValue })),
24373 [data, onChange, setValue]
24374 );
24375 if (isLoading) {
24376 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components39.Spinner, {});
24377 }
24378 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24379 ValidatedRadioControl,
24380 {
24381 required: !!field.isValid?.required,
24382 markWhenOptional,
24383 customValidity: getCustomValidity(isValid2, validity),
24384 label,
24385 help: description,
24386 onChange: onChangeControl,
24387 options: elements,
24388 selected: value,
24389 hideLabelFromVision,
24390 disabled: disabled2
24391 }
24392 );
24393 }
24394
24395 // packages/dataviews/build-module/components/dataform-controls/text.mjs
24396 var import_element74 = __toESM(require_element(), 1);
24397 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24398 function Text3({
24399 data,
24400 field,
24401 onChange,
24402 hideLabelFromVision,
24403 markWhenOptional,
24404 config,
24405 validity
24406 }) {
24407 const { prefix, suffix } = config || {};
24408 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
24409 ValidatedText,
24410 {
24411 ...{
24412 data,
24413 field,
24414 onChange,
24415 hideLabelFromVision,
24416 markWhenOptional,
24417 validity,
24418 prefix: prefix ? (0, import_element74.createElement)(prefix) : void 0,
24419 suffix: suffix ? (0, import_element74.createElement)(suffix) : void 0
24420 }
24421 }
24422 );
24423 }
24424
24425 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
24426 var import_components40 = __toESM(require_components(), 1);
24427 var import_element75 = __toESM(require_element(), 1);
24428 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24429 var { ValidatedToggleControl } = unlock2(import_components40.privateApis);
24430 function Toggle({
24431 field,
24432 onChange,
24433 data,
24434 hideLabelFromVision,
24435 markWhenOptional,
24436 validity
24437 }) {
24438 const { label, description, getValue, setValue, isValid: isValid2 } = field;
24439 const disabled2 = field.isDisabled({ item: data, field });
24440 const onChangeControl = (0, import_element75.useCallback)(() => {
24441 onChange(
24442 setValue({ item: data, value: !getValue({ item: data }) })
24443 );
24444 }, [onChange, setValue, data, getValue]);
24445 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24446 ValidatedToggleControl,
24447 {
24448 required: !!isValid2.required,
24449 markWhenOptional,
24450 customValidity: getCustomValidity(isValid2, validity),
24451 hidden: hideLabelFromVision,
24452 label,
24453 help: description,
24454 checked: getValue({ item: data }),
24455 onChange: onChangeControl,
24456 disabled: disabled2
24457 }
24458 );
24459 }
24460
24461 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
24462 var import_components41 = __toESM(require_components(), 1);
24463 var import_element76 = __toESM(require_element(), 1);
24464 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
24465 var { ValidatedTextareaControl } = unlock2(import_components41.privateApis);
24466 function Textarea({
24467 data,
24468 field,
24469 onChange,
24470 hideLabelFromVision,
24471 markWhenOptional,
24472 config,
24473 validity
24474 }) {
24475 const { rows = 4 } = config || {};
24476 const disabled2 = field.isDisabled({ item: data, field });
24477 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24478 const value = field.getValue({ item: data });
24479 const onChangeControl = (0, import_element76.useCallback)(
24480 (newValue) => onChange(setValue({ item: data, value: newValue })),
24481 [data, onChange, setValue]
24482 );
24483 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
24484 ValidatedTextareaControl,
24485 {
24486 required: !!isValid2.required,
24487 markWhenOptional,
24488 customValidity: getCustomValidity(isValid2, validity),
24489 label,
24490 placeholder,
24491 value: value ?? "",
24492 help: description,
24493 onChange: onChangeControl,
24494 rows,
24495 disabled: disabled2,
24496 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24497 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24498 __next40pxDefaultSize: true,
24499 hideLabelFromVision
24500 }
24501 );
24502 }
24503
24504 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24505 var import_components42 = __toESM(require_components(), 1);
24506 var import_element77 = __toESM(require_element(), 1);
24507 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
24508 var { ValidatedToggleGroupControl } = unlock2(import_components42.privateApis);
24509 function ToggleGroup({
24510 data,
24511 field,
24512 onChange,
24513 hideLabelFromVision,
24514 markWhenOptional,
24515 validity
24516 }) {
24517 const { getValue, setValue, isValid: isValid2 } = field;
24518 const disabled2 = field.isDisabled({ item: data, field });
24519 const value = getValue({ item: data });
24520 const onChangeControl = (0, import_element77.useCallback)(
24521 (newValue) => onChange(setValue({ item: data, value: newValue })),
24522 [data, onChange, setValue]
24523 );
24524 const { elements, isLoading } = useElements({
24525 elements: field.elements,
24526 getElements: field.getElements
24527 });
24528 if (isLoading) {
24529 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_components42.Spinner, {});
24530 }
24531 if (elements.length === 0) {
24532 return null;
24533 }
24534 const selectedOption = elements.find((el) => el.value === value);
24535 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24536 ValidatedToggleGroupControl,
24537 {
24538 required: !!field.isValid?.required,
24539 markWhenOptional,
24540 customValidity: getCustomValidity(isValid2, validity),
24541 __next40pxDefaultSize: true,
24542 isBlock: true,
24543 label: field.label,
24544 help: selectedOption?.description || field.description,
24545 onChange: onChangeControl,
24546 value,
24547 hideLabelFromVision,
24548 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
24549 import_components42.__experimentalToggleGroupControlOption,
24550 {
24551 label: el.label,
24552 value: el.value,
24553 disabled: disabled2
24554 },
24555 el.value
24556 ))
24557 }
24558 );
24559 }
24560
24561 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24562 var import_components43 = __toESM(require_components(), 1);
24563 var import_element78 = __toESM(require_element(), 1);
24564 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
24565 var { ValidatedFormTokenField } = unlock2(import_components43.privateApis);
24566 function ArrayControl({
24567 data,
24568 field,
24569 onChange,
24570 hideLabelFromVision,
24571 markWhenOptional,
24572 validity
24573 }) {
24574 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24575 const value = getValue({ item: data });
24576 const disabled2 = field.isDisabled({ item: data, field });
24577 const { elements, isLoading } = useElements({
24578 elements: field.elements,
24579 getElements: field.getElements
24580 });
24581 const arrayValueAsElements = (0, import_element78.useMemo)(
24582 () => Array.isArray(value) ? value.map((token) => {
24583 const element = elements?.find(
24584 (suggestion) => suggestion.value === token
24585 );
24586 return element || { value: token, label: token };
24587 }) : [],
24588 [value, elements]
24589 );
24590 const onChangeControl = (0, import_element78.useCallback)(
24591 (tokens) => {
24592 const valueTokens = tokens.map((token) => {
24593 if (typeof token === "object" && "value" in token) {
24594 return token.value;
24595 }
24596 return token;
24597 });
24598 onChange(setValue({ item: data, value: valueTokens }));
24599 },
24600 [onChange, setValue, data]
24601 );
24602 if (isLoading) {
24603 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_components43.Spinner, {});
24604 }
24605 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
24606 ValidatedFormTokenField,
24607 {
24608 required: !!isValid2?.required,
24609 markWhenOptional,
24610 customValidity: getCustomValidity(isValid2, validity),
24611 label: hideLabelFromVision ? void 0 : label,
24612 value: arrayValueAsElements,
24613 onChange: onChangeControl,
24614 placeholder,
24615 suggestions: elements?.map((element) => element.value),
24616 disabled: disabled2,
24617 __experimentalValidateInput: (token) => {
24618 if (field.isValid?.elements && elements) {
24619 return elements.some(
24620 (element) => element.value === token || element.label === token
24621 );
24622 }
24623 return true;
24624 },
24625 __experimentalExpandOnFocus: elements && elements.length > 0,
24626 help: description ?? (field.isValid?.elements ? "" : void 0),
24627 displayTransform: (token) => {
24628 if (typeof token === "object" && "label" in token) {
24629 return token.label;
24630 }
24631 if (typeof token === "string" && elements) {
24632 const element = elements.find(
24633 (el) => el.value === token
24634 );
24635 return element?.label || token;
24636 }
24637 return token;
24638 },
24639 __experimentalRenderItem: ({ item }) => {
24640 if (typeof item === "string" && elements) {
24641 const element = elements.find(
24642 (el) => el.value === item
24643 );
24644 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: element?.label || item });
24645 }
24646 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: item });
24647 }
24648 }
24649 );
24650 }
24651
24652 // node_modules/colord/index.mjs
24653 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24654 var t = function(r3) {
24655 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24656 };
24657 var n = function(r3, t2, n2) {
24658 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24659 };
24660 var e = function(r3, t2, n2) {
24661 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24662 };
24663 var u = function(r3) {
24664 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24665 };
24666 var a = function(r3) {
24667 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24668 };
24669 var o = function(r3) {
24670 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24671 };
24672 var i = /^#([0-9a-f]{3,8})$/i;
24673 var s = function(r3) {
24674 var t2 = r3.toString(16);
24675 return t2.length < 2 ? "0" + t2 : t2;
24676 };
24677 var h = function(r3) {
24678 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;
24679 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24680 };
24681 var b = function(r3) {
24682 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24683 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24684 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;
24685 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 };
24686 };
24687 var g = function(r3) {
24688 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24689 };
24690 var d = function(r3) {
24691 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24692 };
24693 var f = function(r3) {
24694 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 }));
24695 var t2, n2, e2;
24696 };
24697 var c = function(r3) {
24698 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 };
24699 var t2, n2, e2, u2;
24700 };
24701 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24702 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24703 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24704 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24705 var y = { string: [[function(r3) {
24706 var t2 = i.exec(r3);
24707 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;
24708 }, "hex"], [function(r3) {
24709 var t2 = v.exec(r3) || m.exec(r3);
24710 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;
24711 }, "rgb"], [function(t2) {
24712 var n2 = l.exec(t2) || p.exec(t2);
24713 if (!n2) return null;
24714 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) });
24715 return f(a2);
24716 }, "hsl"]], object: [[function(r3) {
24717 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24718 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24719 }, "rgb"], [function(r3) {
24720 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24721 if (!t(n2) || !t(e2) || !t(u2)) return null;
24722 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24723 return f(i2);
24724 }, "hsl"], [function(r3) {
24725 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24726 if (!t(n2) || !t(a2) || !t(o2)) return null;
24727 var h2 = (function(r4) {
24728 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24729 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24730 return b(h2);
24731 }, "hsv"]] };
24732 var N = function(r3, t2) {
24733 for (var n2 = 0; n2 < t2.length; n2++) {
24734 var e2 = t2[n2][0](r3);
24735 if (e2) return [e2, t2[n2][1]];
24736 }
24737 return [null, void 0];
24738 };
24739 var x = function(r3) {
24740 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24741 };
24742 var M = function(r3, t2) {
24743 var n2 = c(r3);
24744 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24745 };
24746 var H = function(r3) {
24747 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24748 };
24749 var $ = function(r3, t2) {
24750 var n2 = c(r3);
24751 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24752 };
24753 var j = (function() {
24754 function r3(r4) {
24755 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24756 }
24757 return r3.prototype.isValid = function() {
24758 return null !== this.parsed;
24759 }, r3.prototype.brightness = function() {
24760 return n(H(this.rgba), 2);
24761 }, r3.prototype.isDark = function() {
24762 return H(this.rgba) < 0.5;
24763 }, r3.prototype.isLight = function() {
24764 return H(this.rgba) >= 0.5;
24765 }, r3.prototype.toHex = function() {
24766 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;
24767 var r4, t2, e2, u2, a2, i2;
24768 }, r3.prototype.toRgb = function() {
24769 return o(this.rgba);
24770 }, r3.prototype.toRgbString = function() {
24771 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 + ")";
24772 var r4, t2, n2, e2, u2;
24773 }, r3.prototype.toHsl = function() {
24774 return d(c(this.rgba));
24775 }, r3.prototype.toHslString = function() {
24776 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 + "%)";
24777 var r4, t2, n2, e2, u2;
24778 }, r3.prototype.toHsv = function() {
24779 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24780 var r4;
24781 }, r3.prototype.invert = function() {
24782 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24783 var r4;
24784 }, r3.prototype.saturate = function(r4) {
24785 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24786 }, r3.prototype.desaturate = function(r4) {
24787 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24788 }, r3.prototype.grayscale = function() {
24789 return w(M(this.rgba, -1));
24790 }, r3.prototype.lighten = function(r4) {
24791 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24792 }, r3.prototype.darken = function(r4) {
24793 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24794 }, r3.prototype.rotate = function(r4) {
24795 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24796 }, r3.prototype.alpha = function(r4) {
24797 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24798 var t2;
24799 }, r3.prototype.hue = function(r4) {
24800 var t2 = c(this.rgba);
24801 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24802 }, r3.prototype.isEqual = function(r4) {
24803 return this.toHex() === w(r4).toHex();
24804 }, r3;
24805 })();
24806 var w = function(r3) {
24807 return r3 instanceof j ? r3 : new j(r3);
24808 };
24809
24810 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24811 var import_components44 = __toESM(require_components(), 1);
24812 var import_element79 = __toESM(require_element(), 1);
24813 var import_i18n37 = __toESM(require_i18n(), 1);
24814 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
24815 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components44.privateApis);
24816 var ColorPickerDropdown = ({
24817 color,
24818 onColorChange,
24819 disabled: disabled2
24820 }) => {
24821 const validColor = color && w(color).isValid() ? color : "#ffffff";
24822 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24823 import_components44.Dropdown,
24824 {
24825 className: "dataviews-controls__color-picker-dropdown",
24826 popoverProps: { resize: false },
24827 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24828 import_components44.Button,
24829 {
24830 onClick: onToggle,
24831 "aria-label": (0, import_i18n37.__)("Open color picker"),
24832 size: "small",
24833 disabled: disabled2,
24834 accessibleWhenDisabled: true,
24835 icon: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
24836 }
24837 ),
24838 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24839 import_components44.ColorPicker,
24840 {
24841 color: validColor,
24842 onChange: onColorChange,
24843 enableAlpha: true
24844 }
24845 ) })
24846 }
24847 );
24848 };
24849 function Color({
24850 data,
24851 field,
24852 onChange,
24853 hideLabelFromVision,
24854 markWhenOptional,
24855 validity
24856 }) {
24857 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24858 const disabled2 = field.isDisabled({ item: data, field });
24859 const value = field.getValue({ item: data }) || "";
24860 const handleColorChange = (0, import_element79.useCallback)(
24861 (newColor) => {
24862 onChange(setValue({ item: data, value: newColor }));
24863 },
24864 [data, onChange, setValue]
24865 );
24866 const handleInputChange = (0, import_element79.useCallback)(
24867 (newValue) => {
24868 onChange(setValue({ item: data, value: newValue || "" }));
24869 },
24870 [data, onChange, setValue]
24871 );
24872 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24873 ValidatedInputControl3,
24874 {
24875 required: !!field.isValid?.required,
24876 markWhenOptional,
24877 customValidity: getCustomValidity(isValid2, validity),
24878 label,
24879 placeholder,
24880 value,
24881 help: description,
24882 onChange: handleInputChange,
24883 hideLabelFromVision,
24884 type: "text",
24885 disabled: disabled2,
24886 prefix: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
24887 ColorPickerDropdown,
24888 {
24889 color: value,
24890 onColorChange: handleColorChange,
24891 disabled: disabled2
24892 }
24893 ) })
24894 }
24895 );
24896 }
24897
24898 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24899 var import_components45 = __toESM(require_components(), 1);
24900 var import_element80 = __toESM(require_element(), 1);
24901 var import_i18n38 = __toESM(require_i18n(), 1);
24902 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
24903 function Password({
24904 data,
24905 field,
24906 onChange,
24907 hideLabelFromVision,
24908 markWhenOptional,
24909 validity
24910 }) {
24911 const [isVisible2, setIsVisible] = (0, import_element80.useState)(false);
24912 const disabled2 = field.isDisabled({ item: data, field });
24913 const toggleVisibility = (0, import_element80.useCallback)(() => {
24914 setIsVisible((prev) => !prev);
24915 }, []);
24916 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24917 ValidatedText,
24918 {
24919 ...{
24920 data,
24921 field,
24922 onChange,
24923 hideLabelFromVision,
24924 markWhenOptional,
24925 validity,
24926 type: isVisible2 ? "text" : "password",
24927 suffix: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
24928 import_components45.Button,
24929 {
24930 icon: isVisible2 ? unseen_default : seen_default,
24931 onClick: toggleVisibility,
24932 size: "small",
24933 label: isVisible2 ? (0, import_i18n38.__)("Hide password") : (0, import_i18n38.__)("Show password"),
24934 disabled: disabled2,
24935 accessibleWhenDisabled: true
24936 }
24937 ) })
24938 }
24939 }
24940 );
24941 }
24942
24943 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24944 function hasElements(field) {
24945 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24946 }
24947
24948 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24949 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
24950 var FORM_CONTROLS = {
24951 adaptiveSelect: AdaptiveSelect,
24952 array: ArrayControl,
24953 checkbox: Checkbox,
24954 color: Color,
24955 combobox: Combobox3,
24956 datetime: DateTime,
24957 date: DateControl,
24958 email: Email,
24959 telephone: Telephone,
24960 url: Url,
24961 integer: Integer,
24962 number: Number2,
24963 password: Password,
24964 radio: Radio,
24965 select: Select,
24966 text: Text3,
24967 toggle: Toggle,
24968 textarea: Textarea,
24969 toggleGroup: ToggleGroup
24970 };
24971 function isEditConfig(value) {
24972 return value && typeof value === "object" && typeof value.control === "string";
24973 }
24974 function createConfiguredControl(config) {
24975 const { control, ...controlConfig } = config;
24976 const BaseControlType = getControlByType(control);
24977 if (BaseControlType === null) {
24978 return null;
24979 }
24980 return function ConfiguredControl(props) {
24981 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(BaseControlType, { ...props, config: controlConfig });
24982 };
24983 }
24984 function getControl(field, fallback) {
24985 if (typeof field.Edit === "function") {
24986 return field.Edit;
24987 }
24988 if (typeof field.Edit === "string") {
24989 return getControlByType(field.Edit);
24990 }
24991 if (isEditConfig(field.Edit)) {
24992 return createConfiguredControl(field.Edit);
24993 }
24994 if (hasElements(field) && field.type !== "array") {
24995 return getControlByType("adaptiveSelect");
24996 }
24997 if (fallback === null) {
24998 return null;
24999 }
25000 return getControlByType(fallback);
25001 }
25002 function getControlByType(type) {
25003 if (Object.keys(FORM_CONTROLS).includes(type)) {
25004 return FORM_CONTROLS[type];
25005 }
25006 return null;
25007 }
25008
25009 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
25010 function getFilterBy(field, defaultOperators, validOperators) {
25011 if (field.filterBy === false) {
25012 return false;
25013 }
25014 const operators = field.filterBy?.operators?.filter(
25015 (op) => validOperators.includes(op)
25016 ) ?? defaultOperators;
25017 if (operators.length === 0) {
25018 return false;
25019 }
25020 return {
25021 isPrimary: !!field.filterBy?.isPrimary,
25022 operators
25023 };
25024 }
25025 var get_filter_by_default = getFilterBy;
25026
25027 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
25028 var getValueFromId = (id) => ({ item }) => {
25029 const path = id.split(".");
25030 let value = item;
25031 for (const segment of path) {
25032 if (value.hasOwnProperty(segment)) {
25033 value = value[segment];
25034 } else {
25035 value = void 0;
25036 }
25037 }
25038 return value;
25039 };
25040 var get_value_from_id_default = getValueFromId;
25041
25042 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
25043 var setValueFromId = (id) => ({ value }) => {
25044 const path = id.split(".");
25045 const result = {};
25046 let current = result;
25047 for (const segment of path.slice(0, -1)) {
25048 current[segment] = {};
25049 current = current[segment];
25050 }
25051 current[path.at(-1)] = value;
25052 return result;
25053 };
25054 var set_value_from_id_default = setValueFromId;
25055
25056 // packages/dataviews/build-module/field-types/email.mjs
25057 var import_i18n39 = __toESM(require_i18n(), 1);
25058
25059 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
25060 function RenderFromElements({
25061 item,
25062 field
25063 }) {
25064 const { elements, isLoading } = useElements({
25065 elements: field.elements,
25066 getElements: field.getElements
25067 });
25068 const value = field.getValue({ item });
25069 if (isLoading) {
25070 return value;
25071 }
25072 if (elements.length === 0) {
25073 return value;
25074 }
25075 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
25076 }
25077
25078 // packages/dataviews/build-module/field-types/utils/render-default.mjs
25079 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
25080 function render({
25081 item,
25082 field
25083 }) {
25084 if (field.hasElements) {
25085 return /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(RenderFromElements, { item, field });
25086 }
25087 return field.getValueFormatted({ item, field });
25088 }
25089
25090 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
25091 var sort_text_default = (a2, b2, direction) => {
25092 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
25093 };
25094
25095 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
25096 function isValidRequired(item, field) {
25097 const value = field.getValue({ item });
25098 return ![void 0, "", null].includes(value);
25099 }
25100
25101 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
25102 function isValidMinLength(item, field) {
25103 if (typeof field.isValid.minLength?.constraint !== "number") {
25104 return false;
25105 }
25106 const value = field.getValue({ item });
25107 if ([void 0, "", null].includes(value)) {
25108 return true;
25109 }
25110 return String(value).length >= field.isValid.minLength.constraint;
25111 }
25112
25113 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
25114 function isValidMaxLength(item, field) {
25115 if (typeof field.isValid.maxLength?.constraint !== "number") {
25116 return false;
25117 }
25118 const value = field.getValue({ item });
25119 if ([void 0, "", null].includes(value)) {
25120 return true;
25121 }
25122 return String(value).length <= field.isValid.maxLength.constraint;
25123 }
25124
25125 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
25126 function isValidPattern(item, field) {
25127 if (field.isValid.pattern?.constraint === void 0) {
25128 return true;
25129 }
25130 try {
25131 const regexp = new RegExp(field.isValid.pattern.constraint);
25132 const value = field.getValue({ item });
25133 if ([void 0, "", null].includes(value)) {
25134 return true;
25135 }
25136 return regexp.test(String(value));
25137 } catch {
25138 return false;
25139 }
25140 }
25141
25142 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
25143 function isValidElements(item, field) {
25144 const elements = field.elements ?? [];
25145 const validValues = elements.map((el) => el.value);
25146 if (validValues.length === 0) {
25147 return true;
25148 }
25149 const value = field.getValue({ item });
25150 return [].concat(value).every((v2) => validValues.includes(v2));
25151 }
25152
25153 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
25154 function getValueFormatted({
25155 item,
25156 field
25157 }) {
25158 return field.getValue({ item });
25159 }
25160 var get_value_formatted_default_default = getValueFormatted;
25161
25162 // packages/dataviews/build-module/field-types/email.mjs
25163 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])?)*$/;
25164 function isValidCustom(item, field) {
25165 const value = field.getValue({ item });
25166 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
25167 return (0, import_i18n39.__)("Value must be a valid email address.");
25168 }
25169 return null;
25170 }
25171 var email_default = {
25172 type: "email",
25173 render,
25174 Edit: "email",
25175 sort: sort_text_default,
25176 enableSorting: true,
25177 enableGlobalSearch: false,
25178 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25179 validOperators: [
25180 OPERATOR_IS,
25181 OPERATOR_IS_NOT,
25182 OPERATOR_CONTAINS,
25183 OPERATOR_NOT_CONTAINS,
25184 OPERATOR_STARTS_WITH,
25185 // Multiple selection
25186 OPERATOR_IS_ANY,
25187 OPERATOR_IS_NONE,
25188 OPERATOR_IS_ALL,
25189 OPERATOR_IS_NOT_ALL
25190 ],
25191 format: {},
25192 getValueFormatted: get_value_formatted_default_default,
25193 validate: {
25194 required: isValidRequired,
25195 pattern: isValidPattern,
25196 minLength: isValidMinLength,
25197 maxLength: isValidMaxLength,
25198 elements: isValidElements,
25199 custom: isValidCustom
25200 }
25201 };
25202
25203 // packages/dataviews/build-module/field-types/integer.mjs
25204 var import_i18n40 = __toESM(require_i18n(), 1);
25205
25206 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
25207 var sort_number_default = (a2, b2, direction) => {
25208 return direction === "asc" ? a2 - b2 : b2 - a2;
25209 };
25210
25211 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
25212 function isValidMin(item, field) {
25213 if (typeof field.isValid.min?.constraint !== "number") {
25214 return false;
25215 }
25216 const value = field.getValue({ item });
25217 if ([void 0, "", null].includes(value)) {
25218 return true;
25219 }
25220 return Number(value) >= field.isValid.min.constraint;
25221 }
25222
25223 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
25224 function isValidMax(item, field) {
25225 if (typeof field.isValid.max?.constraint !== "number") {
25226 return false;
25227 }
25228 const value = field.getValue({ item });
25229 if ([void 0, "", null].includes(value)) {
25230 return true;
25231 }
25232 return Number(value) <= field.isValid.max.constraint;
25233 }
25234
25235 // packages/dataviews/build-module/field-types/integer.mjs
25236 var format2 = {
25237 separatorThousand: ","
25238 };
25239 function getValueFormatted2({
25240 item,
25241 field
25242 }) {
25243 let value = field.getValue({ item });
25244 if (value === null || value === void 0) {
25245 return "";
25246 }
25247 value = Number(value);
25248 if (!Number.isFinite(value)) {
25249 return String(value);
25250 }
25251 let formatInteger;
25252 if (field.type !== "integer") {
25253 formatInteger = format2;
25254 } else {
25255 formatInteger = field.format;
25256 }
25257 const { separatorThousand } = formatInteger;
25258 const integerValue = Math.trunc(value);
25259 if (!separatorThousand) {
25260 return String(integerValue);
25261 }
25262 return String(integerValue).replace(
25263 /\B(?=(\d{3})+(?!\d))/g,
25264 separatorThousand
25265 );
25266 }
25267 function isValidCustom2(item, field) {
25268 const value = field.getValue({ item });
25269 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
25270 return (0, import_i18n40.__)("Value must be an integer.");
25271 }
25272 return null;
25273 }
25274 var integer_default = {
25275 type: "integer",
25276 render,
25277 Edit: "integer",
25278 sort: sort_number_default,
25279 enableSorting: true,
25280 enableGlobalSearch: false,
25281 defaultOperators: [
25282 OPERATOR_IS,
25283 OPERATOR_IS_NOT,
25284 OPERATOR_LESS_THAN,
25285 OPERATOR_GREATER_THAN,
25286 OPERATOR_LESS_THAN_OR_EQUAL,
25287 OPERATOR_GREATER_THAN_OR_EQUAL,
25288 OPERATOR_BETWEEN
25289 ],
25290 validOperators: [
25291 // Single-selection
25292 OPERATOR_IS,
25293 OPERATOR_IS_NOT,
25294 OPERATOR_LESS_THAN,
25295 OPERATOR_GREATER_THAN,
25296 OPERATOR_LESS_THAN_OR_EQUAL,
25297 OPERATOR_GREATER_THAN_OR_EQUAL,
25298 OPERATOR_BETWEEN,
25299 // Multiple-selection
25300 OPERATOR_IS_ANY,
25301 OPERATOR_IS_NONE,
25302 OPERATOR_IS_ALL,
25303 OPERATOR_IS_NOT_ALL
25304 ],
25305 format: format2,
25306 getValueFormatted: getValueFormatted2,
25307 validate: {
25308 required: isValidRequired,
25309 min: isValidMin,
25310 max: isValidMax,
25311 elements: isValidElements,
25312 custom: isValidCustom2
25313 }
25314 };
25315
25316 // packages/dataviews/build-module/field-types/number.mjs
25317 var import_i18n41 = __toESM(require_i18n(), 1);
25318 var format3 = {
25319 separatorThousand: ",",
25320 separatorDecimal: ".",
25321 decimals: 2
25322 };
25323 function getValueFormatted3({
25324 item,
25325 field
25326 }) {
25327 let value = field.getValue({ item });
25328 if (value === null || value === void 0) {
25329 return "";
25330 }
25331 value = Number(value);
25332 if (!Number.isFinite(value)) {
25333 return String(value);
25334 }
25335 let formatNumber;
25336 if (field.type !== "number") {
25337 formatNumber = format3;
25338 } else {
25339 formatNumber = field.format;
25340 }
25341 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
25342 const fixedValue = value.toFixed(decimals);
25343 const [integerPart, decimalPart] = fixedValue.split(".");
25344 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
25345 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
25346 }
25347 function isEmpty2(value) {
25348 return value === "" || value === void 0 || value === null;
25349 }
25350 function isValidCustom3(item, field) {
25351 const value = field.getValue({ item });
25352 if (!isEmpty2(value) && !Number.isFinite(value)) {
25353 return (0, import_i18n41.__)("Value must be a number.");
25354 }
25355 return null;
25356 }
25357 var number_default = {
25358 type: "number",
25359 render,
25360 Edit: "number",
25361 sort: sort_number_default,
25362 enableSorting: true,
25363 enableGlobalSearch: false,
25364 defaultOperators: [
25365 OPERATOR_IS,
25366 OPERATOR_IS_NOT,
25367 OPERATOR_LESS_THAN,
25368 OPERATOR_GREATER_THAN,
25369 OPERATOR_LESS_THAN_OR_EQUAL,
25370 OPERATOR_GREATER_THAN_OR_EQUAL,
25371 OPERATOR_BETWEEN
25372 ],
25373 validOperators: [
25374 // Single-selection
25375 OPERATOR_IS,
25376 OPERATOR_IS_NOT,
25377 OPERATOR_LESS_THAN,
25378 OPERATOR_GREATER_THAN,
25379 OPERATOR_LESS_THAN_OR_EQUAL,
25380 OPERATOR_GREATER_THAN_OR_EQUAL,
25381 OPERATOR_BETWEEN,
25382 // Multiple-selection
25383 OPERATOR_IS_ANY,
25384 OPERATOR_IS_NONE,
25385 OPERATOR_IS_ALL,
25386 OPERATOR_IS_NOT_ALL
25387 ],
25388 format: format3,
25389 getValueFormatted: getValueFormatted3,
25390 validate: {
25391 required: isValidRequired,
25392 min: isValidMin,
25393 max: isValidMax,
25394 elements: isValidElements,
25395 custom: isValidCustom3
25396 }
25397 };
25398
25399 // packages/dataviews/build-module/field-types/text.mjs
25400 var text_default = {
25401 type: "text",
25402 render,
25403 Edit: "text",
25404 sort: sort_text_default,
25405 enableSorting: true,
25406 enableGlobalSearch: false,
25407 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25408 validOperators: [
25409 // Single selection
25410 OPERATOR_IS,
25411 OPERATOR_IS_NOT,
25412 OPERATOR_CONTAINS,
25413 OPERATOR_NOT_CONTAINS,
25414 OPERATOR_STARTS_WITH,
25415 // Multiple selection
25416 OPERATOR_IS_ANY,
25417 OPERATOR_IS_NONE,
25418 OPERATOR_IS_ALL,
25419 OPERATOR_IS_NOT_ALL
25420 ],
25421 format: {},
25422 getValueFormatted: get_value_formatted_default_default,
25423 validate: {
25424 required: isValidRequired,
25425 pattern: isValidPattern,
25426 minLength: isValidMinLength,
25427 maxLength: isValidMaxLength,
25428 elements: isValidElements
25429 }
25430 };
25431
25432 // packages/dataviews/build-module/field-types/datetime.mjs
25433 var import_date7 = __toESM(require_date(), 1);
25434
25435 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
25436 var import_date6 = __toESM(require_date(), 1);
25437 function parseDateLike(value) {
25438 if (!value) {
25439 return null;
25440 }
25441 if (!isValid(new Date(value))) {
25442 return null;
25443 }
25444 const parsed = (0, import_date6.getDate)(value);
25445 return parsed && isValid(parsed) ? parsed : null;
25446 }
25447 function validateDateLikeBoundary(item, field, boundary) {
25448 const constraint = field.isValid[boundary]?.constraint;
25449 if (typeof constraint !== "string") {
25450 return false;
25451 }
25452 const value = field.getValue({ item });
25453 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
25454 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
25455 return true;
25456 }
25457 const parsedConstraint = parseDateLike(constraint);
25458 const parsedValue = parseDateLike(String(boundaryValue));
25459 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
25460 }
25461 function isValidMinDate(item, field) {
25462 return validateDateLikeBoundary(item, field, "min");
25463 }
25464 function isValidMaxDate(item, field) {
25465 return validateDateLikeBoundary(item, field, "max");
25466 }
25467
25468 // packages/dataviews/build-module/field-types/datetime.mjs
25469 var format4 = {
25470 datetime: (0, import_date7.getSettings)().formats.datetime,
25471 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25472 };
25473 function getValueFormatted4({
25474 item,
25475 field
25476 }) {
25477 const value = field.getValue({ item });
25478 if (["", void 0, null].includes(value)) {
25479 return "";
25480 }
25481 let formatDatetime;
25482 if (field.type !== "datetime") {
25483 formatDatetime = format4;
25484 } else {
25485 formatDatetime = field.format;
25486 }
25487 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25488 }
25489 var sort = (a2, b2, direction) => {
25490 const timeA = new Date(a2).getTime();
25491 const timeB = new Date(b2).getTime();
25492 return direction === "asc" ? timeA - timeB : timeB - timeA;
25493 };
25494 var datetime_default = {
25495 type: "datetime",
25496 render,
25497 Edit: "datetime",
25498 sort,
25499 enableSorting: true,
25500 enableGlobalSearch: false,
25501 defaultOperators: [
25502 OPERATOR_ON,
25503 OPERATOR_NOT_ON,
25504 OPERATOR_BEFORE,
25505 OPERATOR_AFTER,
25506 OPERATOR_BEFORE_INC,
25507 OPERATOR_AFTER_INC,
25508 OPERATOR_IN_THE_PAST,
25509 OPERATOR_OVER
25510 ],
25511 validOperators: [
25512 OPERATOR_ON,
25513 OPERATOR_NOT_ON,
25514 OPERATOR_BEFORE,
25515 OPERATOR_AFTER,
25516 OPERATOR_BEFORE_INC,
25517 OPERATOR_AFTER_INC,
25518 OPERATOR_IN_THE_PAST,
25519 OPERATOR_OVER
25520 ],
25521 format: format4,
25522 getValueFormatted: getValueFormatted4,
25523 validate: {
25524 required: isValidRequired,
25525 elements: isValidElements,
25526 min: isValidMinDate,
25527 max: isValidMaxDate
25528 }
25529 };
25530
25531 // packages/dataviews/build-module/field-types/date.mjs
25532 var import_date8 = __toESM(require_date(), 1);
25533 var format5 = {
25534 date: (0, import_date8.getSettings)().formats.date,
25535 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25536 };
25537 function getValueFormatted5({
25538 item,
25539 field
25540 }) {
25541 const value = field.getValue({ item });
25542 if (["", void 0, null].includes(value)) {
25543 return "";
25544 }
25545 let formatDate2;
25546 if (field.type !== "date") {
25547 formatDate2 = format5;
25548 } else {
25549 formatDate2 = field.format;
25550 }
25551 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25552 }
25553 var sort2 = (a2, b2, direction) => {
25554 const timeA = new Date(a2).getTime();
25555 const timeB = new Date(b2).getTime();
25556 return direction === "asc" ? timeA - timeB : timeB - timeA;
25557 };
25558 var date_default = {
25559 type: "date",
25560 render,
25561 Edit: "date",
25562 sort: sort2,
25563 enableSorting: true,
25564 enableGlobalSearch: false,
25565 defaultOperators: [
25566 OPERATOR_ON,
25567 OPERATOR_NOT_ON,
25568 OPERATOR_BEFORE,
25569 OPERATOR_AFTER,
25570 OPERATOR_BEFORE_INC,
25571 OPERATOR_AFTER_INC,
25572 OPERATOR_IN_THE_PAST,
25573 OPERATOR_OVER,
25574 OPERATOR_BETWEEN
25575 ],
25576 validOperators: [
25577 OPERATOR_ON,
25578 OPERATOR_NOT_ON,
25579 OPERATOR_BEFORE,
25580 OPERATOR_AFTER,
25581 OPERATOR_BEFORE_INC,
25582 OPERATOR_AFTER_INC,
25583 OPERATOR_IN_THE_PAST,
25584 OPERATOR_OVER,
25585 OPERATOR_BETWEEN
25586 ],
25587 format: format5,
25588 getValueFormatted: getValueFormatted5,
25589 validate: {
25590 required: isValidRequired,
25591 elements: isValidElements,
25592 min: isValidMinDate,
25593 max: isValidMaxDate
25594 }
25595 };
25596
25597 // packages/dataviews/build-module/field-types/boolean.mjs
25598 var import_i18n42 = __toESM(require_i18n(), 1);
25599
25600 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25601 function isValidRequiredForBool(item, field) {
25602 const value = field.getValue({ item });
25603 return value === true;
25604 }
25605
25606 // packages/dataviews/build-module/field-types/boolean.mjs
25607 function getValueFormatted6({
25608 item,
25609 field
25610 }) {
25611 const value = field.getValue({ item });
25612 if (value === true) {
25613 return (0, import_i18n42.__)("True");
25614 }
25615 if (value === false) {
25616 return (0, import_i18n42.__)("False");
25617 }
25618 return "";
25619 }
25620 function isValidCustom4(item, field) {
25621 const value = field.getValue({ item });
25622 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25623 return (0, import_i18n42.__)("Value must be true, false, or undefined");
25624 }
25625 return null;
25626 }
25627 var sort3 = (a2, b2, direction) => {
25628 const boolA = Boolean(a2);
25629 const boolB = Boolean(b2);
25630 if (boolA === boolB) {
25631 return 0;
25632 }
25633 if (direction === "asc") {
25634 return boolA ? 1 : -1;
25635 }
25636 return boolA ? -1 : 1;
25637 };
25638 var boolean_default = {
25639 type: "boolean",
25640 render,
25641 Edit: "checkbox",
25642 sort: sort3,
25643 validate: {
25644 required: isValidRequiredForBool,
25645 elements: isValidElements,
25646 custom: isValidCustom4
25647 },
25648 enableSorting: true,
25649 enableGlobalSearch: false,
25650 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25651 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25652 format: {},
25653 getValueFormatted: getValueFormatted6
25654 };
25655
25656 // packages/dataviews/build-module/field-types/media.mjs
25657 var media_default = {
25658 type: "media",
25659 render: () => null,
25660 Edit: null,
25661 sort: () => 0,
25662 enableSorting: false,
25663 enableGlobalSearch: false,
25664 defaultOperators: [],
25665 validOperators: [],
25666 format: {},
25667 getValueFormatted: get_value_formatted_default_default,
25668 // cannot validate any constraint, so
25669 // the only available validation for the field author
25670 // would be providing a custom validator.
25671 validate: {}
25672 };
25673
25674 // packages/dataviews/build-module/field-types/array.mjs
25675 var import_i18n43 = __toESM(require_i18n(), 1);
25676
25677 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25678 function isValidRequiredForArray(item, field) {
25679 const value = field.getValue({ item });
25680 return Array.isArray(value) && value.length > 0 && value.every(
25681 (element) => ![void 0, "", null].includes(element)
25682 );
25683 }
25684
25685 // packages/dataviews/build-module/field-types/array.mjs
25686 function getValueFormatted7({
25687 item,
25688 field
25689 }) {
25690 const value = field.getValue({ item });
25691 const arr = Array.isArray(value) ? value : [];
25692 return arr.join(", ");
25693 }
25694 function render2({ item, field }) {
25695 return getValueFormatted7({ item, field });
25696 }
25697 function isValidCustom5(item, field) {
25698 const value = field.getValue({ item });
25699 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25700 return (0, import_i18n43.__)("Value must be an array.");
25701 }
25702 if (!value.every((v2) => typeof v2 === "string")) {
25703 return (0, import_i18n43.__)("Every value must be a string.");
25704 }
25705 return null;
25706 }
25707 var sort4 = (a2, b2, direction) => {
25708 const arrA = Array.isArray(a2) ? a2 : [];
25709 const arrB = Array.isArray(b2) ? b2 : [];
25710 if (arrA.length !== arrB.length) {
25711 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25712 }
25713 const joinedA = arrA.join(",");
25714 const joinedB = arrB.join(",");
25715 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25716 };
25717 var array_default = {
25718 type: "array",
25719 render: render2,
25720 Edit: "array",
25721 sort: sort4,
25722 enableSorting: true,
25723 enableGlobalSearch: false,
25724 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25725 validOperators: [
25726 OPERATOR_IS_ANY,
25727 OPERATOR_IS_NONE,
25728 OPERATOR_IS_ALL,
25729 OPERATOR_IS_NOT_ALL
25730 ],
25731 format: {},
25732 getValueFormatted: getValueFormatted7,
25733 validate: {
25734 required: isValidRequiredForArray,
25735 elements: isValidElements,
25736 custom: isValidCustom5
25737 }
25738 };
25739
25740 // packages/dataviews/build-module/field-types/password.mjs
25741 function getValueFormatted8({
25742 item,
25743 field
25744 }) {
25745 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25746 }
25747 var password_default = {
25748 type: "password",
25749 render,
25750 Edit: "password",
25751 sort: () => 0,
25752 // Passwords should not be sortable for security reasons
25753 enableSorting: false,
25754 enableGlobalSearch: false,
25755 defaultOperators: [],
25756 validOperators: [],
25757 format: {},
25758 getValueFormatted: getValueFormatted8,
25759 validate: {
25760 required: isValidRequired,
25761 pattern: isValidPattern,
25762 minLength: isValidMinLength,
25763 maxLength: isValidMaxLength,
25764 elements: isValidElements
25765 }
25766 };
25767
25768 // packages/dataviews/build-module/field-types/telephone.mjs
25769 var telephone_default = {
25770 type: "telephone",
25771 render,
25772 Edit: "telephone",
25773 sort: sort_text_default,
25774 enableSorting: true,
25775 enableGlobalSearch: false,
25776 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25777 validOperators: [
25778 OPERATOR_IS,
25779 OPERATOR_IS_NOT,
25780 OPERATOR_CONTAINS,
25781 OPERATOR_NOT_CONTAINS,
25782 OPERATOR_STARTS_WITH,
25783 // Multiple selection
25784 OPERATOR_IS_ANY,
25785 OPERATOR_IS_NONE,
25786 OPERATOR_IS_ALL,
25787 OPERATOR_IS_NOT_ALL
25788 ],
25789 format: {},
25790 getValueFormatted: get_value_formatted_default_default,
25791 validate: {
25792 required: isValidRequired,
25793 pattern: isValidPattern,
25794 minLength: isValidMinLength,
25795 maxLength: isValidMaxLength,
25796 elements: isValidElements
25797 }
25798 };
25799
25800 // packages/dataviews/build-module/field-types/color.mjs
25801 var import_i18n44 = __toESM(require_i18n(), 1);
25802 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
25803 function render3({ item, field }) {
25804 if (field.hasElements) {
25805 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(RenderFromElements, { item, field });
25806 }
25807 const value = get_value_formatted_default_default({ item, field });
25808 if (!value || !w(value).isValid()) {
25809 return value;
25810 }
25811 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25812 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
25813 "div",
25814 {
25815 style: {
25816 width: "16px",
25817 height: "16px",
25818 borderRadius: "50%",
25819 backgroundColor: value,
25820 border: "1px solid #ddd",
25821 flexShrink: 0
25822 }
25823 }
25824 ),
25825 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { children: value })
25826 ] });
25827 }
25828 function isValidCustom6(item, field) {
25829 const value = field.getValue({ item });
25830 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25831 return (0, import_i18n44.__)("Value must be a valid color.");
25832 }
25833 return null;
25834 }
25835 var sort5 = (a2, b2, direction) => {
25836 const colorA = w(a2);
25837 const colorB = w(b2);
25838 if (!colorA.isValid() && !colorB.isValid()) {
25839 return 0;
25840 }
25841 if (!colorA.isValid()) {
25842 return direction === "asc" ? 1 : -1;
25843 }
25844 if (!colorB.isValid()) {
25845 return direction === "asc" ? -1 : 1;
25846 }
25847 const hslA = colorA.toHsl();
25848 const hslB = colorB.toHsl();
25849 if (hslA.h !== hslB.h) {
25850 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25851 }
25852 if (hslA.s !== hslB.s) {
25853 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25854 }
25855 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25856 };
25857 var color_default = {
25858 type: "color",
25859 render: render3,
25860 Edit: "color",
25861 sort: sort5,
25862 enableSorting: true,
25863 enableGlobalSearch: false,
25864 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25865 validOperators: [
25866 OPERATOR_IS,
25867 OPERATOR_IS_NOT,
25868 OPERATOR_IS_ANY,
25869 OPERATOR_IS_NONE
25870 ],
25871 format: {},
25872 getValueFormatted: get_value_formatted_default_default,
25873 validate: {
25874 required: isValidRequired,
25875 elements: isValidElements,
25876 custom: isValidCustom6
25877 }
25878 };
25879
25880 // packages/dataviews/build-module/field-types/url.mjs
25881 var url_default = {
25882 type: "url",
25883 render,
25884 Edit: "url",
25885 sort: sort_text_default,
25886 enableSorting: true,
25887 enableGlobalSearch: false,
25888 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25889 validOperators: [
25890 OPERATOR_IS,
25891 OPERATOR_IS_NOT,
25892 OPERATOR_CONTAINS,
25893 OPERATOR_NOT_CONTAINS,
25894 OPERATOR_STARTS_WITH,
25895 // Multiple selection
25896 OPERATOR_IS_ANY,
25897 OPERATOR_IS_NONE,
25898 OPERATOR_IS_ALL,
25899 OPERATOR_IS_NOT_ALL
25900 ],
25901 format: {},
25902 getValueFormatted: get_value_formatted_default_default,
25903 validate: {
25904 required: isValidRequired,
25905 pattern: isValidPattern,
25906 minLength: isValidMinLength,
25907 maxLength: isValidMaxLength,
25908 elements: isValidElements
25909 }
25910 };
25911
25912 // packages/dataviews/build-module/field-types/no-type.mjs
25913 var sort6 = (a2, b2, direction) => {
25914 if (typeof a2 === "number" && typeof b2 === "number") {
25915 return sort_number_default(a2, b2, direction);
25916 }
25917 return sort_text_default(a2, b2, direction);
25918 };
25919 var no_type_default = {
25920 // type: no type for this one
25921 render,
25922 Edit: null,
25923 sort: sort6,
25924 enableSorting: true,
25925 enableGlobalSearch: false,
25926 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25927 validOperators: getAllOperatorNames(),
25928 format: {},
25929 getValueFormatted: get_value_formatted_default_default,
25930 validate: {
25931 required: isValidRequired,
25932 elements: isValidElements
25933 }
25934 };
25935
25936 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25937 function supportsNumericRangeConstraint(type) {
25938 return type === "integer" || type === "number";
25939 }
25940 function supportsDateRangeConstraint(type) {
25941 return type === "date" || type === "datetime";
25942 }
25943 function normalizeRangeRule(value, fieldType, key) {
25944 const validator = fieldType.validate[key];
25945 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25946 return { constraint: value, validate: validator };
25947 }
25948 return void 0;
25949 }
25950 function getIsValid(field, fieldType) {
25951 const rules = field.isValid;
25952 let required;
25953 if (rules?.required === true && fieldType.validate.required !== void 0) {
25954 required = {
25955 constraint: true,
25956 validate: fieldType.validate.required
25957 };
25958 }
25959 let elements;
25960 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25961 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25962 elements = {
25963 constraint: true,
25964 validate: fieldType.validate.elements
25965 };
25966 }
25967 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25968 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25969 const minLengthValue = rules?.minLength;
25970 let minLength;
25971 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25972 minLength = {
25973 constraint: minLengthValue,
25974 validate: fieldType.validate.minLength
25975 };
25976 }
25977 const maxLengthValue = rules?.maxLength;
25978 let maxLength;
25979 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25980 maxLength = {
25981 constraint: maxLengthValue,
25982 validate: fieldType.validate.maxLength
25983 };
25984 }
25985 const patternValue = rules?.pattern;
25986 let pattern;
25987 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25988 pattern = {
25989 constraint: patternValue,
25990 validate: fieldType.validate.pattern
25991 };
25992 }
25993 const custom = rules?.custom ?? fieldType.validate.custom;
25994 return {
25995 required,
25996 elements,
25997 min: min2,
25998 max: max2,
25999 minLength,
26000 maxLength,
26001 pattern,
26002 custom
26003 };
26004 }
26005
26006 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
26007 function getFilter(fieldType) {
26008 return fieldType.validOperators.reduce((accumulator, operator) => {
26009 const operatorObj = getOperatorByName(operator);
26010 if (operatorObj?.filter) {
26011 accumulator[operator] = operatorObj.filter;
26012 }
26013 return accumulator;
26014 }, {});
26015 }
26016
26017 // packages/dataviews/build-module/field-types/utils/get-format.mjs
26018 function getFormat(field, fieldType) {
26019 return {
26020 ...fieldType.format,
26021 ...field.format
26022 };
26023 }
26024 var get_format_default = getFormat;
26025
26026 // packages/dataviews/build-module/field-types/index.mjs
26027 function getFieldTypeByName(type) {
26028 const found = [
26029 email_default,
26030 integer_default,
26031 number_default,
26032 text_default,
26033 datetime_default,
26034 date_default,
26035 boolean_default,
26036 media_default,
26037 array_default,
26038 password_default,
26039 telephone_default,
26040 color_default,
26041 url_default
26042 ].find((fieldType) => fieldType?.type === type);
26043 if (!!found) {
26044 return found;
26045 }
26046 return no_type_default;
26047 }
26048 function normalizeFields(fields) {
26049 return fields.map((field) => {
26050 const fieldType = getFieldTypeByName(field.type);
26051 const getValue = field.getValue || get_value_from_id_default(field.id);
26052 const sort7 = function(a2, b2, direction) {
26053 const aValue = getValue({ item: a2 });
26054 const bValue = getValue({ item: b2 });
26055 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
26056 };
26057 return {
26058 id: field.id,
26059 label: field.label || field.id,
26060 header: field.header || field.label || field.id,
26061 description: field.description,
26062 placeholder: field.placeholder,
26063 getValue,
26064 setValue: field.setValue || set_value_from_id_default(field.id),
26065 elements: field.elements,
26066 getElements: field.getElements,
26067 hasElements: hasElements(field),
26068 isVisible: field.isVisible,
26069 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
26070 enableHiding: field.enableHiding ?? true,
26071 readOnly: field.readOnly ?? false,
26072 // The type provides defaults for the following props
26073 type: fieldType.type,
26074 render: field.render ?? fieldType.render,
26075 Edit: getControl(field, fieldType.Edit),
26076 sort: sort7,
26077 enableSorting: field.enableSorting ?? fieldType.enableSorting,
26078 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
26079 isValid: getIsValid(field, fieldType),
26080 filterBy: get_filter_by_default(
26081 field,
26082 fieldType.defaultOperators,
26083 fieldType.validOperators
26084 ),
26085 filter: getFilter(fieldType),
26086 format: get_format_default(field, fieldType),
26087 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
26088 };
26089 });
26090 }
26091
26092 // packages/dataviews/build-module/hooks/use-data.mjs
26093 var import_element81 = __toESM(require_element(), 1);
26094 function useData({
26095 view,
26096 data: shownData,
26097 getItemId,
26098 isLoading,
26099 paginationInfo,
26100 selection
26101 }) {
26102 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
26103 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element81.useState)(
26104 !isLoading
26105 );
26106 (0, import_element81.useEffect)(() => {
26107 if (!isLoading) {
26108 setHasInitiallyLoaded(true);
26109 }
26110 }, [isLoading]);
26111 const previousDataRef = (0, import_element81.useRef)(shownData);
26112 const previousPaginationInfoRef = (0, import_element81.useRef)(paginationInfo);
26113 (0, import_element81.useEffect)(() => {
26114 if (!isLoading) {
26115 previousDataRef.current = shownData;
26116 previousPaginationInfoRef.current = paginationInfo;
26117 }
26118 }, [shownData, isLoading, paginationInfo]);
26119 const [visibleEntries, setVisibleEntries] = (0, import_element81.useState)([]);
26120 const positionMapRef = (0, import_element81.useRef)(/* @__PURE__ */ new Map());
26121 const allLoadedRecordsRef = (0, import_element81.useRef)([]);
26122 const prevViewParamsRef = (0, import_element81.useRef)({
26123 search: void 0,
26124 filters: void 0,
26125 perPage: void 0
26126 });
26127 const scrollDirectionRef = (0, import_element81.useRef)(void 0);
26128 const prevStartPositionRef = (0, import_element81.useRef)(void 0);
26129 const hasInitializedRef = (0, import_element81.useRef)(false);
26130 const allLoadedRecords = (0, import_element81.useMemo)(() => {
26131 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
26132 if (view.startPosition < prevStartPositionRef.current) {
26133 scrollDirectionRef.current = "up";
26134 } else if (view.startPosition > prevStartPositionRef.current) {
26135 scrollDirectionRef.current = "down";
26136 }
26137 }
26138 prevStartPositionRef.current = view.startPosition;
26139 const currentFiltersKey = JSON.stringify(view.filters ?? []);
26140 const prevFiltersKey = prevViewParamsRef.current.filters;
26141 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
26142 hasInitializedRef.current = true;
26143 prevViewParamsRef.current = {
26144 search: view.search,
26145 filters: currentFiltersKey,
26146 perPage: view.perPage
26147 };
26148 if (shouldReset) {
26149 positionMapRef.current.clear();
26150 scrollDirectionRef.current = void 0;
26151 const startPosition = view.search ? 1 : view.startPosition ?? 1;
26152 const records = shownData.map((record, index2) => {
26153 const position = startPosition + index2;
26154 positionMapRef.current.set(getItemId(record), position);
26155 return {
26156 ...record,
26157 position
26158 };
26159 });
26160 allLoadedRecordsRef.current = records;
26161 return records;
26162 }
26163 const prev = allLoadedRecordsRef.current;
26164 const shownDataIds = new Set(shownData.map(getItemId));
26165 const scrollDirection = scrollDirectionRef.current;
26166 const basePosition = view.search ? 1 : view.startPosition ?? 1;
26167 const newRecords = shownData.map((record, index2) => {
26168 const itemId = getItemId(record);
26169 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
26170 if (position !== void 0) {
26171 positionMapRef.current.set(itemId, position);
26172 }
26173 return {
26174 ...record,
26175 position
26176 };
26177 });
26178 if (newRecords.length === 0) {
26179 return prev;
26180 }
26181 const prevWithoutDuplicates = prev.filter(
26182 (record) => !shownDataIds.has(getItemId(record))
26183 );
26184 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
26185 allRecords.sort((a2, b2) => {
26186 const posA = a2.position;
26187 const posB = b2.position;
26188 return posA - posB;
26189 });
26190 let result = allRecords;
26191 if (visibleEntries.length > 0) {
26192 const visibleMin = Math.min(...visibleEntries);
26193 const visibleMax = Math.max(...visibleEntries);
26194 const buffer = 20;
26195 const recordPositions = allRecords.map(
26196 (r3) => r3.position
26197 );
26198 const minRecordPos = Math.min(...recordPositions);
26199 const maxRecordPos = Math.max(...recordPositions);
26200 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
26201 if (hasOverlap) {
26202 result = allRecords.filter((record) => {
26203 const itemId = getItemId(record);
26204 const isSelected2 = selection?.includes(itemId);
26205 if (isSelected2) {
26206 return true;
26207 }
26208 const itemPosition = record.position;
26209 if (scrollDirection === "up") {
26210 return itemPosition <= visibleMax + buffer;
26211 } else if (scrollDirection === "down") {
26212 return itemPosition >= visibleMin - buffer;
26213 }
26214 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
26215 });
26216 }
26217 }
26218 allLoadedRecordsRef.current = result;
26219 return result;
26220 }, [
26221 shownData,
26222 view.search,
26223 view.filters,
26224 view.perPage,
26225 view.startPosition,
26226 view.infiniteScrollEnabled,
26227 visibleEntries,
26228 selection,
26229 getItemId
26230 ]);
26231 if (!isInfiniteScrollEnabled) {
26232 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
26233 return {
26234 data: dataToReturn.map((item) => ({
26235 ...item,
26236 position: void 0
26237 })),
26238 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
26239 hasInitiallyLoaded,
26240 setVisibleEntries: void 0
26241 };
26242 }
26243 return {
26244 data: allLoadedRecords,
26245 paginationInfo,
26246 hasInitiallyLoaded,
26247 setVisibleEntries
26248 };
26249 }
26250
26251 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
26252 var import_element82 = __toESM(require_element(), 1);
26253 var import_compose12 = __toESM(require_compose(), 1);
26254 function captureAnchorElement(container, anchorElementRef, direction) {
26255 const containerRect = container.getBoundingClientRect();
26256 const centerY = containerRect.top + containerRect.height / 2;
26257 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
26258 if (items.length === 0) {
26259 return false;
26260 }
26261 const bestAnchor = items.reduce((best, item) => {
26262 const itemRect = item.getBoundingClientRect();
26263 const itemCenterY = itemRect.top + itemRect.height / 2;
26264 const distance = Math.abs(itemCenterY - centerY);
26265 const bestRect = best.getBoundingClientRect();
26266 const bestCenterY = bestRect.top + bestRect.height / 2;
26267 const bestDistance = Math.abs(bestCenterY - centerY);
26268 return distance < bestDistance ? item : best;
26269 });
26270 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
26271 const anchorRect = bestAnchor.getBoundingClientRect();
26272 anchorElementRef.current = {
26273 posinset,
26274 viewportOffset: anchorRect.top - containerRect.top,
26275 direction
26276 };
26277 return true;
26278 }
26279 function useInfiniteScroll({
26280 view,
26281 onChangeView,
26282 isLoading,
26283 paginationInfo,
26284 containerRef,
26285 setVisibleEntries
26286 }) {
26287 const anchorElementRef = (0, import_element82.useRef)(null);
26288 const viewRef = (0, import_element82.useRef)(view);
26289 const isLoadingRef = (0, import_element82.useRef)(isLoading);
26290 const onChangeViewRef = (0, import_element82.useRef)(onChangeView);
26291 const totalItemsRef = (0, import_element82.useRef)(paginationInfo.totalItems);
26292 (0, import_element82.useLayoutEffect)(() => {
26293 viewRef.current = view;
26294 isLoadingRef.current = isLoading;
26295 onChangeViewRef.current = onChangeView;
26296 totalItemsRef.current = paginationInfo.totalItems;
26297 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
26298 const intersectionObserverCallback = (0, import_element82.useCallback)(
26299 (entries) => {
26300 if (!setVisibleEntries) {
26301 return;
26302 }
26303 setVisibleEntries((prev) => {
26304 const newVisibleEntries = new Set(prev);
26305 let hasChanged = false;
26306 entries.forEach((entry) => {
26307 const posInSet = Number(
26308 entry.target?.attributes?.getNamedItem(
26309 "aria-posinset"
26310 )?.value
26311 );
26312 if (isNaN(posInSet)) {
26313 return;
26314 }
26315 if (entry.isIntersecting) {
26316 if (!newVisibleEntries.has(posInSet)) {
26317 newVisibleEntries.add(posInSet);
26318 hasChanged = true;
26319 }
26320 } else if (newVisibleEntries.has(posInSet)) {
26321 newVisibleEntries.delete(posInSet);
26322 hasChanged = true;
26323 }
26324 });
26325 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
26326 });
26327 },
26328 [setVisibleEntries]
26329 );
26330 (0, import_element82.useLayoutEffect)(() => {
26331 const container = containerRef.current;
26332 const anchor = anchorElementRef.current;
26333 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
26334 return;
26335 }
26336 const anchorElement = container.querySelector(
26337 `[aria-posinset="${anchor.posinset}"]`
26338 );
26339 if (anchorElement) {
26340 const containerRect = container.getBoundingClientRect();
26341 const anchorRect = anchorElement.getBoundingClientRect();
26342 const currentOffset = anchorRect.top - containerRect.top;
26343 const scrollAdjustment = currentOffset - anchor.viewportOffset;
26344 if (Math.abs(scrollAdjustment) > 1) {
26345 container.scrollTop += scrollAdjustment;
26346 }
26347 }
26348 anchorElementRef.current = null;
26349 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
26350 const intersectionObserverRef = (0, import_element82.useRef)(
26351 null
26352 );
26353 (0, import_element82.useEffect)(() => {
26354 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
26355 if (intersectionObserverRef.current) {
26356 intersectionObserverRef.current.disconnect();
26357 intersectionObserverRef.current = null;
26358 }
26359 return;
26360 }
26361 intersectionObserverRef.current = new IntersectionObserver(
26362 intersectionObserverCallback,
26363 { root: null, rootMargin: "0px", threshold: 0.1 }
26364 );
26365 return () => {
26366 if (intersectionObserverRef.current) {
26367 intersectionObserverRef.current.disconnect();
26368 intersectionObserverRef.current = null;
26369 }
26370 };
26371 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
26372 (0, import_element82.useEffect)(() => {
26373 if (!view.infiniteScrollEnabled || !containerRef.current) {
26374 return;
26375 }
26376 let lastScrollTop = 0;
26377 const BOTTOM_THRESHOLD = 600;
26378 const TOP_THRESHOLD = 800;
26379 const handleScroll = (0, import_compose12.throttle)((event) => {
26380 const currentView = viewRef.current;
26381 const totalItems = totalItemsRef.current;
26382 const target = event.target;
26383 const scrollTop = target.scrollTop;
26384 const scrollHeight = target.scrollHeight;
26385 const clientHeight = target.clientHeight;
26386 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
26387 lastScrollTop = scrollTop;
26388 if (isLoadingRef.current) {
26389 return;
26390 }
26391 const currentStartPosition = currentView.startPosition || 1;
26392 const batchSize = currentView.perPage || 10;
26393 const currentEndPosition = Math.min(
26394 currentStartPosition + batchSize,
26395 totalItems
26396 );
26397 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
26398 if (currentEndPosition < totalItems) {
26399 const newStartPosition = currentEndPosition;
26400 captureAnchorElement(target, anchorElementRef, "down");
26401 onChangeViewRef.current({
26402 ...currentView,
26403 startPosition: newStartPosition
26404 });
26405 }
26406 }
26407 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
26408 if (currentStartPosition > 1) {
26409 const calculatedStartPosition = currentStartPosition - batchSize;
26410 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
26411 captureAnchorElement(target, anchorElementRef, "up");
26412 onChangeViewRef.current({
26413 ...currentView,
26414 startPosition: newStartPosition
26415 });
26416 }
26417 }
26418 }, 50);
26419 const container = containerRef.current;
26420 container.addEventListener("scroll", handleScroll);
26421 return () => {
26422 container.removeEventListener("scroll", handleScroll);
26423 handleScroll.cancel();
26424 };
26425 }, [containerRef, view.infiniteScrollEnabled]);
26426 return {
26427 intersectionObserver: intersectionObserverRef.current
26428 };
26429 }
26430
26431 // packages/dataviews/build-module/dataviews/index.mjs
26432 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
26433 var defaultGetItemId = (item) => item.id;
26434 var defaultIsItemClickable = () => true;
26435 var EMPTY_ARRAY6 = [];
26436 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
26437 var dataViewsLayouts = VIEW_LAYOUTS.filter(
26438 (viewLayout) => !viewLayout.isPicker
26439 );
26440 function DefaultUI({
26441 header,
26442 search = true,
26443 searchLabel = void 0
26444 }) {
26445 const { view } = (0, import_element83.useContext)(dataviews_context_default);
26446 const isInfiniteScroll = view.infiniteScrollEnabled;
26447 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
26448 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
26449 Stack,
26450 {
26451 direction: "row",
26452 align: "top",
26453 justify: "space-between",
26454 className: clsx_default("dataviews__view-actions", {
26455 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
26456 }),
26457 gap: "xs",
26458 children: [
26459 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
26460 Stack,
26461 {
26462 direction: "row",
26463 justify: "start",
26464 gap: "sm",
26465 className: "dataviews__search",
26466 children: [
26467 search && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_search_default, { label: searchLabel }),
26468 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(toggle_default, {})
26469 ]
26470 }
26471 ),
26472 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26473 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(dataviews_view_config_default, {}),
26474 header
26475 ] })
26476 ]
26477 }
26478 ),
26479 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26480 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsLayout, {}),
26481 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DataViewsFooter, {})
26482 ] });
26483 }
26484 function DataViews({
26485 view,
26486 onChangeView,
26487 fields,
26488 search = true,
26489 searchLabel = void 0,
26490 actions = EMPTY_ARRAY6,
26491 data,
26492 getItemId = defaultGetItemId,
26493 getItemLevel,
26494 isLoading = false,
26495 paginationInfo,
26496 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26497 selection: selectionProperty,
26498 onChangeSelection,
26499 onClickItem,
26500 renderItemLink,
26501 isItemClickable = defaultIsItemClickable,
26502 header,
26503 children,
26504 config = { perPageSizes: [10, 20, 50, 100] },
26505 empty,
26506 onReset
26507 }) {
26508 const [selectionState, setSelectionState] = (0, import_element83.useState)([]);
26509 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26510 const selection = isUncontrolled ? selectionState : selectionProperty;
26511 const {
26512 data: displayData,
26513 paginationInfo: displayPaginationInfo,
26514 hasInitiallyLoaded,
26515 setVisibleEntries
26516 } = useData({
26517 view,
26518 data,
26519 getItemId,
26520 isLoading,
26521 selection,
26522 paginationInfo
26523 });
26524 const containerRef = (0, import_element83.useRef)(null);
26525 const [containerWidth, setContainerWidth] = (0, import_element83.useState)(0);
26526 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
26527 (resizeObserverEntries) => {
26528 setContainerWidth(
26529 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26530 );
26531 },
26532 { box: "border-box" }
26533 );
26534 const [openedFilter, setOpenedFilter] = (0, import_element83.useState)(null);
26535 function setSelectionWithChange(value) {
26536 const newValue = typeof value === "function" ? value(selection) : value;
26537 if (isUncontrolled) {
26538 setSelectionState(newValue);
26539 }
26540 if (onChangeSelection) {
26541 onChangeSelection(newValue);
26542 }
26543 }
26544 const _fields = (0, import_element83.useMemo)(() => normalizeFields(fields), [fields]);
26545 const _selection = (0, import_element83.useMemo)(() => {
26546 if (view.infiniteScrollEnabled) {
26547 return selection;
26548 }
26549 return selection.filter(
26550 (id) => data.some((item) => getItemId(item) === id)
26551 );
26552 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26553 const filters = use_filters_default(_fields, view);
26554 const hasPrimaryOrLockedFilters = (0, import_element83.useMemo)(
26555 () => (filters || []).some(
26556 (filter) => filter.isPrimary || filter.isLocked
26557 ),
26558 [filters]
26559 );
26560 const [isShowingFilter, setIsShowingFilter] = (0, import_element83.useState)(
26561 hasPrimaryOrLockedFilters
26562 );
26563 const { intersectionObserver } = useInfiniteScroll({
26564 view,
26565 onChangeView,
26566 isLoading,
26567 paginationInfo,
26568 containerRef,
26569 setVisibleEntries
26570 });
26571 (0, import_element83.useEffect)(() => {
26572 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26573 setIsShowingFilter(true);
26574 }
26575 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26576 const defaultLayouts = (0, import_element83.useMemo)(
26577 () => Object.fromEntries(
26578 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26579 return dataViewsLayouts.some(
26580 (viewLayout) => viewLayout.type === layoutType
26581 );
26582 }).map(([key, value]) => [
26583 key,
26584 value === true ? {} : value
26585 ])
26586 ),
26587 [defaultLayoutsProperty]
26588 );
26589 if (!defaultLayouts[view.type]) {
26590 return null;
26591 }
26592 return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26593 dataviews_context_default.Provider,
26594 {
26595 value: {
26596 view,
26597 onChangeView,
26598 fields: _fields,
26599 actions,
26600 data: displayData,
26601 isLoading,
26602 paginationInfo: displayPaginationInfo,
26603 selection: _selection,
26604 onChangeSelection: setSelectionWithChange,
26605 openedFilter,
26606 setOpenedFilter,
26607 getItemId,
26608 getItemLevel,
26609 isItemClickable,
26610 onClickItem,
26611 renderItemLink,
26612 containerWidth,
26613 containerRef,
26614 resizeObserverRef,
26615 defaultLayouts,
26616 filters,
26617 isShowingFilter,
26618 setIsShowingFilter,
26619 config,
26620 empty,
26621 hasInitiallyLoaded,
26622 onReset,
26623 intersectionObserver
26624 },
26625 children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
26626 DefaultUI,
26627 {
26628 header,
26629 search,
26630 searchLabel
26631 }
26632 ) })
26633 }
26634 );
26635 }
26636 var DataViewsSubComponents = DataViews;
26637 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26638 DataViewsSubComponents.Filters = filters_default;
26639 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26640 DataViewsSubComponents.FiltersToggle = toggle_default;
26641 DataViewsSubComponents.Layout = DataViewsLayout;
26642 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26643 DataViewsSubComponents.Pagination = DataViewsPagination;
26644 DataViewsSubComponents.Search = dataviews_search_default;
26645 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26646 DataViewsSubComponents.Footer = DataViewsFooter;
26647 var dataviews_default = DataViewsSubComponents;
26648
26649 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
26650 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
26651 var import_deprecated = __toESM(require_deprecated(), 1);
26652 function normalizeSearchInput2(input = "") {
26653 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
26654 }
26655 var EMPTY_ARRAY7 = [];
26656 function filterSortAndPaginate(data, view, fields) {
26657 if (!data) {
26658 return {
26659 data: EMPTY_ARRAY7,
26660 paginationInfo: { totalItems: 0, totalPages: 0 }
26661 };
26662 }
26663 const _fields = normalizeFields(fields);
26664 let filteredData = [...data];
26665 if (view.search) {
26666 const normalizedSearch = normalizeSearchInput2(view.search);
26667 filteredData = filteredData.filter((item) => {
26668 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
26669 const fieldValue = field.getValue({ item });
26670 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
26671 return values.some(
26672 (value) => normalizeSearchInput2(String(value)).includes(
26673 normalizedSearch
26674 )
26675 );
26676 });
26677 });
26678 }
26679 if (view.filters && view.filters?.length > 0) {
26680 view.filters.forEach((filter) => {
26681 const field = _fields.find(
26682 (_field) => _field.id === filter.field
26683 );
26684 if (field) {
26685 if (filter.operator === OPERATOR_IS_NOT_ALL) {
26686 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
26687 since: "7.0",
26688 alternative: "'isNone'"
26689 });
26690 }
26691 const handler = field.filter[filter.operator];
26692 if (handler) {
26693 filteredData = filteredData.filter(
26694 (item) => handler(item, field, filter.value)
26695 );
26696 }
26697 }
26698 });
26699 }
26700 const sortByField = view.sort?.field ? _fields.find((field) => {
26701 return field.enableSorting !== false && field.id === view.sort?.field;
26702 }) : null;
26703 const groupByField = view.groupBy?.field ? _fields.find((field) => {
26704 return field.enableSorting !== false && field.id === view.groupBy?.field;
26705 }) : null;
26706 if (sortByField || groupByField) {
26707 filteredData.sort((a2, b2) => {
26708 if (groupByField) {
26709 const groupCompare = groupByField.sort(
26710 a2,
26711 b2,
26712 view.groupBy?.direction ?? "asc"
26713 );
26714 if (groupCompare !== 0) {
26715 return groupCompare;
26716 }
26717 }
26718 if (sortByField) {
26719 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
26720 }
26721 return 0;
26722 });
26723 }
26724 let totalItems = filteredData.length;
26725 let totalPages = 1;
26726 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
26727 const start = view.startPosition - 1;
26728 const end = Math.min(start + view.perPage, totalItems);
26729 filteredData = filteredData?.slice(start, end);
26730 } else if (view.page !== void 0 && view.perPage !== void 0) {
26731 const start = (view.page - 1) * view.perPage;
26732 totalItems = filteredData?.length || 0;
26733 totalPages = Math.ceil(totalItems / view.perPage);
26734 filteredData = filteredData?.slice(start, start + view.perPage);
26735 }
26736 return {
26737 data: filteredData,
26738 paginationInfo: {
26739 totalItems,
26740 totalPages
26741 }
26742 };
26743 }
26744
26745 // packages/style-runtime/src/index.ts
26746 var STYLE_HASH_ATTRIBUTE14 = "data-wp-hash";
26747 function getRuntime14() {
26748 const globalScope = globalThis;
26749 if (globalScope.__wpStyleRuntime) {
26750 return globalScope.__wpStyleRuntime;
26751 }
26752 globalScope.__wpStyleRuntime = {
26753 documents: /* @__PURE__ */ new Map(),
26754 styles: /* @__PURE__ */ new Map(),
26755 injectedStyles: /* @__PURE__ */ new WeakMap()
26756 };
26757 if (typeof document !== "undefined") {
26758 registerDocument14(document);
26759 }
26760 return globalScope.__wpStyleRuntime;
26761 }
26762 function documentContainsStyleHash14(targetDocument, hash) {
26763 if (!targetDocument.head) {
26764 return false;
26765 }
26766 for (const style of targetDocument.head.querySelectorAll(
26767 `style[${STYLE_HASH_ATTRIBUTE14}]`
26768 )) {
26769 if (style.getAttribute(STYLE_HASH_ATTRIBUTE14) === hash) {
26770 return true;
26771 }
26772 }
26773 return false;
26774 }
26775 function injectStyle14(targetDocument, hash, css) {
26776 if (!targetDocument.head) {
26777 return;
26778 }
26779 const runtime = getRuntime14();
26780 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26781 if (!injectedStyles) {
26782 injectedStyles = /* @__PURE__ */ new Set();
26783 runtime.injectedStyles.set(targetDocument, injectedStyles);
26784 }
26785 if (injectedStyles.has(hash)) {
26786 return;
26787 }
26788 if (documentContainsStyleHash14(targetDocument, hash)) {
26789 injectedStyles.add(hash);
26790 return;
26791 }
26792 const style = targetDocument.createElement("style");
26793 style.setAttribute(STYLE_HASH_ATTRIBUTE14, hash);
26794 style.appendChild(targetDocument.createTextNode(css));
26795 targetDocument.head.appendChild(style);
26796 injectedStyles.add(hash);
26797 }
26798 function registerDocument14(targetDocument) {
26799 const runtime = getRuntime14();
26800 runtime.documents.set(
26801 targetDocument,
26802 (runtime.documents.get(targetDocument) ?? 0) + 1
26803 );
26804 for (const [hash, css] of runtime.styles) {
26805 injectStyle14(targetDocument, hash, css);
26806 }
26807 return () => {
26808 const count = runtime.documents.get(targetDocument);
26809 if (count === void 0) {
26810 return;
26811 }
26812 if (count <= 1) {
26813 runtime.documents.delete(targetDocument);
26814 return;
26815 }
26816 runtime.documents.set(targetDocument, count - 1);
26817 };
26818 }
26819 function registerStyle14(hash, css) {
26820 const runtime = getRuntime14();
26821 runtime.styles.set(hash, css);
26822 for (const targetDocument of runtime.documents.keys()) {
26823 injectStyle14(targetDocument, hash, css);
26824 }
26825 }
26826
26827 // widgets/activity/style.module.css
26828 if (typeof process === "undefined" || true) {
26829 registerStyle14("4aa3daa799", "._784d2967c5e53514__loading{height:100%}._21768f83511c9ec9__list{max-height:420px}");
26830 }
26831 var style_default13 = { "loading": "_784d2967c5e53514__loading", "list": "_21768f83511c9ec9__list" };
26832
26833 // widgets/activity/render.tsx
26834 var import_jsx_runtime118 = __toESM(require_jsx_runtime());
26835 function formatGroupDate(dateStr) {
26836 const now = (0, import_date10.getDate)();
26837 const today = (0, import_date10.dateI18n)("Y-m-d", now);
26838 if (dateStr === today) {
26839 return (0, import_i18n45.__)("Today");
26840 }
26841 const yesterday = (0, import_date10.getDate)();
26842 yesterday.setDate(yesterday.getDate() - 1);
26843 const yesterdayStr = (0, import_date10.dateI18n)("Y-m-d", yesterday);
26844 if (dateStr === yesterdayStr) {
26845 return (0, import_i18n45.__)("Yesterday");
26846 }
26847 const currentYear = (0, import_date10.dateI18n)("Y", now);
26848 if (dateStr.slice(0, 4) === currentYear) {
26849 return (0, import_date10.dateI18n)((0, import_i18n45.__)("M jS"), dateStr);
26850 }
26851 return (0, import_date10.dateI18n)((0, import_i18n45.__)("M jS Y"), dateStr);
26852 }
26853 function htmlToPlainText(html) {
26854 const { body } = new window.DOMParser().parseFromString(
26855 html,
26856 "text/html"
26857 );
26858 return (body.textContent ?? "").trim();
26859 }
26860 var FIELDS = [
26861 {
26862 id: "icon",
26863 label: (0, import_i18n45.__)("Icon"),
26864 type: "media",
26865 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(icon_default, { icon: item.kind === "comment" ? comment_default : post_list_default }),
26866 enableSorting: false,
26867 enableHiding: false
26868 },
26869 {
26870 id: "title",
26871 label: (0, import_i18n45.__)("Title"),
26872 type: "text",
26873 getValue: ({ item }) => item.title,
26874 enableSorting: false,
26875 enableGlobalSearch: true
26876 },
26877 {
26878 id: "description",
26879 label: (0, import_i18n45.__)("Description"),
26880 type: "text",
26881 getValue: ({ item }) => item.description,
26882 enableSorting: false,
26883 enableGlobalSearch: true
26884 },
26885 {
26886 id: "datetime",
26887 label: (0, import_i18n45.__)("Time"),
26888 getValue: ({ item }) => item.datetime,
26889 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("span", { children: (0, import_date10.dateI18n)((0, import_i18n45.__)("g:i a"), item.datetime) }),
26890 enableSorting: true
26891 },
26892 {
26893 id: "date",
26894 label: (0, import_i18n45.__)("Date"),
26895 getValue: ({ item }) => item.datetime.split("T")[0],
26896 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("span", { children: formatGroupDate(item.datetime.split("T")[0]) }),
26897 enableSorting: true,
26898 enableHiding: false
26899 }
26900 ];
26901 var DEFAULT_PER_PAGE = 5;
26902 var SOURCE_COUNT = 3;
26903 var DEFAULT_VIEW = {
26904 type: "activity",
26905 search: "",
26906 page: 1,
26907 perPage: DEFAULT_PER_PAGE,
26908 filters: [],
26909 fields: ["datetime"],
26910 titleField: "title",
26911 descriptionField: "description",
26912 mediaField: "icon",
26913 showMedia: true,
26914 sort: {
26915 field: "datetime",
26916 direction: "desc"
26917 },
26918 groupBy: {
26919 field: "date",
26920 direction: "desc",
26921 showLabel: false
26922 }
26923 };
26924 function Activity({
26925 attributes
26926 }) {
26927 const perPage = Math.max(1, attributes?.perPage ?? DEFAULT_PER_PAGE);
26928 const [view, setView] = (0, import_element84.useState)(DEFAULT_VIEW);
26929 const queries = (0, import_element84.useMemo)(
26930 () => ({
26931 future: {
26932 status: "future",
26933 orderby: "date",
26934 order: "asc",
26935 per_page: perPage
26936 },
26937 recent: {
26938 status: "publish",
26939 orderby: "date",
26940 order: "desc",
26941 per_page: perPage
26942 },
26943 comments: { per_page: perPage }
26944 }),
26945 [perPage]
26946 );
26947 const { futurePosts, recentPosts, comments, isResolved } = (0, import_data6.useSelect)(
26948 (select) => {
26949 const coreData = select(import_core_data.store);
26950 return {
26951 futurePosts: coreData.getEntityRecords(
26952 "postType",
26953 "post",
26954 queries.future
26955 ),
26956 recentPosts: coreData.getEntityRecords(
26957 "postType",
26958 "post",
26959 queries.recent
26960 ),
26961 comments: coreData.getEntityRecords(
26962 "root",
26963 "comment",
26964 queries.comments
26965 ),
26966 isResolved: coreData.hasFinishedResolution("getEntityRecords", [
26967 "postType",
26968 "post",
26969 queries.future
26970 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26971 "postType",
26972 "post",
26973 queries.recent
26974 ]) && coreData.hasFinishedResolution("getEntityRecords", [
26975 "root",
26976 "comment",
26977 queries.comments
26978 ])
26979 };
26980 },
26981 [queries]
26982 );
26983 const allEvents = (0, import_element84.useMemo)(() => {
26984 const events = [];
26985 for (const post of futurePosts ?? []) {
26986 events.push({
26987 id: `post-future-${post.id}`,
26988 datetime: post.date ?? "",
26989 title: (0, import_html_entities.decodeEntities)(
26990 post.title?.rendered ?? ""
26991 ),
26992 description: "",
26993 link: post.link ?? "",
26994 kind: "post-future"
26995 });
26996 }
26997 for (const post of recentPosts ?? []) {
26998 events.push({
26999 id: `post-published-${post.id}`,
27000 datetime: post.date ?? "",
27001 title: (0, import_html_entities.decodeEntities)(
27002 post.title?.rendered ?? ""
27003 ),
27004 description: "",
27005 link: post.link ?? "",
27006 kind: "post-published"
27007 });
27008 }
27009 for (const c2 of comments ?? []) {
27010 events.push({
27011 id: `comment-${c2.id}`,
27012 datetime: c2.date ?? "",
27013 title: (0, import_html_entities.decodeEntities)(c2.author_name ?? ""),
27014 description: htmlToPlainText(
27015 c2.content?.rendered ?? ""
27016 ),
27017 link: c2.link ?? "",
27018 kind: "comment"
27019 });
27020 }
27021 return events;
27022 }, [futurePosts, recentPosts, comments]);
27023 const resolvedView = (0, import_element84.useMemo)(
27024 () => ({ ...view, perPage: perPage * SOURCE_COUNT }),
27025 [view, perPage]
27026 );
27027 const { data: shownData, paginationInfo } = (0, import_element84.useMemo)(
27028 () => filterSortAndPaginate(allEvents, resolvedView, FIELDS),
27029 [allEvents, resolvedView]
27030 );
27031 if (!isResolved) {
27032 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
27033 Stack,
27034 {
27035 direction: "column",
27036 align: "center",
27037 justify: "center",
27038 className: style_default13.loading,
27039 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components46.Spinner, {})
27040 }
27041 );
27042 }
27043 if (allEvents.length === 0) {
27044 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
27045 Stack,
27046 {
27047 direction: "column",
27048 align: "center",
27049 justify: "center",
27050 className: style_default13.loading,
27051 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(empty_state_exports.Root, { children: [
27052 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Icon, { icon: post_list_default }),
27053 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Title, { children: (0, import_i18n45.__)("No activity yet.") }),
27054 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(empty_state_exports.Description, { children: (0, import_i18n45.__)(
27055 "When you publish posts or receive comments, they will appear here."
27056 ) })
27057 ] })
27058 }
27059 );
27060 }
27061 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Stack, { direction: "column", className: style_default13.list, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
27062 dataviews_default,
27063 {
27064 data: shownData,
27065 fields: FIELDS,
27066 view: resolvedView,
27067 onChangeView: setView,
27068 paginationInfo,
27069 getItemId: (item) => item.id,
27070 search: false,
27071 isLoading: false,
27072 defaultLayouts: {
27073 activity: {
27074 sort: {
27075 field: "datetime",
27076 direction: "desc"
27077 }
27078 }
27079 },
27080 renderItemLink: ({ item, children, ...aProps }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Link, { href: item.link, ...aProps, children }),
27081 isItemClickable: (item) => !!item.link,
27082 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(dataviews_default.Layout, {})
27083 }
27084 ) });
27085 }
27086 export {
27087 Activity as default
27088 };
27089 /*! Bundled license information:
27090
27091 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
27092 (**
27093 * @license React
27094 * use-sync-external-store-shim.development.js
27095 *
27096 * Copyright (c) Meta Platforms, Inc. and affiliates.
27097 *
27098 * This source code is licensed under the MIT license found in the
27099 * LICENSE file in the root directory of this source tree.
27100 *)
27101
27102 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
27103 (**
27104 * @license React
27105 * use-sync-external-store-shim/with-selector.development.js
27106 *
27107 * Copyright (c) Meta Platforms, Inc. and affiliates.
27108 *
27109 * This source code is licensed under the MIT license found in the
27110 * LICENSE file in the root directory of this source tree.
27111 *)
27112 */
27113