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 / routes / pattern-list / content.js

content.js in Gutenberg 23.4.0, at build/routes/pattern-list/content.js

27,383 lines 930.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/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/preferences
46 var require_preferences = __commonJS({
47 "package-external:@wordpress/preferences"(exports, module) {
48 module.exports = window.wp.preferences;
49 }
50 });
51
52 // package-external:@wordpress/core-data
53 var require_core_data = __commonJS({
54 "package-external:@wordpress/core-data"(exports, module) {
55 module.exports = window.wp.coreData;
56 }
57 });
58
59 // package-external:@wordpress/private-apis
60 var require_private_apis = __commonJS({
61 "package-external:@wordpress/private-apis"(exports, module) {
62 module.exports = window.wp.privateApis;
63 }
64 });
65
66 // package-external:@wordpress/compose
67 var require_compose = __commonJS({
68 "package-external:@wordpress/compose"(exports, module) {
69 module.exports = window.wp.compose;
70 }
71 });
72
73 // vendor-external:react
74 var require_react = __commonJS({
75 "vendor-external:react"(exports, module) {
76 module.exports = window.React;
77 }
78 });
79
80 // vendor-external:react/jsx-runtime
81 var require_jsx_runtime = __commonJS({
82 "vendor-external:react/jsx-runtime"(exports, module) {
83 module.exports = window.ReactJSXRuntime;
84 }
85 });
86
87 // vendor-external:react-dom
88 var require_react_dom = __commonJS({
89 "vendor-external:react-dom"(exports, module) {
90 module.exports = window.ReactDOM;
91 }
92 });
93
94 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
95 var require_use_sync_external_store_shim_development = __commonJS({
96 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
97 "use strict";
98 (function() {
99 function is(x2, y2) {
100 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
101 }
102 function useSyncExternalStore$2(subscribe2, getSnapshot) {
103 didWarnOld18Alpha || void 0 === React51.startTransition || (didWarnOld18Alpha = true, console.error(
104 "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."
105 ));
106 var value = getSnapshot();
107 if (!didWarnUncachedGetSnapshot) {
108 var cachedValue = getSnapshot();
109 objectIs(value, cachedValue) || (console.error(
110 "The result of getSnapshot should be cached to avoid an infinite loop"
111 ), didWarnUncachedGetSnapshot = true);
112 }
113 cachedValue = useState36({
114 inst: { value, getSnapshot }
115 });
116 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
117 useLayoutEffect5(
118 function() {
119 inst.value = value;
120 inst.getSnapshot = getSnapshot;
121 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
122 },
123 [subscribe2, value, getSnapshot]
124 );
125 useEffect31(
126 function() {
127 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
128 return subscribe2(function() {
129 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
130 });
131 },
132 [subscribe2]
133 );
134 useDebugValue2(value);
135 return value;
136 }
137 function checkIfSnapshotChanged(inst) {
138 var latestGetSnapshot = inst.getSnapshot;
139 inst = inst.value;
140 try {
141 var nextValue = latestGetSnapshot();
142 return !objectIs(inst, nextValue);
143 } catch (error) {
144 return true;
145 }
146 }
147 function useSyncExternalStore$1(subscribe2, getSnapshot) {
148 return getSnapshot();
149 }
150 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
151 var React51 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React51.useState, useEffect31 = React51.useEffect, useLayoutEffect5 = React51.useLayoutEffect, useDebugValue2 = React51.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
152 exports.useSyncExternalStore = void 0 !== React51.useSyncExternalStore ? React51.useSyncExternalStore : shim;
153 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
154 })();
155 }
156 });
157
158 // node_modules/use-sync-external-store/shim/index.js
159 var require_shim = __commonJS({
160 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
161 "use strict";
162 if (false) {
163 module.exports = null;
164 } else {
165 module.exports = require_use_sync_external_store_shim_development();
166 }
167 }
168 });
169
170 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
171 var require_with_selector_development = __commonJS({
172 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
173 "use strict";
174 (function() {
175 function is(x2, y2) {
176 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
177 }
178 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
179 var React51 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef46 = React51.useRef, useEffect31 = React51.useEffect, useMemo43 = React51.useMemo, useDebugValue2 = React51.useDebugValue;
180 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
181 var instRef = useRef46(null);
182 if (null === instRef.current) {
183 var inst = { hasValue: false, value: null };
184 instRef.current = inst;
185 } else inst = instRef.current;
186 instRef = useMemo43(
187 function() {
188 function memoizedSelector(nextSnapshot) {
189 if (!hasMemo) {
190 hasMemo = true;
191 memoizedSnapshot = nextSnapshot;
192 nextSnapshot = selector2(nextSnapshot);
193 if (void 0 !== isEqual && inst.hasValue) {
194 var currentSelection = inst.value;
195 if (isEqual(currentSelection, nextSnapshot))
196 return memoizedSelection = currentSelection;
197 }
198 return memoizedSelection = nextSnapshot;
199 }
200 currentSelection = memoizedSelection;
201 if (objectIs(memoizedSnapshot, nextSnapshot))
202 return currentSelection;
203 var nextSelection = selector2(nextSnapshot);
204 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
205 return memoizedSnapshot = nextSnapshot, currentSelection;
206 memoizedSnapshot = nextSnapshot;
207 return memoizedSelection = nextSelection;
208 }
209 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
210 return [
211 function() {
212 return memoizedSelector(getSnapshot());
213 },
214 null === maybeGetServerSnapshot ? void 0 : function() {
215 return memoizedSelector(maybeGetServerSnapshot());
216 }
217 ];
218 },
219 [getSnapshot, getServerSnapshot, selector2, isEqual]
220 );
221 var value = useSyncExternalStore3(subscribe2, instRef[0], instRef[1]);
222 useEffect31(
223 function() {
224 inst.hasValue = true;
225 inst.value = value;
226 },
227 [value]
228 );
229 useDebugValue2(value);
230 return value;
231 };
232 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
233 })();
234 }
235 });
236
237 // node_modules/use-sync-external-store/shim/with-selector.js
238 var require_with_selector = __commonJS({
239 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
240 "use strict";
241 if (false) {
242 module.exports = null;
243 } else {
244 module.exports = require_with_selector_development();
245 }
246 }
247 });
248
249 // package-external:@wordpress/i18n
250 var require_i18n = __commonJS({
251 "package-external:@wordpress/i18n"(exports, module) {
252 module.exports = window.wp.i18n;
253 }
254 });
255
256 // package-external:@wordpress/primitives
257 var require_primitives = __commonJS({
258 "package-external:@wordpress/primitives"(exports, module) {
259 module.exports = window.wp.primitives;
260 }
261 });
262
263 // package-external:@wordpress/theme
264 var require_theme = __commonJS({
265 "package-external:@wordpress/theme"(exports, module) {
266 module.exports = window.wp.theme;
267 }
268 });
269
270 // package-external:@wordpress/components
271 var require_components = __commonJS({
272 "package-external:@wordpress/components"(exports, module) {
273 module.exports = window.wp.components;
274 }
275 });
276
277 // package-external:@wordpress/keycodes
278 var require_keycodes = __commonJS({
279 "package-external:@wordpress/keycodes"(exports, module) {
280 module.exports = window.wp.keycodes;
281 }
282 });
283
284 // node_modules/remove-accents/index.js
285 var require_remove_accents = __commonJS({
286 "node_modules/remove-accents/index.js"(exports, module) {
287 var characterMap = {
288 "\xC0": "A",
289 "\xC1": "A",
290 "\xC2": "A",
291 "\xC3": "A",
292 "\xC4": "A",
293 "\xC5": "A",
294 "\u1EA4": "A",
295 "\u1EAE": "A",
296 "\u1EB2": "A",
297 "\u1EB4": "A",
298 "\u1EB6": "A",
299 "\xC6": "AE",
300 "\u1EA6": "A",
301 "\u1EB0": "A",
302 "\u0202": "A",
303 "\u1EA2": "A",
304 "\u1EA0": "A",
305 "\u1EA8": "A",
306 "\u1EAA": "A",
307 "\u1EAC": "A",
308 "\xC7": "C",
309 "\u1E08": "C",
310 "\xC8": "E",
311 "\xC9": "E",
312 "\xCA": "E",
313 "\xCB": "E",
314 "\u1EBE": "E",
315 "\u1E16": "E",
316 "\u1EC0": "E",
317 "\u1E14": "E",
318 "\u1E1C": "E",
319 "\u0206": "E",
320 "\u1EBA": "E",
321 "\u1EBC": "E",
322 "\u1EB8": "E",
323 "\u1EC2": "E",
324 "\u1EC4": "E",
325 "\u1EC6": "E",
326 "\xCC": "I",
327 "\xCD": "I",
328 "\xCE": "I",
329 "\xCF": "I",
330 "\u1E2E": "I",
331 "\u020A": "I",
332 "\u1EC8": "I",
333 "\u1ECA": "I",
334 "\xD0": "D",
335 "\xD1": "N",
336 "\xD2": "O",
337 "\xD3": "O",
338 "\xD4": "O",
339 "\xD5": "O",
340 "\xD6": "O",
341 "\xD8": "O",
342 "\u1ED0": "O",
343 "\u1E4C": "O",
344 "\u1E52": "O",
345 "\u020E": "O",
346 "\u1ECE": "O",
347 "\u1ECC": "O",
348 "\u1ED4": "O",
349 "\u1ED6": "O",
350 "\u1ED8": "O",
351 "\u1EDC": "O",
352 "\u1EDE": "O",
353 "\u1EE0": "O",
354 "\u1EDA": "O",
355 "\u1EE2": "O",
356 "\xD9": "U",
357 "\xDA": "U",
358 "\xDB": "U",
359 "\xDC": "U",
360 "\u1EE6": "U",
361 "\u1EE4": "U",
362 "\u1EEC": "U",
363 "\u1EEE": "U",
364 "\u1EF0": "U",
365 "\xDD": "Y",
366 "\xE0": "a",
367 "\xE1": "a",
368 "\xE2": "a",
369 "\xE3": "a",
370 "\xE4": "a",
371 "\xE5": "a",
372 "\u1EA5": "a",
373 "\u1EAF": "a",
374 "\u1EB3": "a",
375 "\u1EB5": "a",
376 "\u1EB7": "a",
377 "\xE6": "ae",
378 "\u1EA7": "a",
379 "\u1EB1": "a",
380 "\u0203": "a",
381 "\u1EA3": "a",
382 "\u1EA1": "a",
383 "\u1EA9": "a",
384 "\u1EAB": "a",
385 "\u1EAD": "a",
386 "\xE7": "c",
387 "\u1E09": "c",
388 "\xE8": "e",
389 "\xE9": "e",
390 "\xEA": "e",
391 "\xEB": "e",
392 "\u1EBF": "e",
393 "\u1E17": "e",
394 "\u1EC1": "e",
395 "\u1E15": "e",
396 "\u1E1D": "e",
397 "\u0207": "e",
398 "\u1EBB": "e",
399 "\u1EBD": "e",
400 "\u1EB9": "e",
401 "\u1EC3": "e",
402 "\u1EC5": "e",
403 "\u1EC7": "e",
404 "\xEC": "i",
405 "\xED": "i",
406 "\xEE": "i",
407 "\xEF": "i",
408 "\u1E2F": "i",
409 "\u020B": "i",
410 "\u1EC9": "i",
411 "\u1ECB": "i",
412 "\xF0": "d",
413 "\xF1": "n",
414 "\xF2": "o",
415 "\xF3": "o",
416 "\xF4": "o",
417 "\xF5": "o",
418 "\xF6": "o",
419 "\xF8": "o",
420 "\u1ED1": "o",
421 "\u1E4D": "o",
422 "\u1E53": "o",
423 "\u020F": "o",
424 "\u1ECF": "o",
425 "\u1ECD": "o",
426 "\u1ED5": "o",
427 "\u1ED7": "o",
428 "\u1ED9": "o",
429 "\u1EDD": "o",
430 "\u1EDF": "o",
431 "\u1EE1": "o",
432 "\u1EDB": "o",
433 "\u1EE3": "o",
434 "\xF9": "u",
435 "\xFA": "u",
436 "\xFB": "u",
437 "\xFC": "u",
438 "\u1EE7": "u",
439 "\u1EE5": "u",
440 "\u1EED": "u",
441 "\u1EEF": "u",
442 "\u1EF1": "u",
443 "\xFD": "y",
444 "\xFF": "y",
445 "\u0100": "A",
446 "\u0101": "a",
447 "\u0102": "A",
448 "\u0103": "a",
449 "\u0104": "A",
450 "\u0105": "a",
451 "\u0106": "C",
452 "\u0107": "c",
453 "\u0108": "C",
454 "\u0109": "c",
455 "\u010A": "C",
456 "\u010B": "c",
457 "\u010C": "C",
458 "\u010D": "c",
459 "C\u0306": "C",
460 "c\u0306": "c",
461 "\u010E": "D",
462 "\u010F": "d",
463 "\u0110": "D",
464 "\u0111": "d",
465 "\u0112": "E",
466 "\u0113": "e",
467 "\u0114": "E",
468 "\u0115": "e",
469 "\u0116": "E",
470 "\u0117": "e",
471 "\u0118": "E",
472 "\u0119": "e",
473 "\u011A": "E",
474 "\u011B": "e",
475 "\u011C": "G",
476 "\u01F4": "G",
477 "\u011D": "g",
478 "\u01F5": "g",
479 "\u011E": "G",
480 "\u011F": "g",
481 "\u0120": "G",
482 "\u0121": "g",
483 "\u0122": "G",
484 "\u0123": "g",
485 "\u0124": "H",
486 "\u0125": "h",
487 "\u0126": "H",
488 "\u0127": "h",
489 "\u1E2A": "H",
490 "\u1E2B": "h",
491 "\u0128": "I",
492 "\u0129": "i",
493 "\u012A": "I",
494 "\u012B": "i",
495 "\u012C": "I",
496 "\u012D": "i",
497 "\u012E": "I",
498 "\u012F": "i",
499 "\u0130": "I",
500 "\u0131": "i",
501 "\u0132": "IJ",
502 "\u0133": "ij",
503 "\u0134": "J",
504 "\u0135": "j",
505 "\u0136": "K",
506 "\u0137": "k",
507 "\u1E30": "K",
508 "\u1E31": "k",
509 "K\u0306": "K",
510 "k\u0306": "k",
511 "\u0139": "L",
512 "\u013A": "l",
513 "\u013B": "L",
514 "\u013C": "l",
515 "\u013D": "L",
516 "\u013E": "l",
517 "\u013F": "L",
518 "\u0140": "l",
519 "\u0141": "l",
520 "\u0142": "l",
521 "\u1E3E": "M",
522 "\u1E3F": "m",
523 "M\u0306": "M",
524 "m\u0306": "m",
525 "\u0143": "N",
526 "\u0144": "n",
527 "\u0145": "N",
528 "\u0146": "n",
529 "\u0147": "N",
530 "\u0148": "n",
531 "\u0149": "n",
532 "N\u0306": "N",
533 "n\u0306": "n",
534 "\u014C": "O",
535 "\u014D": "o",
536 "\u014E": "O",
537 "\u014F": "o",
538 "\u0150": "O",
539 "\u0151": "o",
540 "\u0152": "OE",
541 "\u0153": "oe",
542 "P\u0306": "P",
543 "p\u0306": "p",
544 "\u0154": "R",
545 "\u0155": "r",
546 "\u0156": "R",
547 "\u0157": "r",
548 "\u0158": "R",
549 "\u0159": "r",
550 "R\u0306": "R",
551 "r\u0306": "r",
552 "\u0212": "R",
553 "\u0213": "r",
554 "\u015A": "S",
555 "\u015B": "s",
556 "\u015C": "S",
557 "\u015D": "s",
558 "\u015E": "S",
559 "\u0218": "S",
560 "\u0219": "s",
561 "\u015F": "s",
562 "\u0160": "S",
563 "\u0161": "s",
564 "\u0162": "T",
565 "\u0163": "t",
566 "\u021B": "t",
567 "\u021A": "T",
568 "\u0164": "T",
569 "\u0165": "t",
570 "\u0166": "T",
571 "\u0167": "t",
572 "T\u0306": "T",
573 "t\u0306": "t",
574 "\u0168": "U",
575 "\u0169": "u",
576 "\u016A": "U",
577 "\u016B": "u",
578 "\u016C": "U",
579 "\u016D": "u",
580 "\u016E": "U",
581 "\u016F": "u",
582 "\u0170": "U",
583 "\u0171": "u",
584 "\u0172": "U",
585 "\u0173": "u",
586 "\u0216": "U",
587 "\u0217": "u",
588 "V\u0306": "V",
589 "v\u0306": "v",
590 "\u0174": "W",
591 "\u0175": "w",
592 "\u1E82": "W",
593 "\u1E83": "w",
594 "X\u0306": "X",
595 "x\u0306": "x",
596 "\u0176": "Y",
597 "\u0177": "y",
598 "\u0178": "Y",
599 "Y\u0306": "Y",
600 "y\u0306": "y",
601 "\u0179": "Z",
602 "\u017A": "z",
603 "\u017B": "Z",
604 "\u017C": "z",
605 "\u017D": "Z",
606 "\u017E": "z",
607 "\u017F": "s",
608 "\u0192": "f",
609 "\u01A0": "O",
610 "\u01A1": "o",
611 "\u01AF": "U",
612 "\u01B0": "u",
613 "\u01CD": "A",
614 "\u01CE": "a",
615 "\u01CF": "I",
616 "\u01D0": "i",
617 "\u01D1": "O",
618 "\u01D2": "o",
619 "\u01D3": "U",
620 "\u01D4": "u",
621 "\u01D5": "U",
622 "\u01D6": "u",
623 "\u01D7": "U",
624 "\u01D8": "u",
625 "\u01D9": "U",
626 "\u01DA": "u",
627 "\u01DB": "U",
628 "\u01DC": "u",
629 "\u1EE8": "U",
630 "\u1EE9": "u",
631 "\u1E78": "U",
632 "\u1E79": "u",
633 "\u01FA": "A",
634 "\u01FB": "a",
635 "\u01FC": "AE",
636 "\u01FD": "ae",
637 "\u01FE": "O",
638 "\u01FF": "o",
639 "\xDE": "TH",
640 "\xFE": "th",
641 "\u1E54": "P",
642 "\u1E55": "p",
643 "\u1E64": "S",
644 "\u1E65": "s",
645 "X\u0301": "X",
646 "x\u0301": "x",
647 "\u0403": "\u0413",
648 "\u0453": "\u0433",
649 "\u040C": "\u041A",
650 "\u045C": "\u043A",
651 "A\u030B": "A",
652 "a\u030B": "a",
653 "E\u030B": "E",
654 "e\u030B": "e",
655 "I\u030B": "I",
656 "i\u030B": "i",
657 "\u01F8": "N",
658 "\u01F9": "n",
659 "\u1ED2": "O",
660 "\u1ED3": "o",
661 "\u1E50": "O",
662 "\u1E51": "o",
663 "\u1EEA": "U",
664 "\u1EEB": "u",
665 "\u1E80": "W",
666 "\u1E81": "w",
667 "\u1EF2": "Y",
668 "\u1EF3": "y",
669 "\u0200": "A",
670 "\u0201": "a",
671 "\u0204": "E",
672 "\u0205": "e",
673 "\u0208": "I",
674 "\u0209": "i",
675 "\u020C": "O",
676 "\u020D": "o",
677 "\u0210": "R",
678 "\u0211": "r",
679 "\u0214": "U",
680 "\u0215": "u",
681 "B\u030C": "B",
682 "b\u030C": "b",
683 "\u010C\u0323": "C",
684 "\u010D\u0323": "c",
685 "\xCA\u030C": "E",
686 "\xEA\u030C": "e",
687 "F\u030C": "F",
688 "f\u030C": "f",
689 "\u01E6": "G",
690 "\u01E7": "g",
691 "\u021E": "H",
692 "\u021F": "h",
693 "J\u030C": "J",
694 "\u01F0": "j",
695 "\u01E8": "K",
696 "\u01E9": "k",
697 "M\u030C": "M",
698 "m\u030C": "m",
699 "P\u030C": "P",
700 "p\u030C": "p",
701 "Q\u030C": "Q",
702 "q\u030C": "q",
703 "\u0158\u0329": "R",
704 "\u0159\u0329": "r",
705 "\u1E66": "S",
706 "\u1E67": "s",
707 "V\u030C": "V",
708 "v\u030C": "v",
709 "W\u030C": "W",
710 "w\u030C": "w",
711 "X\u030C": "X",
712 "x\u030C": "x",
713 "Y\u030C": "Y",
714 "y\u030C": "y",
715 "A\u0327": "A",
716 "a\u0327": "a",
717 "B\u0327": "B",
718 "b\u0327": "b",
719 "\u1E10": "D",
720 "\u1E11": "d",
721 "\u0228": "E",
722 "\u0229": "e",
723 "\u0190\u0327": "E",
724 "\u025B\u0327": "e",
725 "\u1E28": "H",
726 "\u1E29": "h",
727 "I\u0327": "I",
728 "i\u0327": "i",
729 "\u0197\u0327": "I",
730 "\u0268\u0327": "i",
731 "M\u0327": "M",
732 "m\u0327": "m",
733 "O\u0327": "O",
734 "o\u0327": "o",
735 "Q\u0327": "Q",
736 "q\u0327": "q",
737 "U\u0327": "U",
738 "u\u0327": "u",
739 "X\u0327": "X",
740 "x\u0327": "x",
741 "Z\u0327": "Z",
742 "z\u0327": "z",
743 "\u0439": "\u0438",
744 "\u0419": "\u0418",
745 "\u0451": "\u0435",
746 "\u0401": "\u0415"
747 };
748 var chars = Object.keys(characterMap).join("|");
749 var allAccents = new RegExp(chars, "g");
750 var firstAccent = new RegExp(chars, "");
751 function matcher(match2) {
752 return characterMap[match2];
753 }
754 var removeAccents3 = function(string) {
755 return string.replace(allAccents, matcher);
756 };
757 var hasAccents = function(string) {
758 return !!string.match(firstAccent);
759 };
760 module.exports = removeAccents3;
761 module.exports.has = hasAccents;
762 module.exports.remove = removeAccents3;
763 }
764 });
765
766 // node_modules/fast-deep-equal/es6/index.js
767 var require_es6 = __commonJS({
768 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
769 "use strict";
770 module.exports = function equal(a2, b2) {
771 if (a2 === b2) return true;
772 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
773 if (a2.constructor !== b2.constructor) return false;
774 var length, i2, keys;
775 if (Array.isArray(a2)) {
776 length = a2.length;
777 if (length != b2.length) return false;
778 for (i2 = length; i2-- !== 0; )
779 if (!equal(a2[i2], b2[i2])) return false;
780 return true;
781 }
782 if (a2 instanceof Map && b2 instanceof Map) {
783 if (a2.size !== b2.size) return false;
784 for (i2 of a2.entries())
785 if (!b2.has(i2[0])) return false;
786 for (i2 of a2.entries())
787 if (!equal(i2[1], b2.get(i2[0]))) return false;
788 return true;
789 }
790 if (a2 instanceof Set && b2 instanceof Set) {
791 if (a2.size !== b2.size) return false;
792 for (i2 of a2.entries())
793 if (!b2.has(i2[0])) return false;
794 return true;
795 }
796 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
797 length = a2.length;
798 if (length != b2.length) return false;
799 for (i2 = length; i2-- !== 0; )
800 if (a2[i2] !== b2[i2]) return false;
801 return true;
802 }
803 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
804 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
805 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
806 keys = Object.keys(a2);
807 length = keys.length;
808 if (length !== Object.keys(b2).length) return false;
809 for (i2 = length; i2-- !== 0; )
810 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
811 for (i2 = length; i2-- !== 0; ) {
812 var key = keys[i2];
813 if (!equal(a2[key], b2[key])) return false;
814 }
815 return true;
816 }
817 return a2 !== a2 && b2 !== b2;
818 };
819 }
820 });
821
822 // package-external:@wordpress/date
823 var require_date = __commonJS({
824 "package-external:@wordpress/date"(exports, module) {
825 module.exports = window.wp.date;
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 // package-external:@wordpress/editor
844 var require_editor = __commonJS({
845 "package-external:@wordpress/editor"(exports, module) {
846 module.exports = window.wp.editor;
847 }
848 });
849
850 // package-external:@wordpress/patterns
851 var require_patterns = __commonJS({
852 "package-external:@wordpress/patterns"(exports, module) {
853 module.exports = window.wp.patterns;
854 }
855 });
856
857 // package-external:@wordpress/block-editor
858 var require_block_editor = __commonJS({
859 "package-external:@wordpress/block-editor"(exports, module) {
860 module.exports = window.wp.blockEditor;
861 }
862 });
863
864 // routes/pattern-list/stage.tsx
865 import {
866 useParams,
867 useNavigate,
868 useSearch,
869 Link,
870 useInvalidate
871 } from "@wordpress/route";
872
873 // node_modules/dequal/dist/index.mjs
874 var has = Object.prototype.hasOwnProperty;
875 function find(iter, tar, key) {
876 for (key of iter.keys()) {
877 if (dequal(key, tar)) return key;
878 }
879 }
880 function dequal(foo, bar) {
881 var ctor, len, tmp;
882 if (foo === bar) return true;
883 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
884 if (ctor === Date) return foo.getTime() === bar.getTime();
885 if (ctor === RegExp) return foo.toString() === bar.toString();
886 if (ctor === Array) {
887 if ((len = foo.length) === bar.length) {
888 while (len-- && dequal(foo[len], bar[len])) ;
889 }
890 return len === -1;
891 }
892 if (ctor === Set) {
893 if (foo.size !== bar.size) {
894 return false;
895 }
896 for (len of foo) {
897 tmp = len;
898 if (tmp && typeof tmp === "object") {
899 tmp = find(bar, tmp);
900 if (!tmp) return false;
901 }
902 if (!bar.has(tmp)) return false;
903 }
904 return true;
905 }
906 if (ctor === Map) {
907 if (foo.size !== bar.size) {
908 return false;
909 }
910 for (len of foo) {
911 tmp = len[0];
912 if (tmp && typeof tmp === "object") {
913 tmp = find(bar, tmp);
914 if (!tmp) return false;
915 }
916 if (!dequal(len[1], bar.get(tmp))) {
917 return false;
918 }
919 }
920 return true;
921 }
922 if (ctor === ArrayBuffer) {
923 foo = new Uint8Array(foo);
924 bar = new Uint8Array(bar);
925 } else if (ctor === DataView) {
926 if ((len = foo.byteLength) === bar.byteLength) {
927 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
928 }
929 return len === -1;
930 }
931 if (ArrayBuffer.isView(foo)) {
932 if ((len = foo.byteLength) === bar.byteLength) {
933 while (len-- && foo[len] === bar[len]) ;
934 }
935 return len === -1;
936 }
937 if (!ctor || typeof foo === "object") {
938 len = 0;
939 for (ctor in foo) {
940 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
941 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
942 }
943 return Object.keys(bar).length === len;
944 }
945 }
946 return foo !== foo && bar !== bar;
947 }
948
949 // packages/views/build-module/use-view.mjs
950 var import_element = __toESM(require_element(), 1);
951 var import_data = __toESM(require_data(), 1);
952 var import_preferences = __toESM(require_preferences(), 1);
953
954 // packages/views/build-module/preference-keys.mjs
955 function generatePreferenceKey(kind, name, slug) {
956 return `dataviews-${kind}-${name}-${slug}`;
957 }
958
959 // packages/views/build-module/filter-utils.mjs
960 var SCALAR_VALUES = [
961 "titleField",
962 "mediaField",
963 "descriptionField",
964 "showTitle",
965 "showMedia",
966 "showDescription",
967 "showLevels",
968 "infiniteScrollEnabled"
969 ];
970 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
971 if (!activeViewOverrides) {
972 return view;
973 }
974 let result = view;
975 for (const key of SCALAR_VALUES) {
976 if (key in activeViewOverrides) {
977 result = { ...result, [key]: activeViewOverrides[key] };
978 }
979 }
980 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
981 const activeFields = new Set(
982 activeViewOverrides.filters.map((f2) => f2.field)
983 );
984 const preserved = (view.filters ?? []).filter(
985 (f2) => !activeFields.has(f2.field)
986 );
987 result = {
988 ...result,
989 filters: [...preserved, ...activeViewOverrides.filters]
990 };
991 }
992 if (activeViewOverrides.sort) {
993 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
994 if (isDefaultSort) {
995 result = {
996 ...result,
997 sort: activeViewOverrides.sort
998 };
999 }
1000 }
1001 if (activeViewOverrides.layout) {
1002 result = {
1003 ...result,
1004 layout: {
1005 ...result.layout,
1006 ...activeViewOverrides.layout
1007 }
1008 };
1009 }
1010 if (activeViewOverrides.groupBy) {
1011 result = {
1012 ...result,
1013 groupBy: activeViewOverrides.groupBy
1014 };
1015 }
1016 return result;
1017 }
1018 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
1019 if (!activeViewOverrides) {
1020 return view;
1021 }
1022 let result = view;
1023 for (const key of SCALAR_VALUES) {
1024 if (key in activeViewOverrides) {
1025 const { [key]: _, ...rest } = result;
1026 result = rest;
1027 }
1028 }
1029 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
1030 const activeFields = new Set(
1031 activeViewOverrides.filters.map((f2) => f2.field)
1032 );
1033 result = {
1034 ...result,
1035 filters: (view.filters ?? []).filter(
1036 (f2) => !activeFields.has(f2.field)
1037 )
1038 };
1039 }
1040 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
1041 result = {
1042 ...result,
1043 sort: defaultView?.sort
1044 };
1045 }
1046 if (activeViewOverrides.layout && "layout" in result && result.layout) {
1047 const layout = { ...result.layout };
1048 for (const key of Object.keys(activeViewOverrides.layout)) {
1049 delete layout[key];
1050 }
1051 result = {
1052 ...result,
1053 layout: Object.keys(layout).length > 0 ? layout : void 0
1054 };
1055 }
1056 if (activeViewOverrides.groupBy && "groupBy" in result) {
1057 const { groupBy: _, ...rest } = result;
1058 result = rest;
1059 }
1060 return result;
1061 }
1062
1063 // packages/views/build-module/use-view.mjs
1064 function omit(obj, keys) {
1065 const result = { ...obj };
1066 for (const key of keys) {
1067 delete result[key];
1068 }
1069 return result;
1070 }
1071 function useView(config) {
1072 const {
1073 kind,
1074 name,
1075 slug,
1076 defaultView,
1077 activeViewOverrides,
1078 queryParams,
1079 onChangeQueryParams
1080 } = config;
1081 const preferenceKey = generatePreferenceKey(kind, name, slug);
1082 const persistedView = (0, import_data.useSelect)(
1083 (select2) => {
1084 return select2(import_preferences.store).get(
1085 "core/views",
1086 preferenceKey
1087 );
1088 },
1089 [preferenceKey]
1090 );
1091 const { set: set2 } = (0, import_data.useDispatch)(import_preferences.store);
1092 const baseView = (0, import_element.useMemo)(
1093 () => persistedView ?? defaultView ?? {},
1094 [persistedView, defaultView]
1095 );
1096 const page = Number(queryParams?.page ?? baseView.page ?? 1);
1097 const search = queryParams?.search ?? baseView.search ?? "";
1098 const combinedOverrides = (0, import_element.useMemo)(() => {
1099 const rawDefaults = config.defaultLayouts?.[baseView.type];
1100 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
1101 return { ...layoutTypeDefaults, ...activeViewOverrides };
1102 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
1103 const view = (0, import_element.useMemo)(() => {
1104 return mergeActiveViewOverrides(
1105 {
1106 ...baseView,
1107 page,
1108 search
1109 },
1110 combinedOverrides,
1111 defaultView
1112 );
1113 }, [baseView, page, search, combinedOverrides, defaultView]);
1114 const isModified = !!persistedView;
1115 const updateView = (0, import_element.useCallback)(
1116 (newView) => {
1117 const urlParams = {
1118 page: newView?.page,
1119 search: newView?.search
1120 };
1121 const preferenceView = stripActiveViewOverrides(
1122 omit(newView, ["page", "search"]),
1123 combinedOverrides,
1124 defaultView
1125 );
1126 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
1127 onChangeQueryParams(urlParams);
1128 }
1129 const comparableBaseView = stripActiveViewOverrides(
1130 baseView,
1131 combinedOverrides,
1132 defaultView
1133 );
1134 const comparableDefaultView = stripActiveViewOverrides(
1135 defaultView,
1136 combinedOverrides,
1137 defaultView
1138 );
1139 if (!dequal(comparableBaseView, preferenceView)) {
1140 if (dequal(preferenceView, comparableDefaultView)) {
1141 set2("core/views", preferenceKey, void 0);
1142 } else {
1143 set2("core/views", preferenceKey, preferenceView);
1144 }
1145 }
1146 },
1147 [
1148 onChangeQueryParams,
1149 page,
1150 search,
1151 baseView,
1152 defaultView,
1153 combinedOverrides,
1154 set2,
1155 preferenceKey
1156 ]
1157 );
1158 const resetToDefault = (0, import_element.useCallback)(() => {
1159 set2("core/views", preferenceKey, void 0);
1160 }, [preferenceKey, set2]);
1161 return {
1162 view,
1163 isModified,
1164 updateView,
1165 resetToDefault
1166 };
1167 }
1168
1169 // packages/views/build-module/load-view.mjs
1170 var import_data2 = __toESM(require_data(), 1);
1171 var import_preferences2 = __toESM(require_preferences(), 1);
1172
1173 // packages/views/build-module/use-view-config.mjs
1174 var import_data3 = __toESM(require_data(), 1);
1175 var import_core_data = __toESM(require_core_data(), 1);
1176
1177 // packages/views/build-module/lock-unlock.mjs
1178 var import_private_apis = __toESM(require_private_apis(), 1);
1179 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1180 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1181 "@wordpress/views"
1182 );
1183
1184 // node_modules/clsx/dist/clsx.mjs
1185 function r(e2) {
1186 var t2, f2, n2 = "";
1187 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1188 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1189 var o2 = e2.length;
1190 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1191 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1192 return n2;
1193 }
1194 function clsx() {
1195 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1196 return n2;
1197 }
1198 var clsx_default = clsx;
1199
1200 // packages/dataviews/build-module/dataviews/index.mjs
1201 var import_element75 = __toESM(require_element(), 1);
1202 var import_compose13 = __toESM(require_compose(), 1);
1203
1204 // node_modules/@base-ui/utils/esm/safeReact.js
1205 var React2 = __toESM(require_react(), 1);
1206 var SafeReact = {
1207 ...React2
1208 };
1209
1210 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1211 var React3 = __toESM(require_react(), 1);
1212 var UNINITIALIZED = {};
1213 function useRefWithInit(init2, initArg) {
1214 const ref = React3.useRef(UNINITIALIZED);
1215 if (ref.current === UNINITIALIZED) {
1216 ref.current = init2(initArg);
1217 }
1218 return ref;
1219 }
1220
1221 // node_modules/@base-ui/utils/esm/useStableCallback.js
1222 var useInsertionEffect = SafeReact.useInsertionEffect;
1223 var useSafeInsertionEffect = (
1224 // React 17 doesn't have useInsertionEffect.
1225 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1226 useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1227 );
1228 function useStableCallback(callback) {
1229 const stable = useRefWithInit(createStableCallback).current;
1230 stable.next = callback;
1231 useSafeInsertionEffect(stable.effect);
1232 return stable.trampoline;
1233 }
1234 function createStableCallback() {
1235 const stable = {
1236 next: void 0,
1237 callback: assertNotCalled,
1238 trampoline: (...args) => stable.callback?.(...args),
1239 effect: () => {
1240 stable.callback = stable.next;
1241 }
1242 };
1243 return stable;
1244 }
1245 function assertNotCalled() {
1246 if (true) {
1247 throw (
1248 /* minify-error-disabled */
1249 new Error("Base UI: Cannot call an event handler while rendering.")
1250 );
1251 }
1252 }
1253
1254 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1255 var React4 = __toESM(require_react(), 1);
1256 var noop = () => {
1257 };
1258 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1259
1260 // node_modules/@base-ui/utils/esm/warn.js
1261 var set;
1262 if (true) {
1263 set = /* @__PURE__ */ new Set();
1264 }
1265 function warn(...messages) {
1266 if (true) {
1267 const messageKey = messages.join(" ");
1268 if (!set.has(messageKey)) {
1269 set.add(messageKey);
1270 console.warn(`Base UI: ${messageKey}`);
1271 }
1272 }
1273 }
1274
1275 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1276 var React5 = __toESM(require_react(), 1);
1277 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1278 if (true) DirectionContext.displayName = "DirectionContext";
1279 function useDirection() {
1280 const context = React5.useContext(DirectionContext);
1281 return context?.direction ?? "ltr";
1282 }
1283
1284 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1285 var React8 = __toESM(require_react(), 1);
1286
1287 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1288 function useMergedRefs(a2, b2, c2, d2) {
1289 const forkRef = useRefWithInit(createForkRef).current;
1290 if (didChange(forkRef, a2, b2, c2, d2)) {
1291 update(forkRef, [a2, b2, c2, d2]);
1292 }
1293 return forkRef.callback;
1294 }
1295 function useMergedRefsN(refs) {
1296 const forkRef = useRefWithInit(createForkRef).current;
1297 if (didChangeN(forkRef, refs)) {
1298 update(forkRef, refs);
1299 }
1300 return forkRef.callback;
1301 }
1302 function createForkRef() {
1303 return {
1304 callback: null,
1305 cleanup: null,
1306 refs: []
1307 };
1308 }
1309 function didChange(forkRef, a2, b2, c2, d2) {
1310 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1311 }
1312 function didChangeN(forkRef, newRefs) {
1313 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1314 }
1315 function update(forkRef, refs) {
1316 forkRef.refs = refs;
1317 if (refs.every((ref) => ref == null)) {
1318 forkRef.callback = null;
1319 return;
1320 }
1321 forkRef.callback = (instance) => {
1322 if (forkRef.cleanup) {
1323 forkRef.cleanup();
1324 forkRef.cleanup = null;
1325 }
1326 if (instance != null) {
1327 const cleanupCallbacks = Array(refs.length).fill(null);
1328 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1329 const ref = refs[i2];
1330 if (ref == null) {
1331 continue;
1332 }
1333 switch (typeof ref) {
1334 case "function": {
1335 const refCleanup = ref(instance);
1336 if (typeof refCleanup === "function") {
1337 cleanupCallbacks[i2] = refCleanup;
1338 }
1339 break;
1340 }
1341 case "object": {
1342 ref.current = instance;
1343 break;
1344 }
1345 default:
1346 }
1347 }
1348 forkRef.cleanup = () => {
1349 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1350 const ref = refs[i2];
1351 if (ref == null) {
1352 continue;
1353 }
1354 switch (typeof ref) {
1355 case "function": {
1356 const cleanupCallback = cleanupCallbacks[i2];
1357 if (typeof cleanupCallback === "function") {
1358 cleanupCallback();
1359 } else {
1360 ref(null);
1361 }
1362 break;
1363 }
1364 case "object": {
1365 ref.current = null;
1366 break;
1367 }
1368 default:
1369 }
1370 }
1371 };
1372 }
1373 };
1374 }
1375
1376 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1377 var React7 = __toESM(require_react(), 1);
1378
1379 // node_modules/@base-ui/utils/esm/reactVersion.js
1380 var React6 = __toESM(require_react(), 1);
1381 var majorVersion = parseInt(React6.version, 10);
1382 function isReactVersionAtLeast(reactVersionToCheck) {
1383 return majorVersion >= reactVersionToCheck;
1384 }
1385
1386 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1387 function getReactElementRef(element) {
1388 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1389 return null;
1390 }
1391 const reactElement = element;
1392 const propsWithRef = reactElement.props;
1393 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1394 }
1395
1396 // node_modules/@base-ui/utils/esm/mergeObjects.js
1397 function mergeObjects(a2, b2) {
1398 if (a2 && !b2) {
1399 return a2;
1400 }
1401 if (!a2 && b2) {
1402 return b2;
1403 }
1404 if (a2 || b2) {
1405 return {
1406 ...a2,
1407 ...b2
1408 };
1409 }
1410 return void 0;
1411 }
1412
1413 // node_modules/@base-ui/utils/esm/empty.js
1414 function NOOP() {
1415 }
1416 var EMPTY_ARRAY = Object.freeze([]);
1417 var EMPTY_OBJECT = Object.freeze({});
1418
1419 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1420 function getStateAttributesProps(state, customMapping) {
1421 const props = {};
1422 for (const key in state) {
1423 const value = state[key];
1424 if (customMapping?.hasOwnProperty(key)) {
1425 const customProps = customMapping[key](value);
1426 if (customProps != null) {
1427 Object.assign(props, customProps);
1428 }
1429 continue;
1430 }
1431 if (value === true) {
1432 props[`data-${key.toLowerCase()}`] = "";
1433 } else if (value) {
1434 props[`data-${key.toLowerCase()}`] = value.toString();
1435 }
1436 }
1437 return props;
1438 }
1439
1440 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1441 function resolveClassName(className, state) {
1442 return typeof className === "function" ? className(state) : className;
1443 }
1444
1445 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1446 function resolveStyle(style, state) {
1447 return typeof style === "function" ? style(state) : style;
1448 }
1449
1450 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1451 var EMPTY_PROPS = {};
1452 function mergeProps(a2, b2, c2, d2, e2) {
1453 if (!c2 && !d2 && !e2 && !a2) {
1454 return createInitialMergedProps(b2);
1455 }
1456 let merged = createInitialMergedProps(a2);
1457 if (b2) {
1458 merged = mergeInto(merged, b2);
1459 }
1460 if (c2) {
1461 merged = mergeInto(merged, c2);
1462 }
1463 if (d2) {
1464 merged = mergeInto(merged, d2);
1465 }
1466 if (e2) {
1467 merged = mergeInto(merged, e2);
1468 }
1469 return merged;
1470 }
1471 function mergePropsN(props) {
1472 if (props.length === 0) {
1473 return EMPTY_PROPS;
1474 }
1475 if (props.length === 1) {
1476 return createInitialMergedProps(props[0]);
1477 }
1478 let merged = createInitialMergedProps(props[0]);
1479 for (let i2 = 1; i2 < props.length; i2 += 1) {
1480 merged = mergeInto(merged, props[i2]);
1481 }
1482 return merged;
1483 }
1484 function createInitialMergedProps(inputProps) {
1485 if (isPropsGetter(inputProps)) {
1486 return {
1487 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1488 };
1489 }
1490 return copyInitialProps(inputProps);
1491 }
1492 function mergeInto(merged, inputProps) {
1493 if (isPropsGetter(inputProps)) {
1494 return resolvePropsGetter(inputProps, merged);
1495 }
1496 return mutablyMergeInto(merged, inputProps);
1497 }
1498 function copyInitialProps(inputProps) {
1499 const copiedProps = {
1500 ...inputProps
1501 };
1502 for (const propName in copiedProps) {
1503 const propValue = copiedProps[propName];
1504 if (isEventHandler(propName, propValue)) {
1505 copiedProps[propName] = wrapEventHandler(propValue);
1506 }
1507 }
1508 return copiedProps;
1509 }
1510 function mutablyMergeInto(mergedProps, externalProps) {
1511 if (!externalProps) {
1512 return mergedProps;
1513 }
1514 for (const propName in externalProps) {
1515 const externalPropValue = externalProps[propName];
1516 switch (propName) {
1517 case "style": {
1518 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1519 break;
1520 }
1521 case "className": {
1522 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1523 break;
1524 }
1525 default: {
1526 if (isEventHandler(propName, externalPropValue)) {
1527 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1528 } else {
1529 mergedProps[propName] = externalPropValue;
1530 }
1531 }
1532 }
1533 }
1534 return mergedProps;
1535 }
1536 function isEventHandler(key, value) {
1537 const code0 = key.charCodeAt(0);
1538 const code1 = key.charCodeAt(1);
1539 const code2 = key.charCodeAt(2);
1540 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1541 }
1542 function isPropsGetter(inputProps) {
1543 return typeof inputProps === "function";
1544 }
1545 function resolvePropsGetter(inputProps, previousProps) {
1546 if (isPropsGetter(inputProps)) {
1547 return inputProps(previousProps);
1548 }
1549 return inputProps ?? EMPTY_PROPS;
1550 }
1551 function mergeEventHandlers(ourHandler, theirHandler) {
1552 if (!theirHandler) {
1553 return ourHandler;
1554 }
1555 if (!ourHandler) {
1556 return wrapEventHandler(theirHandler);
1557 }
1558 return (...args) => {
1559 const event = args[0];
1560 if (isSyntheticEvent(event)) {
1561 const baseUIEvent = event;
1562 makeEventPreventable(baseUIEvent);
1563 const result2 = theirHandler(...args);
1564 if (!baseUIEvent.baseUIHandlerPrevented) {
1565 ourHandler?.(...args);
1566 }
1567 return result2;
1568 }
1569 const result = theirHandler(...args);
1570 ourHandler?.(...args);
1571 return result;
1572 };
1573 }
1574 function wrapEventHandler(handler) {
1575 if (!handler) {
1576 return handler;
1577 }
1578 return (...args) => {
1579 const event = args[0];
1580 if (isSyntheticEvent(event)) {
1581 makeEventPreventable(event);
1582 }
1583 return handler(...args);
1584 };
1585 }
1586 function makeEventPreventable(event) {
1587 event.preventBaseUIHandler = () => {
1588 event.baseUIHandlerPrevented = true;
1589 };
1590 return event;
1591 }
1592 function mergeClassNames(ourClassName, theirClassName) {
1593 if (theirClassName) {
1594 if (ourClassName) {
1595 return theirClassName + " " + ourClassName;
1596 }
1597 return theirClassName;
1598 }
1599 return ourClassName;
1600 }
1601 function isSyntheticEvent(event) {
1602 return event != null && typeof event === "object" && "nativeEvent" in event;
1603 }
1604
1605 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1606 var import_react = __toESM(require_react(), 1);
1607 function useRenderElement(element, componentProps, params = {}) {
1608 const renderProp = componentProps.render;
1609 const outProps = useRenderElementProps(componentProps, params);
1610 if (params.enabled === false) {
1611 return null;
1612 }
1613 const state = params.state ?? EMPTY_OBJECT;
1614 return evaluateRenderProp(element, renderProp, outProps, state);
1615 }
1616 function useRenderElementProps(componentProps, params = {}) {
1617 const {
1618 className: classNameProp,
1619 style: styleProp,
1620 render: renderProp
1621 } = componentProps;
1622 const {
1623 state = EMPTY_OBJECT,
1624 ref,
1625 props,
1626 stateAttributesMapping: stateAttributesMapping3,
1627 enabled = true
1628 } = params;
1629 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1630 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1631 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1632 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1633 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1634 if (typeof document !== "undefined") {
1635 if (!enabled) {
1636 useMergedRefs(null, null);
1637 } else if (Array.isArray(ref)) {
1638 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1639 } else {
1640 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1641 }
1642 }
1643 if (!enabled) {
1644 return EMPTY_OBJECT;
1645 }
1646 if (className !== void 0) {
1647 outProps.className = mergeClassNames(outProps.className, className);
1648 }
1649 if (style !== void 0) {
1650 outProps.style = mergeObjects(outProps.style, style);
1651 }
1652 return outProps;
1653 }
1654 function resolveRenderFunctionProps(props) {
1655 if (Array.isArray(props)) {
1656 return mergePropsN(props);
1657 }
1658 return mergeProps(void 0, props);
1659 }
1660 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1661 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1662 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1663 function evaluateRenderProp(element, render4, props, state) {
1664 if (render4) {
1665 if (typeof render4 === "function") {
1666 if (true) {
1667 warnIfRenderPropLooksLikeComponent(render4);
1668 }
1669 return render4(props, state);
1670 }
1671 const mergedProps = mergeProps(props, render4.props);
1672 mergedProps.ref = props.ref;
1673 let newElement = render4;
1674 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1675 const children = React8.Children.toArray(render4);
1676 newElement = children[0];
1677 }
1678 if (true) {
1679 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1680 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"));
1681 }
1682 }
1683 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1684 }
1685 if (element) {
1686 if (typeof element === "string") {
1687 return renderTag(element, props);
1688 }
1689 }
1690 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1691 }
1692 function warnIfRenderPropLooksLikeComponent(renderFn) {
1693 const functionName = renderFn.name;
1694 if (functionName.length === 0) {
1695 return;
1696 }
1697 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1698 return;
1699 }
1700 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1701 return;
1702 }
1703 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");
1704 }
1705 function renderTag(Tag, props) {
1706 if (Tag === "button") {
1707 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1708 type: "button",
1709 ...props,
1710 key: props.key
1711 });
1712 }
1713 if (Tag === "img") {
1714 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1715 alt: "",
1716 ...props,
1717 key: props.key
1718 });
1719 }
1720 return /* @__PURE__ */ React8.createElement(Tag, props);
1721 }
1722
1723 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1724 var reason_parts_exports = {};
1725 __export(reason_parts_exports, {
1726 cancelOpen: () => cancelOpen,
1727 chipRemovePress: () => chipRemovePress,
1728 clearPress: () => clearPress,
1729 closePress: () => closePress,
1730 closeWatcher: () => closeWatcher,
1731 decrementPress: () => decrementPress,
1732 disabled: () => disabled,
1733 drag: () => drag,
1734 escapeKey: () => escapeKey,
1735 focusOut: () => focusOut,
1736 imperativeAction: () => imperativeAction,
1737 incrementPress: () => incrementPress,
1738 initial: () => initial,
1739 inputBlur: () => inputBlur,
1740 inputChange: () => inputChange,
1741 inputClear: () => inputClear,
1742 inputPaste: () => inputPaste,
1743 inputPress: () => inputPress,
1744 itemPress: () => itemPress,
1745 keyboard: () => keyboard,
1746 linkPress: () => linkPress,
1747 listNavigation: () => listNavigation,
1748 missing: () => missing,
1749 none: () => none,
1750 outsidePress: () => outsidePress,
1751 pointer: () => pointer,
1752 scrub: () => scrub,
1753 siblingOpen: () => siblingOpen,
1754 swipe: () => swipe,
1755 trackPress: () => trackPress,
1756 triggerFocus: () => triggerFocus,
1757 triggerHover: () => triggerHover,
1758 triggerPress: () => triggerPress,
1759 wheel: () => wheel,
1760 windowResize: () => windowResize
1761 });
1762 var none = "none";
1763 var triggerPress = "trigger-press";
1764 var triggerHover = "trigger-hover";
1765 var triggerFocus = "trigger-focus";
1766 var outsidePress = "outside-press";
1767 var itemPress = "item-press";
1768 var closePress = "close-press";
1769 var linkPress = "link-press";
1770 var clearPress = "clear-press";
1771 var chipRemovePress = "chip-remove-press";
1772 var trackPress = "track-press";
1773 var incrementPress = "increment-press";
1774 var decrementPress = "decrement-press";
1775 var inputChange = "input-change";
1776 var inputClear = "input-clear";
1777 var inputBlur = "input-blur";
1778 var inputPaste = "input-paste";
1779 var inputPress = "input-press";
1780 var focusOut = "focus-out";
1781 var escapeKey = "escape-key";
1782 var closeWatcher = "close-watcher";
1783 var listNavigation = "list-navigation";
1784 var keyboard = "keyboard";
1785 var pointer = "pointer";
1786 var drag = "drag";
1787 var wheel = "wheel";
1788 var scrub = "scrub";
1789 var cancelOpen = "cancel-open";
1790 var siblingOpen = "sibling-open";
1791 var disabled = "disabled";
1792 var missing = "missing";
1793 var initial = "initial";
1794 var imperativeAction = "imperative-action";
1795 var swipe = "swipe";
1796 var windowResize = "window-resize";
1797
1798 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1799 function createChangeEventDetails(reason, event, trigger, customProperties) {
1800 let canceled = false;
1801 let allowPropagation = false;
1802 const custom = customProperties ?? EMPTY_OBJECT;
1803 const details = {
1804 reason,
1805 event: event ?? new Event("base-ui"),
1806 cancel() {
1807 canceled = true;
1808 },
1809 allowPropagation() {
1810 allowPropagation = true;
1811 },
1812 get isCanceled() {
1813 return canceled;
1814 },
1815 get isPropagationAllowed() {
1816 return allowPropagation;
1817 },
1818 trigger,
1819 ...custom
1820 };
1821 return details;
1822 }
1823
1824 // node_modules/@base-ui/utils/esm/useId.js
1825 var React9 = __toESM(require_react(), 1);
1826 var globalId = 0;
1827 function useGlobalId(idOverride, prefix = "mui") {
1828 const [defaultId, setDefaultId] = React9.useState(idOverride);
1829 const id = idOverride || defaultId;
1830 React9.useEffect(() => {
1831 if (defaultId == null) {
1832 globalId += 1;
1833 setDefaultId(`${prefix}-${globalId}`);
1834 }
1835 }, [defaultId, prefix]);
1836 return id;
1837 }
1838 var maybeReactUseId = SafeReact.useId;
1839 function useId(idOverride, prefix) {
1840 if (maybeReactUseId !== void 0) {
1841 const reactId = maybeReactUseId();
1842 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1843 }
1844 return useGlobalId(idOverride, prefix);
1845 }
1846
1847 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1848 function useBaseUiId(idOverride) {
1849 return useId(idOverride, "base-ui");
1850 }
1851
1852 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1853 var React11 = __toESM(require_react(), 1);
1854
1855 // node_modules/@base-ui/utils/esm/useOnMount.js
1856 var React10 = __toESM(require_react(), 1);
1857 var EMPTY = [];
1858 function useOnMount(fn) {
1859 React10.useEffect(fn, EMPTY);
1860 }
1861
1862 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1863 var EMPTY2 = null;
1864 var LAST_RAF = globalThis.requestAnimationFrame;
1865 var Scheduler = class {
1866 /* This implementation uses an array as a backing data-structure for frame callbacks.
1867 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1868 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1869 * be much more efficient if there is a call pattern that alterns as
1870 * "request-cancel-request-cancel-…".
1871 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1872 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1873 callbacks = [];
1874 callbacksCount = 0;
1875 nextId = 1;
1876 startId = 1;
1877 isScheduled = false;
1878 tick = (timestamp) => {
1879 this.isScheduled = false;
1880 const currentCallbacks = this.callbacks;
1881 const currentCallbacksCount = this.callbacksCount;
1882 this.callbacks = [];
1883 this.callbacksCount = 0;
1884 this.startId = this.nextId;
1885 if (currentCallbacksCount > 0) {
1886 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1887 currentCallbacks[i2]?.(timestamp);
1888 }
1889 }
1890 };
1891 request(fn) {
1892 const id = this.nextId;
1893 this.nextId += 1;
1894 this.callbacks.push(fn);
1895 this.callbacksCount += 1;
1896 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1897 if (!this.isScheduled || didRAFChange) {
1898 requestAnimationFrame(this.tick);
1899 this.isScheduled = true;
1900 }
1901 return id;
1902 }
1903 cancel(id) {
1904 const index2 = id - this.startId;
1905 if (index2 < 0 || index2 >= this.callbacks.length) {
1906 return;
1907 }
1908 this.callbacks[index2] = null;
1909 this.callbacksCount -= 1;
1910 }
1911 };
1912 var scheduler = new Scheduler();
1913 var AnimationFrame = class _AnimationFrame {
1914 static create() {
1915 return new _AnimationFrame();
1916 }
1917 static request(fn) {
1918 return scheduler.request(fn);
1919 }
1920 static cancel(id) {
1921 return scheduler.cancel(id);
1922 }
1923 currentId = EMPTY2;
1924 /**
1925 * Executes `fn` after `delay`, clearing any previously scheduled call.
1926 */
1927 request(fn) {
1928 this.cancel();
1929 this.currentId = scheduler.request(() => {
1930 this.currentId = EMPTY2;
1931 fn();
1932 });
1933 }
1934 cancel = () => {
1935 if (this.currentId !== EMPTY2) {
1936 scheduler.cancel(this.currentId);
1937 this.currentId = EMPTY2;
1938 }
1939 };
1940 disposeEffect = () => {
1941 return this.cancel;
1942 };
1943 };
1944 function useAnimationFrame() {
1945 const timeout = useRefWithInit(AnimationFrame.create).current;
1946 useOnMount(timeout.disposeEffect);
1947 return timeout;
1948 }
1949
1950 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1951 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1952 const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
1953 const [mounted, setMounted] = React11.useState(open);
1954 if (open && !mounted) {
1955 setMounted(true);
1956 setTransitionStatus("starting");
1957 }
1958 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1959 setTransitionStatus("ending");
1960 }
1961 if (!open && !mounted && transitionStatus === "ending") {
1962 setTransitionStatus(void 0);
1963 }
1964 useIsoLayoutEffect(() => {
1965 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1966 const frame = AnimationFrame.request(() => {
1967 setTransitionStatus("ending");
1968 });
1969 return () => {
1970 AnimationFrame.cancel(frame);
1971 };
1972 }
1973 return void 0;
1974 }, [open, mounted, transitionStatus, deferEndingState]);
1975 useIsoLayoutEffect(() => {
1976 if (!open || enableIdleState) {
1977 return void 0;
1978 }
1979 const frame = AnimationFrame.request(() => {
1980 setTransitionStatus(void 0);
1981 });
1982 return () => {
1983 AnimationFrame.cancel(frame);
1984 };
1985 }, [enableIdleState, open]);
1986 useIsoLayoutEffect(() => {
1987 if (!open || !enableIdleState) {
1988 return void 0;
1989 }
1990 if (open && mounted && transitionStatus !== "idle") {
1991 setTransitionStatus("starting");
1992 }
1993 const frame = AnimationFrame.request(() => {
1994 setTransitionStatus("idle");
1995 });
1996 return () => {
1997 AnimationFrame.cancel(frame);
1998 };
1999 }, [enableIdleState, open, mounted, transitionStatus]);
2000 return {
2001 mounted,
2002 setMounted,
2003 transitionStatus
2004 };
2005 }
2006
2007 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
2008 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
2009 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
2010 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
2011 return TransitionStatusDataAttributes2;
2012 })({});
2013 var STARTING_HOOK = {
2014 [TransitionStatusDataAttributes.startingStyle]: ""
2015 };
2016 var ENDING_HOOK = {
2017 [TransitionStatusDataAttributes.endingStyle]: ""
2018 };
2019 var transitionStatusMapping = {
2020 transitionStatus(value) {
2021 if (value === "starting") {
2022 return STARTING_HOOK;
2023 }
2024 if (value === "ending") {
2025 return ENDING_HOOK;
2026 }
2027 return null;
2028 }
2029 };
2030
2031 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2032 function hasWindow() {
2033 return typeof window !== "undefined";
2034 }
2035 function getNodeName(node) {
2036 if (isNode(node)) {
2037 return (node.nodeName || "").toLowerCase();
2038 }
2039 return "#document";
2040 }
2041 function getWindow(node) {
2042 var _node$ownerDocument;
2043 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2044 }
2045 function getDocumentElement(node) {
2046 var _ref;
2047 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2048 }
2049 function isNode(value) {
2050 if (!hasWindow()) {
2051 return false;
2052 }
2053 return value instanceof Node || value instanceof getWindow(value).Node;
2054 }
2055 function isElement(value) {
2056 if (!hasWindow()) {
2057 return false;
2058 }
2059 return value instanceof Element || value instanceof getWindow(value).Element;
2060 }
2061 function isHTMLElement(value) {
2062 if (!hasWindow()) {
2063 return false;
2064 }
2065 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2066 }
2067 function isShadowRoot(value) {
2068 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2069 return false;
2070 }
2071 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2072 }
2073 function isOverflowElement(element) {
2074 const {
2075 overflow,
2076 overflowX,
2077 overflowY,
2078 display
2079 } = getComputedStyle2(element);
2080 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2081 }
2082 function isTableElement(element) {
2083 return /^(table|td|th)$/.test(getNodeName(element));
2084 }
2085 function isTopLayer(element) {
2086 try {
2087 if (element.matches(":popover-open")) {
2088 return true;
2089 }
2090 } catch (_e) {
2091 }
2092 try {
2093 return element.matches(":modal");
2094 } catch (_e) {
2095 return false;
2096 }
2097 }
2098 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2099 var containRe = /paint|layout|strict|content/;
2100 var isNotNone = (value) => !!value && value !== "none";
2101 var isWebKitValue;
2102 function isContainingBlock(elementOrCss) {
2103 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2104 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 || "");
2105 }
2106 function getContainingBlock(element) {
2107 let currentNode = getParentNode(element);
2108 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2109 if (isContainingBlock(currentNode)) {
2110 return currentNode;
2111 } else if (isTopLayer(currentNode)) {
2112 return null;
2113 }
2114 currentNode = getParentNode(currentNode);
2115 }
2116 return null;
2117 }
2118 function isWebKit() {
2119 if (isWebKitValue == null) {
2120 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2121 }
2122 return isWebKitValue;
2123 }
2124 function isLastTraversableNode(node) {
2125 return /^(html|body|#document)$/.test(getNodeName(node));
2126 }
2127 function getComputedStyle2(element) {
2128 return getWindow(element).getComputedStyle(element);
2129 }
2130 function getNodeScroll(element) {
2131 if (isElement(element)) {
2132 return {
2133 scrollLeft: element.scrollLeft,
2134 scrollTop: element.scrollTop
2135 };
2136 }
2137 return {
2138 scrollLeft: element.scrollX,
2139 scrollTop: element.scrollY
2140 };
2141 }
2142 function getParentNode(node) {
2143 if (getNodeName(node) === "html") {
2144 return node;
2145 }
2146 const result = (
2147 // Step into the shadow DOM of the parent of a slotted node.
2148 node.assignedSlot || // DOM Element detected.
2149 node.parentNode || // ShadowRoot detected.
2150 isShadowRoot(node) && node.host || // Fallback.
2151 getDocumentElement(node)
2152 );
2153 return isShadowRoot(result) ? result.host : result;
2154 }
2155 function getNearestOverflowAncestor(node) {
2156 const parentNode = getParentNode(node);
2157 if (isLastTraversableNode(parentNode)) {
2158 return node.ownerDocument ? node.ownerDocument.body : node.body;
2159 }
2160 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2161 return parentNode;
2162 }
2163 return getNearestOverflowAncestor(parentNode);
2164 }
2165 function getOverflowAncestors(node, list, traverseIframes) {
2166 var _node$ownerDocument2;
2167 if (list === void 0) {
2168 list = [];
2169 }
2170 if (traverseIframes === void 0) {
2171 traverseIframes = true;
2172 }
2173 const scrollableAncestor = getNearestOverflowAncestor(node);
2174 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2175 const win = getWindow(scrollableAncestor);
2176 if (isBody) {
2177 const frameElement = getFrameElement(win);
2178 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2179 } else {
2180 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2181 }
2182 }
2183 function getFrameElement(win) {
2184 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2185 }
2186
2187 // node_modules/@base-ui/utils/esm/detectBrowser.js
2188 var hasNavigator = typeof navigator !== "undefined";
2189 var nav = getNavigatorData();
2190 var platform = getPlatform();
2191 var userAgent = getUserAgent();
2192 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2193 var isIOS = (
2194 // iPads can claim to be MacIntel
2195 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2196 );
2197 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2198 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2199 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2200 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2201 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2202 var isJSDOM = userAgent.includes("jsdom/");
2203 function getNavigatorData() {
2204 if (!hasNavigator) {
2205 return {
2206 platform: "",
2207 maxTouchPoints: -1
2208 };
2209 }
2210 const uaData = navigator.userAgentData;
2211 if (uaData?.platform) {
2212 return {
2213 platform: uaData.platform,
2214 maxTouchPoints: navigator.maxTouchPoints
2215 };
2216 }
2217 return {
2218 platform: navigator.platform ?? "",
2219 maxTouchPoints: navigator.maxTouchPoints ?? -1
2220 };
2221 }
2222 function getUserAgent() {
2223 if (!hasNavigator) {
2224 return "";
2225 }
2226 const uaData = navigator.userAgentData;
2227 if (uaData && Array.isArray(uaData.brands)) {
2228 return uaData.brands.map(({
2229 brand,
2230 version: version2
2231 }) => `${brand}/${version2}`).join(" ");
2232 }
2233 return navigator.userAgent;
2234 }
2235 function getPlatform() {
2236 if (!hasNavigator) {
2237 return "";
2238 }
2239 const uaData = navigator.userAgentData;
2240 if (uaData?.platform) {
2241 return uaData.platform;
2242 }
2243 return navigator.platform ?? "";
2244 }
2245
2246 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2247 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2248 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2249
2250 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2251 function activeElement(doc) {
2252 let element = doc.activeElement;
2253 while (element?.shadowRoot?.activeElement != null) {
2254 element = element.shadowRoot.activeElement;
2255 }
2256 return element;
2257 }
2258 function contains(parent, child) {
2259 if (!parent || !child) {
2260 return false;
2261 }
2262 const rootNode = child.getRootNode?.();
2263 if (parent.contains(child)) {
2264 return true;
2265 }
2266 if (rootNode && isShadowRoot(rootNode)) {
2267 let next = child;
2268 while (next) {
2269 if (parent === next) {
2270 return true;
2271 }
2272 next = next.parentNode || next.host;
2273 }
2274 }
2275 return false;
2276 }
2277 function getTarget(event) {
2278 if ("composedPath" in event) {
2279 return event.composedPath()[0];
2280 }
2281 return event.target;
2282 }
2283
2284 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2285 function isTargetInsideEnabledTrigger(target, triggerElements) {
2286 if (!isElement(target)) {
2287 return false;
2288 }
2289 const targetElement = target;
2290 if (triggerElements.hasElement(targetElement)) {
2291 return !targetElement.hasAttribute("data-trigger-disabled");
2292 }
2293 for (const [, trigger] of triggerElements.entries()) {
2294 if (contains(trigger, targetElement)) {
2295 return !trigger.hasAttribute("data-trigger-disabled");
2296 }
2297 }
2298 return false;
2299 }
2300 function isEventTargetWithin(event, node) {
2301 if (node == null) {
2302 return false;
2303 }
2304 if ("composedPath" in event) {
2305 return event.composedPath().includes(node);
2306 }
2307 const eventAgain = event;
2308 return eventAgain.target != null && node.contains(eventAgain.target);
2309 }
2310 function isRootElement(element) {
2311 return element.matches("html,body");
2312 }
2313 function isTypeableElement(element) {
2314 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2315 }
2316 function isInteractiveElement(element) {
2317 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2318 }
2319 function matchesFocusVisible(element) {
2320 if (!element || isJSDOM) {
2321 return true;
2322 }
2323 try {
2324 return element.matches(":focus-visible");
2325 } catch (_e) {
2326 return true;
2327 }
2328 }
2329
2330 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2331 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2332 const directChildren = nodes.filter((node) => node.parentId === id);
2333 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2334 }
2335
2336 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2337 function isReactEvent(event) {
2338 return "nativeEvent" in event;
2339 }
2340 function isMouseLikePointerType(pointerType, strict) {
2341 const values = ["mouse", "pen"];
2342 if (!strict) {
2343 values.push("", void 0);
2344 }
2345 return values.includes(pointerType);
2346 }
2347 function isClickLikeEvent(event) {
2348 const type = event.type;
2349 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2350 }
2351
2352 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2353 var sides = ["top", "right", "bottom", "left"];
2354 var min = Math.min;
2355 var max = Math.max;
2356 var round = Math.round;
2357 var floor = Math.floor;
2358 var createCoords = (v2) => ({
2359 x: v2,
2360 y: v2
2361 });
2362 var oppositeSideMap = {
2363 left: "right",
2364 right: "left",
2365 bottom: "top",
2366 top: "bottom"
2367 };
2368 function clamp(start, value, end) {
2369 return max(start, min(value, end));
2370 }
2371 function evaluate(value, param) {
2372 return typeof value === "function" ? value(param) : value;
2373 }
2374 function getSide(placement) {
2375 return placement.split("-")[0];
2376 }
2377 function getAlignment(placement) {
2378 return placement.split("-")[1];
2379 }
2380 function getOppositeAxis(axis) {
2381 return axis === "x" ? "y" : "x";
2382 }
2383 function getAxisLength(axis) {
2384 return axis === "y" ? "height" : "width";
2385 }
2386 function getSideAxis(placement) {
2387 const firstChar = placement[0];
2388 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2389 }
2390 function getAlignmentAxis(placement) {
2391 return getOppositeAxis(getSideAxis(placement));
2392 }
2393 function getAlignmentSides(placement, rects, rtl) {
2394 if (rtl === void 0) {
2395 rtl = false;
2396 }
2397 const alignment = getAlignment(placement);
2398 const alignmentAxis = getAlignmentAxis(placement);
2399 const length = getAxisLength(alignmentAxis);
2400 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2401 if (rects.reference[length] > rects.floating[length]) {
2402 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2403 }
2404 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2405 }
2406 function getExpandedPlacements(placement) {
2407 const oppositePlacement = getOppositePlacement(placement);
2408 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2409 }
2410 function getOppositeAlignmentPlacement(placement) {
2411 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2412 }
2413 var lrPlacement = ["left", "right"];
2414 var rlPlacement = ["right", "left"];
2415 var tbPlacement = ["top", "bottom"];
2416 var btPlacement = ["bottom", "top"];
2417 function getSideList(side, isStart, rtl) {
2418 switch (side) {
2419 case "top":
2420 case "bottom":
2421 if (rtl) return isStart ? rlPlacement : lrPlacement;
2422 return isStart ? lrPlacement : rlPlacement;
2423 case "left":
2424 case "right":
2425 return isStart ? tbPlacement : btPlacement;
2426 default:
2427 return [];
2428 }
2429 }
2430 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2431 const alignment = getAlignment(placement);
2432 let list = getSideList(getSide(placement), direction === "start", rtl);
2433 if (alignment) {
2434 list = list.map((side) => side + "-" + alignment);
2435 if (flipAlignment) {
2436 list = list.concat(list.map(getOppositeAlignmentPlacement));
2437 }
2438 }
2439 return list;
2440 }
2441 function getOppositePlacement(placement) {
2442 const side = getSide(placement);
2443 return oppositeSideMap[side] + placement.slice(side.length);
2444 }
2445 function expandPaddingObject(padding) {
2446 return {
2447 top: 0,
2448 right: 0,
2449 bottom: 0,
2450 left: 0,
2451 ...padding
2452 };
2453 }
2454 function getPaddingObject(padding) {
2455 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2456 top: padding,
2457 right: padding,
2458 bottom: padding,
2459 left: padding
2460 };
2461 }
2462 function rectToClientRect(rect) {
2463 const {
2464 x: x2,
2465 y: y2,
2466 width,
2467 height
2468 } = rect;
2469 return {
2470 width,
2471 height,
2472 top: y2,
2473 left: x2,
2474 right: x2 + width,
2475 bottom: y2 + height,
2476 x: x2,
2477 y: y2
2478 };
2479 }
2480
2481 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2482 function isHiddenByStyles(styles) {
2483 return styles.visibility === "hidden" || styles.visibility === "collapse";
2484 }
2485 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2486 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2487 return false;
2488 }
2489 if (typeof element.checkVisibility === "function") {
2490 return element.checkVisibility();
2491 }
2492 return styles.display !== "none" && styles.display !== "contents";
2493 }
2494
2495 // node_modules/@base-ui/utils/esm/owner.js
2496 function ownerDocument(node) {
2497 return node?.ownerDocument || document;
2498 }
2499
2500 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2501 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2502 function getParentElement(element) {
2503 const assignedSlot = element.assignedSlot;
2504 if (assignedSlot) {
2505 return assignedSlot;
2506 }
2507 if (element.parentElement) {
2508 return element.parentElement;
2509 }
2510 const rootNode = element.getRootNode();
2511 return isShadowRoot(rootNode) ? rootNode.host : null;
2512 }
2513 function getDetailsSummary(details) {
2514 for (const child of Array.from(details.children)) {
2515 if (getNodeName(child) === "summary") {
2516 return child;
2517 }
2518 }
2519 return null;
2520 }
2521 function isWithinOpenDetailsSummary(element, details) {
2522 const summary = getDetailsSummary(details);
2523 return !!summary && (element === summary || contains(summary, element));
2524 }
2525 function isFocusableCandidate(element) {
2526 const nodeName = element ? getNodeName(element) : "";
2527 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");
2528 }
2529 function isFocusableElement(element) {
2530 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2531 return false;
2532 }
2533 for (let current = element; current; current = getParentElement(current)) {
2534 const isAncestor = current !== element;
2535 const isSlot = getNodeName(current) === "slot";
2536 if (current.hasAttribute("inert")) {
2537 return false;
2538 }
2539 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2540 return false;
2541 }
2542 }
2543 return true;
2544 }
2545 function isVisibleInTabbableTree(element, isAncestor) {
2546 const styles = getComputedStyle2(element);
2547 if (!isAncestor) {
2548 return isElementVisible(element, styles);
2549 }
2550 return styles.display !== "none";
2551 }
2552 function getTabIndex(element) {
2553 const tabIndex = element.tabIndex;
2554 if (tabIndex < 0) {
2555 const nodeName = getNodeName(element);
2556 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2557 return 0;
2558 }
2559 }
2560 return tabIndex;
2561 }
2562 function getNamedRadioInput(element) {
2563 if (getNodeName(element) !== "input") {
2564 return null;
2565 }
2566 const input = element;
2567 return input.type === "radio" && input.name !== "" ? input : null;
2568 }
2569 function isTabbableRadio(element, candidates) {
2570 const input = getNamedRadioInput(element);
2571 if (!input) {
2572 return true;
2573 }
2574 const checkedRadio = candidates.find((candidate) => {
2575 const radio = getNamedRadioInput(candidate);
2576 return radio?.name === input.name && radio.form === input.form && radio.checked;
2577 });
2578 if (checkedRadio) {
2579 return checkedRadio === input;
2580 }
2581 return candidates.find((candidate) => {
2582 const radio = getNamedRadioInput(candidate);
2583 return radio?.name === input.name && radio.form === input.form;
2584 }) === input;
2585 }
2586 function getComposedChildren(container) {
2587 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2588 const assignedElements = container.assignedElements({
2589 flatten: true
2590 });
2591 if (assignedElements.length > 0) {
2592 return assignedElements;
2593 }
2594 }
2595 if (isHTMLElement(container) && container.shadowRoot) {
2596 return Array.from(container.shadowRoot.children);
2597 }
2598 return Array.from(container.children);
2599 }
2600 function appendCandidates(container, list) {
2601 getComposedChildren(container).forEach((child) => {
2602 if (isFocusableCandidate(child)) {
2603 list.push(child);
2604 }
2605 appendCandidates(child, list);
2606 });
2607 }
2608 function appendMatchingElements(container, selector2, list) {
2609 getComposedChildren(container).forEach((child) => {
2610 if (isHTMLElement(child) && child.matches(selector2)) {
2611 list.push(child);
2612 }
2613 appendMatchingElements(child, selector2, list);
2614 });
2615 }
2616 function focusable(container) {
2617 const candidates = [];
2618 appendCandidates(container, candidates);
2619 return candidates.filter(isFocusableElement);
2620 }
2621 function tabbable(container) {
2622 const candidates = focusable(container);
2623 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2624 }
2625 function getTabbableIn(container, dir) {
2626 const list = tabbable(container);
2627 const len = list.length;
2628 if (len === 0) {
2629 return void 0;
2630 }
2631 const active = activeElement(ownerDocument(container));
2632 const index2 = list.indexOf(active);
2633 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2634 return list[nextIndex];
2635 }
2636 function getNextTabbable(referenceElement) {
2637 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2638 }
2639 function getPreviousTabbable(referenceElement) {
2640 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2641 }
2642 function isOutsideEvent(event, container) {
2643 const containerElement = container || event.currentTarget;
2644 const relatedTarget = event.relatedTarget;
2645 return !relatedTarget || !contains(containerElement, relatedTarget);
2646 }
2647 function disableFocusInside(container) {
2648 const tabbableElements = tabbable(container);
2649 tabbableElements.forEach((element) => {
2650 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2651 element.setAttribute("tabindex", "-1");
2652 });
2653 }
2654 function enableFocusInside(container) {
2655 const elements = [];
2656 appendMatchingElements(container, "[data-tabindex]", elements);
2657 elements.forEach((element) => {
2658 const tabindex = element.dataset.tabindex;
2659 delete element.dataset.tabindex;
2660 if (tabindex) {
2661 element.setAttribute("tabindex", tabindex);
2662 } else {
2663 element.removeAttribute("tabindex");
2664 }
2665 });
2666 }
2667
2668 // node_modules/@base-ui/utils/esm/addEventListener.js
2669 function addEventListener(target, type, listener, options) {
2670 target.addEventListener(type, listener, options);
2671 return () => {
2672 target.removeEventListener(type, listener, options);
2673 };
2674 }
2675
2676 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2677 function useValueAsRef(value) {
2678 const latest = useRefWithInit(createLatestRef, value).current;
2679 latest.next = value;
2680 useIsoLayoutEffect(latest.effect);
2681 return latest;
2682 }
2683 function createLatestRef(value) {
2684 const latest = {
2685 current: value,
2686 next: value,
2687 effect: () => {
2688 latest.current = latest.next;
2689 }
2690 };
2691 return latest;
2692 }
2693
2694 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2695 var React12 = __toESM(require_react(), 1);
2696
2697 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2698 var ReactDOM = __toESM(require_react_dom(), 1);
2699
2700 // node_modules/@base-ui/react/esm/utils/resolveRef.js
2701 function resolveRef(maybeRef) {
2702 if (maybeRef == null) {
2703 return maybeRef;
2704 }
2705 return "current" in maybeRef ? maybeRef.current : maybeRef;
2706 }
2707
2708 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
2709 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
2710 const frame = useAnimationFrame();
2711 return useStableCallback((fnToExecute, signal = null) => {
2712 frame.cancel();
2713 const element = resolveRef(elementOrRef);
2714 if (element == null) {
2715 return;
2716 }
2717 const resolvedElement = element;
2718 const done = () => {
2719 ReactDOM.flushSync(fnToExecute);
2720 };
2721 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
2722 fnToExecute();
2723 return;
2724 }
2725 function exec() {
2726 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2727 if (!signal?.aborted) {
2728 done();
2729 }
2730 }).catch(() => {
2731 if (treatAbortedAsFinished) {
2732 if (!signal?.aborted) {
2733 done();
2734 }
2735 return;
2736 }
2737 const currentAnimations = resolvedElement.getAnimations();
2738 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2739 exec();
2740 }
2741 });
2742 }
2743 if (waitForStartingStyleRemoved) {
2744 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2745 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2746 frame.request(exec);
2747 return;
2748 }
2749 const attributeObserver = new MutationObserver(() => {
2750 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2751 attributeObserver.disconnect();
2752 exec();
2753 }
2754 });
2755 attributeObserver.observe(resolvedElement, {
2756 attributes: true,
2757 attributeFilter: [startingStyleAttribute]
2758 });
2759 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2760 once: true
2761 });
2762 return;
2763 }
2764 frame.request(exec);
2765 });
2766 }
2767
2768 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2769 function useOpenChangeComplete(parameters) {
2770 const {
2771 enabled = true,
2772 open,
2773 ref,
2774 onComplete: onCompleteParam
2775 } = parameters;
2776 const onComplete = useStableCallback(onCompleteParam);
2777 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2778 React12.useEffect(() => {
2779 if (!enabled) {
2780 return void 0;
2781 }
2782 const abortController = new AbortController();
2783 runOnceAnimationsFinish(onComplete, abortController.signal);
2784 return () => {
2785 abortController.abort();
2786 };
2787 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2788 }
2789
2790 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2791 var React13 = __toESM(require_react(), 1);
2792 function useOnFirstRender(fn) {
2793 const ref = React13.useRef(true);
2794 if (ref.current) {
2795 ref.current = false;
2796 fn();
2797 }
2798 }
2799
2800 // node_modules/@base-ui/utils/esm/useTimeout.js
2801 var EMPTY3 = 0;
2802 var Timeout = class _Timeout {
2803 static create() {
2804 return new _Timeout();
2805 }
2806 currentId = EMPTY3;
2807 /**
2808 * Executes `fn` after `delay`, clearing any previously scheduled call.
2809 */
2810 start(delay, fn) {
2811 this.clear();
2812 this.currentId = setTimeout(() => {
2813 this.currentId = EMPTY3;
2814 fn();
2815 }, delay);
2816 }
2817 isStarted() {
2818 return this.currentId !== EMPTY3;
2819 }
2820 clear = () => {
2821 if (this.currentId !== EMPTY3) {
2822 clearTimeout(this.currentId);
2823 this.currentId = EMPTY3;
2824 }
2825 };
2826 disposeEffect = () => {
2827 return this.clear;
2828 };
2829 };
2830 function useTimeout() {
2831 const timeout = useRefWithInit(Timeout.create).current;
2832 useOnMount(timeout.disposeEffect);
2833 return timeout;
2834 }
2835
2836 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2837 var React14 = __toESM(require_react(), 1);
2838
2839 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2840 function resolveValue(value, pointerType) {
2841 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2842 return 0;
2843 }
2844 if (typeof value === "function") {
2845 return value();
2846 }
2847 return value;
2848 }
2849 function getDelay(value, prop, pointerType) {
2850 const result = resolveValue(value, pointerType);
2851 if (typeof result === "number") {
2852 return result;
2853 }
2854 return result?.[prop];
2855 }
2856 function getRestMs(value) {
2857 if (typeof value === "function") {
2858 return value();
2859 }
2860 return value;
2861 }
2862 function isClickLikeOpenEvent(openEventType, interactedInside) {
2863 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2864 }
2865 function isHoverOpenEvent(openEventType) {
2866 return openEventType?.includes("mouse") && openEventType !== "mousedown";
2867 }
2868
2869 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2870 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2871 var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
2872 hasProvider: false,
2873 timeoutMs: 0,
2874 delayRef: {
2875 current: 0
2876 },
2877 initialDelayRef: {
2878 current: 0
2879 },
2880 timeout: new Timeout(),
2881 currentIdRef: {
2882 current: null
2883 },
2884 currentContextRef: {
2885 current: null
2886 }
2887 });
2888 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2889 function FloatingDelayGroup(props) {
2890 const {
2891 children,
2892 delay,
2893 timeoutMs = 0
2894 } = props;
2895 const delayRef = React14.useRef(delay);
2896 const initialDelayRef = React14.useRef(delay);
2897 const currentIdRef = React14.useRef(null);
2898 const currentContextRef = React14.useRef(null);
2899 const timeout = useTimeout();
2900 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2901 value: React14.useMemo(() => ({
2902 hasProvider: true,
2903 delayRef,
2904 initialDelayRef,
2905 currentIdRef,
2906 timeoutMs,
2907 currentContextRef,
2908 timeout
2909 }), [timeoutMs, timeout]),
2910 children
2911 });
2912 }
2913 function useDelayGroup(context, options = {
2914 open: false
2915 }) {
2916 const {
2917 open
2918 } = options;
2919 const store = "rootStore" in context ? context.rootStore : context;
2920 const floatingId = store.useState("floatingId");
2921 const groupContext = React14.useContext(FloatingDelayGroupContext);
2922 const {
2923 currentIdRef,
2924 delayRef,
2925 timeoutMs,
2926 initialDelayRef,
2927 currentContextRef,
2928 hasProvider,
2929 timeout
2930 } = groupContext;
2931 const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
2932 useIsoLayoutEffect(() => {
2933 function unset() {
2934 setIsInstantPhase(false);
2935 currentContextRef.current?.setIsInstantPhase(false);
2936 currentIdRef.current = null;
2937 currentContextRef.current = null;
2938 delayRef.current = initialDelayRef.current;
2939 }
2940 if (!currentIdRef.current) {
2941 return void 0;
2942 }
2943 if (!open && currentIdRef.current === floatingId) {
2944 setIsInstantPhase(false);
2945 if (timeoutMs) {
2946 const closingId = floatingId;
2947 timeout.start(timeoutMs, () => {
2948 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2949 return;
2950 }
2951 unset();
2952 });
2953 return () => {
2954 timeout.clear();
2955 };
2956 }
2957 unset();
2958 }
2959 return void 0;
2960 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2961 useIsoLayoutEffect(() => {
2962 if (!open) {
2963 return;
2964 }
2965 const prevContext = currentContextRef.current;
2966 const prevId = currentIdRef.current;
2967 timeout.clear();
2968 currentContextRef.current = {
2969 onOpenChange: store.setOpen,
2970 setIsInstantPhase
2971 };
2972 currentIdRef.current = floatingId;
2973 delayRef.current = {
2974 open: 0,
2975 close: getDelay(initialDelayRef.current, "close")
2976 };
2977 if (prevId !== null && prevId !== floatingId) {
2978 setIsInstantPhase(true);
2979 prevContext?.setIsInstantPhase(true);
2980 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2981 } else {
2982 setIsInstantPhase(false);
2983 prevContext?.setIsInstantPhase(false);
2984 }
2985 }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
2986 useIsoLayoutEffect(() => {
2987 return () => {
2988 currentContextRef.current = null;
2989 };
2990 }, [currentContextRef]);
2991 return React14.useMemo(() => ({
2992 hasProvider,
2993 delayRef,
2994 isInstantPhase
2995 }), [hasProvider, delayRef, isInstantPhase]);
2996 }
2997
2998 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2999 function mergeCleanups(...cleanups) {
3000 return () => {
3001 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
3002 const cleanup = cleanups[i2];
3003 if (cleanup) {
3004 cleanup();
3005 }
3006 }
3007 };
3008 }
3009
3010 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3011 var React15 = __toESM(require_react(), 1);
3012
3013 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3014 var visuallyHiddenBase = {
3015 clipPath: "inset(50%)",
3016 overflow: "hidden",
3017 whiteSpace: "nowrap",
3018 border: 0,
3019 padding: 0,
3020 width: 1,
3021 height: 1,
3022 margin: -1
3023 };
3024 var visuallyHidden = {
3025 ...visuallyHiddenBase,
3026 position: "fixed",
3027 top: 0,
3028 left: 0
3029 };
3030 var visuallyHiddenInput = {
3031 ...visuallyHiddenBase,
3032 position: "absolute"
3033 };
3034
3035 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3036 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3037 var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
3038 const [role, setRole] = React15.useState();
3039 useIsoLayoutEffect(() => {
3040 if (isSafari) {
3041 setRole("button");
3042 }
3043 }, []);
3044 const restProps = {
3045 tabIndex: 0,
3046 // Role is only for VoiceOver
3047 role
3048 };
3049 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3050 ...props,
3051 ref,
3052 style: visuallyHidden,
3053 "aria-hidden": role ? void 0 : true,
3054 ...restProps,
3055 "data-base-ui-focus-guard": ""
3056 });
3057 });
3058 if (true) FocusGuard.displayName = "FocusGuard";
3059
3060 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3061 function createAttribute(name) {
3062 return `data-base-ui-${name}`;
3063 }
3064
3065 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3066 var React16 = __toESM(require_react(), 1);
3067 var ReactDOM2 = __toESM(require_react_dom(), 1);
3068
3069 // node_modules/@base-ui/react/esm/internals/constants.js
3070 var DISABLED_TRANSITIONS_STYLE = {
3071 style: {
3072 transition: "none"
3073 }
3074 };
3075 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3076 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3077 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3078 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3079 var POPUP_COLLISION_AVOIDANCE = {
3080 fallbackAxisSide: "end"
3081 };
3082 var ownerVisuallyHidden = {
3083 clipPath: "inset(50%)",
3084 position: "fixed",
3085 top: 0,
3086 left: 0
3087 };
3088
3089 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3090 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3091 var PortalContext = /* @__PURE__ */ React16.createContext(null);
3092 if (true) PortalContext.displayName = "PortalContext";
3093 var usePortalContext = () => React16.useContext(PortalContext);
3094 var attr = createAttribute("portal");
3095 function useFloatingPortalNode(props = {}) {
3096 const {
3097 ref,
3098 container: containerProp,
3099 componentProps = EMPTY_OBJECT,
3100 elementProps
3101 } = props;
3102 const uniqueId = useId();
3103 const portalContext = usePortalContext();
3104 const parentPortalNode = portalContext?.portalNode;
3105 const [containerElement, setContainerElement] = React16.useState(null);
3106 const [portalNode, setPortalNode] = React16.useState(null);
3107 const setPortalNodeRef = useStableCallback((node) => {
3108 if (node !== null) {
3109 setPortalNode(node);
3110 }
3111 });
3112 const containerRef = React16.useRef(null);
3113 useIsoLayoutEffect(() => {
3114 if (containerProp === null) {
3115 if (containerRef.current) {
3116 containerRef.current = null;
3117 setPortalNode(null);
3118 setContainerElement(null);
3119 }
3120 return;
3121 }
3122 if (uniqueId == null) {
3123 return;
3124 }
3125 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3126 if (resolvedContainer == null) {
3127 if (containerRef.current) {
3128 containerRef.current = null;
3129 setPortalNode(null);
3130 setContainerElement(null);
3131 }
3132 return;
3133 }
3134 if (containerRef.current !== resolvedContainer) {
3135 containerRef.current = resolvedContainer;
3136 setPortalNode(null);
3137 setContainerElement(resolvedContainer);
3138 }
3139 }, [containerProp, parentPortalNode, uniqueId]);
3140 const portalElement = useRenderElement("div", componentProps, {
3141 ref: [ref, setPortalNodeRef],
3142 props: [{
3143 id: uniqueId,
3144 [attr]: ""
3145 }, elementProps]
3146 });
3147 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3148 return {
3149 portalNode,
3150 portalSubtree
3151 };
3152 }
3153 var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3154 const {
3155 render: render4,
3156 className,
3157 style,
3158 children,
3159 container,
3160 renderGuards,
3161 ...elementProps
3162 } = componentProps;
3163 const {
3164 portalNode,
3165 portalSubtree
3166 } = useFloatingPortalNode({
3167 container,
3168 ref: forwardedRef,
3169 componentProps,
3170 elementProps
3171 });
3172 const beforeOutsideRef = React16.useRef(null);
3173 const afterOutsideRef = React16.useRef(null);
3174 const beforeInsideRef = React16.useRef(null);
3175 const afterInsideRef = React16.useRef(null);
3176 const [focusManagerState, setFocusManagerState] = React16.useState(null);
3177 const focusInsideDisabledRef = React16.useRef(false);
3178 const modal = focusManagerState?.modal;
3179 const open = focusManagerState?.open;
3180 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3181 React16.useEffect(() => {
3182 if (!portalNode || modal) {
3183 return void 0;
3184 }
3185 function onFocus(event) {
3186 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3187 if (event.type === "focusin") {
3188 if (focusInsideDisabledRef.current) {
3189 enableFocusInside(portalNode);
3190 focusInsideDisabledRef.current = false;
3191 }
3192 } else {
3193 disableFocusInside(portalNode);
3194 focusInsideDisabledRef.current = true;
3195 }
3196 }
3197 }
3198 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3199 }, [portalNode, modal]);
3200 React16.useEffect(() => {
3201 if (!portalNode || open !== false) {
3202 return;
3203 }
3204 enableFocusInside(portalNode);
3205 focusInsideDisabledRef.current = false;
3206 }, [open, portalNode]);
3207 const portalContextValue = React16.useMemo(() => ({
3208 beforeOutsideRef,
3209 afterOutsideRef,
3210 beforeInsideRef,
3211 afterInsideRef,
3212 portalNode,
3213 setFocusManagerState
3214 }), [portalNode]);
3215 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
3216 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3217 value: portalContextValue,
3218 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3219 "data-type": "outside",
3220 ref: beforeOutsideRef,
3221 onFocus: (event) => {
3222 if (isOutsideEvent(event, portalNode)) {
3223 beforeInsideRef.current?.focus();
3224 } else {
3225 const domReference = focusManagerState ? focusManagerState.domReference : null;
3226 const prevTabbable = getPreviousTabbable(domReference);
3227 prevTabbable?.focus();
3228 }
3229 }
3230 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3231 "aria-owns": portalNode.id,
3232 style: ownerVisuallyHidden
3233 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3234 "data-type": "outside",
3235 ref: afterOutsideRef,
3236 onFocus: (event) => {
3237 if (isOutsideEvent(event, portalNode)) {
3238 afterInsideRef.current?.focus();
3239 } else {
3240 const domReference = focusManagerState ? focusManagerState.domReference : null;
3241 const nextTabbable = getNextTabbable(domReference);
3242 nextTabbable?.focus();
3243 if (focusManagerState?.closeOnFocusOut) {
3244 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3245 }
3246 }
3247 }
3248 })]
3249 })]
3250 });
3251 });
3252 if (true) FloatingPortal.displayName = "FloatingPortal";
3253
3254 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3255 var React17 = __toESM(require_react(), 1);
3256
3257 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3258 function createEventEmitter() {
3259 const map = /* @__PURE__ */ new Map();
3260 return {
3261 emit(event, data) {
3262 map.get(event)?.forEach((listener) => listener(data));
3263 },
3264 on(event, listener) {
3265 if (!map.has(event)) {
3266 map.set(event, /* @__PURE__ */ new Set());
3267 }
3268 map.get(event).add(listener);
3269 },
3270 off(event, listener) {
3271 map.get(event)?.delete(listener);
3272 }
3273 };
3274 }
3275
3276 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3277 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3278 var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
3279 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3280 var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
3281 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3282 var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
3283 var useFloatingTree = (externalTree) => {
3284 const contextTree = React17.useContext(FloatingTreeContext);
3285 return externalTree ?? contextTree;
3286 };
3287
3288 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3289 var React18 = __toESM(require_react(), 1);
3290 function createVirtualElement(domElement, data) {
3291 let offsetX = null;
3292 let offsetY = null;
3293 let isAutoUpdateEvent = false;
3294 return {
3295 contextElement: domElement || void 0,
3296 getBoundingClientRect() {
3297 const domRect = domElement?.getBoundingClientRect() || {
3298 width: 0,
3299 height: 0,
3300 x: 0,
3301 y: 0
3302 };
3303 const isXAxis = data.axis === "x" || data.axis === "both";
3304 const isYAxis = data.axis === "y" || data.axis === "both";
3305 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3306 let width = domRect.width;
3307 let height = domRect.height;
3308 let x2 = domRect.x;
3309 let y2 = domRect.y;
3310 if (offsetX == null && data.x && isXAxis) {
3311 offsetX = domRect.x - data.x;
3312 }
3313 if (offsetY == null && data.y && isYAxis) {
3314 offsetY = domRect.y - data.y;
3315 }
3316 x2 -= offsetX || 0;
3317 y2 -= offsetY || 0;
3318 width = 0;
3319 height = 0;
3320 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3321 width = data.axis === "y" ? domRect.width : 0;
3322 height = data.axis === "x" ? domRect.height : 0;
3323 x2 = isXAxis && data.x != null ? data.x : x2;
3324 y2 = isYAxis && data.y != null ? data.y : y2;
3325 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3326 height = data.axis === "x" ? domRect.height : height;
3327 width = data.axis === "y" ? domRect.width : width;
3328 }
3329 isAutoUpdateEvent = true;
3330 return {
3331 width,
3332 height,
3333 x: x2,
3334 y: y2,
3335 top: y2,
3336 right: x2 + width,
3337 bottom: y2 + height,
3338 left: x2
3339 };
3340 }
3341 };
3342 }
3343 function isMouseBasedEvent(event) {
3344 return event != null && event.clientX != null;
3345 }
3346 function useClientPoint(context, props = {}) {
3347 const {
3348 enabled = true,
3349 axis = "both"
3350 } = props;
3351 const store = "rootStore" in context ? context.rootStore : context;
3352 const open = store.useState("open");
3353 const floating = store.useState("floatingElement");
3354 const domReference = store.useState("domReferenceElement");
3355 const dataRef = store.context.dataRef;
3356 const initialRef = React18.useRef(false);
3357 const cleanupListenerRef = React18.useRef(null);
3358 const [pointerType, setPointerType] = React18.useState();
3359 const [reactive, setReactive] = React18.useState([]);
3360 const resetReference = useStableCallback((reference2) => {
3361 store.set("positionReference", reference2);
3362 });
3363 const setReference = useStableCallback((newX, newY, referenceElement) => {
3364 if (initialRef.current) {
3365 return;
3366 }
3367 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3368 return;
3369 }
3370 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3371 x: newX,
3372 y: newY,
3373 axis,
3374 dataRef,
3375 pointerType
3376 }));
3377 });
3378 const handleReferenceEnterOrMove = useStableCallback((event) => {
3379 if (!open) {
3380 setReference(event.clientX, event.clientY, event.currentTarget);
3381 } else if (!cleanupListenerRef.current) {
3382 setReference(event.clientX, event.clientY, event.currentTarget);
3383 setReactive([]);
3384 }
3385 });
3386 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3387 React18.useEffect(() => {
3388 if (!enabled) {
3389 resetReference(domReference);
3390 return void 0;
3391 }
3392 if (!openCheck) {
3393 return void 0;
3394 }
3395 function cleanupListener() {
3396 cleanupListenerRef.current?.();
3397 cleanupListenerRef.current = null;
3398 }
3399 const win = getWindow(floating);
3400 function handleMouseMove(event) {
3401 const target = getTarget(event);
3402 if (!contains(floating, target)) {
3403 setReference(event.clientX, event.clientY);
3404 } else {
3405 cleanupListener();
3406 }
3407 }
3408 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3409 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3410 } else {
3411 resetReference(domReference);
3412 }
3413 return cleanupListener;
3414 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
3415 React18.useEffect(() => () => {
3416 store.set("positionReference", null);
3417 }, [store]);
3418 React18.useEffect(() => {
3419 if (enabled && !floating) {
3420 initialRef.current = false;
3421 }
3422 }, [enabled, floating]);
3423 React18.useEffect(() => {
3424 if (!enabled && open) {
3425 initialRef.current = true;
3426 }
3427 }, [enabled, open]);
3428 const reference = React18.useMemo(() => {
3429 function setPointerTypeRef(event) {
3430 setPointerType(event.pointerType);
3431 }
3432 return {
3433 onPointerDown: setPointerTypeRef,
3434 onPointerEnter: setPointerTypeRef,
3435 onMouseMove: handleReferenceEnterOrMove,
3436 onMouseEnter: handleReferenceEnterOrMove
3437 };
3438 }, [handleReferenceEnterOrMove]);
3439 return React18.useMemo(() => enabled ? {
3440 reference,
3441 trigger: reference
3442 } : {}, [enabled, reference]);
3443 }
3444
3445 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3446 var React19 = __toESM(require_react(), 1);
3447 var bubbleHandlerKeys = {
3448 intentional: "onClick",
3449 sloppy: "onPointerDown"
3450 };
3451 function alwaysFalse() {
3452 return false;
3453 }
3454 function normalizeProp(normalizable) {
3455 return {
3456 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3457 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3458 };
3459 }
3460 function useDismiss(context, props = {}) {
3461 const {
3462 enabled = true,
3463 escapeKey: escapeKey2 = true,
3464 outsidePress: outsidePressProp = true,
3465 outsidePressEvent = "sloppy",
3466 referencePress = alwaysFalse,
3467 referencePressEvent = "sloppy",
3468 bubbles,
3469 externalTree
3470 } = props;
3471 const store = "rootStore" in context ? context.rootStore : context;
3472 const open = store.useState("open");
3473 const floatingElement = store.useState("floatingElement");
3474 const {
3475 dataRef
3476 } = store.context;
3477 const tree = useFloatingTree(externalTree);
3478 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3479 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3480 const outsidePressEnabled = outsidePress2 !== false;
3481 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3482 const {
3483 escapeKey: escapeKeyBubbles,
3484 outsidePress: outsidePressBubbles
3485 } = normalizeProp(bubbles);
3486 const pressStartedInsideRef = React19.useRef(false);
3487 const pressStartPreventedRef = React19.useRef(false);
3488 const suppressNextOutsideClickRef = React19.useRef(false);
3489 const isComposingRef = React19.useRef(false);
3490 const currentPointerTypeRef = React19.useRef("");
3491 const touchStateRef = React19.useRef(null);
3492 const cancelDismissOnEndTimeout = useTimeout();
3493 const clearInsideReactTreeTimeout = useTimeout();
3494 const clearInsideReactTree = useStableCallback(() => {
3495 clearInsideReactTreeTimeout.clear();
3496 dataRef.current.insideReactTree = false;
3497 });
3498 const hasBlockingChild = useStableCallback((bubbleKey) => {
3499 const nodeId = dataRef.current.floatingContext?.nodeId;
3500 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3501 return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
3502 });
3503 const isEventWithinOwnElements = useStableCallback((event) => {
3504 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
3505 });
3506 const closeOnReferencePress = useStableCallback((event) => {
3507 if (!referencePress()) {
3508 return;
3509 }
3510 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3511 });
3512 const closeOnEscapeKeyDown = useStableCallback((event) => {
3513 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3514 return;
3515 }
3516 if (isComposingRef.current) {
3517 return;
3518 }
3519 if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
3520 return;
3521 }
3522 const native = isReactEvent(event) ? event.nativeEvent : event;
3523 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3524 store.setOpen(false, eventDetails);
3525 if (!eventDetails.isCanceled) {
3526 event.preventDefault();
3527 }
3528 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3529 event.stopPropagation();
3530 }
3531 });
3532 const markInsideReactTree = useStableCallback(() => {
3533 dataRef.current.insideReactTree = true;
3534 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3535 });
3536 const markPressStartedInsideReactTree = useStableCallback((event) => {
3537 if (!open || !enabled || event.button !== 0) {
3538 return;
3539 }
3540 const target = getTarget(event.nativeEvent);
3541 if (!contains(store.select("floatingElement"), target)) {
3542 return;
3543 }
3544 if (!pressStartedInsideRef.current) {
3545 pressStartedInsideRef.current = true;
3546 pressStartPreventedRef.current = false;
3547 }
3548 });
3549 const markInsidePressStartPrevented = useStableCallback((event) => {
3550 if (!open || !enabled) {
3551 return;
3552 }
3553 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3554 return;
3555 }
3556 if (pressStartedInsideRef.current) {
3557 pressStartPreventedRef.current = true;
3558 }
3559 });
3560 React19.useEffect(() => {
3561 if (!open || !enabled) {
3562 return void 0;
3563 }
3564 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3565 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3566 const compositionTimeout = new Timeout();
3567 const preventedPressSuppressionTimeout = new Timeout();
3568 function handleCompositionStart() {
3569 compositionTimeout.clear();
3570 isComposingRef.current = true;
3571 }
3572 function handleCompositionEnd() {
3573 compositionTimeout.start(
3574 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3575 // Only apply to WebKit for the test to remain 0ms.
3576 isWebKit() ? 5 : 0,
3577 () => {
3578 isComposingRef.current = false;
3579 }
3580 );
3581 }
3582 function suppressImmediateOutsideClickAfterPreventedStart() {
3583 suppressNextOutsideClickRef.current = true;
3584 preventedPressSuppressionTimeout.start(0, () => {
3585 suppressNextOutsideClickRef.current = false;
3586 });
3587 }
3588 function resetPressStartState() {
3589 pressStartedInsideRef.current = false;
3590 pressStartPreventedRef.current = false;
3591 }
3592 function getOutsidePressEvent() {
3593 const type = currentPointerTypeRef.current;
3594 const computedType = type === "pen" || !type ? "mouse" : type;
3595 const outsidePressEventValue = getOutsidePressEventProp();
3596 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3597 if (typeof resolved === "string") {
3598 return resolved;
3599 }
3600 return resolved[computedType];
3601 }
3602 function shouldIgnoreEvent(event) {
3603 const computedOutsidePressEvent = getOutsidePressEvent();
3604 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3605 }
3606 function isEventWithinFloatingTree(event) {
3607 const nodeId = dataRef.current.floatingContext?.nodeId;
3608 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3609 return isEventWithinOwnElements(event) || targetIsInsideChildren;
3610 }
3611 function closeOnPressOutside(event) {
3612 if (shouldIgnoreEvent(event)) {
3613 if (event.type !== "click" && !isEventWithinOwnElements(event)) {
3614 preventedPressSuppressionTimeout.clear();
3615 suppressNextOutsideClickRef.current = false;
3616 }
3617 clearInsideReactTree();
3618 return;
3619 }
3620 if (dataRef.current.insideReactTree) {
3621 clearInsideReactTree();
3622 return;
3623 }
3624 const target = getTarget(event);
3625 const inertSelector = `[${createAttribute("inert")}]`;
3626 const targetRoot = isElement(target) ? target.getRootNode() : null;
3627 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3628 const triggers = store.context.triggerElements;
3629 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3630 return;
3631 }
3632 let targetRootAncestor = isElement(target) ? target : null;
3633 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3634 const nextParent = getParentNode(targetRootAncestor);
3635 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3636 break;
3637 }
3638 targetRootAncestor = nextParent;
3639 }
3640 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3641 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3642 // element was injected after the floating element rendered.
3643 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3644 return;
3645 }
3646 if (isHTMLElement(target) && !("touches" in event)) {
3647 const lastTraversableNode = isLastTraversableNode(target);
3648 const style = getComputedStyle2(target);
3649 const scrollRe = /auto|scroll/;
3650 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3651 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3652 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3653 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3654 const isRTL7 = style.direction === "rtl";
3655 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3656 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3657 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3658 return;
3659 }
3660 }
3661 if (isEventWithinFloatingTree(event)) {
3662 return;
3663 }
3664 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3665 preventedPressSuppressionTimeout.clear();
3666 suppressNextOutsideClickRef.current = false;
3667 return;
3668 }
3669 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3670 return;
3671 }
3672 if (hasBlockingChild("__outsidePressBubbles")) {
3673 return;
3674 }
3675 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3676 clearInsideReactTree();
3677 }
3678 function handlePointerDown(event) {
3679 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3680 return;
3681 }
3682 closeOnPressOutside(event);
3683 }
3684 function handleTouchStart(event) {
3685 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
3686 return;
3687 }
3688 const touch = event.touches[0];
3689 if (touch) {
3690 touchStateRef.current = {
3691 startTime: Date.now(),
3692 startX: touch.clientX,
3693 startY: touch.clientY,
3694 dismissOnTouchEnd: false,
3695 dismissOnMouseDown: true
3696 };
3697 cancelDismissOnEndTimeout.start(1e3, () => {
3698 if (touchStateRef.current) {
3699 touchStateRef.current.dismissOnTouchEnd = false;
3700 touchStateRef.current.dismissOnMouseDown = false;
3701 }
3702 });
3703 }
3704 }
3705 function addTargetEventListenerOnce(event, listener) {
3706 const target = getTarget(event);
3707 if (!target) {
3708 return;
3709 }
3710 const unsubscribe2 = addEventListener(target, event.type, () => {
3711 listener(event);
3712 unsubscribe2();
3713 });
3714 }
3715 function handleTouchStartCapture(event) {
3716 currentPointerTypeRef.current = "touch";
3717 addTargetEventListenerOnce(event, handleTouchStart);
3718 }
3719 function closeOnPressOutsideCapture(event) {
3720 cancelDismissOnEndTimeout.clear();
3721 if (event.type === "pointerdown") {
3722 currentPointerTypeRef.current = event.pointerType;
3723 }
3724 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3725 return;
3726 }
3727 addTargetEventListenerOnce(event, (targetEvent) => {
3728 if (targetEvent.type === "pointerdown") {
3729 handlePointerDown(targetEvent);
3730 } else {
3731 closeOnPressOutside(targetEvent);
3732 }
3733 });
3734 }
3735 function handlePressEndCapture(event) {
3736 if (!pressStartedInsideRef.current) {
3737 return;
3738 }
3739 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3740 resetPressStartState();
3741 if (getOutsidePressEvent() !== "intentional") {
3742 return;
3743 }
3744 if (event.type === "pointercancel") {
3745 if (pressStartedInsideDefaultPrevented) {
3746 suppressImmediateOutsideClickAfterPreventedStart();
3747 }
3748 return;
3749 }
3750 if (isEventWithinFloatingTree(event)) {
3751 return;
3752 }
3753 if (pressStartedInsideDefaultPrevented) {
3754 suppressImmediateOutsideClickAfterPreventedStart();
3755 return;
3756 }
3757 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3758 return;
3759 }
3760 preventedPressSuppressionTimeout.clear();
3761 suppressNextOutsideClickRef.current = true;
3762 clearInsideReactTree();
3763 }
3764 function handleTouchMove(event) {
3765 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3766 return;
3767 }
3768 const touch = event.touches[0];
3769 if (!touch) {
3770 return;
3771 }
3772 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3773 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3774 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3775 if (distance > 5) {
3776 touchStateRef.current.dismissOnTouchEnd = true;
3777 }
3778 if (distance > 10) {
3779 closeOnPressOutside(event);
3780 cancelDismissOnEndTimeout.clear();
3781 touchStateRef.current = null;
3782 }
3783 }
3784 function handleTouchMoveCapture(event) {
3785 addTargetEventListenerOnce(event, handleTouchMove);
3786 }
3787 function handleTouchEnd(event) {
3788 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
3789 return;
3790 }
3791 if (touchStateRef.current.dismissOnTouchEnd) {
3792 closeOnPressOutside(event);
3793 }
3794 cancelDismissOnEndTimeout.clear();
3795 touchStateRef.current = null;
3796 }
3797 function handleTouchEndCapture(event) {
3798 addTargetEventListenerOnce(event, handleTouchEnd);
3799 }
3800 const doc = ownerDocument(floatingElement);
3801 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)));
3802 return () => {
3803 unsubscribe();
3804 compositionTimeout.clear();
3805 preventedPressSuppressionTimeout.clear();
3806 resetPressStartState();
3807 suppressNextOutsideClickRef.current = false;
3808 };
3809 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
3810 React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3811 const reference = React19.useMemo(() => ({
3812 onKeyDown: closeOnEscapeKeyDown,
3813 [bubbleHandlerKeys[referencePressEvent]]: closeOnReferencePress,
3814 ...referencePressEvent !== "intentional" && {
3815 onClick: closeOnReferencePress
3816 }
3817 }), [closeOnEscapeKeyDown, closeOnReferencePress, referencePressEvent]);
3818 const floating = React19.useMemo(() => ({
3819 onKeyDown: closeOnEscapeKeyDown,
3820 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3821 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3822 // See https://github.com/mui/base-ui/pull/3379
3823 onPointerDown: markInsidePressStartPrevented,
3824 onMouseDown: markInsidePressStartPrevented,
3825 onClickCapture: markInsideReactTree,
3826 onMouseDownCapture(event) {
3827 markInsideReactTree();
3828 markPressStartedInsideReactTree(event);
3829 },
3830 onPointerDownCapture(event) {
3831 markInsideReactTree();
3832 markPressStartedInsideReactTree(event);
3833 },
3834 onMouseUpCapture: markInsideReactTree,
3835 onTouchEndCapture: markInsideReactTree,
3836 onTouchMoveCapture: markInsideReactTree
3837 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3838 return React19.useMemo(() => enabled ? {
3839 reference,
3840 floating,
3841 trigger: reference
3842 } : {}, [enabled, reference, floating]);
3843 }
3844
3845 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3846 var React26 = __toESM(require_react(), 1);
3847
3848 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3849 function computeCoordsFromPlacement(_ref, placement, rtl) {
3850 let {
3851 reference,
3852 floating
3853 } = _ref;
3854 const sideAxis = getSideAxis(placement);
3855 const alignmentAxis = getAlignmentAxis(placement);
3856 const alignLength = getAxisLength(alignmentAxis);
3857 const side = getSide(placement);
3858 const isVertical = sideAxis === "y";
3859 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3860 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3861 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3862 let coords;
3863 switch (side) {
3864 case "top":
3865 coords = {
3866 x: commonX,
3867 y: reference.y - floating.height
3868 };
3869 break;
3870 case "bottom":
3871 coords = {
3872 x: commonX,
3873 y: reference.y + reference.height
3874 };
3875 break;
3876 case "right":
3877 coords = {
3878 x: reference.x + reference.width,
3879 y: commonY
3880 };
3881 break;
3882 case "left":
3883 coords = {
3884 x: reference.x - floating.width,
3885 y: commonY
3886 };
3887 break;
3888 default:
3889 coords = {
3890 x: reference.x,
3891 y: reference.y
3892 };
3893 }
3894 switch (getAlignment(placement)) {
3895 case "start":
3896 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3897 break;
3898 case "end":
3899 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3900 break;
3901 }
3902 return coords;
3903 }
3904 async function detectOverflow(state, options) {
3905 var _await$platform$isEle;
3906 if (options === void 0) {
3907 options = {};
3908 }
3909 const {
3910 x: x2,
3911 y: y2,
3912 platform: platform3,
3913 rects,
3914 elements,
3915 strategy
3916 } = state;
3917 const {
3918 boundary = "clippingAncestors",
3919 rootBoundary = "viewport",
3920 elementContext = "floating",
3921 altBoundary = false,
3922 padding = 0
3923 } = evaluate(options, state);
3924 const paddingObject = getPaddingObject(padding);
3925 const altContext = elementContext === "floating" ? "reference" : "floating";
3926 const element = elements[altBoundary ? altContext : elementContext];
3927 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3928 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)),
3929 boundary,
3930 rootBoundary,
3931 strategy
3932 }));
3933 const rect = elementContext === "floating" ? {
3934 x: x2,
3935 y: y2,
3936 width: rects.floating.width,
3937 height: rects.floating.height
3938 } : rects.reference;
3939 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3940 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3941 x: 1,
3942 y: 1
3943 } : {
3944 x: 1,
3945 y: 1
3946 };
3947 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3948 elements,
3949 rect,
3950 offsetParent,
3951 strategy
3952 }) : rect);
3953 return {
3954 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3955 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3956 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3957 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3958 };
3959 }
3960 var MAX_RESET_COUNT = 50;
3961 var computePosition = async (reference, floating, config) => {
3962 const {
3963 placement = "bottom",
3964 strategy = "absolute",
3965 middleware = [],
3966 platform: platform3
3967 } = config;
3968 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3969 ...platform3,
3970 detectOverflow
3971 };
3972 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3973 let rects = await platform3.getElementRects({
3974 reference,
3975 floating,
3976 strategy
3977 });
3978 let {
3979 x: x2,
3980 y: y2
3981 } = computeCoordsFromPlacement(rects, placement, rtl);
3982 let statefulPlacement = placement;
3983 let resetCount = 0;
3984 const middlewareData = {};
3985 for (let i2 = 0; i2 < middleware.length; i2++) {
3986 const currentMiddleware = middleware[i2];
3987 if (!currentMiddleware) {
3988 continue;
3989 }
3990 const {
3991 name,
3992 fn
3993 } = currentMiddleware;
3994 const {
3995 x: nextX,
3996 y: nextY,
3997 data,
3998 reset
3999 } = await fn({
4000 x: x2,
4001 y: y2,
4002 initialPlacement: placement,
4003 placement: statefulPlacement,
4004 strategy,
4005 middlewareData,
4006 rects,
4007 platform: platformWithDetectOverflow,
4008 elements: {
4009 reference,
4010 floating
4011 }
4012 });
4013 x2 = nextX != null ? nextX : x2;
4014 y2 = nextY != null ? nextY : y2;
4015 middlewareData[name] = {
4016 ...middlewareData[name],
4017 ...data
4018 };
4019 if (reset && resetCount < MAX_RESET_COUNT) {
4020 resetCount++;
4021 if (typeof reset === "object") {
4022 if (reset.placement) {
4023 statefulPlacement = reset.placement;
4024 }
4025 if (reset.rects) {
4026 rects = reset.rects === true ? await platform3.getElementRects({
4027 reference,
4028 floating,
4029 strategy
4030 }) : reset.rects;
4031 }
4032 ({
4033 x: x2,
4034 y: y2
4035 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4036 }
4037 i2 = -1;
4038 }
4039 }
4040 return {
4041 x: x2,
4042 y: y2,
4043 placement: statefulPlacement,
4044 strategy,
4045 middlewareData
4046 };
4047 };
4048 var flip = function(options) {
4049 if (options === void 0) {
4050 options = {};
4051 }
4052 return {
4053 name: "flip",
4054 options,
4055 async fn(state) {
4056 var _middlewareData$arrow, _middlewareData$flip;
4057 const {
4058 placement,
4059 middlewareData,
4060 rects,
4061 initialPlacement,
4062 platform: platform3,
4063 elements
4064 } = state;
4065 const {
4066 mainAxis: checkMainAxis = true,
4067 crossAxis: checkCrossAxis = true,
4068 fallbackPlacements: specifiedFallbackPlacements,
4069 fallbackStrategy = "bestFit",
4070 fallbackAxisSideDirection = "none",
4071 flipAlignment = true,
4072 ...detectOverflowOptions
4073 } = evaluate(options, state);
4074 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4075 return {};
4076 }
4077 const side = getSide(placement);
4078 const initialSideAxis = getSideAxis(initialPlacement);
4079 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4080 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4081 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4082 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4083 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4084 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4085 }
4086 const placements2 = [initialPlacement, ...fallbackPlacements];
4087 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4088 const overflows = [];
4089 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4090 if (checkMainAxis) {
4091 overflows.push(overflow[side]);
4092 }
4093 if (checkCrossAxis) {
4094 const sides2 = getAlignmentSides(placement, rects, rtl);
4095 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4096 }
4097 overflowsData = [...overflowsData, {
4098 placement,
4099 overflows
4100 }];
4101 if (!overflows.every((side2) => side2 <= 0)) {
4102 var _middlewareData$flip2, _overflowsData$filter;
4103 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4104 const nextPlacement = placements2[nextIndex];
4105 if (nextPlacement) {
4106 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4107 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4108 // overflows the main axis.
4109 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4110 return {
4111 data: {
4112 index: nextIndex,
4113 overflows: overflowsData
4114 },
4115 reset: {
4116 placement: nextPlacement
4117 }
4118 };
4119 }
4120 }
4121 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;
4122 if (!resetPlacement) {
4123 switch (fallbackStrategy) {
4124 case "bestFit": {
4125 var _overflowsData$filter2;
4126 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4127 if (hasFallbackAxisSideDirection) {
4128 const currentSideAxis = getSideAxis(d2.placement);
4129 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4130 // reading directions favoring greater width.
4131 currentSideAxis === "y";
4132 }
4133 return true;
4134 }).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];
4135 if (placement2) {
4136 resetPlacement = placement2;
4137 }
4138 break;
4139 }
4140 case "initialPlacement":
4141 resetPlacement = initialPlacement;
4142 break;
4143 }
4144 }
4145 if (placement !== resetPlacement) {
4146 return {
4147 reset: {
4148 placement: resetPlacement
4149 }
4150 };
4151 }
4152 }
4153 return {};
4154 }
4155 };
4156 };
4157 function getSideOffsets(overflow, rect) {
4158 return {
4159 top: overflow.top - rect.height,
4160 right: overflow.right - rect.width,
4161 bottom: overflow.bottom - rect.height,
4162 left: overflow.left - rect.width
4163 };
4164 }
4165 function isAnySideFullyClipped(overflow) {
4166 return sides.some((side) => overflow[side] >= 0);
4167 }
4168 var hide = function(options) {
4169 if (options === void 0) {
4170 options = {};
4171 }
4172 return {
4173 name: "hide",
4174 options,
4175 async fn(state) {
4176 const {
4177 rects,
4178 platform: platform3
4179 } = state;
4180 const {
4181 strategy = "referenceHidden",
4182 ...detectOverflowOptions
4183 } = evaluate(options, state);
4184 switch (strategy) {
4185 case "referenceHidden": {
4186 const overflow = await platform3.detectOverflow(state, {
4187 ...detectOverflowOptions,
4188 elementContext: "reference"
4189 });
4190 const offsets = getSideOffsets(overflow, rects.reference);
4191 return {
4192 data: {
4193 referenceHiddenOffsets: offsets,
4194 referenceHidden: isAnySideFullyClipped(offsets)
4195 }
4196 };
4197 }
4198 case "escaped": {
4199 const overflow = await platform3.detectOverflow(state, {
4200 ...detectOverflowOptions,
4201 altBoundary: true
4202 });
4203 const offsets = getSideOffsets(overflow, rects.floating);
4204 return {
4205 data: {
4206 escapedOffsets: offsets,
4207 escaped: isAnySideFullyClipped(offsets)
4208 }
4209 };
4210 }
4211 default: {
4212 return {};
4213 }
4214 }
4215 }
4216 };
4217 };
4218 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4219 async function convertValueToCoords(state, options) {
4220 const {
4221 placement,
4222 platform: platform3,
4223 elements
4224 } = state;
4225 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4226 const side = getSide(placement);
4227 const alignment = getAlignment(placement);
4228 const isVertical = getSideAxis(placement) === "y";
4229 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4230 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4231 const rawValue = evaluate(options, state);
4232 let {
4233 mainAxis,
4234 crossAxis,
4235 alignmentAxis
4236 } = typeof rawValue === "number" ? {
4237 mainAxis: rawValue,
4238 crossAxis: 0,
4239 alignmentAxis: null
4240 } : {
4241 mainAxis: rawValue.mainAxis || 0,
4242 crossAxis: rawValue.crossAxis || 0,
4243 alignmentAxis: rawValue.alignmentAxis
4244 };
4245 if (alignment && typeof alignmentAxis === "number") {
4246 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4247 }
4248 return isVertical ? {
4249 x: crossAxis * crossAxisMulti,
4250 y: mainAxis * mainAxisMulti
4251 } : {
4252 x: mainAxis * mainAxisMulti,
4253 y: crossAxis * crossAxisMulti
4254 };
4255 }
4256 var offset = function(options) {
4257 if (options === void 0) {
4258 options = 0;
4259 }
4260 return {
4261 name: "offset",
4262 options,
4263 async fn(state) {
4264 var _middlewareData$offse, _middlewareData$arrow;
4265 const {
4266 x: x2,
4267 y: y2,
4268 placement,
4269 middlewareData
4270 } = state;
4271 const diffCoords = await convertValueToCoords(state, options);
4272 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4273 return {};
4274 }
4275 return {
4276 x: x2 + diffCoords.x,
4277 y: y2 + diffCoords.y,
4278 data: {
4279 ...diffCoords,
4280 placement
4281 }
4282 };
4283 }
4284 };
4285 };
4286 var shift = function(options) {
4287 if (options === void 0) {
4288 options = {};
4289 }
4290 return {
4291 name: "shift",
4292 options,
4293 async fn(state) {
4294 const {
4295 x: x2,
4296 y: y2,
4297 placement,
4298 platform: platform3
4299 } = state;
4300 const {
4301 mainAxis: checkMainAxis = true,
4302 crossAxis: checkCrossAxis = false,
4303 limiter = {
4304 fn: (_ref) => {
4305 let {
4306 x: x3,
4307 y: y3
4308 } = _ref;
4309 return {
4310 x: x3,
4311 y: y3
4312 };
4313 }
4314 },
4315 ...detectOverflowOptions
4316 } = evaluate(options, state);
4317 const coords = {
4318 x: x2,
4319 y: y2
4320 };
4321 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4322 const crossAxis = getSideAxis(getSide(placement));
4323 const mainAxis = getOppositeAxis(crossAxis);
4324 let mainAxisCoord = coords[mainAxis];
4325 let crossAxisCoord = coords[crossAxis];
4326 if (checkMainAxis) {
4327 const minSide = mainAxis === "y" ? "top" : "left";
4328 const maxSide = mainAxis === "y" ? "bottom" : "right";
4329 const min2 = mainAxisCoord + overflow[minSide];
4330 const max2 = mainAxisCoord - overflow[maxSide];
4331 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4332 }
4333 if (checkCrossAxis) {
4334 const minSide = crossAxis === "y" ? "top" : "left";
4335 const maxSide = crossAxis === "y" ? "bottom" : "right";
4336 const min2 = crossAxisCoord + overflow[minSide];
4337 const max2 = crossAxisCoord - overflow[maxSide];
4338 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4339 }
4340 const limitedCoords = limiter.fn({
4341 ...state,
4342 [mainAxis]: mainAxisCoord,
4343 [crossAxis]: crossAxisCoord
4344 });
4345 return {
4346 ...limitedCoords,
4347 data: {
4348 x: limitedCoords.x - x2,
4349 y: limitedCoords.y - y2,
4350 enabled: {
4351 [mainAxis]: checkMainAxis,
4352 [crossAxis]: checkCrossAxis
4353 }
4354 }
4355 };
4356 }
4357 };
4358 };
4359 var limitShift = function(options) {
4360 if (options === void 0) {
4361 options = {};
4362 }
4363 return {
4364 options,
4365 fn(state) {
4366 const {
4367 x: x2,
4368 y: y2,
4369 placement,
4370 rects,
4371 middlewareData
4372 } = state;
4373 const {
4374 offset: offset4 = 0,
4375 mainAxis: checkMainAxis = true,
4376 crossAxis: checkCrossAxis = true
4377 } = evaluate(options, state);
4378 const coords = {
4379 x: x2,
4380 y: y2
4381 };
4382 const crossAxis = getSideAxis(placement);
4383 const mainAxis = getOppositeAxis(crossAxis);
4384 let mainAxisCoord = coords[mainAxis];
4385 let crossAxisCoord = coords[crossAxis];
4386 const rawOffset = evaluate(offset4, state);
4387 const computedOffset = typeof rawOffset === "number" ? {
4388 mainAxis: rawOffset,
4389 crossAxis: 0
4390 } : {
4391 mainAxis: 0,
4392 crossAxis: 0,
4393 ...rawOffset
4394 };
4395 if (checkMainAxis) {
4396 const len = mainAxis === "y" ? "height" : "width";
4397 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4398 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4399 if (mainAxisCoord < limitMin) {
4400 mainAxisCoord = limitMin;
4401 } else if (mainAxisCoord > limitMax) {
4402 mainAxisCoord = limitMax;
4403 }
4404 }
4405 if (checkCrossAxis) {
4406 var _middlewareData$offse, _middlewareData$offse2;
4407 const len = mainAxis === "y" ? "width" : "height";
4408 const isOriginSide = originSides.has(getSide(placement));
4409 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);
4410 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);
4411 if (crossAxisCoord < limitMin) {
4412 crossAxisCoord = limitMin;
4413 } else if (crossAxisCoord > limitMax) {
4414 crossAxisCoord = limitMax;
4415 }
4416 }
4417 return {
4418 [mainAxis]: mainAxisCoord,
4419 [crossAxis]: crossAxisCoord
4420 };
4421 }
4422 };
4423 };
4424 var size = function(options) {
4425 if (options === void 0) {
4426 options = {};
4427 }
4428 return {
4429 name: "size",
4430 options,
4431 async fn(state) {
4432 var _state$middlewareData, _state$middlewareData2;
4433 const {
4434 placement,
4435 rects,
4436 platform: platform3,
4437 elements
4438 } = state;
4439 const {
4440 apply = () => {
4441 },
4442 ...detectOverflowOptions
4443 } = evaluate(options, state);
4444 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4445 const side = getSide(placement);
4446 const alignment = getAlignment(placement);
4447 const isYAxis = getSideAxis(placement) === "y";
4448 const {
4449 width,
4450 height
4451 } = rects.floating;
4452 let heightSide;
4453 let widthSide;
4454 if (side === "top" || side === "bottom") {
4455 heightSide = side;
4456 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4457 } else {
4458 widthSide = side;
4459 heightSide = alignment === "end" ? "top" : "bottom";
4460 }
4461 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4462 const maximumClippingWidth = width - overflow.left - overflow.right;
4463 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4464 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4465 const noShift = !state.middlewareData.shift;
4466 let availableHeight = overflowAvailableHeight;
4467 let availableWidth = overflowAvailableWidth;
4468 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4469 availableWidth = maximumClippingWidth;
4470 }
4471 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4472 availableHeight = maximumClippingHeight;
4473 }
4474 if (noShift && !alignment) {
4475 const xMin = max(overflow.left, 0);
4476 const xMax = max(overflow.right, 0);
4477 const yMin = max(overflow.top, 0);
4478 const yMax = max(overflow.bottom, 0);
4479 if (isYAxis) {
4480 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4481 } else {
4482 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4483 }
4484 }
4485 await apply({
4486 ...state,
4487 availableWidth,
4488 availableHeight
4489 });
4490 const nextDimensions = await platform3.getDimensions(elements.floating);
4491 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4492 return {
4493 reset: {
4494 rects: true
4495 }
4496 };
4497 }
4498 return {};
4499 }
4500 };
4501 };
4502
4503 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4504 function getCssDimensions(element) {
4505 const css = getComputedStyle2(element);
4506 let width = parseFloat(css.width) || 0;
4507 let height = parseFloat(css.height) || 0;
4508 const hasOffset = isHTMLElement(element);
4509 const offsetWidth = hasOffset ? element.offsetWidth : width;
4510 const offsetHeight = hasOffset ? element.offsetHeight : height;
4511 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4512 if (shouldFallback) {
4513 width = offsetWidth;
4514 height = offsetHeight;
4515 }
4516 return {
4517 width,
4518 height,
4519 $: shouldFallback
4520 };
4521 }
4522 function unwrapElement(element) {
4523 return !isElement(element) ? element.contextElement : element;
4524 }
4525 function getScale(element) {
4526 const domElement = unwrapElement(element);
4527 if (!isHTMLElement(domElement)) {
4528 return createCoords(1);
4529 }
4530 const rect = domElement.getBoundingClientRect();
4531 const {
4532 width,
4533 height,
4534 $: $2
4535 } = getCssDimensions(domElement);
4536 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4537 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4538 if (!x2 || !Number.isFinite(x2)) {
4539 x2 = 1;
4540 }
4541 if (!y2 || !Number.isFinite(y2)) {
4542 y2 = 1;
4543 }
4544 return {
4545 x: x2,
4546 y: y2
4547 };
4548 }
4549 var noOffsets = /* @__PURE__ */ createCoords(0);
4550 function getVisualOffsets(element) {
4551 const win = getWindow(element);
4552 if (!isWebKit() || !win.visualViewport) {
4553 return noOffsets;
4554 }
4555 return {
4556 x: win.visualViewport.offsetLeft,
4557 y: win.visualViewport.offsetTop
4558 };
4559 }
4560 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4561 if (isFixed === void 0) {
4562 isFixed = false;
4563 }
4564 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4565 return false;
4566 }
4567 return isFixed;
4568 }
4569 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4570 if (includeScale === void 0) {
4571 includeScale = false;
4572 }
4573 if (isFixedStrategy === void 0) {
4574 isFixedStrategy = false;
4575 }
4576 const clientRect = element.getBoundingClientRect();
4577 const domElement = unwrapElement(element);
4578 let scale = createCoords(1);
4579 if (includeScale) {
4580 if (offsetParent) {
4581 if (isElement(offsetParent)) {
4582 scale = getScale(offsetParent);
4583 }
4584 } else {
4585 scale = getScale(element);
4586 }
4587 }
4588 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4589 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4590 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4591 let width = clientRect.width / scale.x;
4592 let height = clientRect.height / scale.y;
4593 if (domElement) {
4594 const win = getWindow(domElement);
4595 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4596 let currentWin = win;
4597 let currentIFrame = getFrameElement(currentWin);
4598 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4599 const iframeScale = getScale(currentIFrame);
4600 const iframeRect = currentIFrame.getBoundingClientRect();
4601 const css = getComputedStyle2(currentIFrame);
4602 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4603 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4604 x2 *= iframeScale.x;
4605 y2 *= iframeScale.y;
4606 width *= iframeScale.x;
4607 height *= iframeScale.y;
4608 x2 += left;
4609 y2 += top;
4610 currentWin = getWindow(currentIFrame);
4611 currentIFrame = getFrameElement(currentWin);
4612 }
4613 }
4614 return rectToClientRect({
4615 width,
4616 height,
4617 x: x2,
4618 y: y2
4619 });
4620 }
4621 function getWindowScrollBarX(element, rect) {
4622 const leftScroll = getNodeScroll(element).scrollLeft;
4623 if (!rect) {
4624 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4625 }
4626 return rect.left + leftScroll;
4627 }
4628 function getHTMLOffset(documentElement, scroll) {
4629 const htmlRect = documentElement.getBoundingClientRect();
4630 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4631 const y2 = htmlRect.top + scroll.scrollTop;
4632 return {
4633 x: x2,
4634 y: y2
4635 };
4636 }
4637 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4638 let {
4639 elements,
4640 rect,
4641 offsetParent,
4642 strategy
4643 } = _ref;
4644 const isFixed = strategy === "fixed";
4645 const documentElement = getDocumentElement(offsetParent);
4646 const topLayer = elements ? isTopLayer(elements.floating) : false;
4647 if (offsetParent === documentElement || topLayer && isFixed) {
4648 return rect;
4649 }
4650 let scroll = {
4651 scrollLeft: 0,
4652 scrollTop: 0
4653 };
4654 let scale = createCoords(1);
4655 const offsets = createCoords(0);
4656 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4657 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4658 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4659 scroll = getNodeScroll(offsetParent);
4660 }
4661 if (isOffsetParentAnElement) {
4662 const offsetRect = getBoundingClientRect(offsetParent);
4663 scale = getScale(offsetParent);
4664 offsets.x = offsetRect.x + offsetParent.clientLeft;
4665 offsets.y = offsetRect.y + offsetParent.clientTop;
4666 }
4667 }
4668 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4669 return {
4670 width: rect.width * scale.x,
4671 height: rect.height * scale.y,
4672 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4673 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4674 };
4675 }
4676 function getClientRects(element) {
4677 return Array.from(element.getClientRects());
4678 }
4679 function getDocumentRect(element) {
4680 const html = getDocumentElement(element);
4681 const scroll = getNodeScroll(element);
4682 const body = element.ownerDocument.body;
4683 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4684 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4685 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4686 const y2 = -scroll.scrollTop;
4687 if (getComputedStyle2(body).direction === "rtl") {
4688 x2 += max(html.clientWidth, body.clientWidth) - width;
4689 }
4690 return {
4691 width,
4692 height,
4693 x: x2,
4694 y: y2
4695 };
4696 }
4697 var SCROLLBAR_MAX = 25;
4698 function getViewportRect(element, strategy) {
4699 const win = getWindow(element);
4700 const html = getDocumentElement(element);
4701 const visualViewport = win.visualViewport;
4702 let width = html.clientWidth;
4703 let height = html.clientHeight;
4704 let x2 = 0;
4705 let y2 = 0;
4706 if (visualViewport) {
4707 width = visualViewport.width;
4708 height = visualViewport.height;
4709 const visualViewportBased = isWebKit();
4710 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4711 x2 = visualViewport.offsetLeft;
4712 y2 = visualViewport.offsetTop;
4713 }
4714 }
4715 const windowScrollbarX = getWindowScrollBarX(html);
4716 if (windowScrollbarX <= 0) {
4717 const doc = html.ownerDocument;
4718 const body = doc.body;
4719 const bodyStyles = getComputedStyle(body);
4720 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4721 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4722 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4723 width -= clippingStableScrollbarWidth;
4724 }
4725 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4726 width += windowScrollbarX;
4727 }
4728 return {
4729 width,
4730 height,
4731 x: x2,
4732 y: y2
4733 };
4734 }
4735 function getInnerBoundingClientRect(element, strategy) {
4736 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4737 const top = clientRect.top + element.clientTop;
4738 const left = clientRect.left + element.clientLeft;
4739 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4740 const width = element.clientWidth * scale.x;
4741 const height = element.clientHeight * scale.y;
4742 const x2 = left * scale.x;
4743 const y2 = top * scale.y;
4744 return {
4745 width,
4746 height,
4747 x: x2,
4748 y: y2
4749 };
4750 }
4751 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4752 let rect;
4753 if (clippingAncestor === "viewport") {
4754 rect = getViewportRect(element, strategy);
4755 } else if (clippingAncestor === "document") {
4756 rect = getDocumentRect(getDocumentElement(element));
4757 } else if (isElement(clippingAncestor)) {
4758 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4759 } else {
4760 const visualOffsets = getVisualOffsets(element);
4761 rect = {
4762 x: clippingAncestor.x - visualOffsets.x,
4763 y: clippingAncestor.y - visualOffsets.y,
4764 width: clippingAncestor.width,
4765 height: clippingAncestor.height
4766 };
4767 }
4768 return rectToClientRect(rect);
4769 }
4770 function hasFixedPositionAncestor(element, stopNode) {
4771 const parentNode = getParentNode(element);
4772 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4773 return false;
4774 }
4775 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4776 }
4777 function getClippingElementAncestors(element, cache) {
4778 const cachedResult = cache.get(element);
4779 if (cachedResult) {
4780 return cachedResult;
4781 }
4782 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4783 let currentContainingBlockComputedStyle = null;
4784 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4785 let currentNode = elementIsFixed ? getParentNode(element) : element;
4786 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4787 const computedStyle = getComputedStyle2(currentNode);
4788 const currentNodeIsContaining = isContainingBlock(currentNode);
4789 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4790 currentContainingBlockComputedStyle = null;
4791 }
4792 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4793 if (shouldDropCurrentNode) {
4794 result = result.filter((ancestor) => ancestor !== currentNode);
4795 } else {
4796 currentContainingBlockComputedStyle = computedStyle;
4797 }
4798 currentNode = getParentNode(currentNode);
4799 }
4800 cache.set(element, result);
4801 return result;
4802 }
4803 function getClippingRect(_ref) {
4804 let {
4805 element,
4806 boundary,
4807 rootBoundary,
4808 strategy
4809 } = _ref;
4810 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4811 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4812 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4813 let top = firstRect.top;
4814 let right = firstRect.right;
4815 let bottom = firstRect.bottom;
4816 let left = firstRect.left;
4817 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4818 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4819 top = max(rect.top, top);
4820 right = min(rect.right, right);
4821 bottom = min(rect.bottom, bottom);
4822 left = max(rect.left, left);
4823 }
4824 return {
4825 width: right - left,
4826 height: bottom - top,
4827 x: left,
4828 y: top
4829 };
4830 }
4831 function getDimensions(element) {
4832 const {
4833 width,
4834 height
4835 } = getCssDimensions(element);
4836 return {
4837 width,
4838 height
4839 };
4840 }
4841 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4842 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4843 const documentElement = getDocumentElement(offsetParent);
4844 const isFixed = strategy === "fixed";
4845 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4846 let scroll = {
4847 scrollLeft: 0,
4848 scrollTop: 0
4849 };
4850 const offsets = createCoords(0);
4851 function setLeftRTLScrollbarOffset() {
4852 offsets.x = getWindowScrollBarX(documentElement);
4853 }
4854 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4855 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4856 scroll = getNodeScroll(offsetParent);
4857 }
4858 if (isOffsetParentAnElement) {
4859 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4860 offsets.x = offsetRect.x + offsetParent.clientLeft;
4861 offsets.y = offsetRect.y + offsetParent.clientTop;
4862 } else if (documentElement) {
4863 setLeftRTLScrollbarOffset();
4864 }
4865 }
4866 if (isFixed && !isOffsetParentAnElement && documentElement) {
4867 setLeftRTLScrollbarOffset();
4868 }
4869 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4870 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4871 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4872 return {
4873 x: x2,
4874 y: y2,
4875 width: rect.width,
4876 height: rect.height
4877 };
4878 }
4879 function isStaticPositioned(element) {
4880 return getComputedStyle2(element).position === "static";
4881 }
4882 function getTrueOffsetParent(element, polyfill) {
4883 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4884 return null;
4885 }
4886 if (polyfill) {
4887 return polyfill(element);
4888 }
4889 let rawOffsetParent = element.offsetParent;
4890 if (getDocumentElement(element) === rawOffsetParent) {
4891 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4892 }
4893 return rawOffsetParent;
4894 }
4895 function getOffsetParent(element, polyfill) {
4896 const win = getWindow(element);
4897 if (isTopLayer(element)) {
4898 return win;
4899 }
4900 if (!isHTMLElement(element)) {
4901 let svgOffsetParent = getParentNode(element);
4902 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4903 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4904 return svgOffsetParent;
4905 }
4906 svgOffsetParent = getParentNode(svgOffsetParent);
4907 }
4908 return win;
4909 }
4910 let offsetParent = getTrueOffsetParent(element, polyfill);
4911 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4912 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4913 }
4914 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4915 return win;
4916 }
4917 return offsetParent || getContainingBlock(element) || win;
4918 }
4919 var getElementRects = async function(data) {
4920 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4921 const getDimensionsFn = this.getDimensions;
4922 const floatingDimensions = await getDimensionsFn(data.floating);
4923 return {
4924 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4925 floating: {
4926 x: 0,
4927 y: 0,
4928 width: floatingDimensions.width,
4929 height: floatingDimensions.height
4930 }
4931 };
4932 };
4933 function isRTL(element) {
4934 return getComputedStyle2(element).direction === "rtl";
4935 }
4936 var platform2 = {
4937 convertOffsetParentRelativeRectToViewportRelativeRect,
4938 getDocumentElement,
4939 getClippingRect,
4940 getOffsetParent,
4941 getElementRects,
4942 getClientRects,
4943 getDimensions,
4944 getScale,
4945 isElement,
4946 isRTL
4947 };
4948 function rectsAreEqual(a2, b2) {
4949 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4950 }
4951 function observeMove(element, onMove) {
4952 let io = null;
4953 let timeoutId;
4954 const root = getDocumentElement(element);
4955 function cleanup() {
4956 var _io;
4957 clearTimeout(timeoutId);
4958 (_io = io) == null || _io.disconnect();
4959 io = null;
4960 }
4961 function refresh(skip, threshold) {
4962 if (skip === void 0) {
4963 skip = false;
4964 }
4965 if (threshold === void 0) {
4966 threshold = 1;
4967 }
4968 cleanup();
4969 const elementRectForRootMargin = element.getBoundingClientRect();
4970 const {
4971 left,
4972 top,
4973 width,
4974 height
4975 } = elementRectForRootMargin;
4976 if (!skip) {
4977 onMove();
4978 }
4979 if (!width || !height) {
4980 return;
4981 }
4982 const insetTop = floor(top);
4983 const insetRight = floor(root.clientWidth - (left + width));
4984 const insetBottom = floor(root.clientHeight - (top + height));
4985 const insetLeft = floor(left);
4986 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4987 const options = {
4988 rootMargin,
4989 threshold: max(0, min(1, threshold)) || 1
4990 };
4991 let isFirstUpdate = true;
4992 function handleObserve(entries) {
4993 const ratio = entries[0].intersectionRatio;
4994 if (ratio !== threshold) {
4995 if (!isFirstUpdate) {
4996 return refresh();
4997 }
4998 if (!ratio) {
4999 timeoutId = setTimeout(() => {
5000 refresh(false, 1e-7);
5001 }, 1e3);
5002 } else {
5003 refresh(false, ratio);
5004 }
5005 }
5006 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5007 refresh();
5008 }
5009 isFirstUpdate = false;
5010 }
5011 try {
5012 io = new IntersectionObserver(handleObserve, {
5013 ...options,
5014 // Handle <iframe>s
5015 root: root.ownerDocument
5016 });
5017 } catch (_e) {
5018 io = new IntersectionObserver(handleObserve, options);
5019 }
5020 io.observe(element);
5021 }
5022 refresh(true);
5023 return cleanup;
5024 }
5025 function autoUpdate(reference, floating, update2, options) {
5026 if (options === void 0) {
5027 options = {};
5028 }
5029 const {
5030 ancestorScroll = true,
5031 ancestorResize = true,
5032 elementResize = typeof ResizeObserver === "function",
5033 layoutShift = typeof IntersectionObserver === "function",
5034 animationFrame = false
5035 } = options;
5036 const referenceEl = unwrapElement(reference);
5037 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5038 ancestors.forEach((ancestor) => {
5039 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5040 passive: true
5041 });
5042 ancestorResize && ancestor.addEventListener("resize", update2);
5043 });
5044 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5045 let reobserveFrame = -1;
5046 let resizeObserver = null;
5047 if (elementResize) {
5048 resizeObserver = new ResizeObserver((_ref) => {
5049 let [firstEntry] = _ref;
5050 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5051 resizeObserver.unobserve(floating);
5052 cancelAnimationFrame(reobserveFrame);
5053 reobserveFrame = requestAnimationFrame(() => {
5054 var _resizeObserver;
5055 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5056 });
5057 }
5058 update2();
5059 });
5060 if (referenceEl && !animationFrame) {
5061 resizeObserver.observe(referenceEl);
5062 }
5063 if (floating) {
5064 resizeObserver.observe(floating);
5065 }
5066 }
5067 let frameId;
5068 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5069 if (animationFrame) {
5070 frameLoop();
5071 }
5072 function frameLoop() {
5073 const nextRefRect = getBoundingClientRect(reference);
5074 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5075 update2();
5076 }
5077 prevRefRect = nextRefRect;
5078 frameId = requestAnimationFrame(frameLoop);
5079 }
5080 update2();
5081 return () => {
5082 var _resizeObserver2;
5083 ancestors.forEach((ancestor) => {
5084 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5085 ancestorResize && ancestor.removeEventListener("resize", update2);
5086 });
5087 cleanupIo == null || cleanupIo();
5088 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5089 resizeObserver = null;
5090 if (animationFrame) {
5091 cancelAnimationFrame(frameId);
5092 }
5093 };
5094 }
5095 var offset2 = offset;
5096 var shift2 = shift;
5097 var flip2 = flip;
5098 var size2 = size;
5099 var hide2 = hide;
5100 var limitShift2 = limitShift;
5101 var computePosition2 = (reference, floating, options) => {
5102 const cache = /* @__PURE__ */ new Map();
5103 const mergedOptions = {
5104 platform: platform2,
5105 ...options
5106 };
5107 const platformWithCache = {
5108 ...mergedOptions.platform,
5109 _c: cache
5110 };
5111 return computePosition(reference, floating, {
5112 ...mergedOptions,
5113 platform: platformWithCache
5114 });
5115 };
5116
5117 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5118 var React20 = __toESM(require_react(), 1);
5119 var import_react2 = __toESM(require_react(), 1);
5120 var ReactDOM3 = __toESM(require_react_dom(), 1);
5121 var isClient = typeof document !== "undefined";
5122 var noop2 = function noop3() {
5123 };
5124 var index = isClient ? import_react2.useLayoutEffect : noop2;
5125 function deepEqual(a2, b2) {
5126 if (a2 === b2) {
5127 return true;
5128 }
5129 if (typeof a2 !== typeof b2) {
5130 return false;
5131 }
5132 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5133 return true;
5134 }
5135 let length;
5136 let i2;
5137 let keys;
5138 if (a2 && b2 && typeof a2 === "object") {
5139 if (Array.isArray(a2)) {
5140 length = a2.length;
5141 if (length !== b2.length) return false;
5142 for (i2 = length; i2-- !== 0; ) {
5143 if (!deepEqual(a2[i2], b2[i2])) {
5144 return false;
5145 }
5146 }
5147 return true;
5148 }
5149 keys = Object.keys(a2);
5150 length = keys.length;
5151 if (length !== Object.keys(b2).length) {
5152 return false;
5153 }
5154 for (i2 = length; i2-- !== 0; ) {
5155 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5156 return false;
5157 }
5158 }
5159 for (i2 = length; i2-- !== 0; ) {
5160 const key = keys[i2];
5161 if (key === "_owner" && a2.$$typeof) {
5162 continue;
5163 }
5164 if (!deepEqual(a2[key], b2[key])) {
5165 return false;
5166 }
5167 }
5168 return true;
5169 }
5170 return a2 !== a2 && b2 !== b2;
5171 }
5172 function getDPR(element) {
5173 if (typeof window === "undefined") {
5174 return 1;
5175 }
5176 const win = element.ownerDocument.defaultView || window;
5177 return win.devicePixelRatio || 1;
5178 }
5179 function roundByDPR(element, value) {
5180 const dpr = getDPR(element);
5181 return Math.round(value * dpr) / dpr;
5182 }
5183 function useLatestRef(value) {
5184 const ref = React20.useRef(value);
5185 index(() => {
5186 ref.current = value;
5187 });
5188 return ref;
5189 }
5190 function useFloating(options) {
5191 if (options === void 0) {
5192 options = {};
5193 }
5194 const {
5195 placement = "bottom",
5196 strategy = "absolute",
5197 middleware = [],
5198 platform: platform3,
5199 elements: {
5200 reference: externalReference,
5201 floating: externalFloating
5202 } = {},
5203 transform = true,
5204 whileElementsMounted,
5205 open
5206 } = options;
5207 const [data, setData] = React20.useState({
5208 x: 0,
5209 y: 0,
5210 strategy,
5211 placement,
5212 middlewareData: {},
5213 isPositioned: false
5214 });
5215 const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
5216 if (!deepEqual(latestMiddleware, middleware)) {
5217 setLatestMiddleware(middleware);
5218 }
5219 const [_reference, _setReference] = React20.useState(null);
5220 const [_floating, _setFloating] = React20.useState(null);
5221 const setReference = React20.useCallback((node) => {
5222 if (node !== referenceRef.current) {
5223 referenceRef.current = node;
5224 _setReference(node);
5225 }
5226 }, []);
5227 const setFloating = React20.useCallback((node) => {
5228 if (node !== floatingRef.current) {
5229 floatingRef.current = node;
5230 _setFloating(node);
5231 }
5232 }, []);
5233 const referenceEl = externalReference || _reference;
5234 const floatingEl = externalFloating || _floating;
5235 const referenceRef = React20.useRef(null);
5236 const floatingRef = React20.useRef(null);
5237 const dataRef = React20.useRef(data);
5238 const hasWhileElementsMounted = whileElementsMounted != null;
5239 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5240 const platformRef = useLatestRef(platform3);
5241 const openRef = useLatestRef(open);
5242 const update2 = React20.useCallback(() => {
5243 if (!referenceRef.current || !floatingRef.current) {
5244 return;
5245 }
5246 const config = {
5247 placement,
5248 strategy,
5249 middleware: latestMiddleware
5250 };
5251 if (platformRef.current) {
5252 config.platform = platformRef.current;
5253 }
5254 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5255 const fullData = {
5256 ...data2,
5257 // The floating element's position may be recomputed while it's closed
5258 // but still mounted (such as when transitioning out). To ensure
5259 // `isPositioned` will be `false` initially on the next open, avoid
5260 // setting it to `true` when `open === false` (must be specified).
5261 isPositioned: openRef.current !== false
5262 };
5263 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5264 dataRef.current = fullData;
5265 ReactDOM3.flushSync(() => {
5266 setData(fullData);
5267 });
5268 }
5269 });
5270 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5271 index(() => {
5272 if (open === false && dataRef.current.isPositioned) {
5273 dataRef.current.isPositioned = false;
5274 setData((data2) => ({
5275 ...data2,
5276 isPositioned: false
5277 }));
5278 }
5279 }, [open]);
5280 const isMountedRef = React20.useRef(false);
5281 index(() => {
5282 isMountedRef.current = true;
5283 return () => {
5284 isMountedRef.current = false;
5285 };
5286 }, []);
5287 index(() => {
5288 if (referenceEl) referenceRef.current = referenceEl;
5289 if (floatingEl) floatingRef.current = floatingEl;
5290 if (referenceEl && floatingEl) {
5291 if (whileElementsMountedRef.current) {
5292 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5293 }
5294 update2();
5295 }
5296 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5297 const refs = React20.useMemo(() => ({
5298 reference: referenceRef,
5299 floating: floatingRef,
5300 setReference,
5301 setFloating
5302 }), [setReference, setFloating]);
5303 const elements = React20.useMemo(() => ({
5304 reference: referenceEl,
5305 floating: floatingEl
5306 }), [referenceEl, floatingEl]);
5307 const floatingStyles = React20.useMemo(() => {
5308 const initialStyles = {
5309 position: strategy,
5310 left: 0,
5311 top: 0
5312 };
5313 if (!elements.floating) {
5314 return initialStyles;
5315 }
5316 const x2 = roundByDPR(elements.floating, data.x);
5317 const y2 = roundByDPR(elements.floating, data.y);
5318 if (transform) {
5319 return {
5320 ...initialStyles,
5321 transform: "translate(" + x2 + "px, " + y2 + "px)",
5322 ...getDPR(elements.floating) >= 1.5 && {
5323 willChange: "transform"
5324 }
5325 };
5326 }
5327 return {
5328 position: strategy,
5329 left: x2,
5330 top: y2
5331 };
5332 }, [strategy, transform, elements.floating, data.x, data.y]);
5333 return React20.useMemo(() => ({
5334 ...data,
5335 update: update2,
5336 refs,
5337 elements,
5338 floatingStyles
5339 }), [data, update2, refs, elements, floatingStyles]);
5340 }
5341 var offset3 = (options, deps) => {
5342 const result = offset2(options);
5343 return {
5344 name: result.name,
5345 fn: result.fn,
5346 options: [options, deps]
5347 };
5348 };
5349 var shift3 = (options, deps) => {
5350 const result = shift2(options);
5351 return {
5352 name: result.name,
5353 fn: result.fn,
5354 options: [options, deps]
5355 };
5356 };
5357 var limitShift3 = (options, deps) => {
5358 const result = limitShift2(options);
5359 return {
5360 fn: result.fn,
5361 options: [options, deps]
5362 };
5363 };
5364 var flip3 = (options, deps) => {
5365 const result = flip2(options);
5366 return {
5367 name: result.name,
5368 fn: result.fn,
5369 options: [options, deps]
5370 };
5371 };
5372 var size3 = (options, deps) => {
5373 const result = size2(options);
5374 return {
5375 name: result.name,
5376 fn: result.fn,
5377 options: [options, deps]
5378 };
5379 };
5380 var hide3 = (options, deps) => {
5381 const result = hide2(options);
5382 return {
5383 name: result.name,
5384 fn: result.fn,
5385 options: [options, deps]
5386 };
5387 };
5388
5389 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5390 var React25 = __toESM(require_react(), 1);
5391
5392 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5393 var React24 = __toESM(require_react(), 1);
5394
5395 // node_modules/@base-ui/utils/esm/store/createSelector.js
5396 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5397 if (other.length > 0) {
5398 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5399 }
5400 let selector2;
5401 if (a2 && b2 && c2 && d2 && e2 && f2) {
5402 selector2 = (state, a1, a22, a3) => {
5403 const va = a2(state, a1, a22, a3);
5404 const vb = b2(state, a1, a22, a3);
5405 const vc = c2(state, a1, a22, a3);
5406 const vd = d2(state, a1, a22, a3);
5407 const ve = e2(state, a1, a22, a3);
5408 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5409 };
5410 } else if (a2 && b2 && c2 && d2 && e2) {
5411 selector2 = (state, a1, a22, a3) => {
5412 const va = a2(state, a1, a22, a3);
5413 const vb = b2(state, a1, a22, a3);
5414 const vc = c2(state, a1, a22, a3);
5415 const vd = d2(state, a1, a22, a3);
5416 return e2(va, vb, vc, vd, a1, a22, a3);
5417 };
5418 } else if (a2 && b2 && c2 && d2) {
5419 selector2 = (state, a1, a22, a3) => {
5420 const va = a2(state, a1, a22, a3);
5421 const vb = b2(state, a1, a22, a3);
5422 const vc = c2(state, a1, a22, a3);
5423 return d2(va, vb, vc, a1, a22, a3);
5424 };
5425 } else if (a2 && b2 && c2) {
5426 selector2 = (state, a1, a22, a3) => {
5427 const va = a2(state, a1, a22, a3);
5428 const vb = b2(state, a1, a22, a3);
5429 return c2(va, vb, a1, a22, a3);
5430 };
5431 } else if (a2 && b2) {
5432 selector2 = (state, a1, a22, a3) => {
5433 const va = a2(state, a1, a22, a3);
5434 return b2(va, a1, a22, a3);
5435 };
5436 } else if (a2) {
5437 selector2 = a2;
5438 } else {
5439 throw (
5440 /* minify-error-disabled */
5441 new Error("Missing arguments")
5442 );
5443 }
5444 return selector2;
5445 };
5446
5447 // node_modules/@base-ui/utils/esm/store/useStore.js
5448 var React22 = __toESM(require_react(), 1);
5449 var import_shim = __toESM(require_shim(), 1);
5450 var import_with_selector = __toESM(require_with_selector(), 1);
5451
5452 // node_modules/@base-ui/utils/esm/fastHooks.js
5453 var React21 = __toESM(require_react(), 1);
5454 var hooks = [];
5455 var currentInstance = void 0;
5456 function getInstance() {
5457 return currentInstance;
5458 }
5459 function register(hook) {
5460 hooks.push(hook);
5461 }
5462 function fastComponent(fn) {
5463 const FastComponent = (props, forwardedRef) => {
5464 const instance = useRefWithInit(createInstance).current;
5465 let result;
5466 try {
5467 currentInstance = instance;
5468 for (const hook of hooks) {
5469 hook.before(instance);
5470 }
5471 result = fn(props, forwardedRef);
5472 for (const hook of hooks) {
5473 hook.after(instance);
5474 }
5475 instance.didInitialize = true;
5476 } finally {
5477 currentInstance = void 0;
5478 }
5479 return result;
5480 };
5481 FastComponent.displayName = fn.displayName || fn.name;
5482 return FastComponent;
5483 }
5484 function fastComponentRef(fn) {
5485 return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
5486 }
5487 function createInstance() {
5488 return {
5489 didInitialize: false
5490 };
5491 }
5492
5493 // node_modules/@base-ui/utils/esm/store/useStore.js
5494 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5495 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5496 function useStore(store, selector2, a1, a2, a3) {
5497 return useStoreImplementation(store, selector2, a1, a2, a3);
5498 }
5499 function useStoreR19(store, selector2, a1, a2, a3) {
5500 const getSelection = React22.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5501 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5502 }
5503 register({
5504 before(instance) {
5505 instance.syncIndex = 0;
5506 if (!instance.didInitialize) {
5507 instance.syncTick = 1;
5508 instance.syncHooks = [];
5509 instance.didChangeStore = true;
5510 instance.getSnapshot = () => {
5511 let didChange2 = false;
5512 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5513 const hook = instance.syncHooks[i2];
5514 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5515 if (hook.didChange || !Object.is(hook.value, value)) {
5516 didChange2 = true;
5517 hook.value = value;
5518 hook.didChange = false;
5519 }
5520 }
5521 if (didChange2) {
5522 instance.syncTick += 1;
5523 }
5524 return instance.syncTick;
5525 };
5526 }
5527 },
5528 after(instance) {
5529 if (instance.syncHooks.length > 0) {
5530 if (instance.didChangeStore) {
5531 instance.didChangeStore = false;
5532 instance.subscribe = (onStoreChange) => {
5533 const stores = /* @__PURE__ */ new Set();
5534 for (const hook of instance.syncHooks) {
5535 stores.add(hook.store);
5536 }
5537 const unsubscribes = [];
5538 for (const store of stores) {
5539 unsubscribes.push(store.subscribe(onStoreChange));
5540 }
5541 return () => {
5542 for (const unsubscribe of unsubscribes) {
5543 unsubscribe();
5544 }
5545 };
5546 };
5547 }
5548 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5549 }
5550 }
5551 });
5552 function useStoreFast(store, selector2, a1, a2, a3) {
5553 const instance = getInstance();
5554 if (!instance) {
5555 return useStoreR19(store, selector2, a1, a2, a3);
5556 }
5557 const index2 = instance.syncIndex;
5558 instance.syncIndex += 1;
5559 let hook;
5560 if (!instance.didInitialize) {
5561 hook = {
5562 store,
5563 selector: selector2,
5564 a1,
5565 a2,
5566 a3,
5567 value: selector2(store.getSnapshot(), a1, a2, a3),
5568 didChange: false
5569 };
5570 instance.syncHooks.push(hook);
5571 } else {
5572 hook = instance.syncHooks[index2];
5573 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5574 if (hook.store !== store) {
5575 instance.didChangeStore = true;
5576 }
5577 hook.store = store;
5578 hook.selector = selector2;
5579 hook.a1 = a1;
5580 hook.a2 = a2;
5581 hook.a3 = a3;
5582 hook.didChange = true;
5583 }
5584 }
5585 return hook.value;
5586 }
5587 function useStoreLegacy(store, selector2, a1, a2, a3) {
5588 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5589 }
5590
5591 // node_modules/@base-ui/utils/esm/store/Store.js
5592 var Store = class {
5593 /**
5594 * The current state of the store.
5595 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5596 * 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).
5597 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5598 *
5599 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5600 */
5601 // Internal state to handle recursive `setState()` calls
5602 constructor(state) {
5603 this.state = state;
5604 this.listeners = /* @__PURE__ */ new Set();
5605 this.updateTick = 0;
5606 }
5607 /**
5608 * Registers a listener that will be called whenever the store's state changes.
5609 *
5610 * @param fn The listener function to be called on state changes.
5611 * @returns A function to unsubscribe the listener.
5612 */
5613 subscribe = (fn) => {
5614 this.listeners.add(fn);
5615 return () => {
5616 this.listeners.delete(fn);
5617 };
5618 };
5619 /**
5620 * Returns the current state of the store.
5621 */
5622 getSnapshot = () => {
5623 return this.state;
5624 };
5625 /**
5626 * Updates the entire store's state and notifies all registered listeners.
5627 *
5628 * @param newState The new state to set for the store.
5629 */
5630 setState(newState) {
5631 if (this.state === newState) {
5632 return;
5633 }
5634 this.state = newState;
5635 this.updateTick += 1;
5636 const currentTick = this.updateTick;
5637 for (const listener of this.listeners) {
5638 if (currentTick !== this.updateTick) {
5639 return;
5640 }
5641 listener(newState);
5642 }
5643 }
5644 /**
5645 * Merges the provided changes into the current state and notifies listeners if there are changes.
5646 *
5647 * @param changes An object containing the changes to apply to the current state.
5648 */
5649 update(changes) {
5650 for (const key in changes) {
5651 if (!Object.is(this.state[key], changes[key])) {
5652 this.setState({
5653 ...this.state,
5654 ...changes
5655 });
5656 return;
5657 }
5658 }
5659 }
5660 /**
5661 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5662 *
5663 * @param key The key in the store's state to update.
5664 * @param value The new value to set for the specified key.
5665 */
5666 set(key, value) {
5667 if (!Object.is(this.state[key], value)) {
5668 this.setState({
5669 ...this.state,
5670 [key]: value
5671 });
5672 }
5673 }
5674 /**
5675 * Gives the state a new reference and updates all registered listeners.
5676 */
5677 notifyAll() {
5678 const newState = {
5679 ...this.state
5680 };
5681 this.setState(newState);
5682 }
5683 use(selector2, a1, a2, a3) {
5684 return useStore(this, selector2, a1, a2, a3);
5685 }
5686 };
5687
5688 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5689 var React23 = __toESM(require_react(), 1);
5690 var ReactStore = class extends Store {
5691 /**
5692 * Creates a new ReactStore instance.
5693 *
5694 * @param state Initial state of the store.
5695 * @param context Non-reactive context values.
5696 * @param selectors Optional selectors for use with `useState`.
5697 */
5698 constructor(state, context = {}, selectors3) {
5699 super(state);
5700 this.context = context;
5701 this.selectors = selectors3;
5702 }
5703 /**
5704 * Non-reactive values such as refs, callbacks, etc.
5705 */
5706 /**
5707 * Synchronizes a single external value into the store.
5708 *
5709 * Note that the while the value in `state` is updated immediately, the value returned
5710 * by `useState` is updated before the next render (similarly to React's `useState`).
5711 */
5712 useSyncedValue(key, value) {
5713 React23.useDebugValue(key);
5714 const store = this;
5715 useIsoLayoutEffect(() => {
5716 if (store.state[key] !== value) {
5717 store.set(key, value);
5718 }
5719 }, [store, key, value]);
5720 }
5721 /**
5722 * Synchronizes a single external value into the store and
5723 * cleans it up (sets to `undefined`) on unmount.
5724 *
5725 * Note that the while the value in `state` is updated immediately, the value returned
5726 * by `useState` is updated before the next render (similarly to React's `useState`).
5727 */
5728 useSyncedValueWithCleanup(key, value) {
5729 const store = this;
5730 useIsoLayoutEffect(() => {
5731 if (store.state[key] !== value) {
5732 store.set(key, value);
5733 }
5734 return () => {
5735 store.set(key, void 0);
5736 };
5737 }, [store, key, value]);
5738 }
5739 /**
5740 * Synchronizes multiple external values into the store.
5741 *
5742 * Note that the while the values in `state` are updated immediately, the values returned
5743 * by `useState` are updated before the next render (similarly to React's `useState`).
5744 */
5745 useSyncedValues(statePart) {
5746 const store = this;
5747 if (true) {
5748 React23.useDebugValue(statePart, (p2) => Object.keys(p2));
5749 const keys = React23.useRef(Object.keys(statePart)).current;
5750 const nextKeys = Object.keys(statePart);
5751 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5752 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5753 }
5754 }
5755 const dependencies = Object.values(statePart);
5756 useIsoLayoutEffect(() => {
5757 store.update(statePart);
5758 }, [store, ...dependencies]);
5759 }
5760 /**
5761 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5762 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5763 */
5764 useControlledProp(key, controlled) {
5765 React23.useDebugValue(key);
5766 const store = this;
5767 const isControlled = controlled !== void 0;
5768 useIsoLayoutEffect(() => {
5769 if (isControlled && !Object.is(store.state[key], controlled)) {
5770 store.setState({
5771 ...store.state,
5772 [key]: controlled
5773 });
5774 }
5775 }, [store, key, controlled, isControlled]);
5776 if (true) {
5777 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5778 if (!cache.has(key)) {
5779 cache.set(key, isControlled);
5780 }
5781 const previouslyControlled = cache.get(key);
5782 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5783 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).`);
5784 }
5785 }
5786 }
5787 /** Gets the current value from the store using a selector with the provided key.
5788 *
5789 * @param key Key of the selector to use.
5790 */
5791 select(key, a1, a2, a3) {
5792 const selector2 = this.selectors[key];
5793 return selector2(this.state, a1, a2, a3);
5794 }
5795 /**
5796 * Returns a value from the store's state using a selector function.
5797 * Used to subscribe to specific parts of the state.
5798 * This methods causes a rerender whenever the selected state changes.
5799 *
5800 * @param key Key of the selector to use.
5801 */
5802 useState(key, a1, a2, a3) {
5803 React23.useDebugValue(key);
5804 return useStore(this, this.selectors[key], a1, a2, a3);
5805 }
5806 /**
5807 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5808 * and assigns it to the context.
5809 *
5810 * @param key Key of the event callback. Must be a function in the context.
5811 * @param fn Function to assign.
5812 */
5813 useContextCallback(key, fn) {
5814 React23.useDebugValue(key);
5815 const stableFunction = useStableCallback(fn ?? NOOP);
5816 this.context[key] = stableFunction;
5817 }
5818 /**
5819 * Returns a stable setter function for a specific key in the store's state.
5820 * It's commonly used to pass as a ref callback to React elements.
5821 *
5822 * @param key Key of the state to set.
5823 */
5824 useStateSetter(key) {
5825 const ref = React23.useRef(void 0);
5826 if (ref.current === void 0) {
5827 ref.current = (value) => {
5828 this.set(key, value);
5829 };
5830 }
5831 return ref.current;
5832 }
5833 /**
5834 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5835 *
5836 * @param key Key of the selector to observe.
5837 * @param listener Listener function called when the selector result changes.
5838 */
5839 observe(selector2, listener) {
5840 let selectFn;
5841 if (typeof selector2 === "function") {
5842 selectFn = selector2;
5843 } else {
5844 selectFn = this.selectors[selector2];
5845 }
5846 let prevValue = selectFn(this.state);
5847 listener(prevValue, prevValue, this);
5848 return this.subscribe((nextState) => {
5849 const nextValue = selectFn(nextState);
5850 if (!Object.is(prevValue, nextValue)) {
5851 const oldValue = prevValue;
5852 prevValue = nextValue;
5853 listener(nextValue, oldValue, this);
5854 }
5855 });
5856 }
5857 };
5858
5859 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5860 var selectors = {
5861 open: createSelector((state) => state.open),
5862 transitionStatus: createSelector((state) => state.transitionStatus),
5863 domReferenceElement: createSelector((state) => state.domReferenceElement),
5864 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5865 floatingElement: createSelector((state) => state.floatingElement),
5866 floatingId: createSelector((state) => state.floatingId)
5867 };
5868 var FloatingRootStore = class extends ReactStore {
5869 constructor(options) {
5870 const {
5871 syncOnly,
5872 nested,
5873 onOpenChange,
5874 triggerElements,
5875 ...initialState
5876 } = options;
5877 super({
5878 ...initialState,
5879 positionReference: initialState.referenceElement,
5880 domReferenceElement: initialState.referenceElement
5881 }, {
5882 onOpenChange,
5883 dataRef: {
5884 current: {}
5885 },
5886 events: createEventEmitter(),
5887 nested,
5888 triggerElements
5889 }, selectors);
5890 this.syncOnly = syncOnly;
5891 }
5892 /**
5893 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5894 */
5895 syncOpenEvent = (newOpen, event) => {
5896 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5897 // click events to upgrade a hover-open.
5898 event != null && isClickLikeEvent(event)) {
5899 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5900 }
5901 };
5902 /**
5903 * Runs the root-owned side effects for an open state change.
5904 */
5905 dispatchOpenChange = (newOpen, eventDetails) => {
5906 this.syncOpenEvent(newOpen, eventDetails.event);
5907 const details = {
5908 open: newOpen,
5909 reason: eventDetails.reason,
5910 nativeEvent: eventDetails.event,
5911 nested: this.context.nested,
5912 triggerElement: eventDetails.trigger
5913 };
5914 this.context.events.emit("openchange", details);
5915 };
5916 /**
5917 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5918 *
5919 * @param newOpen The new open state.
5920 * @param eventDetails Details about the event that triggered the open state change.
5921 */
5922 setOpen = (newOpen, eventDetails) => {
5923 if (this.syncOnly) {
5924 this.context.onOpenChange?.(newOpen, eventDetails);
5925 return;
5926 }
5927 this.dispatchOpenChange(newOpen, eventDetails);
5928 this.context.onOpenChange?.(newOpen, eventDetails);
5929 };
5930 };
5931
5932 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
5933 function useSyncedFloatingRootContext(options) {
5934 const {
5935 popupStore,
5936 treatPopupAsFloatingElement = false,
5937 floatingRootContext: floatingRootContextProp,
5938 floatingId,
5939 nested,
5940 onOpenChange
5941 } = options;
5942 const open = popupStore.useState("open");
5943 const referenceElement = popupStore.useState("activeTriggerElement");
5944 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
5945 const triggerElements = popupStore.context.triggerElements;
5946 const handleOpenChange = onOpenChange;
5947 const internalStoreRef = React24.useRef(null);
5948 if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
5949 internalStoreRef.current = new FloatingRootStore({
5950 open,
5951 transitionStatus: void 0,
5952 referenceElement,
5953 floatingElement,
5954 triggerElements,
5955 onOpenChange: handleOpenChange,
5956 floatingId,
5957 syncOnly: true,
5958 nested
5959 });
5960 }
5961 const store = floatingRootContextProp ?? internalStoreRef.current;
5962 popupStore.useSyncedValue("floatingId", floatingId);
5963 useIsoLayoutEffect(() => {
5964 const valuesToSync = {
5965 open,
5966 floatingId,
5967 referenceElement,
5968 floatingElement
5969 };
5970 if (isElement(referenceElement)) {
5971 valuesToSync.domReferenceElement = referenceElement;
5972 }
5973 if (store.state.positionReference === store.state.referenceElement) {
5974 valuesToSync.positionReference = referenceElement;
5975 }
5976 store.update(valuesToSync);
5977 }, [open, floatingId, referenceElement, floatingElement, store]);
5978 store.context.onOpenChange = handleOpenChange;
5979 store.context.nested = nested;
5980 return store;
5981 }
5982
5983 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5984 var FOCUSABLE_POPUP_PROPS = {
5985 tabIndex: -1,
5986 [FOCUSABLE_ATTRIBUTE]: ""
5987 };
5988 function usePopupStore(externalStore, createStore2, treatPopupAsFloatingElement = false) {
5989 const floatingId = useId();
5990 const nested = useFloatingParentNodeId() != null;
5991 const internalStoreRef = React25.useRef(null);
5992 if (externalStore === void 0 && internalStoreRef.current === null) {
5993 internalStoreRef.current = createStore2(floatingId, nested);
5994 }
5995 const store = externalStore ?? internalStoreRef.current;
5996 useSyncedFloatingRootContext({
5997 popupStore: store,
5998 treatPopupAsFloatingElement,
5999 floatingRootContext: store.state.floatingRootContext,
6000 floatingId,
6001 nested,
6002 onOpenChange: store.setOpen
6003 });
6004 return {
6005 store,
6006 internalStore: internalStoreRef.current
6007 };
6008 }
6009 function useTriggerRegistration(id, store) {
6010 const registeredElementIdRef = React25.useRef(null);
6011 const registeredElementRef = React25.useRef(null);
6012 return React25.useCallback((element) => {
6013 if (id === void 0) {
6014 return;
6015 }
6016 let shouldSyncTriggerCount = false;
6017 if (registeredElementIdRef.current !== null) {
6018 const registeredId = registeredElementIdRef.current;
6019 const registeredElement = registeredElementRef.current;
6020 const currentElement = store.context.triggerElements.getById(registeredId);
6021 if (registeredElement && currentElement === registeredElement) {
6022 store.context.triggerElements.delete(registeredId);
6023 shouldSyncTriggerCount = true;
6024 }
6025 registeredElementIdRef.current = null;
6026 registeredElementRef.current = null;
6027 }
6028 if (element !== null) {
6029 registeredElementIdRef.current = id;
6030 registeredElementRef.current = element;
6031 store.context.triggerElements.add(id, element);
6032 shouldSyncTriggerCount = true;
6033 }
6034 if (shouldSyncTriggerCount) {
6035 const triggerCount = store.context.triggerElements.size;
6036 if (store.select("open") && store.state.triggerCount !== triggerCount) {
6037 store.set("triggerCount", triggerCount);
6038 }
6039 }
6040 }, [store, id]);
6041 }
6042 function setOpenTriggerState(state, open, trigger) {
6043 const triggerId = trigger?.id ?? null;
6044 if (triggerId || open) {
6045 state.activeTriggerId = triggerId;
6046 state.activeTriggerElement = trigger ?? null;
6047 }
6048 }
6049 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
6050 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
6051 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
6052 const registerTrigger = useStableCallback((element) => {
6053 baseRegisterTrigger(element);
6054 if (!element) {
6055 return;
6056 }
6057 const open = store.select("open");
6058 const activeTriggerId = store.select("activeTriggerId");
6059 if (activeTriggerId === triggerId) {
6060 store.update({
6061 activeTriggerElement: element,
6062 ...open ? stateUpdates : null
6063 });
6064 return;
6065 }
6066 if (activeTriggerId == null && open) {
6067 store.update({
6068 activeTriggerId: triggerId,
6069 activeTriggerElement: element,
6070 ...stateUpdates
6071 });
6072 }
6073 });
6074 useIsoLayoutEffect(() => {
6075 if (isMountedByThisTrigger) {
6076 store.update({
6077 activeTriggerElement: triggerElementRef.current,
6078 ...stateUpdates
6079 });
6080 }
6081 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
6082 return {
6083 registerTrigger,
6084 isMountedByThisTrigger
6085 };
6086 }
6087 function useImplicitActiveTrigger(store) {
6088 const open = store.useState("open");
6089 const reactiveTriggerCount = store.useState("triggerCount");
6090 useIsoLayoutEffect(() => {
6091 if (!open) {
6092 if (store.state.triggerCount !== 0) {
6093 store.set("triggerCount", 0);
6094 }
6095 return;
6096 }
6097 const triggerCount = store.context.triggerElements.size;
6098 const stateUpdates = {};
6099 if (store.state.triggerCount !== triggerCount) {
6100 stateUpdates.triggerCount = triggerCount;
6101 }
6102 if (!store.select("activeTriggerId") && triggerCount === 1) {
6103 const iteratorResult = store.context.triggerElements.entries().next();
6104 if (!iteratorResult.done) {
6105 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
6106 stateUpdates.activeTriggerId = implicitTriggerId;
6107 stateUpdates.activeTriggerElement = implicitTriggerElement;
6108 }
6109 }
6110 if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0) {
6111 store.update(stateUpdates);
6112 }
6113 }, [open, store, reactiveTriggerCount]);
6114 }
6115 function useOpenStateTransitions(open, store, onUnmount) {
6116 const {
6117 mounted,
6118 setMounted,
6119 transitionStatus
6120 } = useTransitionStatus(open);
6121 store.useSyncedValues({
6122 mounted,
6123 transitionStatus
6124 });
6125 const forceUnmount = useStableCallback(() => {
6126 setMounted(false);
6127 store.update({
6128 activeTriggerId: null,
6129 activeTriggerElement: null,
6130 mounted: false,
6131 preventUnmountingOnClose: false
6132 });
6133 onUnmount?.();
6134 store.context.onOpenChangeComplete?.(false);
6135 });
6136 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6137 useOpenChangeComplete({
6138 enabled: mounted && !open && !preventUnmountingOnClose,
6139 open,
6140 ref: store.context.popupRef,
6141 onComplete() {
6142 if (!open) {
6143 forceUnmount();
6144 }
6145 }
6146 });
6147 return {
6148 forceUnmount,
6149 transitionStatus
6150 };
6151 }
6152 function usePopupInteractionProps(store, statePart) {
6153 store.useSyncedValues(statePart);
6154 useIsoLayoutEffect(() => () => {
6155 store.update({
6156 activeTriggerProps: EMPTY_OBJECT,
6157 inactiveTriggerProps: EMPTY_OBJECT,
6158 popupProps: EMPTY_OBJECT
6159 });
6160 }, [store]);
6161 }
6162
6163 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6164 var PopupTriggerMap = class {
6165 constructor() {
6166 this.elementsSet = /* @__PURE__ */ new Set();
6167 this.idMap = /* @__PURE__ */ new Map();
6168 }
6169 /**
6170 * Adds a trigger element with the given ID.
6171 *
6172 * Note: The provided element is assumed to not be registered under multiple IDs.
6173 */
6174 add(id, element) {
6175 const existingElement = this.idMap.get(id);
6176 if (existingElement === element) {
6177 return;
6178 }
6179 if (existingElement !== void 0) {
6180 this.elementsSet.delete(existingElement);
6181 }
6182 this.elementsSet.add(element);
6183 this.idMap.set(id, element);
6184 if (true) {
6185 if (this.elementsSet.size !== this.idMap.size) {
6186 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6187 }
6188 }
6189 }
6190 /**
6191 * Removes the trigger element with the given ID.
6192 */
6193 delete(id) {
6194 const element = this.idMap.get(id);
6195 if (element) {
6196 this.elementsSet.delete(element);
6197 this.idMap.delete(id);
6198 }
6199 }
6200 /**
6201 * Whether the given element is registered as a trigger.
6202 */
6203 hasElement(element) {
6204 return this.elementsSet.has(element);
6205 }
6206 /**
6207 * Whether there is a registered trigger element matching the given predicate.
6208 */
6209 hasMatchingElement(predicate) {
6210 for (const element of this.elementsSet) {
6211 if (predicate(element)) {
6212 return true;
6213 }
6214 }
6215 return false;
6216 }
6217 /**
6218 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6219 */
6220 getById(id) {
6221 return this.idMap.get(id);
6222 }
6223 /**
6224 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6225 */
6226 entries() {
6227 return this.idMap.entries();
6228 }
6229 /**
6230 * Returns an iterable of all registered trigger elements.
6231 */
6232 elements() {
6233 return this.elementsSet.values();
6234 }
6235 /**
6236 * Returns the number of registered trigger elements.
6237 */
6238 get size() {
6239 return this.idMap.size;
6240 }
6241 };
6242
6243 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6244 function getEmptyRootContext() {
6245 return new FloatingRootStore({
6246 open: false,
6247 transitionStatus: void 0,
6248 floatingElement: null,
6249 referenceElement: null,
6250 triggerElements: new PopupTriggerMap(),
6251 floatingId: void 0,
6252 syncOnly: false,
6253 nested: false,
6254 onOpenChange: void 0
6255 });
6256 }
6257
6258 // node_modules/@base-ui/react/esm/utils/popups/store.js
6259 function createInitialPopupStoreState() {
6260 return {
6261 open: false,
6262 openProp: void 0,
6263 mounted: false,
6264 transitionStatus: void 0,
6265 floatingRootContext: getEmptyRootContext(),
6266 floatingId: void 0,
6267 triggerCount: 0,
6268 preventUnmountingOnClose: false,
6269 payload: void 0,
6270 activeTriggerId: null,
6271 activeTriggerElement: null,
6272 triggerIdProp: void 0,
6273 popupElement: null,
6274 positionerElement: null,
6275 activeTriggerProps: EMPTY_OBJECT,
6276 inactiveTriggerProps: EMPTY_OBJECT,
6277 popupProps: EMPTY_OBJECT
6278 };
6279 }
6280 function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
6281 return new FloatingRootStore({
6282 open: false,
6283 transitionStatus: void 0,
6284 floatingElement: null,
6285 referenceElement: null,
6286 triggerElements,
6287 floatingId,
6288 syncOnly: true,
6289 nested,
6290 onOpenChange: void 0
6291 });
6292 }
6293 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6294 var openSelector = createSelector((state) => state.openProp ?? state.open);
6295 var popupIdSelector = createSelector((state) => {
6296 const popupId = state.popupElement?.id ?? state.floatingId;
6297 return popupId || void 0;
6298 });
6299 function triggerOwnsOpenPopup(state, triggerId) {
6300 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
6301 }
6302 function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
6303 if (triggerOwnsOpenPopup(state, triggerId)) {
6304 return true;
6305 }
6306 return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
6307 }
6308 var popupStoreSelectors = {
6309 open: openSelector,
6310 mounted: createSelector((state) => state.mounted),
6311 transitionStatus: createSelector((state) => state.transitionStatus),
6312 floatingRootContext: createSelector((state) => state.floatingRootContext),
6313 triggerCount: createSelector((state) => state.triggerCount),
6314 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6315 payload: createSelector((state) => state.payload),
6316 activeTriggerId: activeTriggerIdSelector,
6317 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6318 popupId: popupIdSelector,
6319 /**
6320 * Whether the trigger with the given ID was used to open the popup.
6321 */
6322 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6323 /**
6324 * Whether the popup is open and was activated by a trigger with the given ID.
6325 */
6326 isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
6327 /**
6328 * Whether the popup is mounted and was activated by a trigger with the given ID.
6329 */
6330 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6331 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6332 /**
6333 * Popup id for the trigger that currently owns the open popup.
6334 */
6335 triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
6336 popupProps: createSelector((state) => state.popupProps),
6337 popupElement: createSelector((state) => state.popupElement),
6338 positionerElement: createSelector((state) => state.positionerElement)
6339 };
6340
6341 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6342 function useFloatingRootContext(options) {
6343 const {
6344 open = false,
6345 onOpenChange,
6346 elements = {}
6347 } = options;
6348 const floatingId = useId();
6349 const nested = useFloatingParentNodeId() != null;
6350 if (true) {
6351 const optionDomReference = elements.reference;
6352 if (optionDomReference && !isElement(optionDomReference)) {
6353 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6354 }
6355 }
6356 const store = useRefWithInit(() => new FloatingRootStore({
6357 open,
6358 transitionStatus: void 0,
6359 onOpenChange,
6360 referenceElement: elements.reference ?? null,
6361 floatingElement: elements.floating ?? null,
6362 triggerElements: new PopupTriggerMap(),
6363 floatingId,
6364 syncOnly: false,
6365 nested
6366 })).current;
6367 useIsoLayoutEffect(() => {
6368 const valuesToSync = {
6369 open,
6370 floatingId
6371 };
6372 if (elements.reference !== void 0) {
6373 valuesToSync.referenceElement = elements.reference;
6374 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6375 }
6376 if (elements.floating !== void 0) {
6377 valuesToSync.floatingElement = elements.floating;
6378 }
6379 store.update(valuesToSync);
6380 }, [open, floatingId, elements.reference, elements.floating, store]);
6381 store.context.onOpenChange = onOpenChange;
6382 store.context.nested = nested;
6383 return store;
6384 }
6385
6386 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6387 function useFloating2(options = {}) {
6388 const {
6389 nodeId,
6390 externalTree
6391 } = options;
6392 const internalStore = useFloatingRootContext(options);
6393 const store = options.rootContext || internalStore;
6394 const referenceElement = store.useState("referenceElement");
6395 const floatingElement = store.useState("floatingElement");
6396 const domReferenceElement = store.useState("domReferenceElement");
6397 const open = store.useState("open");
6398 const floatingId = store.useState("floatingId");
6399 const [positionReference, setPositionReferenceRaw] = React26.useState(null);
6400 const [localDomReference, setLocalDomReference] = React26.useState(void 0);
6401 const [localFloatingElement, setLocalFloatingElement] = React26.useState(void 0);
6402 const domReferenceRef = React26.useRef(null);
6403 const tree = useFloatingTree(externalTree);
6404 const storeElements = React26.useMemo(() => ({
6405 reference: referenceElement,
6406 floating: floatingElement,
6407 domReference: domReferenceElement
6408 }), [referenceElement, floatingElement, domReferenceElement]);
6409 const position = useFloating({
6410 ...options,
6411 elements: {
6412 ...storeElements,
6413 ...positionReference && {
6414 reference: positionReference
6415 }
6416 }
6417 });
6418 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6419 const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
6420 store.useSyncedValue("referenceElement", localDomReference ?? null);
6421 store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
6422 store.useSyncedValue("floatingElement", syncedFloatingElement);
6423 const setPositionReference = React26.useCallback((node) => {
6424 const computedPositionReference = isElement(node) ? {
6425 getBoundingClientRect: () => node.getBoundingClientRect(),
6426 getClientRects: () => node.getClientRects(),
6427 contextElement: node
6428 } : node;
6429 setPositionReferenceRaw(computedPositionReference);
6430 position.refs.setReference(computedPositionReference);
6431 }, [position.refs]);
6432 const setReference = React26.useCallback((node) => {
6433 if (isElement(node) || node === null) {
6434 domReferenceRef.current = node;
6435 setLocalDomReference(node);
6436 }
6437 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6438 // `null` to support `positionReference` + an unstable `reference`
6439 // callback ref.
6440 node !== null && !isElement(node)) {
6441 position.refs.setReference(node);
6442 }
6443 }, [position.refs, setLocalDomReference]);
6444 const setFloating = React26.useCallback((node) => {
6445 setLocalFloatingElement(node);
6446 position.refs.setFloating(node);
6447 }, [position.refs]);
6448 const refs = React26.useMemo(() => ({
6449 ...position.refs,
6450 setReference,
6451 setFloating,
6452 setPositionReference,
6453 domReference: domReferenceRef
6454 }), [position.refs, setReference, setFloating, setPositionReference]);
6455 const elements = React26.useMemo(() => ({
6456 ...position.elements,
6457 domReference: domReferenceElement
6458 }), [position.elements, domReferenceElement]);
6459 const context = React26.useMemo(() => ({
6460 ...position,
6461 dataRef: store.context.dataRef,
6462 open,
6463 onOpenChange: store.setOpen,
6464 events: store.context.events,
6465 floatingId,
6466 refs,
6467 elements,
6468 nodeId,
6469 rootStore: store
6470 }), [position, refs, elements, nodeId, store, open, floatingId]);
6471 useIsoLayoutEffect(() => {
6472 if (domReferenceElement) {
6473 domReferenceRef.current = domReferenceElement;
6474 }
6475 }, [domReferenceElement]);
6476 useIsoLayoutEffect(() => {
6477 store.context.dataRef.current.floatingContext = context;
6478 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6479 if (node) {
6480 node.context = context;
6481 }
6482 });
6483 return React26.useMemo(() => ({
6484 ...position,
6485 context,
6486 refs,
6487 elements,
6488 rootStore: store
6489 }), [position, refs, elements, context, store]);
6490 }
6491
6492 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6493 var React27 = __toESM(require_react(), 1);
6494 var isMacSafari = isMac && isSafari;
6495 function useFocus(context, props = {}) {
6496 const {
6497 enabled = true,
6498 delay
6499 } = props;
6500 const store = "rootStore" in context ? context.rootStore : context;
6501 const {
6502 events,
6503 dataRef
6504 } = store.context;
6505 const blockFocusRef = React27.useRef(false);
6506 const blockedReferenceRef = React27.useRef(null);
6507 const keyboardModalityRef = React27.useRef(true);
6508 const timeout = useTimeout();
6509 React27.useEffect(() => {
6510 const domReference = store.select("domReferenceElement");
6511 if (!enabled) {
6512 return void 0;
6513 }
6514 const win = getWindow(domReference);
6515 function onBlur() {
6516 const currentDomReference = store.select("domReferenceElement");
6517 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6518 blockFocusRef.current = true;
6519 }
6520 }
6521 function onKeyDown() {
6522 keyboardModalityRef.current = true;
6523 }
6524 function onPointerDown() {
6525 keyboardModalityRef.current = false;
6526 }
6527 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6528 }, [store, enabled]);
6529 React27.useEffect(() => {
6530 if (!enabled) {
6531 return void 0;
6532 }
6533 function onOpenChangeLocal(details) {
6534 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6535 const referenceElement = store.select("domReferenceElement");
6536 if (isElement(referenceElement)) {
6537 blockedReferenceRef.current = referenceElement;
6538 blockFocusRef.current = true;
6539 }
6540 }
6541 }
6542 events.on("openchange", onOpenChangeLocal);
6543 return () => {
6544 events.off("openchange", onOpenChangeLocal);
6545 };
6546 }, [events, enabled, store]);
6547 const reference = React27.useMemo(() => {
6548 function resetBlockedFocus() {
6549 blockFocusRef.current = false;
6550 blockedReferenceRef.current = null;
6551 }
6552 return {
6553 onMouseLeave() {
6554 resetBlockedFocus();
6555 },
6556 onFocus(event) {
6557 const focusTarget = event.currentTarget;
6558 if (blockFocusRef.current) {
6559 if (blockedReferenceRef.current === focusTarget) {
6560 return;
6561 }
6562 resetBlockedFocus();
6563 }
6564 const target = getTarget(event.nativeEvent);
6565 if (isElement(target)) {
6566 if (isMacSafari && !event.relatedTarget) {
6567 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6568 return;
6569 }
6570 } else if (!matchesFocusVisible(target)) {
6571 return;
6572 }
6573 }
6574 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6575 const {
6576 nativeEvent,
6577 currentTarget
6578 } = event;
6579 const delayValue = typeof delay === "function" ? delay() : delay;
6580 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6581 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6582 return;
6583 }
6584 timeout.start(delayValue, () => {
6585 if (blockFocusRef.current) {
6586 return;
6587 }
6588 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6589 });
6590 },
6591 onBlur(event) {
6592 resetBlockedFocus();
6593 const relatedTarget = event.relatedTarget;
6594 const nativeEvent = event.nativeEvent;
6595 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6596 timeout.start(0, () => {
6597 const domReference = store.select("domReferenceElement");
6598 const activeEl = activeElement(ownerDocument(domReference));
6599 if (!relatedTarget && activeEl === domReference) {
6600 return;
6601 }
6602 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6603 return;
6604 }
6605 const nextFocusedElement = relatedTarget ?? activeEl;
6606 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6607 return;
6608 }
6609 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6610 });
6611 }
6612 };
6613 }, [dataRef, delay, store, timeout]);
6614 return React27.useMemo(() => enabled ? {
6615 reference,
6616 trigger: reference
6617 } : {}, [enabled, reference]);
6618 }
6619
6620 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6621 var React28 = __toESM(require_react(), 1);
6622
6623 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6624 var HoverInteraction = class _HoverInteraction {
6625 constructor() {
6626 this.pointerType = void 0;
6627 this.interactedInside = false;
6628 this.handler = void 0;
6629 this.blockMouseMove = true;
6630 this.performedPointerEventsMutation = false;
6631 this.pointerEventsScopeElement = null;
6632 this.pointerEventsReferenceElement = null;
6633 this.pointerEventsFloatingElement = null;
6634 this.restTimeoutPending = false;
6635 this.openChangeTimeout = new Timeout();
6636 this.restTimeout = new Timeout();
6637 this.handleCloseOptions = void 0;
6638 }
6639 static create() {
6640 return new _HoverInteraction();
6641 }
6642 dispose = () => {
6643 this.openChangeTimeout.clear();
6644 this.restTimeout.clear();
6645 };
6646 disposeEffect = () => {
6647 return this.dispose;
6648 };
6649 };
6650 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6651 function clearSafePolygonPointerEventsMutation(instance) {
6652 if (!instance.performedPointerEventsMutation) {
6653 return;
6654 }
6655 const scopeElement = instance.pointerEventsScopeElement;
6656 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6657 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6658 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6659 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6660 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6661 }
6662 instance.performedPointerEventsMutation = false;
6663 instance.pointerEventsScopeElement = null;
6664 instance.pointerEventsReferenceElement = null;
6665 instance.pointerEventsFloatingElement = null;
6666 }
6667 function applySafePolygonPointerEventsMutation(instance, options) {
6668 const {
6669 scopeElement,
6670 referenceElement,
6671 floatingElement
6672 } = options;
6673 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6674 if (existingOwner && existingOwner !== instance) {
6675 clearSafePolygonPointerEventsMutation(existingOwner);
6676 }
6677 clearSafePolygonPointerEventsMutation(instance);
6678 instance.performedPointerEventsMutation = true;
6679 instance.pointerEventsScopeElement = scopeElement;
6680 instance.pointerEventsReferenceElement = referenceElement;
6681 instance.pointerEventsFloatingElement = floatingElement;
6682 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6683 scopeElement.style.pointerEvents = "none";
6684 referenceElement.style.pointerEvents = "auto";
6685 floatingElement.style.pointerEvents = "auto";
6686 }
6687 function useHoverInteractionSharedState(store) {
6688 const data = store.context.dataRef.current;
6689 const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
6690 if (!data.hoverInteractionState) {
6691 data.hoverInteractionState = instance;
6692 }
6693 useOnMount(data.hoverInteractionState.disposeEffect);
6694 return data.hoverInteractionState;
6695 }
6696
6697 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6698 function useHoverFloatingInteraction(context, parameters = {}) {
6699 const {
6700 enabled = true,
6701 closeDelay: closeDelayProp = 0,
6702 nodeId: nodeIdProp
6703 } = parameters;
6704 const store = "rootStore" in context ? context.rootStore : context;
6705 const open = store.useState("open");
6706 const floatingElement = store.useState("floatingElement");
6707 const domReferenceElement = store.useState("domReferenceElement");
6708 const {
6709 dataRef
6710 } = store.context;
6711 const tree = useFloatingTree();
6712 const parentId = useFloatingParentNodeId();
6713 const instance = useHoverInteractionSharedState(store);
6714 const childClosedTimeout = useTimeout();
6715 const isClickLikeOpenEvent2 = useStableCallback(() => {
6716 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6717 });
6718 const isHoverOpen = useStableCallback(() => {
6719 return isHoverOpenEvent(dataRef.current.openEvent?.type);
6720 });
6721 const clearPointerEvents = useStableCallback(() => {
6722 clearSafePolygonPointerEventsMutation(instance);
6723 });
6724 useIsoLayoutEffect(() => {
6725 if (!open) {
6726 instance.pointerType = void 0;
6727 instance.restTimeoutPending = false;
6728 instance.interactedInside = false;
6729 clearPointerEvents();
6730 }
6731 }, [open, instance, clearPointerEvents]);
6732 React28.useEffect(() => {
6733 return clearPointerEvents;
6734 }, [clearPointerEvents]);
6735 useIsoLayoutEffect(() => {
6736 if (!enabled) {
6737 return void 0;
6738 }
6739 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6740 const ref = domReferenceElement;
6741 const floatingEl = floatingElement;
6742 const doc = ownerDocument(floatingElement);
6743 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6744 if (parentFloating) {
6745 parentFloating.style.pointerEvents = "";
6746 }
6747 const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
6748 const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
6749 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
6750 applySafePolygonPointerEventsMutation(instance, {
6751 scopeElement,
6752 referenceElement: ref,
6753 floatingElement: floatingEl
6754 });
6755 return () => {
6756 clearPointerEvents();
6757 };
6758 }
6759 return void 0;
6760 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6761 React28.useEffect(() => {
6762 if (!enabled) {
6763 return void 0;
6764 }
6765 function hasParentChildren() {
6766 return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
6767 }
6768 function closeWithDelay(event) {
6769 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6770 const close = () => {
6771 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6772 tree?.events.emit("floating.closed", event);
6773 };
6774 if (closeDelay) {
6775 instance.openChangeTimeout.start(closeDelay, close);
6776 } else {
6777 instance.openChangeTimeout.clear();
6778 close();
6779 }
6780 }
6781 function handleInteractInside(event) {
6782 const target = getTarget(event);
6783 if (!isInteractiveElement(target)) {
6784 instance.interactedInside = false;
6785 return;
6786 }
6787 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6788 }
6789 function onFloatingMouseEnter() {
6790 instance.openChangeTimeout.clear();
6791 childClosedTimeout.clear();
6792 tree?.events.off("floating.closed", onNodeClosed);
6793 clearPointerEvents();
6794 }
6795 function onFloatingMouseLeave(event) {
6796 if (hasParentChildren() && tree) {
6797 tree.events.on("floating.closed", onNodeClosed);
6798 return;
6799 }
6800 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
6801 return;
6802 }
6803 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6804 const relatedTarget = event.relatedTarget;
6805 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6806 if (isMovingIntoDescendantFloating) {
6807 return;
6808 }
6809 if (instance.handler) {
6810 instance.handler(event);
6811 return;
6812 }
6813 clearPointerEvents();
6814 if (!isClickLikeOpenEvent2()) {
6815 closeWithDelay(event);
6816 }
6817 }
6818 function onNodeClosed(event) {
6819 if (!tree || !parentId || hasParentChildren()) {
6820 return;
6821 }
6822 childClosedTimeout.start(0, () => {
6823 tree.events.off("floating.closed", onNodeClosed);
6824 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6825 tree.events.emit("floating.closed", event);
6826 });
6827 }
6828 const floating = floatingElement;
6829 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6830 tree?.events.off("floating.closed", onNodeClosed);
6831 });
6832 }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
6833 }
6834
6835 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6836 var React29 = __toESM(require_react(), 1);
6837 var ReactDOM4 = __toESM(require_react_dom(), 1);
6838 var EMPTY_REF = {
6839 current: null
6840 };
6841 function useHoverReferenceInteraction(context, props = {}) {
6842 const {
6843 enabled = true,
6844 delay = 0,
6845 handleClose = null,
6846 mouseOnly = false,
6847 restMs = 0,
6848 move = true,
6849 triggerElementRef = EMPTY_REF,
6850 externalTree,
6851 isActiveTrigger = true,
6852 getHandleCloseContext,
6853 isClosing,
6854 shouldOpen: shouldOpenProp
6855 } = props;
6856 const store = "rootStore" in context ? context.rootStore : context;
6857 const {
6858 dataRef,
6859 events
6860 } = store.context;
6861 const tree = useFloatingTree(externalTree);
6862 const instance = useHoverInteractionSharedState(store);
6863 const isHoverCloseActiveRef = React29.useRef(false);
6864 const handleCloseRef = useValueAsRef(handleClose);
6865 const delayRef = useValueAsRef(delay);
6866 const restMsRef = useValueAsRef(restMs);
6867 const enabledRef = useValueAsRef(enabled);
6868 const shouldOpenRef = useValueAsRef(shouldOpenProp);
6869 const isClosingRef = useValueAsRef(isClosing);
6870 const isClickLikeOpenEvent2 = useStableCallback(() => {
6871 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6872 });
6873 const checkShouldOpen = useStableCallback(() => {
6874 return shouldOpenRef.current?.() !== false;
6875 });
6876 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6877 const allTriggers = store.context.triggerElements;
6878 if (allTriggers.hasElement(currentTarget)) {
6879 return !currentDomReference || !contains(currentDomReference, currentTarget);
6880 }
6881 if (!isElement(target)) {
6882 return false;
6883 }
6884 const targetElement = target;
6885 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6886 });
6887 const cleanupMouseMoveHandler = useStableCallback(() => {
6888 if (!instance.handler) {
6889 return;
6890 }
6891 const doc = ownerDocument(store.select("domReferenceElement"));
6892 doc.removeEventListener("mousemove", instance.handler);
6893 instance.handler = void 0;
6894 });
6895 const clearPointerEvents = useStableCallback(() => {
6896 clearSafePolygonPointerEventsMutation(instance);
6897 });
6898 if (isActiveTrigger) {
6899 instance.handleCloseOptions = handleCloseRef.current?.__options;
6900 }
6901 React29.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6902 React29.useEffect(() => {
6903 if (!enabled) {
6904 return void 0;
6905 }
6906 function onOpenChangeLocal(details) {
6907 if (!details.open) {
6908 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6909 cleanupMouseMoveHandler();
6910 instance.openChangeTimeout.clear();
6911 instance.restTimeout.clear();
6912 instance.blockMouseMove = true;
6913 instance.restTimeoutPending = false;
6914 } else {
6915 isHoverCloseActiveRef.current = false;
6916 }
6917 }
6918 events.on("openchange", onOpenChangeLocal);
6919 return () => {
6920 events.off("openchange", onOpenChangeLocal);
6921 };
6922 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6923 React29.useEffect(() => {
6924 if (!enabled) {
6925 return void 0;
6926 }
6927 function closeWithDelay(event, runElseBranch = true) {
6928 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6929 if (closeDelay) {
6930 instance.openChangeTimeout.start(closeDelay, () => {
6931 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6932 tree?.events.emit("floating.closed", event);
6933 });
6934 } else if (runElseBranch) {
6935 instance.openChangeTimeout.clear();
6936 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6937 tree?.events.emit("floating.closed", event);
6938 }
6939 }
6940 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6941 if (!isElement(trigger)) {
6942 return void 0;
6943 }
6944 function onMouseEnter(event) {
6945 instance.openChangeTimeout.clear();
6946 instance.blockMouseMove = false;
6947 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6948 return;
6949 }
6950 const restMsValue = getRestMs(restMsRef.current);
6951 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6952 const eventTarget = getTarget(event);
6953 const currentTarget = event.currentTarget ?? null;
6954 const currentDomReference = store.select("domReferenceElement");
6955 let triggerNode = currentTarget;
6956 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6957 for (const triggerElement of store.context.triggerElements.elements()) {
6958 if (contains(triggerElement, eventTarget)) {
6959 triggerNode = triggerElement;
6960 break;
6961 }
6962 }
6963 }
6964 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6965 triggerNode = currentDomReference;
6966 }
6967 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6968 const isOpen = store.select("open");
6969 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6970 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6971 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6972 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6973 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6974 const shouldOpen = !isOpen || isOverInactive;
6975 if (shouldOpenImmediately) {
6976 if (checkShouldOpen()) {
6977 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6978 }
6979 return;
6980 }
6981 if (isRestOnlyDelay) {
6982 return;
6983 }
6984 if (openDelay) {
6985 instance.openChangeTimeout.start(openDelay, () => {
6986 if (shouldOpen && checkShouldOpen()) {
6987 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6988 }
6989 });
6990 } else if (shouldOpen) {
6991 if (checkShouldOpen()) {
6992 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6993 }
6994 }
6995 }
6996 function onMouseLeave(event) {
6997 if (isClickLikeOpenEvent2()) {
6998 clearPointerEvents();
6999 return;
7000 }
7001 cleanupMouseMoveHandler();
7002 const domReferenceElement = store.select("domReferenceElement");
7003 const doc = ownerDocument(domReferenceElement);
7004 instance.restTimeout.clear();
7005 instance.restTimeoutPending = false;
7006 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
7007 if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
7008 return;
7009 }
7010 if (handleCloseRef.current && handleCloseContextBase) {
7011 if (!store.select("open")) {
7012 instance.openChangeTimeout.clear();
7013 }
7014 const currentTrigger = triggerElementRef.current;
7015 instance.handler = handleCloseRef.current({
7016 ...handleCloseContextBase,
7017 tree,
7018 x: event.clientX,
7019 y: event.clientY,
7020 onClose() {
7021 clearPointerEvents();
7022 cleanupMouseMoveHandler();
7023 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
7024 closeWithDelay(event, true);
7025 }
7026 }
7027 });
7028 doc.addEventListener("mousemove", instance.handler);
7029 instance.handler(event);
7030 return;
7031 }
7032 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
7033 if (shouldClose) {
7034 closeWithDelay(event);
7035 }
7036 }
7037 if (move) {
7038 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
7039 once: true
7040 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7041 }
7042 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
7043 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
7044 return React29.useMemo(() => {
7045 if (!enabled) {
7046 return void 0;
7047 }
7048 function setPointerRef(event) {
7049 instance.pointerType = event.pointerType;
7050 }
7051 return {
7052 onPointerDown: setPointerRef,
7053 onPointerEnter: setPointerRef,
7054 onMouseMove(event) {
7055 const {
7056 nativeEvent
7057 } = event;
7058 const trigger = event.currentTarget;
7059 const currentDomReference = store.select("domReferenceElement");
7060 const currentOpen = store.select("open");
7061 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
7062 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
7063 return;
7064 }
7065 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
7066 const floatingElement = store.select("floatingElement");
7067 if (floatingElement) {
7068 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
7069 applySafePolygonPointerEventsMutation(instance, {
7070 scopeElement,
7071 referenceElement: trigger,
7072 floatingElement
7073 });
7074 }
7075 }
7076 const restMsValue = getRestMs(restMsRef.current);
7077 if (currentOpen && !isOverInactive || restMsValue === 0) {
7078 return;
7079 }
7080 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
7081 return;
7082 }
7083 instance.restTimeout.clear();
7084 function handleMouseMove() {
7085 instance.restTimeoutPending = false;
7086 if (isClickLikeOpenEvent2()) {
7087 return;
7088 }
7089 const latestOpen = store.select("open");
7090 if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
7091 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
7092 }
7093 }
7094 if (instance.pointerType === "touch") {
7095 ReactDOM4.flushSync(() => {
7096 handleMouseMove();
7097 });
7098 } else if (isOverInactive && currentOpen) {
7099 handleMouseMove();
7100 } else {
7101 instance.restTimeoutPending = true;
7102 instance.restTimeout.start(restMsValue, handleMouseMove);
7103 }
7104 }
7105 };
7106 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
7107 }
7108
7109 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
7110 var CURSOR_SPEED_THRESHOLD = 0.1;
7111 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7112 var POLYGON_BUFFER = 0.5;
7113 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7114 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7115 }
7116 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7117 let isInsideValue = false;
7118 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7119 isInsideValue = !isInsideValue;
7120 }
7121 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7122 isInsideValue = !isInsideValue;
7123 }
7124 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7125 isInsideValue = !isInsideValue;
7126 }
7127 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7128 isInsideValue = !isInsideValue;
7129 }
7130 return isInsideValue;
7131 }
7132 function isInsideRect(pointX, pointY, rect) {
7133 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7134 }
7135 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7136 const minX = Math.min(x1, x2);
7137 const maxX = Math.max(x1, x2);
7138 const minY = Math.min(y1, y2);
7139 const maxY = Math.max(y1, y2);
7140 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7141 }
7142 function safePolygon(options = {}) {
7143 const {
7144 blockPointerEvents = false
7145 } = options;
7146 const timeout = new Timeout();
7147 const fn = ({
7148 x: x2,
7149 y: y2,
7150 placement,
7151 elements,
7152 onClose,
7153 nodeId,
7154 tree
7155 }) => {
7156 const side = placement?.split("-")[0];
7157 let hasLanded = false;
7158 let lastX = null;
7159 let lastY = null;
7160 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7161 function isCursorMovingSlowly(nextX, nextY) {
7162 const currentTime = performance.now();
7163 const elapsedTime = currentTime - lastCursorTime;
7164 if (lastX === null || lastY === null || elapsedTime === 0) {
7165 lastX = nextX;
7166 lastY = nextY;
7167 lastCursorTime = currentTime;
7168 return false;
7169 }
7170 const deltaX = nextX - lastX;
7171 const deltaY = nextY - lastY;
7172 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7173 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7174 lastX = nextX;
7175 lastY = nextY;
7176 lastCursorTime = currentTime;
7177 return distanceSquared < thresholdSquared;
7178 }
7179 function close() {
7180 timeout.clear();
7181 onClose();
7182 }
7183 return function onMouseMove(event) {
7184 timeout.clear();
7185 const domReference = elements.domReference;
7186 const floating = elements.floating;
7187 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7188 return void 0;
7189 }
7190 const {
7191 clientX,
7192 clientY
7193 } = event;
7194 const target = getTarget(event);
7195 const isLeave = event.type === "mouseleave";
7196 const isOverFloatingEl = contains(floating, target);
7197 const isOverReferenceEl = contains(domReference, target);
7198 if (isOverFloatingEl) {
7199 hasLanded = true;
7200 if (!isLeave) {
7201 return void 0;
7202 }
7203 }
7204 if (isOverReferenceEl) {
7205 hasLanded = false;
7206 if (!isLeave) {
7207 hasLanded = true;
7208 return void 0;
7209 }
7210 }
7211 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7212 return void 0;
7213 }
7214 function hasOpenChildNode() {
7215 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7216 }
7217 function closeIfNoOpenChild() {
7218 if (!hasOpenChildNode()) {
7219 close();
7220 }
7221 }
7222 if (hasOpenChildNode()) {
7223 return void 0;
7224 }
7225 const refRect = domReference.getBoundingClientRect();
7226 const rect = floating.getBoundingClientRect();
7227 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7228 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7229 const isFloatingWider = rect.width > refRect.width;
7230 const isFloatingTaller = rect.height > refRect.height;
7231 const left = (isFloatingWider ? refRect : rect).left;
7232 const right = (isFloatingWider ? refRect : rect).right;
7233 const top = (isFloatingTaller ? refRect : rect).top;
7234 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7235 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) {
7236 closeIfNoOpenChild();
7237 return void 0;
7238 }
7239 let isInsideTroughRect = false;
7240 switch (side) {
7241 case "top":
7242 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7243 break;
7244 case "bottom":
7245 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7246 break;
7247 case "left":
7248 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7249 break;
7250 case "right":
7251 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7252 break;
7253 default:
7254 }
7255 if (isInsideTroughRect) {
7256 return void 0;
7257 }
7258 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7259 closeIfNoOpenChild();
7260 return void 0;
7261 }
7262 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7263 closeIfNoOpenChild();
7264 return void 0;
7265 }
7266 let isInsidePolygon = false;
7267 switch (side) {
7268 case "top": {
7269 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7270 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7271 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7272 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7273 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7274 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7275 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7276 break;
7277 }
7278 case "bottom": {
7279 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7280 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7281 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7282 const cursorPointY = y2 - POLYGON_BUFFER;
7283 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7284 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7285 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7286 break;
7287 }
7288 case "left": {
7289 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7290 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7291 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7292 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7293 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7294 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7295 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7296 break;
7297 }
7298 case "right": {
7299 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7300 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7301 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7302 const cursorPointX = x2 - POLYGON_BUFFER;
7303 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7304 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7305 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7306 break;
7307 }
7308 default:
7309 }
7310 if (!isInsidePolygon) {
7311 closeIfNoOpenChild();
7312 } else if (!hasLanded) {
7313 timeout.start(40, closeIfNoOpenChild);
7314 }
7315 return void 0;
7316 };
7317 };
7318 fn.__options = {
7319 ...options,
7320 blockPointerEvents
7321 };
7322 return fn;
7323 }
7324
7325 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7326 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7327 CommonPopupDataAttributes2["open"] = "data-open";
7328 CommonPopupDataAttributes2["closed"] = "data-closed";
7329 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7330 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7331 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7332 CommonPopupDataAttributes2["side"] = "data-side";
7333 CommonPopupDataAttributes2["align"] = "data-align";
7334 return CommonPopupDataAttributes2;
7335 })({});
7336 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7337 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7338 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7339 return CommonTriggerDataAttributes2;
7340 })({});
7341 var TRIGGER_HOOK = {
7342 [CommonTriggerDataAttributes.popupOpen]: ""
7343 };
7344 var PRESSABLE_TRIGGER_HOOK = {
7345 [CommonTriggerDataAttributes.popupOpen]: "",
7346 [CommonTriggerDataAttributes.pressed]: ""
7347 };
7348 var POPUP_OPEN_HOOK = {
7349 [CommonPopupDataAttributes.open]: ""
7350 };
7351 var POPUP_CLOSED_HOOK = {
7352 [CommonPopupDataAttributes.closed]: ""
7353 };
7354 var ANCHOR_HIDDEN_HOOK = {
7355 [CommonPopupDataAttributes.anchorHidden]: ""
7356 };
7357 var triggerOpenStateMapping = {
7358 open(value) {
7359 if (value) {
7360 return TRIGGER_HOOK;
7361 }
7362 return null;
7363 }
7364 };
7365 var popupStateMapping = {
7366 open(value) {
7367 if (value) {
7368 return POPUP_OPEN_HOOK;
7369 }
7370 return POPUP_CLOSED_HOOK;
7371 },
7372 anchorHidden(value) {
7373 if (value) {
7374 return ANCHOR_HIDDEN_HOOK;
7375 }
7376 return null;
7377 }
7378 };
7379
7380 // node_modules/@base-ui/utils/esm/inertValue.js
7381 function inertValue(value) {
7382 if (isReactVersionAtLeast(19)) {
7383 return value;
7384 }
7385 return value ? "true" : void 0;
7386 }
7387
7388 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7389 var React30 = __toESM(require_react(), 1);
7390
7391 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7392 var baseArrow = (options) => ({
7393 name: "arrow",
7394 options,
7395 async fn(state) {
7396 const {
7397 x: x2,
7398 y: y2,
7399 placement,
7400 rects,
7401 platform: platform3,
7402 elements,
7403 middlewareData
7404 } = state;
7405 const {
7406 element,
7407 padding = 0,
7408 offsetParent = "real"
7409 } = evaluate(options, state) || {};
7410 if (element == null) {
7411 return {};
7412 }
7413 const paddingObject = getPaddingObject(padding);
7414 const coords = {
7415 x: x2,
7416 y: y2
7417 };
7418 const axis = getAlignmentAxis(placement);
7419 const length = getAxisLength(axis);
7420 const arrowDimensions = await platform3.getDimensions(element);
7421 const isYAxis = axis === "y";
7422 const minProp = isYAxis ? "top" : "left";
7423 const maxProp = isYAxis ? "bottom" : "right";
7424 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7425 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7426 const startDiff = coords[axis] - rects.reference[axis];
7427 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7428 let clientSize = elements.floating[clientProp] || rects.floating[length];
7429 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7430 clientSize = elements.floating[clientProp] || rects.floating[length];
7431 }
7432 const centerToReference = endDiff / 2 - startDiff / 2;
7433 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7434 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7435 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7436 const min2 = minPadding;
7437 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7438 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7439 const offset4 = clamp(min2, center, max2);
7440 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7441 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7442 return {
7443 [axis]: coords[axis] + alignmentOffset,
7444 data: {
7445 [axis]: offset4,
7446 centerOffset: center - offset4 - alignmentOffset,
7447 ...shouldAddOffset && {
7448 alignmentOffset
7449 }
7450 },
7451 reset: shouldAddOffset
7452 };
7453 }
7454 });
7455 var arrow4 = (options, deps) => ({
7456 ...baseArrow(options),
7457 options: [options, deps]
7458 });
7459
7460 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7461 var hide4 = {
7462 name: "hide",
7463 async fn(state) {
7464 const {
7465 width,
7466 height,
7467 x: x2,
7468 y: y2
7469 } = state.rects.reference;
7470 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7471 const nativeHideResult = await hide3().fn(state);
7472 return {
7473 data: {
7474 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7475 }
7476 };
7477 }
7478 };
7479
7480 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7481 var DEFAULT_SIDES = {
7482 sideX: "left",
7483 sideY: "top"
7484 };
7485 var adaptiveOrigin = {
7486 name: "adaptiveOrigin",
7487 async fn(state) {
7488 const {
7489 x: rawX,
7490 y: rawY,
7491 rects: {
7492 floating: floatRect
7493 },
7494 elements: {
7495 floating
7496 },
7497 platform: platform3,
7498 strategy,
7499 placement
7500 } = state;
7501 const win = getWindow(floating);
7502 const styles = win.getComputedStyle(floating);
7503 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7504 if (!hasTransition) {
7505 return {
7506 x: rawX,
7507 y: rawY,
7508 data: DEFAULT_SIDES
7509 };
7510 }
7511 const offsetParent = await platform3.getOffsetParent?.(floating);
7512 let offsetDimensions = {
7513 width: 0,
7514 height: 0
7515 };
7516 if (strategy === "fixed" && win?.visualViewport) {
7517 offsetDimensions = {
7518 width: win.visualViewport.width,
7519 height: win.visualViewport.height
7520 };
7521 } else if (offsetParent === win) {
7522 const doc = ownerDocument(floating);
7523 offsetDimensions = {
7524 width: doc.documentElement.clientWidth,
7525 height: doc.documentElement.clientHeight
7526 };
7527 } else if (await platform3.isElement?.(offsetParent)) {
7528 offsetDimensions = await platform3.getDimensions(offsetParent);
7529 }
7530 const currentSide = getSide(placement);
7531 let x2 = rawX;
7532 let y2 = rawY;
7533 if (currentSide === "left") {
7534 x2 = offsetDimensions.width - (rawX + floatRect.width);
7535 }
7536 if (currentSide === "top") {
7537 y2 = offsetDimensions.height - (rawY + floatRect.height);
7538 }
7539 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7540 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7541 return {
7542 x: x2,
7543 y: y2,
7544 data: {
7545 sideX,
7546 sideY
7547 }
7548 };
7549 }
7550 };
7551
7552 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7553 function getLogicalSide(sideParam, renderedSide, isRtl) {
7554 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7555 const logicalRight = isRtl ? "inline-start" : "inline-end";
7556 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7557 return {
7558 top: "top",
7559 right: isLogicalSideParam ? logicalRight : "right",
7560 bottom: "bottom",
7561 left: isLogicalSideParam ? logicalLeft : "left"
7562 }[renderedSide];
7563 }
7564 function getOffsetData(state, sideParam, isRtl) {
7565 const {
7566 rects,
7567 placement
7568 } = state;
7569 const data = {
7570 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7571 align: getAlignment(placement) || "center",
7572 anchor: {
7573 width: rects.reference.width,
7574 height: rects.reference.height
7575 },
7576 positioner: {
7577 width: rects.floating.width,
7578 height: rects.floating.height
7579 }
7580 };
7581 return data;
7582 }
7583 function useAnchorPositioning(params) {
7584 const {
7585 // Public parameters
7586 anchor,
7587 positionMethod = "absolute",
7588 side: sideParam = "bottom",
7589 sideOffset = 0,
7590 align = "center",
7591 alignOffset = 0,
7592 collisionBoundary,
7593 collisionPadding: collisionPaddingParam = 5,
7594 sticky = false,
7595 arrowPadding = 5,
7596 disableAnchorTracking = false,
7597 inline: inlineMiddleware,
7598 // Private parameters
7599 keepMounted = false,
7600 floatingRootContext,
7601 mounted,
7602 collisionAvoidance,
7603 shiftCrossAxis = false,
7604 nodeId,
7605 adaptiveOrigin: adaptiveOrigin2,
7606 lazyFlip = false,
7607 externalTree
7608 } = params;
7609 const [mountSide, setMountSide] = React30.useState(null);
7610 if (!mounted && mountSide !== null) {
7611 setMountSide(null);
7612 }
7613 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7614 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7615 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7616 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7617 const anchorFnCallback = useStableCallback(anchorFn);
7618 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7619 const anchorValueRef = useValueAsRef(anchor);
7620 const mountedRef = useValueAsRef(mounted);
7621 const direction = useDirection();
7622 const isRtl = direction === "rtl";
7623 const side = mountSide || {
7624 top: "top",
7625 right: "right",
7626 bottom: "bottom",
7627 left: "left",
7628 "inline-end": isRtl ? "left" : "right",
7629 "inline-start": isRtl ? "right" : "left"
7630 }[sideParam];
7631 const placement = align === "center" ? side : `${side}-${align}`;
7632 let collisionPadding = collisionPaddingParam;
7633 const bias = 1;
7634 const biasTop = sideParam === "bottom" ? bias : 0;
7635 const biasBottom = sideParam === "top" ? bias : 0;
7636 const biasLeft = sideParam === "right" ? bias : 0;
7637 const biasRight = sideParam === "left" ? bias : 0;
7638 if (typeof collisionPadding === "number") {
7639 collisionPadding = {
7640 top: collisionPadding + biasTop,
7641 right: collisionPadding + biasRight,
7642 bottom: collisionPadding + biasBottom,
7643 left: collisionPadding + biasLeft
7644 };
7645 } else if (collisionPadding) {
7646 collisionPadding = {
7647 top: (collisionPadding.top || 0) + biasTop,
7648 right: (collisionPadding.right || 0) + biasRight,
7649 bottom: (collisionPadding.bottom || 0) + biasBottom,
7650 left: (collisionPadding.left || 0) + biasLeft
7651 };
7652 }
7653 const commonCollisionProps = {
7654 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7655 padding: collisionPadding
7656 };
7657 const arrowRef = React30.useRef(null);
7658 const sideOffsetRef = useValueAsRef(sideOffset);
7659 const alignOffsetRef = useValueAsRef(alignOffset);
7660 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7661 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7662 const middleware = [];
7663 if (inlineMiddleware) {
7664 middleware.push(inlineMiddleware);
7665 }
7666 middleware.push(offset3((state) => {
7667 const data = getOffsetData(state, sideParam, isRtl);
7668 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7669 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7670 return {
7671 mainAxis: sideAxis,
7672 crossAxis: alignAxis,
7673 alignmentAxis: alignAxis
7674 };
7675 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
7676 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7677 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7678 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7679 ...commonCollisionProps,
7680 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7681 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7682 padding: {
7683 top: collisionPadding.top + bias,
7684 right: collisionPadding.right + bias,
7685 bottom: collisionPadding.bottom + bias,
7686 left: collisionPadding.left + bias
7687 },
7688 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7689 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7690 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7691 });
7692 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7693 const html = ownerDocument(data.elements.floating).documentElement;
7694 return {
7695 ...commonCollisionProps,
7696 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7697 // for context menus.
7698 rootBoundary: shiftCrossAxis ? {
7699 x: 0,
7700 y: 0,
7701 width: html.clientWidth,
7702 height: html.clientHeight
7703 } : void 0,
7704 mainAxis: collisionAvoidanceAlign !== "none",
7705 crossAxis: crossAxisShiftEnabled,
7706 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7707 if (!arrowRef.current) {
7708 return {};
7709 }
7710 const {
7711 width,
7712 height
7713 } = arrowRef.current.getBoundingClientRect();
7714 const sideAxis = getSideAxis(getSide(limitData.placement));
7715 const arrowSize = sideAxis === "y" ? width : height;
7716 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7717 return {
7718 offset: arrowSize / 2 + offsetAmount / 2
7719 };
7720 })
7721 };
7722 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7723 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7724 middleware.push(shiftMiddleware, flipMiddleware);
7725 } else {
7726 middleware.push(flipMiddleware, shiftMiddleware);
7727 }
7728 middleware.push(size3({
7729 ...commonCollisionProps,
7730 apply({
7731 elements: {
7732 floating
7733 },
7734 availableWidth,
7735 availableHeight,
7736 rects
7737 }) {
7738 if (!mountedRef.current) {
7739 return;
7740 }
7741 const floatingStyle = floating.style;
7742 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7743 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7744 const dpr = getWindow(floating).devicePixelRatio || 1;
7745 const {
7746 x: x3,
7747 y: y3,
7748 width,
7749 height
7750 } = rects.reference;
7751 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7752 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7753 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7754 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7755 }
7756 }), arrow4((state) => ({
7757 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7758 // we'll create a fake element.
7759 element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
7760 padding: arrowPadding,
7761 offsetParent: "floating"
7762 }), [arrowPadding]), {
7763 name: "transformOrigin",
7764 fn(state) {
7765 const {
7766 elements: elements2,
7767 middlewareData: middlewareData2,
7768 placement: renderedPlacement2,
7769 rects,
7770 y: y3
7771 } = state;
7772 const currentRenderedSide = getSide(renderedPlacement2);
7773 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7774 const arrowEl = arrowRef.current;
7775 const arrowX = middlewareData2.arrow?.x || 0;
7776 const arrowY = middlewareData2.arrow?.y || 0;
7777 const arrowWidth = arrowEl?.clientWidth || 0;
7778 const arrowHeight = arrowEl?.clientHeight || 0;
7779 const transformX = arrowX + arrowWidth / 2;
7780 const transformY = arrowY + arrowHeight / 2;
7781 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7782 const halfAnchorHeight = rects.reference.height / 2;
7783 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7784 const isOverlappingAnchor = shiftY > sideOffsetValue;
7785 const adjacentTransformOrigin = {
7786 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7787 bottom: `${transformX}px ${-sideOffsetValue}px`,
7788 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7789 right: `${-sideOffsetValue}px ${transformY}px`
7790 }[currentRenderedSide];
7791 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7792 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7793 return {};
7794 }
7795 }, hide4, adaptiveOrigin2);
7796 useIsoLayoutEffect(() => {
7797 if (!mounted && floatingRootContext) {
7798 floatingRootContext.update({
7799 referenceElement: null,
7800 floatingElement: null,
7801 domReferenceElement: null,
7802 positionReference: null
7803 });
7804 }
7805 }, [mounted, floatingRootContext]);
7806 const autoUpdateOptions = React30.useMemo(() => ({
7807 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7808 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7809 }), [disableAnchorTracking]);
7810 const {
7811 refs,
7812 elements,
7813 x: x2,
7814 y: y2,
7815 middlewareData,
7816 update: update2,
7817 placement: renderedPlacement,
7818 context,
7819 isPositioned,
7820 floatingStyles: originalFloatingStyles
7821 } = useFloating2({
7822 rootContext: floatingRootContext,
7823 open: keepMounted ? mounted : void 0,
7824 placement,
7825 middleware,
7826 strategy: positionMethod,
7827 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7828 nodeId,
7829 externalTree
7830 });
7831 const {
7832 sideX,
7833 sideY
7834 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7835 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7836 const floatingStyles = React30.useMemo(() => {
7837 const base = adaptiveOrigin2 ? {
7838 position: resolvedPosition,
7839 [sideX]: x2,
7840 [sideY]: y2
7841 } : {
7842 position: resolvedPosition,
7843 ...originalFloatingStyles
7844 };
7845 if (!isPositioned) {
7846 base.opacity = 0;
7847 }
7848 return base;
7849 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7850 const registeredPositionReferenceRef = React30.useRef(null);
7851 useIsoLayoutEffect(() => {
7852 if (!mounted) {
7853 return;
7854 }
7855 const anchorValue = anchorValueRef.current;
7856 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7857 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7858 const finalAnchor = unwrappedElement || null;
7859 if (finalAnchor !== registeredPositionReferenceRef.current) {
7860 refs.setPositionReference(finalAnchor);
7861 registeredPositionReferenceRef.current = finalAnchor;
7862 }
7863 }, [mounted, refs, anchorDep, anchorValueRef]);
7864 React30.useEffect(() => {
7865 if (!mounted) {
7866 return;
7867 }
7868 const anchorValue = anchorValueRef.current;
7869 if (typeof anchorValue === "function") {
7870 return;
7871 }
7872 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7873 refs.setPositionReference(anchorValue.current);
7874 registeredPositionReferenceRef.current = anchorValue.current;
7875 }
7876 }, [mounted, refs, anchorDep, anchorValueRef]);
7877 React30.useEffect(() => {
7878 if (keepMounted && mounted && elements.domReference && elements.floating) {
7879 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7880 }
7881 return void 0;
7882 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7883 const renderedSide = getSide(renderedPlacement);
7884 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7885 const renderedAlign = getAlignment(renderedPlacement) || "center";
7886 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7887 useIsoLayoutEffect(() => {
7888 if (lazyFlip && mounted && isPositioned) {
7889 setMountSide(renderedSide);
7890 }
7891 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7892 const arrowStyles = React30.useMemo(() => ({
7893 position: "absolute",
7894 top: middlewareData.arrow?.y,
7895 left: middlewareData.arrow?.x
7896 }), [middlewareData.arrow]);
7897 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7898 return React30.useMemo(() => ({
7899 positionerStyles: floatingStyles,
7900 arrowStyles,
7901 arrowRef,
7902 arrowUncentered,
7903 side: logicalRenderedSide,
7904 align: renderedAlign,
7905 physicalSide: renderedSide,
7906 anchorHidden,
7907 refs,
7908 context,
7909 isPositioned,
7910 update: update2
7911 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7912 }
7913 function isRef(param) {
7914 return param != null && "current" in param;
7915 }
7916
7917 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7918 function getDisabledMountTransitionStyles(transitionStatus) {
7919 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7920 }
7921
7922 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7923 function usePositioner(componentProps, state, {
7924 styles,
7925 transitionStatus,
7926 props,
7927 refs,
7928 hidden,
7929 inert = false
7930 }) {
7931 const style = {
7932 ...styles
7933 };
7934 if (inert) {
7935 style.pointerEvents = "none";
7936 }
7937 return useRenderElement("div", componentProps, {
7938 state,
7939 ref: refs,
7940 props: [{
7941 role: "presentation",
7942 hidden,
7943 style
7944 }, getDisabledMountTransitionStyles(transitionStatus), props],
7945 stateAttributesMapping: popupStateMapping
7946 });
7947 }
7948
7949 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7950 var React33 = __toESM(require_react(), 1);
7951 var ReactDOM5 = __toESM(require_react_dom(), 1);
7952
7953 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7954 var React31 = __toESM(require_react(), 1);
7955 function usePreviousValue(value) {
7956 const [state, setState] = React31.useState({
7957 current: value,
7958 previous: null
7959 });
7960 if (value !== state.current) {
7961 setState({
7962 current: value,
7963 previous: state.current
7964 });
7965 }
7966 return state.previous;
7967 }
7968
7969 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7970 var React32 = __toESM(require_react(), 1);
7971
7972 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7973 function getCssDimensions2(element) {
7974 const css = getComputedStyle2(element);
7975 let width = parseFloat(css.width) || 0;
7976 let height = parseFloat(css.height) || 0;
7977 const hasOffset = isHTMLElement(element);
7978 const offsetWidth = hasOffset ? element.offsetWidth : width;
7979 const offsetHeight = hasOffset ? element.offsetHeight : height;
7980 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7981 if (shouldFallback) {
7982 width = offsetWidth;
7983 height = offsetHeight;
7984 }
7985 return {
7986 width,
7987 height
7988 };
7989 }
7990
7991 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7992 var DEFAULT_ENABLED = () => true;
7993 function usePopupAutoResize(parameters) {
7994 const {
7995 popupElement,
7996 positionerElement,
7997 content,
7998 mounted,
7999 enabled = DEFAULT_ENABLED,
8000 onMeasureLayout: onMeasureLayoutParam,
8001 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
8002 side,
8003 direction
8004 } = parameters;
8005 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
8006 const animationFrame = useAnimationFrame();
8007 const committedDimensionsRef = React32.useRef(null);
8008 const liveDimensionsRef = React32.useRef(null);
8009 const isInitialRenderRef = React32.useRef(true);
8010 const restoreAnchoringStylesRef = React32.useRef(NOOP);
8011 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
8012 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
8013 const anchoringStyles = React32.useMemo(() => {
8014 let isOriginSide = side === "top";
8015 let isPhysicalLeft = side === "left";
8016 if (direction === "rtl") {
8017 isOriginSide = isOriginSide || side === "inline-end";
8018 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
8019 } else {
8020 isOriginSide = isOriginSide || side === "inline-start";
8021 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
8022 }
8023 return isOriginSide ? {
8024 position: "absolute",
8025 [side === "top" ? "bottom" : "top"]: "0",
8026 [isPhysicalLeft ? "right" : "left"]: "0"
8027 } : EMPTY_OBJECT;
8028 }, [side, direction]);
8029 useIsoLayoutEffect(() => {
8030 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
8031 restoreAnchoringStylesRef.current = NOOP;
8032 isInitialRenderRef.current = true;
8033 committedDimensionsRef.current = null;
8034 liveDimensionsRef.current = null;
8035 return void 0;
8036 }
8037 if (!popupElement || !positionerElement) {
8038 return void 0;
8039 }
8040 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
8041 const observer = new ResizeObserver((entries) => {
8042 const entry = entries[0];
8043 if (entry) {
8044 liveDimensionsRef.current = {
8045 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
8046 height: Math.ceil(entry.borderBoxSize[0].blockSize)
8047 };
8048 }
8049 });
8050 observer.observe(popupElement);
8051 setPopupCssSize(popupElement, "auto");
8052 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8053 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8054 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8055 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8056 "--available-width": "max-content",
8057 "--available-height": "max-content"
8058 });
8059 function restoreMeasurementOverrides() {
8060 restorePopupPosition();
8061 restorePopupTransform();
8062 restorePositionerAvailableSize();
8063 }
8064 function restoreMeasurementOverridesIncludingScale() {
8065 restoreMeasurementOverrides();
8066 restorePopupScale();
8067 }
8068 onMeasureLayout?.();
8069 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8070 setPositionerCssSize(positionerElement, "max-content");
8071 const dimensions = getCssDimensions2(popupElement);
8072 committedDimensionsRef.current = dimensions;
8073 setPositionerCssSize(positionerElement, dimensions);
8074 restoreMeasurementOverridesIncludingScale();
8075 onMeasureLayoutComplete?.(null, dimensions);
8076 isInitialRenderRef.current = false;
8077 return () => {
8078 observer.disconnect();
8079 restoreAnchoringStylesRef.current();
8080 restoreAnchoringStylesRef.current = NOOP;
8081 };
8082 }
8083 setPopupCssSize(popupElement, "auto");
8084 setPositionerCssSize(positionerElement, "max-content");
8085 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
8086 const newDimensions = getCssDimensions2(popupElement);
8087 committedDimensionsRef.current = newDimensions;
8088 if (!previousDimensions) {
8089 setPositionerCssSize(positionerElement, newDimensions);
8090 restoreMeasurementOverridesIncludingScale();
8091 onMeasureLayoutComplete?.(null, newDimensions);
8092 return () => {
8093 observer.disconnect();
8094 animationFrame.cancel();
8095 restoreAnchoringStylesRef.current();
8096 restoreAnchoringStylesRef.current = NOOP;
8097 };
8098 }
8099 setPopupCssSize(popupElement, previousDimensions);
8100 restoreMeasurementOverridesIncludingScale();
8101 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8102 setPositionerCssSize(positionerElement, newDimensions);
8103 const abortController = new AbortController();
8104 animationFrame.request(() => {
8105 setPopupCssSize(popupElement, newDimensions);
8106 runOnceAnimationsFinish(() => {
8107 popupElement.style.setProperty("--popup-width", "auto");
8108 popupElement.style.setProperty("--popup-height", "auto");
8109 }, abortController.signal);
8110 });
8111 return () => {
8112 observer.disconnect();
8113 abortController.abort();
8114 animationFrame.cancel();
8115 restoreAnchoringStylesRef.current();
8116 restoreAnchoringStylesRef.current = NOOP;
8117 };
8118 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8119 }
8120 function overrideElementStyle(element, property, value) {
8121 const originalValue = element.style.getPropertyValue(property);
8122 element.style.setProperty(property, value);
8123 return () => {
8124 element.style.setProperty(property, originalValue);
8125 };
8126 }
8127 function applyElementStyles(element, styles) {
8128 const restorers = [];
8129 for (const [key, value] of Object.entries(styles)) {
8130 restorers.push(overrideElementStyle(element, key, value));
8131 }
8132 return restorers.length ? () => {
8133 restorers.forEach((restore) => restore());
8134 } : NOOP;
8135 }
8136 function setPopupCssSize(popupElement, size4) {
8137 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8138 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8139 popupElement.style.setProperty("--popup-width", width);
8140 popupElement.style.setProperty("--popup-height", height);
8141 }
8142 function setPositionerCssSize(positionerElement, size4) {
8143 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8144 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8145 positionerElement.style.setProperty("--positioner-width", width);
8146 positionerElement.style.setProperty("--positioner-height", height);
8147 }
8148
8149 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8150 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8151 function usePopupViewport(parameters) {
8152 const {
8153 store,
8154 side,
8155 cssVars,
8156 children
8157 } = parameters;
8158 const direction = useDirection();
8159 const activeTrigger = store.useState("activeTriggerElement");
8160 const activeTriggerId = store.useState("activeTriggerId");
8161 const open = store.useState("open");
8162 const payload = store.useState("payload");
8163 const mounted = store.useState("mounted");
8164 const popupElement = store.useState("popupElement");
8165 const positionerElement = store.useState("positionerElement");
8166 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8167 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8168 const capturedNodeRef = React33.useRef(null);
8169 const [previousContentNode, setPreviousContentNode] = React33.useState(null);
8170 const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
8171 const currentContainerRef = React33.useRef(null);
8172 const previousContainerRef = React33.useRef(null);
8173 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8174 const cleanupFrame = useAnimationFrame();
8175 const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
8176 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
8177 useIsoLayoutEffect(() => {
8178 store.set("hasViewport", true);
8179 return () => {
8180 store.set("hasViewport", false);
8181 };
8182 }, [store]);
8183 const handleMeasureLayout = useStableCallback(() => {
8184 currentContainerRef.current?.style.setProperty("animation", "none");
8185 currentContainerRef.current?.style.setProperty("transition", "none");
8186 previousContainerRef.current?.style.setProperty("display", "none");
8187 });
8188 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8189 currentContainerRef.current?.style.removeProperty("animation");
8190 currentContainerRef.current?.style.removeProperty("transition");
8191 previousContainerRef.current?.style.removeProperty("display");
8192 if (previousDimensions) {
8193 setPreviousContentDimensions(previousDimensions);
8194 }
8195 });
8196 const lastHandledTriggerRef = React33.useRef(null);
8197 useIsoLayoutEffect(() => {
8198 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8199 setPreviousContentNode(capturedNodeRef.current);
8200 setShowStartingStyleAttribute(true);
8201 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8202 setNewTriggerOffset(offset4);
8203 cleanupFrame.request(() => {
8204 ReactDOM5.flushSync(() => {
8205 setShowStartingStyleAttribute(false);
8206 });
8207 onAnimationsFinished(() => {
8208 setPreviousContentNode(null);
8209 setPreviousContentDimensions(null);
8210 capturedNodeRef.current = null;
8211 });
8212 });
8213 lastHandledTriggerRef.current = activeTrigger;
8214 }
8215 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8216 useIsoLayoutEffect(() => {
8217 const source = currentContainerRef.current;
8218 if (!source) {
8219 return;
8220 }
8221 const wrapper = ownerDocument(source).createElement("div");
8222 for (const child of Array.from(source.childNodes)) {
8223 wrapper.appendChild(child.cloneNode(true));
8224 }
8225 capturedNodeRef.current = wrapper;
8226 });
8227 const isTransitioning = previousContentNode != null;
8228 let childrenToRender;
8229 if (!isTransitioning) {
8230 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8231 "data-current": true,
8232 ref: currentContainerRef,
8233 children
8234 }, currentContentKey);
8235 } else {
8236 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
8237 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8238 "data-previous": true,
8239 inert: inertValue(true),
8240 ref: previousContainerRef,
8241 style: {
8242 ...previousContentDimensions ? {
8243 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8244 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8245 } : null,
8246 position: "absolute"
8247 },
8248 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8249 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8250 "data-current": true,
8251 ref: currentContainerRef,
8252 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8253 children
8254 }, currentContentKey)]
8255 });
8256 }
8257 useIsoLayoutEffect(() => {
8258 const container = previousContainerRef.current;
8259 if (!container || !previousContentNode) {
8260 return;
8261 }
8262 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8263 }, [previousContentNode]);
8264 usePopupAutoResize({
8265 popupElement,
8266 positionerElement,
8267 mounted,
8268 content: payload,
8269 onMeasureLayout: handleMeasureLayout,
8270 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8271 side,
8272 direction
8273 });
8274 const state = {
8275 activationDirection: getActivationDirection(newTriggerOffset),
8276 transitioning: isTransitioning
8277 };
8278 return {
8279 children: childrenToRender,
8280 state
8281 };
8282 }
8283 function getActivationDirection(offset4) {
8284 if (!offset4) {
8285 return void 0;
8286 }
8287 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8288 }
8289 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8290 if (value > tolerance) {
8291 return positiveLabel;
8292 }
8293 if (value < -tolerance) {
8294 return negativeLabel;
8295 }
8296 return "";
8297 }
8298 function calculateRelativePosition(from, to) {
8299 const fromRect = from.getBoundingClientRect();
8300 const toRect = to.getBoundingClientRect();
8301 const fromCenter = {
8302 x: fromRect.left + fromRect.width / 2,
8303 y: fromRect.top + fromRect.height / 2
8304 };
8305 const toCenter = {
8306 x: toRect.left + toRect.width / 2,
8307 y: toRect.top + toRect.height / 2
8308 };
8309 return {
8310 horizontal: toCenter.x - fromCenter.x,
8311 vertical: toCenter.y - fromCenter.y
8312 };
8313 }
8314 function usePopupContentKey(activeTriggerId, payload) {
8315 const [contentKey, setContentKey] = React33.useState(0);
8316 const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
8317 const previousPayloadRef = React33.useRef(payload);
8318 const pendingPayloadUpdateRef = React33.useRef(false);
8319 useIsoLayoutEffect(() => {
8320 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8321 const previousPayload = previousPayloadRef.current;
8322 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8323 const payloadChanged = payload !== previousPayload;
8324 if (triggerIdChanged) {
8325 setContentKey((value) => value + 1);
8326 pendingPayloadUpdateRef.current = !payloadChanged;
8327 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8328 setContentKey((value) => value + 1);
8329 pendingPayloadUpdateRef.current = false;
8330 }
8331 previousActiveTriggerIdRef.current = activeTriggerId;
8332 previousPayloadRef.current = payload;
8333 }, [activeTriggerId, payload]);
8334 return `${activeTriggerId ?? "current"}-${contentKey}`;
8335 }
8336
8337 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8338 var React34 = __toESM(require_react(), 1);
8339 var ReactDOM6 = __toESM(require_react_dom(), 1);
8340 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8341 var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8342 const {
8343 children,
8344 container,
8345 className,
8346 render: render4,
8347 style,
8348 ...elementProps
8349 } = componentProps;
8350 const {
8351 portalNode,
8352 portalSubtree
8353 } = useFloatingPortalNode({
8354 container,
8355 ref: forwardedRef,
8356 componentProps,
8357 elementProps
8358 });
8359 if (!portalSubtree && !portalNode) {
8360 return null;
8361 }
8362 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
8363 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8364 });
8365 });
8366 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8367
8368 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8369 var index_parts_exports = {};
8370 __export(index_parts_exports, {
8371 Arrow: () => TooltipArrow,
8372 Handle: () => TooltipHandle,
8373 Popup: () => TooltipPopup,
8374 Portal: () => TooltipPortal,
8375 Positioner: () => TooltipPositioner,
8376 Provider: () => TooltipProvider,
8377 Root: () => TooltipRoot,
8378 Trigger: () => TooltipTrigger,
8379 Viewport: () => TooltipViewport,
8380 createHandle: () => createTooltipHandle
8381 });
8382
8383 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8384 var React37 = __toESM(require_react(), 1);
8385
8386 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8387 var React35 = __toESM(require_react(), 1);
8388 var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
8389 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8390 function useTooltipRootContext(optional) {
8391 const context = React35.useContext(TooltipRootContext);
8392 if (context === void 0 && !optional) {
8393 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8394 }
8395 return context;
8396 }
8397
8398 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8399 var React36 = __toESM(require_react(), 1);
8400 var ReactDOM7 = __toESM(require_react_dom(), 1);
8401 var selectors2 = {
8402 ...popupStoreSelectors,
8403 disabled: createSelector((state) => state.disabled),
8404 instantType: createSelector((state) => state.instantType),
8405 isInstantPhase: createSelector((state) => state.isInstantPhase),
8406 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8407 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8408 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8409 closeOnClick: createSelector((state) => state.closeOnClick),
8410 closeDelay: createSelector((state) => state.closeDelay),
8411 hasViewport: createSelector((state) => state.hasViewport)
8412 };
8413 var TooltipStore = class _TooltipStore extends ReactStore {
8414 constructor(initialState, floatingId, nested = false) {
8415 const triggerElements = new PopupTriggerMap();
8416 const state = {
8417 ...createInitialState(),
8418 ...initialState
8419 };
8420 state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
8421 super(state, {
8422 popupRef: /* @__PURE__ */ React36.createRef(),
8423 onOpenChange: void 0,
8424 onOpenChangeComplete: void 0,
8425 triggerElements
8426 }, selectors2);
8427 }
8428 setOpen = (nextOpen, eventDetails) => {
8429 const reason = eventDetails.reason;
8430 const isHover = reason === reason_parts_exports.triggerHover;
8431 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8432 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8433 eventDetails.preventUnmountOnClose = () => {
8434 this.set("preventUnmountingOnClose", true);
8435 };
8436 this.context.onOpenChange?.(nextOpen, eventDetails);
8437 if (eventDetails.isCanceled) {
8438 return;
8439 }
8440 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8441 const changeState = () => {
8442 const updatedState = {
8443 open: nextOpen,
8444 openChangeReason: reason
8445 };
8446 if (isFocusOpen) {
8447 updatedState.instantType = "focus";
8448 } else if (isDismissClose) {
8449 updatedState.instantType = "dismiss";
8450 } else if (reason === reason_parts_exports.triggerHover) {
8451 updatedState.instantType = void 0;
8452 }
8453 setOpenTriggerState(updatedState, nextOpen, eventDetails.trigger);
8454 this.update(updatedState);
8455 };
8456 if (isHover) {
8457 ReactDOM7.flushSync(changeState);
8458 } else {
8459 changeState();
8460 }
8461 };
8462 // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
8463 cancelPendingOpen(event) {
8464 this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
8465 }
8466 static useStore(externalStore, initialState) {
8467 const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
8468 return store;
8469 }
8470 };
8471 function createInitialState() {
8472 return {
8473 ...createInitialPopupStoreState(),
8474 disabled: false,
8475 instantType: void 0,
8476 isInstantPhase: false,
8477 trackCursorAxis: "none",
8478 disableHoverablePopup: false,
8479 openChangeReason: null,
8480 closeOnClick: true,
8481 closeDelay: 0,
8482 hasViewport: false
8483 };
8484 }
8485
8486 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8487 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8488 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8489 const {
8490 disabled: disabled2 = false,
8491 defaultOpen = false,
8492 open: openProp,
8493 disableHoverablePopup = false,
8494 trackCursorAxis = "none",
8495 actionsRef,
8496 onOpenChange,
8497 onOpenChangeComplete,
8498 handle,
8499 triggerId: triggerIdProp,
8500 defaultTriggerId: defaultTriggerIdProp = null,
8501 children
8502 } = props;
8503 const store = TooltipStore.useStore(handle?.store, {
8504 open: defaultOpen,
8505 openProp,
8506 activeTriggerId: defaultTriggerIdProp,
8507 triggerIdProp
8508 });
8509 useOnFirstRender(() => {
8510 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8511 store.update({
8512 open: true,
8513 activeTriggerId: defaultTriggerIdProp
8514 });
8515 }
8516 });
8517 store.useControlledProp("openProp", openProp);
8518 store.useControlledProp("triggerIdProp", triggerIdProp);
8519 store.useContextCallback("onOpenChange", onOpenChange);
8520 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8521 const openState = store.useState("open");
8522 const open = !disabled2 && openState;
8523 const activeTriggerId = store.useState("activeTriggerId");
8524 const mounted = store.useState("mounted");
8525 const payload = store.useState("payload");
8526 store.useSyncedValues({
8527 trackCursorAxis,
8528 disableHoverablePopup
8529 });
8530 store.useSyncedValue("disabled", disabled2);
8531 useImplicitActiveTrigger(store);
8532 const {
8533 forceUnmount,
8534 transitionStatus
8535 } = useOpenStateTransitions(open, store);
8536 const isInstantPhase = store.useState("isInstantPhase");
8537 const instantType = store.useState("instantType");
8538 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8539 const previousInstantTypeRef = React37.useRef(null);
8540 useIsoLayoutEffect(() => {
8541 if (openState && disabled2) {
8542 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8543 }
8544 }, [openState, disabled2, store]);
8545 useIsoLayoutEffect(() => {
8546 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8547 if (instantType !== "delay") {
8548 previousInstantTypeRef.current = instantType;
8549 }
8550 store.set("instantType", "delay");
8551 } else if (previousInstantTypeRef.current !== null) {
8552 store.set("instantType", previousInstantTypeRef.current);
8553 previousInstantTypeRef.current = null;
8554 }
8555 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8556 useIsoLayoutEffect(() => {
8557 if (open) {
8558 if (activeTriggerId == null) {
8559 store.set("payload", void 0);
8560 }
8561 }
8562 }, [store, activeTriggerId, open]);
8563 const handleImperativeClose = React37.useCallback(() => {
8564 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8565 }, [store]);
8566 React37.useImperativeHandle(actionsRef, () => ({
8567 unmount: forceUnmount,
8568 close: handleImperativeClose
8569 }), [forceUnmount, handleImperativeClose]);
8570 const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
8571 return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
8572 value: store,
8573 children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
8574 store,
8575 disabled: disabled2,
8576 trackCursorAxis
8577 }), typeof children === "function" ? children({
8578 payload
8579 }) : children]
8580 });
8581 });
8582 if (true) TooltipRoot.displayName = "TooltipRoot";
8583 function TooltipInteractions({
8584 store,
8585 disabled: disabled2,
8586 trackCursorAxis
8587 }) {
8588 const floatingRootContext = store.useState("floatingRootContext");
8589 const dismiss = useDismiss(floatingRootContext, {
8590 enabled: !disabled2,
8591 referencePress: () => store.select("closeOnClick")
8592 });
8593 const clientPoint = useClientPoint(floatingRootContext, {
8594 enabled: !disabled2 && trackCursorAxis !== "none",
8595 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8596 });
8597 const activeTriggerProps = React37.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
8598 const inactiveTriggerProps = React37.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
8599 const popupProps = React37.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
8600 usePopupInteractionProps(store, {
8601 activeTriggerProps,
8602 inactiveTriggerProps,
8603 popupProps
8604 });
8605 return null;
8606 }
8607
8608 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8609 var React39 = __toESM(require_react(), 1);
8610
8611 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8612 var React38 = __toESM(require_react(), 1);
8613 var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
8614 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8615 function useTooltipProviderContext() {
8616 return React38.useContext(TooltipProviderContext);
8617 }
8618
8619 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8620 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8621 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8622 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8623 return TooltipTriggerDataAttributes2;
8624 })({});
8625
8626 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8627 var OPEN_DELAY = 600;
8628
8629 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8630 var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
8631 function getTargetElement(event) {
8632 if ("composedPath" in event) {
8633 const path = event.composedPath();
8634 for (let i2 = 0; i2 < path.length; i2 += 1) {
8635 const element = path[i2];
8636 if (isElement(element)) {
8637 return element;
8638 }
8639 }
8640 }
8641 const target = event.target;
8642 if (isElement(target)) {
8643 return target;
8644 }
8645 return null;
8646 }
8647 function closestEnabledTooltipTrigger(element) {
8648 let current = element;
8649 while (current) {
8650 if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
8651 return current;
8652 }
8653 const parentElement = current.parentElement;
8654 if (parentElement) {
8655 current = parentElement;
8656 continue;
8657 }
8658 const root = current.getRootNode();
8659 current = "host" in root && isElement(root.host) ? root.host : null;
8660 }
8661 return null;
8662 }
8663 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8664 const {
8665 render: render4,
8666 className,
8667 style,
8668 handle,
8669 payload,
8670 disabled: disabledProp,
8671 delay,
8672 closeOnClick = true,
8673 closeDelay,
8674 id: idProp,
8675 ...elementProps
8676 } = componentProps;
8677 const rootContext = useTooltipRootContext(true);
8678 const store = handle?.store ?? rootContext;
8679 if (!store) {
8680 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));
8681 }
8682 const thisTriggerId = useBaseUiId(idProp);
8683 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8684 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8685 const floatingRootContext = store.useState("floatingRootContext");
8686 const triggerElementRef = React39.useRef(null);
8687 const delayWithDefault = delay ?? OPEN_DELAY;
8688 const closeDelayWithDefault = closeDelay ?? 0;
8689 const {
8690 registerTrigger,
8691 isMountedByThisTrigger
8692 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8693 payload,
8694 closeOnClick,
8695 closeDelay: closeDelayWithDefault
8696 });
8697 const providerContext = useTooltipProviderContext();
8698 const {
8699 delayRef,
8700 isInstantPhase,
8701 hasProvider
8702 } = useDelayGroup(floatingRootContext, {
8703 open: isOpenedByThisTrigger
8704 });
8705 const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
8706 store.useSyncedValue("isInstantPhase", isInstantPhase);
8707 const rootDisabled = store.useState("disabled");
8708 const disabled2 = disabledProp ?? rootDisabled;
8709 const disabledRef = useValueAsRef(disabled2);
8710 const trackCursorAxis = store.useState("trackCursorAxis");
8711 const disableHoverablePopup = store.useState("disableHoverablePopup");
8712 const isNestedTriggerHoveredRef = React39.useRef(false);
8713 const nestedTriggerOpenTimeout = useTimeout();
8714 const pointerTypeRef = React39.useRef(void 0);
8715 function getOpenDelay() {
8716 const providerDelay = providerContext?.delay;
8717 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8718 let computedOpenDelay = delayWithDefault;
8719 if (hasProvider) {
8720 if (groupOpenValue !== 0) {
8721 computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
8722 } else {
8723 computedOpenDelay = 0;
8724 }
8725 }
8726 return computedOpenDelay;
8727 }
8728 function isEnabledNestedTriggerTarget(target) {
8729 const triggerEl = triggerElementRef.current;
8730 if (!triggerEl || !target) {
8731 return false;
8732 }
8733 const nearestTrigger = closestEnabledTooltipTrigger(target);
8734 return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
8735 }
8736 function detectNestedTriggerHover(target) {
8737 const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
8738 isNestedTriggerHoveredRef.current = nestedTriggerHovered;
8739 if (nestedTriggerHovered) {
8740 hoverInteraction.openChangeTimeout.clear();
8741 hoverInteraction.restTimeout.clear();
8742 hoverInteraction.restTimeoutPending = false;
8743 nestedTriggerOpenTimeout.clear();
8744 }
8745 return nestedTriggerHovered;
8746 }
8747 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8748 enabled: !disabled2,
8749 mouseOnly: true,
8750 move: false,
8751 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8752 restMs: getOpenDelay,
8753 delay() {
8754 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8755 let computedCloseDelay = closeDelayWithDefault;
8756 if (closeDelay == null && hasProvider) {
8757 computedCloseDelay = closeValue;
8758 }
8759 return {
8760 close: computedCloseDelay
8761 };
8762 },
8763 triggerElementRef,
8764 isActiveTrigger: isTriggerActive,
8765 isClosing: () => store.select("transitionStatus") === "ending",
8766 shouldOpen() {
8767 return !isNestedTriggerHoveredRef.current;
8768 }
8769 });
8770 const focusProps = useFocus(floatingRootContext, {
8771 enabled: !disabled2
8772 }).reference;
8773 const handleNestedTriggerHover = (event) => {
8774 const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
8775 const target = getTargetElement(event);
8776 const nestedTriggerHovered = detectNestedTriggerHover(target);
8777 const triggerEl = triggerElementRef.current;
8778 const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
8779 if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
8780 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
8781 return;
8782 }
8783 if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
8784 isMouseLikePointerType(pointerTypeRef.current)) {
8785 const open = () => {
8786 if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
8787 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
8788 }
8789 };
8790 const openDelay = getOpenDelay();
8791 if (openDelay === 0) {
8792 nestedTriggerOpenTimeout.clear();
8793 open();
8794 } else {
8795 nestedTriggerOpenTimeout.start(openDelay, open);
8796 }
8797 }
8798 };
8799 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8800 const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
8801 const state = {
8802 open: isOpenedByThisTrigger
8803 };
8804 const element = useRenderElement("button", componentProps, {
8805 state,
8806 ref: [forwardedRef, registerTrigger, triggerElementRef],
8807 props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
8808 onMouseOver(event) {
8809 handleNestedTriggerHover(event.nativeEvent);
8810 },
8811 onFocus(event) {
8812 if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
8813 event.preventBaseUIHandler();
8814 }
8815 },
8816 onMouseLeave() {
8817 isNestedTriggerHoveredRef.current = false;
8818 nestedTriggerOpenTimeout.clear();
8819 pointerTypeRef.current = void 0;
8820 },
8821 onPointerEnter(event) {
8822 pointerTypeRef.current = event.pointerType;
8823 },
8824 onPointerDown(event) {
8825 pointerTypeRef.current = event.pointerType;
8826 store.set("closeOnClick", closeOnClick);
8827 if (closeOnClick && !store.select("open")) {
8828 store.cancelPendingOpen(event.nativeEvent);
8829 }
8830 },
8831 onClick(event) {
8832 if (closeOnClick && !store.select("open")) {
8833 store.cancelPendingOpen(event.nativeEvent);
8834 }
8835 },
8836 id: thisTriggerId,
8837 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
8838 [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
8839 }, elementProps],
8840 stateAttributesMapping: triggerOpenStateMapping
8841 });
8842 return element;
8843 });
8844 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8845
8846 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8847 var React41 = __toESM(require_react(), 1);
8848
8849 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8850 var React40 = __toESM(require_react(), 1);
8851 var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
8852 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8853 function useTooltipPortalContext() {
8854 const value = React40.useContext(TooltipPortalContext);
8855 if (value === void 0) {
8856 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8857 }
8858 return value;
8859 }
8860
8861 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8862 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8863 var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
8864 const {
8865 keepMounted = false,
8866 ...portalProps
8867 } = props;
8868 const store = useTooltipRootContext();
8869 const mounted = store.useState("mounted");
8870 const shouldRender = mounted || keepMounted;
8871 if (!shouldRender) {
8872 return null;
8873 }
8874 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8875 value: keepMounted,
8876 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8877 ref: forwardedRef,
8878 ...portalProps
8879 })
8880 });
8881 });
8882 if (true) TooltipPortal.displayName = "TooltipPortal";
8883
8884 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8885 var React43 = __toESM(require_react(), 1);
8886
8887 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8888 var React42 = __toESM(require_react(), 1);
8889 var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
8890 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8891 function useTooltipPositionerContext() {
8892 const context = React42.useContext(TooltipPositionerContext);
8893 if (context === void 0) {
8894 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8895 }
8896 return context;
8897 }
8898
8899 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8900 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8901 var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8902 const {
8903 render: render4,
8904 className,
8905 anchor,
8906 positionMethod = "absolute",
8907 side = "top",
8908 align = "center",
8909 sideOffset = 0,
8910 alignOffset = 0,
8911 collisionBoundary = "clipping-ancestors",
8912 collisionPadding = 5,
8913 arrowPadding = 5,
8914 sticky = false,
8915 disableAnchorTracking = false,
8916 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8917 style,
8918 ...elementProps
8919 } = componentProps;
8920 const store = useTooltipRootContext();
8921 const keepMounted = useTooltipPortalContext();
8922 const open = store.useState("open");
8923 const mounted = store.useState("mounted");
8924 const trackCursorAxis = store.useState("trackCursorAxis");
8925 const disableHoverablePopup = store.useState("disableHoverablePopup");
8926 const floatingRootContext = store.useState("floatingRootContext");
8927 const instantType = store.useState("instantType");
8928 const transitionStatus = store.useState("transitionStatus");
8929 const hasViewport = store.useState("hasViewport");
8930 const positioning = useAnchorPositioning({
8931 anchor,
8932 positionMethod,
8933 floatingRootContext,
8934 mounted,
8935 side,
8936 sideOffset,
8937 align,
8938 alignOffset,
8939 collisionBoundary,
8940 collisionPadding,
8941 sticky,
8942 arrowPadding,
8943 disableAnchorTracking,
8944 keepMounted,
8945 collisionAvoidance,
8946 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8947 });
8948 const state = React43.useMemo(() => ({
8949 open,
8950 side: positioning.side,
8951 align: positioning.align,
8952 anchorHidden: positioning.anchorHidden,
8953 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8954 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8955 const element = usePositioner(componentProps, state, {
8956 styles: positioning.positionerStyles,
8957 transitionStatus,
8958 props: elementProps,
8959 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8960 hidden: !mounted,
8961 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8962 });
8963 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8964 value: positioning,
8965 children: element
8966 });
8967 });
8968 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8969
8970 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8971 var React44 = __toESM(require_react(), 1);
8972 var stateAttributesMapping = {
8973 ...popupStateMapping,
8974 ...transitionStatusMapping
8975 };
8976 var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8977 const {
8978 render: render4,
8979 className,
8980 style,
8981 ...elementProps
8982 } = componentProps;
8983 const store = useTooltipRootContext();
8984 const {
8985 side,
8986 align
8987 } = useTooltipPositionerContext();
8988 const open = store.useState("open");
8989 const instantType = store.useState("instantType");
8990 const transitionStatus = store.useState("transitionStatus");
8991 const popupProps = store.useState("popupProps");
8992 const floatingContext = store.useState("floatingRootContext");
8993 const disabled2 = store.useState("disabled");
8994 const closeDelay = store.useState("closeDelay");
8995 useOpenChangeComplete({
8996 open,
8997 ref: store.context.popupRef,
8998 onComplete() {
8999 if (open) {
9000 store.context.onOpenChangeComplete?.(true);
9001 }
9002 }
9003 });
9004 useHoverFloatingInteraction(floatingContext, {
9005 enabled: !disabled2,
9006 closeDelay
9007 });
9008 const setPopupElement = store.useStateSetter("popupElement");
9009 const state = {
9010 open,
9011 side,
9012 align,
9013 instant: instantType,
9014 transitionStatus
9015 };
9016 const element = useRenderElement("div", componentProps, {
9017 state,
9018 ref: [forwardedRef, store.context.popupRef, setPopupElement],
9019 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
9020 stateAttributesMapping
9021 });
9022 return element;
9023 });
9024 if (true) TooltipPopup.displayName = "TooltipPopup";
9025
9026 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
9027 var React45 = __toESM(require_react(), 1);
9028 var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
9029 const {
9030 render: render4,
9031 className,
9032 style,
9033 ...elementProps
9034 } = componentProps;
9035 const store = useTooltipRootContext();
9036 const {
9037 arrowRef,
9038 side,
9039 align,
9040 arrowUncentered,
9041 arrowStyles
9042 } = useTooltipPositionerContext();
9043 const open = store.useState("open");
9044 const instantType = store.useState("instantType");
9045 const state = {
9046 open,
9047 side,
9048 align,
9049 uncentered: arrowUncentered,
9050 instant: instantType
9051 };
9052 const element = useRenderElement("div", componentProps, {
9053 state,
9054 ref: [forwardedRef, arrowRef],
9055 props: [{
9056 style: arrowStyles,
9057 "aria-hidden": true
9058 }, elementProps],
9059 stateAttributesMapping: popupStateMapping
9060 });
9061 return element;
9062 });
9063 if (true) TooltipArrow.displayName = "TooltipArrow";
9064
9065 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
9066 var React46 = __toESM(require_react(), 1);
9067 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
9068 var TooltipProvider = function TooltipProvider2(props) {
9069 const {
9070 delay,
9071 closeDelay,
9072 timeout = 400
9073 } = props;
9074 const contextValue = React46.useMemo(() => ({
9075 delay,
9076 closeDelay
9077 }), [delay, closeDelay]);
9078 const delayValue = React46.useMemo(() => ({
9079 open: delay,
9080 close: closeDelay
9081 }), [delay, closeDelay]);
9082 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
9083 value: contextValue,
9084 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
9085 delay: delayValue,
9086 timeoutMs: timeout,
9087 children: props.children
9088 })
9089 });
9090 };
9091 if (true) TooltipProvider.displayName = "TooltipProvider";
9092
9093 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9094 var React47 = __toESM(require_react(), 1);
9095
9096 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
9097 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
9098 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
9099 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
9100 return TooltipViewportCssVars2;
9101 })({});
9102
9103 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
9104 var stateAttributesMapping2 = {
9105 activationDirection: (value) => value ? {
9106 "data-activation-direction": value
9107 } : null
9108 };
9109 var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
9110 const {
9111 render: render4,
9112 className,
9113 style,
9114 children,
9115 ...elementProps
9116 } = componentProps;
9117 const store = useTooltipRootContext();
9118 const positioner = useTooltipPositionerContext();
9119 const instantType = store.useState("instantType");
9120 const {
9121 children: childrenToRender,
9122 state: viewportState
9123 } = usePopupViewport({
9124 store,
9125 side: positioner.side,
9126 cssVars: TooltipViewportCssVars,
9127 children
9128 });
9129 const state = {
9130 activationDirection: viewportState.activationDirection,
9131 transitioning: viewportState.transitioning,
9132 instant: instantType
9133 };
9134 return useRenderElement("div", componentProps, {
9135 state,
9136 ref: forwardedRef,
9137 props: [elementProps, {
9138 children: childrenToRender
9139 }],
9140 stateAttributesMapping: stateAttributesMapping2
9141 });
9142 });
9143 if (true) TooltipViewport.displayName = "TooltipViewport";
9144
9145 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
9146 var TooltipHandle = class {
9147 /**
9148 * Internal store holding the tooltip state.
9149 * @internal
9150 */
9151 constructor() {
9152 this.store = new TooltipStore();
9153 }
9154 /**
9155 * Opens the tooltip and associates it with the trigger with the given ID.
9156 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
9157 *
9158 * This method should only be called in an event handler or an effect (not during rendering).
9159 *
9160 * @param triggerId ID of the trigger to associate with the tooltip.
9161 */
9162 open(triggerId) {
9163 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9164 if (triggerId && !triggerElement) {
9165 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9166 }
9167 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9168 }
9169 /**
9170 * Closes the tooltip.
9171 */
9172 close() {
9173 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9174 }
9175 /**
9176 * Indicates whether the tooltip is currently open.
9177 */
9178 get isOpen() {
9179 return this.store.select("open");
9180 }
9181 };
9182 function createTooltipHandle() {
9183 return new TooltipHandle();
9184 }
9185
9186 // node_modules/@base-ui/react/esm/use-render/useRender.js
9187 function useRender(params) {
9188 return useRenderElement(params.defaultTagName ?? "div", params, params);
9189 }
9190
9191 // packages/ui/build-module/text/text.mjs
9192 var import_element11 = __toESM(require_element(), 1);
9193 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9194 function getRuntime() {
9195 const globalScope = globalThis;
9196 if (globalScope.__wpStyleRuntime) {
9197 return globalScope.__wpStyleRuntime;
9198 }
9199 globalScope.__wpStyleRuntime = {
9200 documents: /* @__PURE__ */ new Map(),
9201 styles: /* @__PURE__ */ new Map(),
9202 injectedStyles: /* @__PURE__ */ new WeakMap()
9203 };
9204 if (typeof document !== "undefined") {
9205 registerDocument(document);
9206 }
9207 return globalScope.__wpStyleRuntime;
9208 }
9209 function documentContainsStyleHash(targetDocument, hash) {
9210 if (!targetDocument.head) {
9211 return false;
9212 }
9213 for (const style of targetDocument.head.querySelectorAll(
9214 `style[${STYLE_HASH_ATTRIBUTE}]`
9215 )) {
9216 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9217 return true;
9218 }
9219 }
9220 return false;
9221 }
9222 function injectStyle(targetDocument, hash, css) {
9223 if (!targetDocument.head) {
9224 return;
9225 }
9226 const runtime = getRuntime();
9227 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9228 if (!injectedStyles) {
9229 injectedStyles = /* @__PURE__ */ new Set();
9230 runtime.injectedStyles.set(targetDocument, injectedStyles);
9231 }
9232 if (injectedStyles.has(hash)) {
9233 return;
9234 }
9235 if (documentContainsStyleHash(targetDocument, hash)) {
9236 injectedStyles.add(hash);
9237 return;
9238 }
9239 const style = targetDocument.createElement("style");
9240 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9241 style.appendChild(targetDocument.createTextNode(css));
9242 targetDocument.head.appendChild(style);
9243 injectedStyles.add(hash);
9244 }
9245 function registerDocument(targetDocument) {
9246 const runtime = getRuntime();
9247 runtime.documents.set(
9248 targetDocument,
9249 (runtime.documents.get(targetDocument) ?? 0) + 1
9250 );
9251 for (const [hash, css] of runtime.styles) {
9252 injectStyle(targetDocument, hash, css);
9253 }
9254 return () => {
9255 const count = runtime.documents.get(targetDocument);
9256 if (count === void 0) {
9257 return;
9258 }
9259 if (count <= 1) {
9260 runtime.documents.delete(targetDocument);
9261 return;
9262 }
9263 runtime.documents.set(targetDocument, count - 1);
9264 };
9265 }
9266 function registerStyle(hash, css) {
9267 const runtime = getRuntime();
9268 runtime.styles.set(hash, css);
9269 for (const targetDocument of runtime.documents.keys()) {
9270 injectStyle(targetDocument, hash, css);
9271 }
9272 }
9273 if (typeof process === "undefined" || true) {
9274 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)}}}');
9275 }
9276 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" };
9277 if (typeof process === "undefined" || true) {
9278 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)}");
9279 }
9280 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" };
9281 var Text = (0, import_element11.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9282 const element = useRender({
9283 render: render4,
9284 defaultTagName: "span",
9285 ref,
9286 props: mergeProps(props, {
9287 className: clsx_default(
9288 style_default.text,
9289 global_css_defense_default.heading,
9290 global_css_defense_default.p,
9291 style_default[variant],
9292 className
9293 )
9294 })
9295 });
9296 return element;
9297 });
9298
9299 // packages/icons/build-module/library/arrow-down.mjs
9300 var import_primitives = __toESM(require_primitives(), 1);
9301 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9302 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.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" }) });
9303
9304 // packages/icons/build-module/library/arrow-left.mjs
9305 var import_primitives2 = __toESM(require_primitives(), 1);
9306 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
9307 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
9308
9309 // packages/icons/build-module/library/arrow-right.mjs
9310 var import_primitives3 = __toESM(require_primitives(), 1);
9311 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
9312 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
9313
9314 // packages/icons/build-module/library/arrow-up.mjs
9315 var import_primitives4 = __toESM(require_primitives(), 1);
9316 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9317 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
9318
9319 // packages/icons/build-module/library/block-table.mjs
9320 var import_primitives5 = __toESM(require_primitives(), 1);
9321 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9322 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "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" }) });
9323
9324 // packages/icons/build-module/library/category.mjs
9325 var import_primitives6 = __toESM(require_primitives(), 1);
9326 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9327 var category_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives6.Path, { 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" }) });
9328
9329 // packages/icons/build-module/library/check.mjs
9330 var import_primitives7 = __toESM(require_primitives(), 1);
9331 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9332 var check_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives7.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
9333
9334 // packages/icons/build-module/library/close-small.mjs
9335 var import_primitives8 = __toESM(require_primitives(), 1);
9336 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9337 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives8.Path, { d: "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" }) });
9338
9339 // packages/icons/build-module/library/cog.mjs
9340 var import_primitives9 = __toESM(require_primitives(), 1);
9341 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9342 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives9.Path, { 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" }) });
9343
9344 // packages/icons/build-module/library/envelope.mjs
9345 var import_primitives10 = __toESM(require_primitives(), 1);
9346 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9347 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives10.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9348
9349 // packages/icons/build-module/library/error.mjs
9350 var import_primitives11 = __toESM(require_primitives(), 1);
9351 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9352 var error_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "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" }) });
9353
9354 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9355 var import_primitives12 = __toESM(require_primitives(), 1);
9356 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9357 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives12.Path, { 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" }) });
9358
9359 // packages/icons/build-module/library/format-list-bullets.mjs
9360 var import_primitives13 = __toESM(require_primitives(), 1);
9361 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9362 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives13.Path, { d: "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" }) });
9363
9364 // packages/icons/build-module/library/funnel.mjs
9365 var import_primitives14 = __toESM(require_primitives(), 1);
9366 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9367 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives14.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
9368
9369 // packages/icons/build-module/library/link.mjs
9370 var import_primitives15 = __toESM(require_primitives(), 1);
9371 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9372 var link_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives15.Path, { d: "M10 17.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" }) });
9373
9374 // packages/icons/build-module/library/mobile.mjs
9375 var import_primitives16 = __toESM(require_primitives(), 1);
9376 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9377 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives16.Path, { d: "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" }) });
9378
9379 // packages/icons/build-module/library/more-vertical.mjs
9380 var import_primitives17 = __toESM(require_primitives(), 1);
9381 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9382 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives17.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
9383
9384 // packages/icons/build-module/library/next.mjs
9385 var import_primitives18 = __toESM(require_primitives(), 1);
9386 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9387 var next_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives18.Path, { d: "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" }) });
9388
9389 // packages/icons/build-module/library/previous.mjs
9390 var import_primitives19 = __toESM(require_primitives(), 1);
9391 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9392 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives19.Path, { d: "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" }) });
9393
9394 // packages/icons/build-module/library/scheduled.mjs
9395 var import_primitives20 = __toESM(require_primitives(), 1);
9396 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9397 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives20.Path, { 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" }) });
9398
9399 // packages/icons/build-module/library/search.mjs
9400 var import_primitives21 = __toESM(require_primitives(), 1);
9401 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9402 var search_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives21.Path, { d: "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" }) });
9403
9404 // packages/icons/build-module/library/seen.mjs
9405 var import_primitives22 = __toESM(require_primitives(), 1);
9406 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9407 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives22.Path, { d: "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" }) });
9408
9409 // packages/icons/build-module/library/unseen.mjs
9410 var import_primitives23 = __toESM(require_primitives(), 1);
9411 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9412 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives23.Path, { 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" }) });
9413
9414 // packages/ui/build-module/utils/render-slot-with-children.mjs
9415 var import_element12 = __toESM(require_element(), 1);
9416 function renderSlotWithChildren(slot, defaultSlot, children) {
9417 return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
9418 }
9419
9420 // packages/ui/build-module/lock-unlock.mjs
9421 var import_private_apis2 = __toESM(require_private_apis(), 1);
9422 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9423 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9424 "@wordpress/ui"
9425 );
9426
9427 // packages/ui/build-module/stack/stack.mjs
9428 var import_element13 = __toESM(require_element(), 1);
9429 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9430 function getRuntime2() {
9431 const globalScope = globalThis;
9432 if (globalScope.__wpStyleRuntime) {
9433 return globalScope.__wpStyleRuntime;
9434 }
9435 globalScope.__wpStyleRuntime = {
9436 documents: /* @__PURE__ */ new Map(),
9437 styles: /* @__PURE__ */ new Map(),
9438 injectedStyles: /* @__PURE__ */ new WeakMap()
9439 };
9440 if (typeof document !== "undefined") {
9441 registerDocument2(document);
9442 }
9443 return globalScope.__wpStyleRuntime;
9444 }
9445 function documentContainsStyleHash2(targetDocument, hash) {
9446 if (!targetDocument.head) {
9447 return false;
9448 }
9449 for (const style of targetDocument.head.querySelectorAll(
9450 `style[${STYLE_HASH_ATTRIBUTE2}]`
9451 )) {
9452 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9453 return true;
9454 }
9455 }
9456 return false;
9457 }
9458 function injectStyle2(targetDocument, hash, css) {
9459 if (!targetDocument.head) {
9460 return;
9461 }
9462 const runtime = getRuntime2();
9463 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9464 if (!injectedStyles) {
9465 injectedStyles = /* @__PURE__ */ new Set();
9466 runtime.injectedStyles.set(targetDocument, injectedStyles);
9467 }
9468 if (injectedStyles.has(hash)) {
9469 return;
9470 }
9471 if (documentContainsStyleHash2(targetDocument, hash)) {
9472 injectedStyles.add(hash);
9473 return;
9474 }
9475 const style = targetDocument.createElement("style");
9476 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9477 style.appendChild(targetDocument.createTextNode(css));
9478 targetDocument.head.appendChild(style);
9479 injectedStyles.add(hash);
9480 }
9481 function registerDocument2(targetDocument) {
9482 const runtime = getRuntime2();
9483 runtime.documents.set(
9484 targetDocument,
9485 (runtime.documents.get(targetDocument) ?? 0) + 1
9486 );
9487 for (const [hash, css] of runtime.styles) {
9488 injectStyle2(targetDocument, hash, css);
9489 }
9490 return () => {
9491 const count = runtime.documents.get(targetDocument);
9492 if (count === void 0) {
9493 return;
9494 }
9495 if (count <= 1) {
9496 runtime.documents.delete(targetDocument);
9497 return;
9498 }
9499 runtime.documents.set(targetDocument, count - 1);
9500 };
9501 }
9502 function registerStyle2(hash, css) {
9503 const runtime = getRuntime2();
9504 runtime.styles.set(hash, css);
9505 for (const targetDocument of runtime.documents.keys()) {
9506 injectStyle2(targetDocument, hash, css);
9507 }
9508 }
9509 if (typeof process === "undefined" || true) {
9510 registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
9511 }
9512 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9513 var gapTokens = {
9514 xs: "var(--wpds-dimension-gap-xs, 4px)",
9515 sm: "var(--wpds-dimension-gap-sm, 8px)",
9516 md: "var(--wpds-dimension-gap-md, 12px)",
9517 lg: "var(--wpds-dimension-gap-lg, 16px)",
9518 xl: "var(--wpds-dimension-gap-xl, 24px)",
9519 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9520 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9521 };
9522 var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9523 const style = {
9524 gap: gap && gapTokens[gap],
9525 alignItems: align,
9526 justifyContent: justify,
9527 flexDirection: direction,
9528 flexWrap: wrap
9529 };
9530 const element = useRender({
9531 render: render4,
9532 ref,
9533 props: mergeProps(props, { style, className: style_default2.stack })
9534 });
9535 return element;
9536 });
9537
9538 // packages/ui/build-module/tooltip/index.mjs
9539 var tooltip_exports = {};
9540 __export(tooltip_exports, {
9541 Popup: () => Popup,
9542 Portal: () => Portal,
9543 Positioner: () => Positioner,
9544 Provider: () => Provider,
9545 Root: () => Root,
9546 Trigger: () => Trigger
9547 });
9548
9549 // packages/ui/build-module/tooltip/popup.mjs
9550 var import_element16 = __toESM(require_element(), 1);
9551 var import_theme = __toESM(require_theme(), 1);
9552
9553 // packages/ui/build-module/tooltip/portal.mjs
9554 var import_element14 = __toESM(require_element(), 1);
9555
9556 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9557 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9558 function getRuntime3() {
9559 const globalScope = globalThis;
9560 if (globalScope.__wpStyleRuntime) {
9561 return globalScope.__wpStyleRuntime;
9562 }
9563 globalScope.__wpStyleRuntime = {
9564 documents: /* @__PURE__ */ new Map(),
9565 styles: /* @__PURE__ */ new Map(),
9566 injectedStyles: /* @__PURE__ */ new WeakMap()
9567 };
9568 if (typeof document !== "undefined") {
9569 registerDocument3(document);
9570 }
9571 return globalScope.__wpStyleRuntime;
9572 }
9573 function documentContainsStyleHash3(targetDocument, hash) {
9574 if (!targetDocument.head) {
9575 return false;
9576 }
9577 for (const style of targetDocument.head.querySelectorAll(
9578 `style[${STYLE_HASH_ATTRIBUTE3}]`
9579 )) {
9580 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9581 return true;
9582 }
9583 }
9584 return false;
9585 }
9586 function injectStyle3(targetDocument, hash, css) {
9587 if (!targetDocument.head) {
9588 return;
9589 }
9590 const runtime = getRuntime3();
9591 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9592 if (!injectedStyles) {
9593 injectedStyles = /* @__PURE__ */ new Set();
9594 runtime.injectedStyles.set(targetDocument, injectedStyles);
9595 }
9596 if (injectedStyles.has(hash)) {
9597 return;
9598 }
9599 if (documentContainsStyleHash3(targetDocument, hash)) {
9600 injectedStyles.add(hash);
9601 return;
9602 }
9603 const style = targetDocument.createElement("style");
9604 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9605 style.appendChild(targetDocument.createTextNode(css));
9606 targetDocument.head.appendChild(style);
9607 injectedStyles.add(hash);
9608 }
9609 function registerDocument3(targetDocument) {
9610 const runtime = getRuntime3();
9611 runtime.documents.set(
9612 targetDocument,
9613 (runtime.documents.get(targetDocument) ?? 0) + 1
9614 );
9615 for (const [hash, css] of runtime.styles) {
9616 injectStyle3(targetDocument, hash, css);
9617 }
9618 return () => {
9619 const count = runtime.documents.get(targetDocument);
9620 if (count === void 0) {
9621 return;
9622 }
9623 if (count <= 1) {
9624 runtime.documents.delete(targetDocument);
9625 return;
9626 }
9627 runtime.documents.set(targetDocument, count - 1);
9628 };
9629 }
9630 function registerStyle3(hash, css) {
9631 const runtime = getRuntime3();
9632 runtime.styles.set(hash, css);
9633 for (const targetDocument of runtime.documents.keys()) {
9634 injectStyle3(targetDocument, hash, css);
9635 }
9636 }
9637 if (typeof process === "undefined" || true) {
9638 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}}}");
9639 }
9640 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9641 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9642 function resolveOwnerDocument() {
9643 return typeof document === "undefined" ? null : document;
9644 }
9645 function isInWordPressEnvironment() {
9646 let topWp;
9647 try {
9648 topWp = window.top?.wp;
9649 } catch {
9650 }
9651 const wp = topWp ?? window.wp;
9652 return typeof wp?.components === "object" && wp.components !== null;
9653 }
9654 var cachedSlot = null;
9655 function createSlot(ownerDocument2) {
9656 const element = ownerDocument2.createElement("div");
9657 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9658 if (wp_compat_overlay_slot_default.slot) {
9659 element.classList.add(wp_compat_overlay_slot_default.slot);
9660 }
9661 ownerDocument2.body.appendChild(element);
9662 return element;
9663 }
9664 function getWpCompatOverlaySlot() {
9665 if (typeof window === "undefined") {
9666 return void 0;
9667 }
9668 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9669 return void 0;
9670 }
9671 const ownerDocument2 = resolveOwnerDocument();
9672 if (!ownerDocument2 || !ownerDocument2.body) {
9673 return void 0;
9674 }
9675 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9676 return cachedSlot;
9677 }
9678 const existing = ownerDocument2.querySelector(
9679 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9680 );
9681 if (existing instanceof HTMLDivElement) {
9682 cachedSlot = existing;
9683 return existing;
9684 }
9685 if (cachedSlot?.isConnected) {
9686 cachedSlot.remove();
9687 }
9688 cachedSlot = createSlot(ownerDocument2);
9689 return cachedSlot;
9690 }
9691
9692 // packages/ui/build-module/tooltip/portal.mjs
9693 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9694 var Portal = (0, import_element14.forwardRef)(
9695 function TooltipPortal3({ container, ...restProps }, ref) {
9696 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9697 index_parts_exports.Portal,
9698 {
9699 container: container ?? getWpCompatOverlaySlot(),
9700 ...restProps,
9701 ref
9702 }
9703 );
9704 }
9705 );
9706
9707 // packages/ui/build-module/tooltip/positioner.mjs
9708 var import_element15 = __toESM(require_element(), 1);
9709 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9710 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9711 function getRuntime4() {
9712 const globalScope = globalThis;
9713 if (globalScope.__wpStyleRuntime) {
9714 return globalScope.__wpStyleRuntime;
9715 }
9716 globalScope.__wpStyleRuntime = {
9717 documents: /* @__PURE__ */ new Map(),
9718 styles: /* @__PURE__ */ new Map(),
9719 injectedStyles: /* @__PURE__ */ new WeakMap()
9720 };
9721 if (typeof document !== "undefined") {
9722 registerDocument4(document);
9723 }
9724 return globalScope.__wpStyleRuntime;
9725 }
9726 function documentContainsStyleHash4(targetDocument, hash) {
9727 if (!targetDocument.head) {
9728 return false;
9729 }
9730 for (const style of targetDocument.head.querySelectorAll(
9731 `style[${STYLE_HASH_ATTRIBUTE4}]`
9732 )) {
9733 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9734 return true;
9735 }
9736 }
9737 return false;
9738 }
9739 function injectStyle4(targetDocument, hash, css) {
9740 if (!targetDocument.head) {
9741 return;
9742 }
9743 const runtime = getRuntime4();
9744 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9745 if (!injectedStyles) {
9746 injectedStyles = /* @__PURE__ */ new Set();
9747 runtime.injectedStyles.set(targetDocument, injectedStyles);
9748 }
9749 if (injectedStyles.has(hash)) {
9750 return;
9751 }
9752 if (documentContainsStyleHash4(targetDocument, hash)) {
9753 injectedStyles.add(hash);
9754 return;
9755 }
9756 const style = targetDocument.createElement("style");
9757 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9758 style.appendChild(targetDocument.createTextNode(css));
9759 targetDocument.head.appendChild(style);
9760 injectedStyles.add(hash);
9761 }
9762 function registerDocument4(targetDocument) {
9763 const runtime = getRuntime4();
9764 runtime.documents.set(
9765 targetDocument,
9766 (runtime.documents.get(targetDocument) ?? 0) + 1
9767 );
9768 for (const [hash, css] of runtime.styles) {
9769 injectStyle4(targetDocument, hash, css);
9770 }
9771 return () => {
9772 const count = runtime.documents.get(targetDocument);
9773 if (count === void 0) {
9774 return;
9775 }
9776 if (count <= 1) {
9777 runtime.documents.delete(targetDocument);
9778 return;
9779 }
9780 runtime.documents.set(targetDocument, count - 1);
9781 };
9782 }
9783 function registerStyle4(hash, css) {
9784 const runtime = getRuntime4();
9785 runtime.styles.set(hash, css);
9786 for (const targetDocument of runtime.documents.keys()) {
9787 injectStyle4(targetDocument, hash, css);
9788 }
9789 }
9790 if (typeof process === "undefined" || true) {
9791 registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
9792 }
9793 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9794 if (typeof process === "undefined" || true) {
9795 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}}}}');
9796 }
9797 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9798 var Positioner = (0, import_element15.forwardRef)(
9799 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9800 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9801 index_parts_exports.Positioner,
9802 {
9803 ref,
9804 align,
9805 side,
9806 sideOffset,
9807 ...props,
9808 className: clsx_default(
9809 resets_default["box-sizing"],
9810 style_default3.positioner,
9811 className
9812 )
9813 }
9814 );
9815 }
9816 );
9817
9818 // packages/ui/build-module/tooltip/popup.mjs
9819 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9820 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9821 function getRuntime5() {
9822 const globalScope = globalThis;
9823 if (globalScope.__wpStyleRuntime) {
9824 return globalScope.__wpStyleRuntime;
9825 }
9826 globalScope.__wpStyleRuntime = {
9827 documents: /* @__PURE__ */ new Map(),
9828 styles: /* @__PURE__ */ new Map(),
9829 injectedStyles: /* @__PURE__ */ new WeakMap()
9830 };
9831 if (typeof document !== "undefined") {
9832 registerDocument5(document);
9833 }
9834 return globalScope.__wpStyleRuntime;
9835 }
9836 function documentContainsStyleHash5(targetDocument, hash) {
9837 if (!targetDocument.head) {
9838 return false;
9839 }
9840 for (const style of targetDocument.head.querySelectorAll(
9841 `style[${STYLE_HASH_ATTRIBUTE5}]`
9842 )) {
9843 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9844 return true;
9845 }
9846 }
9847 return false;
9848 }
9849 function injectStyle5(targetDocument, hash, css) {
9850 if (!targetDocument.head) {
9851 return;
9852 }
9853 const runtime = getRuntime5();
9854 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9855 if (!injectedStyles) {
9856 injectedStyles = /* @__PURE__ */ new Set();
9857 runtime.injectedStyles.set(targetDocument, injectedStyles);
9858 }
9859 if (injectedStyles.has(hash)) {
9860 return;
9861 }
9862 if (documentContainsStyleHash5(targetDocument, hash)) {
9863 injectedStyles.add(hash);
9864 return;
9865 }
9866 const style = targetDocument.createElement("style");
9867 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9868 style.appendChild(targetDocument.createTextNode(css));
9869 targetDocument.head.appendChild(style);
9870 injectedStyles.add(hash);
9871 }
9872 function registerDocument5(targetDocument) {
9873 const runtime = getRuntime5();
9874 runtime.documents.set(
9875 targetDocument,
9876 (runtime.documents.get(targetDocument) ?? 0) + 1
9877 );
9878 for (const [hash, css] of runtime.styles) {
9879 injectStyle5(targetDocument, hash, css);
9880 }
9881 return () => {
9882 const count = runtime.documents.get(targetDocument);
9883 if (count === void 0) {
9884 return;
9885 }
9886 if (count <= 1) {
9887 runtime.documents.delete(targetDocument);
9888 return;
9889 }
9890 runtime.documents.set(targetDocument, count - 1);
9891 };
9892 }
9893 function registerStyle5(hash, css) {
9894 const runtime = getRuntime5();
9895 runtime.styles.set(hash, css);
9896 for (const targetDocument of runtime.documents.keys()) {
9897 injectStyle5(targetDocument, hash, css);
9898 }
9899 }
9900 if (typeof process === "undefined" || true) {
9901 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}}}}');
9902 }
9903 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9904 var ThemeProvider = unlock2(import_theme.privateApis).ThemeProvider;
9905 var POPUP_COLOR = { background: "#1e1e1e" };
9906 var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9907 const popupContent = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
9908 index_parts_exports.Popup,
9909 {
9910 ref,
9911 className: clsx_default(style_default4.popup, className),
9912 ...props,
9913 children
9914 }
9915 ) });
9916 const positionedPopup = renderSlotWithChildren(
9917 positioner,
9918 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Positioner, {}),
9919 popupContent
9920 );
9921 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Portal, {}), positionedPopup);
9922 });
9923
9924 // packages/ui/build-module/tooltip/trigger.mjs
9925 var import_element17 = __toESM(require_element(), 1);
9926 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9927 var Trigger = (0, import_element17.forwardRef)(
9928 function TooltipTrigger3(props, ref) {
9929 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(index_parts_exports.Trigger, { ref, ...props });
9930 }
9931 );
9932
9933 // packages/ui/build-module/tooltip/root.mjs
9934 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9935 function Root(props) {
9936 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(index_parts_exports.Root, { ...props });
9937 }
9938
9939 // packages/ui/build-module/tooltip/provider.mjs
9940 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9941 function Provider({ ...props }) {
9942 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(index_parts_exports.Provider, { ...props });
9943 }
9944
9945 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
9946 var import_element18 = __toESM(require_element(), 1);
9947 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9948 function getRuntime6() {
9949 const globalScope = globalThis;
9950 if (globalScope.__wpStyleRuntime) {
9951 return globalScope.__wpStyleRuntime;
9952 }
9953 globalScope.__wpStyleRuntime = {
9954 documents: /* @__PURE__ */ new Map(),
9955 styles: /* @__PURE__ */ new Map(),
9956 injectedStyles: /* @__PURE__ */ new WeakMap()
9957 };
9958 if (typeof document !== "undefined") {
9959 registerDocument6(document);
9960 }
9961 return globalScope.__wpStyleRuntime;
9962 }
9963 function documentContainsStyleHash6(targetDocument, hash) {
9964 if (!targetDocument.head) {
9965 return false;
9966 }
9967 for (const style of targetDocument.head.querySelectorAll(
9968 `style[${STYLE_HASH_ATTRIBUTE6}]`
9969 )) {
9970 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9971 return true;
9972 }
9973 }
9974 return false;
9975 }
9976 function injectStyle6(targetDocument, hash, css) {
9977 if (!targetDocument.head) {
9978 return;
9979 }
9980 const runtime = getRuntime6();
9981 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9982 if (!injectedStyles) {
9983 injectedStyles = /* @__PURE__ */ new Set();
9984 runtime.injectedStyles.set(targetDocument, injectedStyles);
9985 }
9986 if (injectedStyles.has(hash)) {
9987 return;
9988 }
9989 if (documentContainsStyleHash6(targetDocument, hash)) {
9990 injectedStyles.add(hash);
9991 return;
9992 }
9993 const style = targetDocument.createElement("style");
9994 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9995 style.appendChild(targetDocument.createTextNode(css));
9996 targetDocument.head.appendChild(style);
9997 injectedStyles.add(hash);
9998 }
9999 function registerDocument6(targetDocument) {
10000 const runtime = getRuntime6();
10001 runtime.documents.set(
10002 targetDocument,
10003 (runtime.documents.get(targetDocument) ?? 0) + 1
10004 );
10005 for (const [hash, css] of runtime.styles) {
10006 injectStyle6(targetDocument, hash, css);
10007 }
10008 return () => {
10009 const count = runtime.documents.get(targetDocument);
10010 if (count === void 0) {
10011 return;
10012 }
10013 if (count <= 1) {
10014 runtime.documents.delete(targetDocument);
10015 return;
10016 }
10017 runtime.documents.set(targetDocument, count - 1);
10018 };
10019 }
10020 function registerStyle6(hash, css) {
10021 const runtime = getRuntime6();
10022 runtime.styles.set(hash, css);
10023 for (const targetDocument of runtime.documents.keys()) {
10024 injectStyle6(targetDocument, hash, css);
10025 }
10026 }
10027 if (typeof process === "undefined" || true) {
10028 registerStyle6("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}}}");
10029 }
10030 var style_default5 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
10031 var VisuallyHidden = (0, import_element18.forwardRef)(
10032 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
10033 const element = useRender({
10034 render: render4,
10035 ref,
10036 props: mergeProps(
10037 { className: style_default5["visually-hidden"] },
10038 restProps,
10039 {
10040 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
10041 "data-visually-hidden": ""
10042 }
10043 )
10044 });
10045 return element;
10046 }
10047 );
10048
10049 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10050 var import_element19 = __toESM(require_element(), 1);
10051
10052 // packages/dataviews/build-module/constants.mjs
10053 var import_i18n = __toESM(require_i18n(), 1);
10054 var OPERATOR_IS_ANY = "isAny";
10055 var OPERATOR_IS_NONE = "isNone";
10056 var OPERATOR_IS_ALL = "isAll";
10057 var OPERATOR_IS_NOT_ALL = "isNotAll";
10058 var OPERATOR_BETWEEN = "between";
10059 var OPERATOR_IN_THE_PAST = "inThePast";
10060 var OPERATOR_OVER = "over";
10061 var OPERATOR_IS = "is";
10062 var OPERATOR_IS_NOT = "isNot";
10063 var OPERATOR_LESS_THAN = "lessThan";
10064 var OPERATOR_GREATER_THAN = "greaterThan";
10065 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
10066 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
10067 var OPERATOR_BEFORE = "before";
10068 var OPERATOR_AFTER = "after";
10069 var OPERATOR_BEFORE_INC = "beforeInc";
10070 var OPERATOR_AFTER_INC = "afterInc";
10071 var OPERATOR_CONTAINS = "contains";
10072 var OPERATOR_NOT_CONTAINS = "notContains";
10073 var OPERATOR_STARTS_WITH = "startsWith";
10074 var OPERATOR_ON = "on";
10075 var OPERATOR_NOT_ON = "notOn";
10076 var SORTING_DIRECTIONS = ["asc", "desc"];
10077 var sortArrows = { asc: "\u2191", desc: "\u2193" };
10078 var sortValues = { asc: "ascending", desc: "descending" };
10079 var sortLabels = {
10080 asc: (0, import_i18n.__)("Sort ascending"),
10081 desc: (0, import_i18n.__)("Sort descending")
10082 };
10083 var sortIcons = {
10084 asc: arrow_up_default,
10085 desc: arrow_down_default
10086 };
10087 var LAYOUT_TABLE = "table";
10088 var LAYOUT_GRID = "grid";
10089 var LAYOUT_LIST = "list";
10090 var LAYOUT_ACTIVITY = "activity";
10091 var LAYOUT_PICKER_GRID = "pickerGrid";
10092 var LAYOUT_PICKER_TABLE = "pickerTable";
10093 var LAYOUT_PICKER_ACTIVITY = "pickerActivity";
10094
10095 // packages/dataviews/build-module/components/dataviews-context/index.mjs
10096 var DataViewsContext = (0, import_element19.createContext)({
10097 view: { type: LAYOUT_TABLE },
10098 onChangeView: () => {
10099 },
10100 fields: [],
10101 data: [],
10102 paginationInfo: {
10103 totalItems: 0,
10104 totalPages: 0
10105 },
10106 selection: [],
10107 onChangeSelection: () => {
10108 },
10109 setOpenedFilter: () => {
10110 },
10111 openedFilter: null,
10112 getItemId: (item) => item.id,
10113 isItemClickable: () => true,
10114 renderItemLink: void 0,
10115 containerWidth: 0,
10116 containerRef: (0, import_element19.createRef)(),
10117 resizeObserverRef: () => {
10118 },
10119 defaultLayouts: { list: {}, grid: {}, table: {} },
10120 filters: [],
10121 isShowingFilter: false,
10122 setIsShowingFilter: () => {
10123 },
10124 hasInitiallyLoaded: false,
10125 config: {
10126 perPageSizes: []
10127 },
10128 intersectionObserver: null
10129 });
10130 DataViewsContext.displayName = "DataViewsContext";
10131 var dataviews_context_default = DataViewsContext;
10132
10133 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
10134 var import_i18n22 = __toESM(require_i18n(), 1);
10135
10136 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
10137 var import_i18n9 = __toESM(require_i18n(), 1);
10138 var import_components6 = __toESM(require_components(), 1);
10139 var import_element27 = __toESM(require_element(), 1);
10140 var import_keycodes = __toESM(require_keycodes(), 1);
10141
10142 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
10143 var import_components = __toESM(require_components(), 1);
10144 var import_i18n2 = __toESM(require_i18n(), 1);
10145 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
10146 function DataViewsSelectionCheckbox({
10147 selection,
10148 onChangeSelection,
10149 item,
10150 getItemId,
10151 titleField,
10152 disabled: disabled2,
10153 ...extraProps
10154 }) {
10155 const id = getItemId(item);
10156 const isInSelectionArray = selection.includes(id);
10157 const checked = !disabled2 && isInSelectionArray;
10158 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
10159 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10160 import_components.CheckboxControl,
10161 {
10162 className: "dataviews-selection-checkbox",
10163 "aria-label": selectionLabel,
10164 "aria-disabled": disabled2,
10165 checked,
10166 onChange: () => {
10167 if (disabled2) {
10168 return;
10169 }
10170 onChangeSelection(
10171 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10172 );
10173 },
10174 ...extraProps
10175 }
10176 );
10177 }
10178
10179 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10180 var import_components2 = __toESM(require_components(), 1);
10181 var import_i18n3 = __toESM(require_i18n(), 1);
10182 var import_element20 = __toESM(require_element(), 1);
10183 var import_data4 = __toESM(require_data(), 1);
10184 var import_compose = __toESM(require_compose(), 1);
10185
10186 // packages/dataviews/build-module/lock-unlock.mjs
10187 var import_private_apis3 = __toESM(require_private_apis(), 1);
10188 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10189 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10190 "@wordpress/dataviews"
10191 );
10192
10193 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10194 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10195 var { Menu, kebabCase } = unlock3(import_components2.privateApis);
10196 function ButtonTrigger({
10197 action,
10198 onClick,
10199 items,
10200 variant
10201 }) {
10202 const label = typeof action.label === "string" ? action.label : action.label(items);
10203 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10204 import_components2.Button,
10205 {
10206 disabled: !!action.disabled,
10207 accessibleWhenDisabled: true,
10208 size: "compact",
10209 variant,
10210 onClick,
10211 children: label
10212 }
10213 );
10214 }
10215 function MenuItemTrigger({
10216 action,
10217 onClick,
10218 items
10219 }) {
10220 const label = typeof action.label === "string" ? action.label : action.label(items);
10221 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.ItemLabel, { children: label }) });
10222 }
10223 function ActionModal({
10224 action,
10225 items,
10226 closeModal
10227 }) {
10228 const label = typeof action.label === "string" ? action.label : action.label(items);
10229 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10230 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10231 import_components2.Modal,
10232 {
10233 title: modalHeader || label,
10234 __experimentalHideHeader: !!action.hideModalHeader,
10235 onRequestClose: closeModal,
10236 focusOnMount: action.modalFocusOnMount ?? true,
10237 size: action.modalSize || "medium",
10238 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10239 action.id
10240 )}`,
10241 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(action.RenderModal, { items, closeModal })
10242 }
10243 );
10244 }
10245 function ActionsMenuGroup({
10246 actions,
10247 item,
10248 registry,
10249 setActiveModalAction
10250 }) {
10251 const { primaryActions, regularActions } = (0, import_element20.useMemo)(() => {
10252 return actions.reduce(
10253 (acc, action) => {
10254 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10255 return acc;
10256 },
10257 {
10258 primaryActions: [],
10259 regularActions: []
10260 }
10261 );
10262 }, [actions]);
10263 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10264 MenuItemTrigger,
10265 {
10266 action,
10267 onClick: () => {
10268 if ("RenderModal" in action) {
10269 setActiveModalAction(action);
10270 return;
10271 }
10272 action.callback([item], { registry });
10273 },
10274 items: [item]
10275 },
10276 action.id
10277 ));
10278 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu.Group, { children: [
10279 renderActionGroup(primaryActions),
10280 renderActionGroup(regularActions)
10281 ] });
10282 }
10283 function ItemActions({
10284 item,
10285 actions,
10286 isCompact
10287 }) {
10288 const registry = (0, import_data4.useRegistry)();
10289 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
10290 const _eligibleActions = actions.filter(
10291 (action) => !action.isEligible || action.isEligible(item)
10292 );
10293 const _primaryActions = _eligibleActions.filter(
10294 (action) => action.isPrimary
10295 );
10296 return {
10297 primaryActions: _primaryActions,
10298 eligibleActions: _eligibleActions
10299 };
10300 }, [actions, item]);
10301 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10302 if (isCompact) {
10303 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10304 CompactItemActions,
10305 {
10306 item,
10307 actions: eligibleActions,
10308 isSmall: true,
10309 registry
10310 }
10311 );
10312 }
10313 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
10314 Stack,
10315 {
10316 direction: "row",
10317 justify: "flex-end",
10318 className: "dataviews-item-actions",
10319 style: {
10320 flexShrink: 0,
10321 width: "auto"
10322 },
10323 children: [
10324 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10325 PrimaryActions,
10326 {
10327 item,
10328 actions: primaryActions,
10329 registry
10330 }
10331 ),
10332 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10333 // there if there are any actions at all.
10334 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10335 CompactItemActions,
10336 {
10337 item,
10338 actions: eligibleActions,
10339 registry
10340 }
10341 )
10342 ]
10343 }
10344 );
10345 }
10346 function CompactItemActions({
10347 item,
10348 actions,
10349 isSmall,
10350 registry
10351 }) {
10352 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(
10353 null
10354 );
10355 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10356 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu, { placement: "bottom-end", children: [
10357 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10358 Menu.TriggerButton,
10359 {
10360 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10361 import_components2.Button,
10362 {
10363 size: isSmall ? "small" : "compact",
10364 icon: more_vertical_default,
10365 label: (0, import_i18n3.__)("Actions"),
10366 accessibleWhenDisabled: true,
10367 disabled: !actions.length,
10368 className: "dataviews-all-actions-button"
10369 }
10370 )
10371 }
10372 ),
10373 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10374 ActionsMenuGroup,
10375 {
10376 actions,
10377 item,
10378 registry,
10379 setActiveModalAction
10380 }
10381 ) })
10382 ] }),
10383 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10384 ActionModal,
10385 {
10386 action: activeModalAction,
10387 items: [item],
10388 closeModal: () => setActiveModalAction(null)
10389 }
10390 )
10391 ] });
10392 }
10393 function PrimaryActions({
10394 item,
10395 actions,
10396 registry,
10397 buttonVariant
10398 }) {
10399 const [activeModalAction, setActiveModalAction] = (0, import_element20.useState)(null);
10400 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10401 if (isMobileViewport) {
10402 return null;
10403 }
10404 if (!Array.isArray(actions) || actions.length === 0) {
10405 return null;
10406 }
10407 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10408 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10409 ButtonTrigger,
10410 {
10411 action,
10412 onClick: () => {
10413 if ("RenderModal" in action) {
10414 setActiveModalAction(action);
10415 return;
10416 }
10417 action.callback([item], { registry });
10418 },
10419 items: [item],
10420 variant: buttonVariant
10421 },
10422 action.id
10423 )),
10424 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10425 ActionModal,
10426 {
10427 action: activeModalAction,
10428 items: [item],
10429 closeModal: () => setActiveModalAction(null)
10430 }
10431 )
10432 ] });
10433 }
10434
10435 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10436 var import_components3 = __toESM(require_components(), 1);
10437 var import_i18n5 = __toESM(require_i18n(), 1);
10438 var import_element21 = __toESM(require_element(), 1);
10439 var import_data5 = __toESM(require_data(), 1);
10440 var import_compose2 = __toESM(require_compose(), 1);
10441
10442 // packages/dataviews/build-module/utils/get-footer-message.mjs
10443 var import_i18n4 = __toESM(require_i18n(), 1);
10444 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10445 if (selectionCount > 0) {
10446 return (0, import_i18n4.sprintf)(
10447 /* translators: %d: number of items. */
10448 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
10449 selectionCount
10450 );
10451 }
10452 if (onlyTotalCount || totalItems <= itemsCount) {
10453 return (0, import_i18n4.sprintf)(
10454 /* translators: %d: number of items. */
10455 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
10456 totalItems
10457 );
10458 }
10459 return (0, import_i18n4.sprintf)(
10460 /* translators: %1$d: number of items. %2$d: total number of items. */
10461 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10462 itemsCount,
10463 totalItems
10464 );
10465 }
10466
10467 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10468 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10469 function ActionWithModal({
10470 action,
10471 items,
10472 ActionTriggerComponent
10473 }) {
10474 const [isModalOpen, setIsModalOpen] = (0, import_element21.useState)(false);
10475 const actionTriggerProps = {
10476 action,
10477 onClick: () => {
10478 setIsModalOpen(true);
10479 },
10480 items
10481 };
10482 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
10483 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10484 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10485 ActionModal,
10486 {
10487 action,
10488 items,
10489 closeModal: () => setIsModalOpen(false)
10490 }
10491 )
10492 ] });
10493 }
10494 function useHasAPossibleBulkAction(actions, item) {
10495 return (0, import_element21.useMemo)(() => {
10496 return actions.some((action) => {
10497 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10498 });
10499 }, [actions, item]);
10500 }
10501 function useSomeItemHasAPossibleBulkAction(actions, data) {
10502 return (0, import_element21.useMemo)(() => {
10503 return data.some((item) => {
10504 return actions.some((action) => {
10505 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10506 });
10507 });
10508 }, [actions, data]);
10509 }
10510 function BulkSelectionCheckbox({
10511 selection,
10512 onChangeSelection,
10513 data,
10514 actions,
10515 getItemId,
10516 disableSelectAll = false
10517 }) {
10518 const selectableItems = (0, import_element21.useMemo)(() => {
10519 return data.filter((item) => {
10520 return actions.some(
10521 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10522 );
10523 });
10524 }, [data, actions]);
10525 const selectedItems = data.filter(
10526 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10527 );
10528 const hasSelection = selection.length > 0;
10529 const areAllSelected = selectedItems.length === selectableItems.length;
10530 if (disableSelectAll) {
10531 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10532 import_components3.CheckboxControl,
10533 {
10534 className: "dataviews-view-table-selection-checkbox",
10535 checked: hasSelection,
10536 disabled: !hasSelection,
10537 onChange: () => {
10538 onChangeSelection([]);
10539 },
10540 "aria-label": (0, import_i18n5.__)("Deselect all")
10541 }
10542 );
10543 }
10544 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10545 import_components3.CheckboxControl,
10546 {
10547 className: "dataviews-view-table-selection-checkbox",
10548 checked: areAllSelected,
10549 indeterminate: !areAllSelected && !!selectedItems.length,
10550 onChange: () => {
10551 if (areAllSelected) {
10552 onChangeSelection([]);
10553 } else {
10554 onChangeSelection(
10555 selectableItems.map((item) => getItemId(item))
10556 );
10557 }
10558 },
10559 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
10560 }
10561 );
10562 }
10563 function ActionTrigger({
10564 action,
10565 onClick,
10566 isBusy,
10567 items
10568 }) {
10569 const label = typeof action.label === "string" ? action.label : action.label(items);
10570 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10571 if (isMobile) {
10572 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10573 import_components3.Button,
10574 {
10575 disabled: isBusy,
10576 accessibleWhenDisabled: true,
10577 label,
10578 icon: action.icon,
10579 size: "compact",
10580 onClick,
10581 isBusy
10582 }
10583 );
10584 }
10585 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10586 import_components3.Button,
10587 {
10588 disabled: isBusy,
10589 accessibleWhenDisabled: true,
10590 size: "compact",
10591 onClick,
10592 isBusy,
10593 children: label
10594 }
10595 );
10596 }
10597 var EMPTY_ARRAY2 = [];
10598 function ActionButton({
10599 action,
10600 selectedItems,
10601 actionInProgress,
10602 setActionInProgress
10603 }) {
10604 const registry = (0, import_data5.useRegistry)();
10605 const selectedEligibleItems = (0, import_element21.useMemo)(() => {
10606 return selectedItems.filter((item) => {
10607 return !action.isEligible || action.isEligible(item);
10608 });
10609 }, [action, selectedItems]);
10610 if ("RenderModal" in action) {
10611 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10612 ActionWithModal,
10613 {
10614 action,
10615 items: selectedEligibleItems,
10616 ActionTriggerComponent: ActionTrigger
10617 },
10618 action.id
10619 );
10620 }
10621 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10622 ActionTrigger,
10623 {
10624 action,
10625 onClick: async () => {
10626 setActionInProgress(action.id);
10627 await action.callback(selectedItems, {
10628 registry
10629 });
10630 setActionInProgress(null);
10631 },
10632 items: selectedEligibleItems,
10633 isBusy: actionInProgress === action.id
10634 },
10635 action.id
10636 );
10637 }
10638 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10639 const message2 = getFooterMessage(
10640 selection.length,
10641 data.length,
10642 paginationInfo.totalItems,
10643 isInfiniteScroll
10644 );
10645 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10646 Stack,
10647 {
10648 direction: "row",
10649 className: "dataviews-bulk-actions-footer__container",
10650 gap: "md",
10651 align: "center",
10652 children: [
10653 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10654 BulkSelectionCheckbox,
10655 {
10656 selection,
10657 onChangeSelection,
10658 data,
10659 actions,
10660 getItemId,
10661 disableSelectAll: isInfiniteScroll
10662 }
10663 ),
10664 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10665 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10666 Stack,
10667 {
10668 direction: "row",
10669 className: "dataviews-bulk-actions-footer__action-buttons",
10670 gap: "xs",
10671 children: [
10672 actionsToShow.map((action) => {
10673 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10674 ActionButton,
10675 {
10676 action,
10677 selectedItems,
10678 actionInProgress,
10679 setActionInProgress
10680 },
10681 action.id
10682 );
10683 }),
10684 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10685 import_components3.Button,
10686 {
10687 icon: close_small_default,
10688 showTooltip: true,
10689 tooltipPosition: "top",
10690 size: "compact",
10691 label: (0, import_i18n5.__)("Cancel"),
10692 disabled: !!actionInProgress,
10693 accessibleWhenDisabled: false,
10694 onClick: () => {
10695 onChangeSelection(EMPTY_ARRAY2);
10696 }
10697 }
10698 )
10699 ]
10700 }
10701 )
10702 ]
10703 }
10704 );
10705 }
10706 function FooterContent({
10707 selection,
10708 actions,
10709 onChangeSelection,
10710 data,
10711 getItemId,
10712 isInfiniteScroll,
10713 paginationInfo
10714 }) {
10715 const [actionInProgress, setActionInProgress] = (0, import_element21.useState)(
10716 null
10717 );
10718 const footerContentRef = (0, import_element21.useRef)(void 0);
10719 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10720 const bulkActions = (0, import_element21.useMemo)(
10721 () => actions.filter((action) => action.supportsBulk),
10722 [actions]
10723 );
10724 const selectableItems = (0, import_element21.useMemo)(() => {
10725 return data.filter((item) => {
10726 return bulkActions.some(
10727 (action) => !action.isEligible || action.isEligible(item)
10728 );
10729 });
10730 }, [data, bulkActions]);
10731 const selectedItems = (0, import_element21.useMemo)(() => {
10732 return data.filter(
10733 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10734 );
10735 }, [selection, data, getItemId, selectableItems]);
10736 const actionsToShow = (0, import_element21.useMemo)(
10737 () => actions.filter((action) => {
10738 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
10739 (item) => !action.isEligible || action.isEligible(item)
10740 );
10741 }),
10742 [actions, selectedItems, isMobile]
10743 );
10744 if (!actionInProgress) {
10745 if (footerContentRef.current) {
10746 footerContentRef.current = void 0;
10747 }
10748 return renderFooterContent(
10749 data,
10750 actions,
10751 getItemId,
10752 isInfiniteScroll,
10753 selection,
10754 actionsToShow,
10755 selectedItems,
10756 actionInProgress,
10757 setActionInProgress,
10758 onChangeSelection,
10759 paginationInfo
10760 );
10761 } else if (!footerContentRef.current) {
10762 footerContentRef.current = renderFooterContent(
10763 data,
10764 actions,
10765 getItemId,
10766 isInfiniteScroll,
10767 selection,
10768 actionsToShow,
10769 selectedItems,
10770 actionInProgress,
10771 setActionInProgress,
10772 onChangeSelection,
10773 paginationInfo
10774 );
10775 }
10776 return footerContentRef.current;
10777 }
10778 function BulkActionsFooter() {
10779 const {
10780 data,
10781 selection,
10782 actions = EMPTY_ARRAY2,
10783 onChangeSelection,
10784 getItemId,
10785 paginationInfo,
10786 view
10787 } = (0, import_element21.useContext)(dataviews_context_default);
10788 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10789 FooterContent,
10790 {
10791 selection,
10792 onChangeSelection,
10793 data,
10794 actions,
10795 getItemId,
10796 isInfiniteScroll: !!view.infiniteScrollEnabled,
10797 paginationInfo
10798 }
10799 );
10800 }
10801
10802 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10803 var import_i18n6 = __toESM(require_i18n(), 1);
10804 var import_components4 = __toESM(require_components(), 1);
10805 var import_element22 = __toESM(require_element(), 1);
10806
10807 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
10808 function getHideableFields(view, fields) {
10809 const togglableFields = [
10810 view?.titleField,
10811 view?.mediaField,
10812 view?.descriptionField
10813 ].filter(Boolean);
10814 return fields.filter(
10815 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
10816 );
10817 }
10818
10819 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10820 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10821 var { Menu: Menu2 } = unlock3(import_components4.privateApis);
10822 function WithMenuSeparators({ children }) {
10823 return import_element22.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_element22.Fragment, { children: [
10824 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Separator, {}),
10825 child
10826 ] }, i2));
10827 }
10828 var _HeaderMenu = (0, import_element22.forwardRef)(function HeaderMenu({
10829 fieldId,
10830 view,
10831 fields,
10832 onChangeView,
10833 onHide,
10834 setOpenedFilter,
10835 canMove = true,
10836 canInsertLeft = true,
10837 canInsertRight = true
10838 }, ref) {
10839 const visibleFieldIds = view.fields ?? [];
10840 const index2 = visibleFieldIds?.indexOf(fieldId);
10841 const isSorted = view.sort?.field === fieldId;
10842 let isHidable = false;
10843 let isSortable = false;
10844 let canAddFilter = false;
10845 let operators = [];
10846 const field = fields.find((f2) => f2.id === fieldId);
10847 const { setIsShowingFilter } = (0, import_element22.useContext)(dataviews_context_default);
10848 if (!field) {
10849 return null;
10850 }
10851 isHidable = field.enableHiding !== false;
10852 isSortable = field.enableSorting !== false;
10853 const header = field.header;
10854 operators = !!field.filterBy && field.filterBy?.operators || [];
10855 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
10856 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
10857 return header;
10858 }
10859 const hiddenFields = getHideableFields(view, fields).filter(
10860 (f2) => !visibleFieldIds.includes(f2.id)
10861 );
10862 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
10863 const isRtl = (0, import_i18n6.isRTL)();
10864 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10865 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10866 Menu2.TriggerButton,
10867 {
10868 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10869 import_components4.Button,
10870 {
10871 size: "compact",
10872 className: "dataviews-view-table-header-button",
10873 ref,
10874 variant: "tertiary"
10875 }
10876 ),
10877 children: [
10878 header,
10879 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
10880 ]
10881 }
10882 ),
10883 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(WithMenuSeparators, { children: [
10884 isSortable && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
10885 (direction) => {
10886 const isChecked = view.sort && isSorted && view.sort.direction === direction;
10887 const value = `${fieldId}-${direction}`;
10888 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10889 Menu2.RadioItem,
10890 {
10891 name: "view-table-sorting",
10892 value,
10893 checked: isChecked,
10894 onChange: () => {
10895 onChangeView({
10896 ...view,
10897 sort: {
10898 field: fieldId,
10899 direction
10900 },
10901 showLevels: false
10902 });
10903 },
10904 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
10905 },
10906 value
10907 );
10908 }
10909 ) }),
10910 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10911 Menu2.Item,
10912 {
10913 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: funnel_default }),
10914 onClick: () => {
10915 setOpenedFilter(fieldId);
10916 setIsShowingFilter(true);
10917 onChangeView({
10918 ...view,
10919 page: 1,
10920 filters: [
10921 ...view.filters || [],
10922 {
10923 field: fieldId,
10924 value: void 0,
10925 operator: operators[0]
10926 }
10927 ]
10928 });
10929 },
10930 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
10931 }
10932 ) }),
10933 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2.Group, { children: [
10934 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10935 Menu2.Item,
10936 {
10937 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_left_default }),
10938 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
10939 onClick: () => {
10940 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
10941 const newFields = [
10942 ...visibleFieldIds
10943 ];
10944 newFields.splice(index2, 1);
10945 newFields.splice(
10946 targetIndex,
10947 0,
10948 fieldId
10949 );
10950 onChangeView({
10951 ...view,
10952 fields: newFields
10953 });
10954 },
10955 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
10956 }
10957 ),
10958 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10959 Menu2.Item,
10960 {
10961 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_right_default }),
10962 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
10963 onClick: () => {
10964 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
10965 const newFields = [
10966 ...visibleFieldIds
10967 ];
10968 newFields.splice(index2, 1);
10969 newFields.splice(
10970 targetIndex,
10971 0,
10972 fieldId
10973 );
10974 onChangeView({
10975 ...view,
10976 fields: newFields
10977 });
10978 },
10979 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
10980 }
10981 ),
10982 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10983 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
10984 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
10985 const insertIndex = isRtl ? index2 + 1 : index2;
10986 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10987 Menu2.Item,
10988 {
10989 onClick: () => {
10990 onChangeView({
10991 ...view,
10992 fields: [
10993 ...visibleFieldIds.slice(
10994 0,
10995 insertIndex
10996 ),
10997 hiddenField.id,
10998 ...visibleFieldIds.slice(
10999 insertIndex
11000 )
11001 ]
11002 });
11003 },
11004 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11005 },
11006 hiddenField.id
11007 );
11008 }) })
11009 ] }),
11010 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
11011 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
11012 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
11013 const insertIndex = isRtl ? index2 : index2 + 1;
11014 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11015 Menu2.Item,
11016 {
11017 onClick: () => {
11018 onChangeView({
11019 ...view,
11020 fields: [
11021 ...visibleFieldIds.slice(
11022 0,
11023 insertIndex
11024 ),
11025 hiddenField.id,
11026 ...visibleFieldIds.slice(
11027 insertIndex
11028 )
11029 ]
11030 });
11031 },
11032 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
11033 },
11034 hiddenField.id
11035 );
11036 }) })
11037 ] }),
11038 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
11039 Menu2.Item,
11040 {
11041 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: unseen_default }),
11042 onClick: () => {
11043 onHide(field);
11044 onChangeView({
11045 ...view,
11046 fields: visibleFieldIds.filter(
11047 (id) => id !== fieldId
11048 )
11049 });
11050 },
11051 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
11052 }
11053 )
11054 ] })
11055 ] }) })
11056 ] });
11057 });
11058 var ColumnHeaderMenu = _HeaderMenu;
11059 var column_header_menu_default = ColumnHeaderMenu;
11060
11061 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
11062 var import_element23 = __toESM(require_element(), 1);
11063 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
11064 function getClickableItemProps({
11065 item,
11066 isItemClickable,
11067 onClickItem,
11068 className
11069 }) {
11070 if (!isItemClickable(item) || !onClickItem) {
11071 return { className };
11072 }
11073 return {
11074 className: className ? `${className} ${className}--clickable` : void 0,
11075 role: "button",
11076 tabIndex: 0,
11077 onClick: (event) => {
11078 event.stopPropagation();
11079 onClickItem(item);
11080 },
11081 onKeyDown: (event) => {
11082 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11083 event.stopPropagation();
11084 onClickItem(item);
11085 }
11086 }
11087 };
11088 }
11089 function ItemClickWrapper({
11090 item,
11091 isItemClickable,
11092 onClickItem,
11093 renderItemLink,
11094 className,
11095 children,
11096 ...extraProps
11097 }) {
11098 if (!isItemClickable(item)) {
11099 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className, ...extraProps, children });
11100 }
11101 if (renderItemLink) {
11102 const renderedElement = renderItemLink({
11103 item,
11104 className: `${className} ${className}--clickable`,
11105 ...extraProps,
11106 children
11107 });
11108 return (0, import_element23.cloneElement)(renderedElement, {
11109 onClick: (event) => {
11110 event.stopPropagation();
11111 if (renderedElement.props.onClick) {
11112 renderedElement.props.onClick(event);
11113 }
11114 },
11115 onKeyDown: (event) => {
11116 if (event.key === "Enter" || event.key === "" || event.key === " ") {
11117 event.stopPropagation();
11118 if (renderedElement.props.onKeyDown) {
11119 renderedElement.props.onKeyDown(event);
11120 }
11121 }
11122 }
11123 });
11124 }
11125 const clickProps = getClickableItemProps({
11126 item,
11127 isItemClickable,
11128 onClickItem,
11129 className
11130 });
11131 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...clickProps, ...extraProps, children });
11132 }
11133
11134 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
11135 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
11136 function ColumnPrimary({
11137 item,
11138 level,
11139 titleField,
11140 mediaField,
11141 descriptionField,
11142 onClickItem,
11143 renderItemLink,
11144 isItemClickable
11145 }) {
11146 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
11147 mediaField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11148 ItemClickWrapper,
11149 {
11150 item,
11151 isItemClickable,
11152 onClickItem,
11153 renderItemLink,
11154 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11155 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11156 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11157 mediaField.render,
11158 {
11159 item,
11160 field: mediaField,
11161 config: { sizes: "32px" }
11162 }
11163 )
11164 }
11165 ),
11166 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11167 Stack,
11168 {
11169 direction: "column",
11170 align: "flex-start",
11171 className: "dataviews-view-table__primary-column-content",
11172 children: [
11173 titleField && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11174 ItemClickWrapper,
11175 {
11176 item,
11177 isItemClickable,
11178 onClickItem,
11179 renderItemLink,
11180 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11181 children: [
11182 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "dataviews-view-table__level", children: [
11183 Array(level).fill("\u2014").join(" "),
11184 "\xA0"
11185 ] }),
11186 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(titleField.render, { item, field: titleField })
11187 ]
11188 }
11189 ),
11190 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11191 descriptionField.render,
11192 {
11193 item,
11194 field: descriptionField
11195 }
11196 )
11197 ]
11198 }
11199 )
11200 ] });
11201 }
11202 var column_primary_default = ColumnPrimary;
11203
11204 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11205 var import_element24 = __toESM(require_element(), 1);
11206 var import_i18n7 = __toESM(require_i18n(), 1);
11207 var isScrolledToEnd = (element) => {
11208 if ((0, import_i18n7.isRTL)()) {
11209 const scrollLeft = Math.abs(element.scrollLeft);
11210 return scrollLeft <= 1;
11211 }
11212 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11213 };
11214 function useScrollState({
11215 scrollContainerRef,
11216 enabledHorizontal = false
11217 }) {
11218 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element24.useState)(false);
11219 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element24.useState)(false);
11220 const handleScroll = (0, import_element24.useCallback)(() => {
11221 const scrollContainer = scrollContainerRef.current;
11222 if (!scrollContainer) {
11223 return;
11224 }
11225 if (enabledHorizontal) {
11226 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11227 }
11228 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11229 }, [scrollContainerRef, enabledHorizontal]);
11230 (0, import_element24.useEffect)(() => {
11231 if (typeof window === "undefined" || !scrollContainerRef.current) {
11232 return () => {
11233 };
11234 }
11235 const scrollContainer = scrollContainerRef.current;
11236 handleScroll();
11237 scrollContainer.addEventListener("scroll", handleScroll);
11238 window.addEventListener("resize", handleScroll);
11239 return () => {
11240 scrollContainer.removeEventListener("scroll", handleScroll);
11241 window.removeEventListener("resize", handleScroll);
11242 };
11243 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11244 return { isHorizontalScrollEnd, isVerticallyScrolled };
11245 }
11246
11247 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11248 function getDataByGroup(data, groupByField) {
11249 return data.reduce((groups, item) => {
11250 const groupName = groupByField.getValue({ item });
11251 if (!groups.has(groupName)) {
11252 groups.set(groupName, []);
11253 }
11254 groups.get(groupName)?.push(item);
11255 return groups;
11256 }, /* @__PURE__ */ new Map());
11257 }
11258
11259 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11260 var import_components5 = __toESM(require_components(), 1);
11261 var import_i18n8 = __toESM(require_i18n(), 1);
11262 var import_element25 = __toESM(require_element(), 1);
11263 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11264 function FieldItem({
11265 field,
11266 isVisible: isVisible2,
11267 onToggleVisibility
11268 }) {
11269 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
11270 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.Icon, { icon: check_default }) }),
11271 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11272 ] }) });
11273 }
11274 function isDefined(item) {
11275 return !!item;
11276 }
11277 function PropertiesSection({
11278 showLabel = true
11279 }) {
11280 const { view, fields, onChangeView } = (0, import_element25.useContext)(dataviews_context_default);
11281 const regularFields = getHideableFields(view, fields);
11282 if (!regularFields?.length) {
11283 return null;
11284 }
11285 const titleField = fields.find((f2) => f2.id === view.titleField);
11286 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
11287 const descriptionField = fields.find(
11288 (f2) => f2.id === view.descriptionField
11289 );
11290 const lockedFields = [
11291 {
11292 field: titleField,
11293 isVisibleFlag: "showTitle"
11294 },
11295 {
11296 field: previewField2,
11297 isVisibleFlag: "showMedia"
11298 },
11299 {
11300 field: descriptionField,
11301 isVisibleFlag: "showDescription"
11302 }
11303 ].filter(({ field }) => isDefined(field));
11304 const visibleFieldIds = view.fields ?? [];
11305 const visibleRegularFieldsCount = regularFields.filter(
11306 (f2) => visibleFieldIds.includes(f2.id)
11307 ).length;
11308 const visibleLockedFields = lockedFields.filter(
11309 ({ isVisibleFlag }) => (
11310 // @ts-expect-error
11311 view[isVisibleFlag] ?? true
11312 )
11313 );
11314 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11315 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11316 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11317 showLabel && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
11318 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11319 Stack,
11320 {
11321 direction: "column",
11322 className: "dataviews-view-config__properties",
11323 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11324 lockedFields.map(({ field, isVisibleFlag }) => {
11325 const isVisible2 = view[isVisibleFlag] ?? true;
11326 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11327 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11328 FieldItem,
11329 {
11330 field: fieldToRender,
11331 isVisible: isVisible2,
11332 onToggleVisibility: () => {
11333 onChangeView({
11334 ...view,
11335 [isVisibleFlag]: !isVisible2
11336 });
11337 }
11338 },
11339 field.id
11340 );
11341 }),
11342 regularFields.map((field) => {
11343 const isVisible2 = visibleFieldIds.includes(field.id);
11344 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11345 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11346 FieldItem,
11347 {
11348 field: fieldToRender,
11349 isVisible: isVisible2,
11350 onToggleVisibility: () => {
11351 onChangeView({
11352 ...view,
11353 fields: isVisible2 ? visibleFieldIds.filter(
11354 (fieldId) => fieldId !== field.id
11355 ) : [...visibleFieldIds, field.id]
11356 });
11357 }
11358 },
11359 field.id
11360 );
11361 })
11362 ] })
11363 }
11364 )
11365 ] });
11366 }
11367
11368 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11369 var import_element26 = __toESM(require_element(), 1);
11370 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11371 const [showLoader, setShowLoader] = (0, import_element26.useState)(false);
11372 (0, import_element26.useEffect)(() => {
11373 if (!isLoading) {
11374 return;
11375 }
11376 const timeout = setTimeout(() => {
11377 setShowLoader(true);
11378 }, options.delay);
11379 return () => {
11380 clearTimeout(timeout);
11381 setShowLoader(false);
11382 };
11383 }, [isLoading, options.delay]);
11384 return showLoader;
11385 }
11386
11387 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11388 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11389 function getEffectiveAlign(explicitAlign, fieldType) {
11390 if (explicitAlign) {
11391 return explicitAlign;
11392 }
11393 if (fieldType === "integer" || fieldType === "number") {
11394 return "end";
11395 }
11396 return void 0;
11397 }
11398 function TableColumnField({
11399 item,
11400 fields,
11401 column,
11402 align
11403 }) {
11404 const field = fields.find((f2) => f2.id === column);
11405 if (!field) {
11406 return null;
11407 }
11408 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11409 "dataviews-view-table__cell-align-end": align === "end",
11410 "dataviews-view-table__cell-align-center": align === "center"
11411 });
11412 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) });
11413 }
11414 function TableRow({
11415 hasBulkActions,
11416 item,
11417 level,
11418 actions,
11419 fields,
11420 id,
11421 view,
11422 titleField,
11423 mediaField,
11424 descriptionField,
11425 selection,
11426 getItemId,
11427 isItemClickable,
11428 onClickItem,
11429 renderItemLink,
11430 onChangeSelection,
11431 isActionsColumnSticky,
11432 posinset
11433 }) {
11434 const { paginationInfo } = (0, import_element27.useContext)(dataviews_context_default);
11435 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11436 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11437 const {
11438 showTitle = true,
11439 showMedia = true,
11440 showDescription = true,
11441 infiniteScrollEnabled
11442 } = view;
11443 const isTouchDeviceRef = (0, import_element27.useRef)(false);
11444 const columns = view.fields ?? [];
11445 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11446 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11447 "tr",
11448 {
11449 className: clsx_default("dataviews-view-table__row", {
11450 "is-selected": hasPossibleBulkAction && isSelected2,
11451 "has-bulk-actions": hasPossibleBulkAction
11452 }),
11453 onTouchStart: () => {
11454 isTouchDeviceRef.current = true;
11455 },
11456 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11457 "aria-posinset": posinset,
11458 role: infiniteScrollEnabled ? "article" : void 0,
11459 onMouseDown: (event) => {
11460 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11461 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11462 event?.preventDefault();
11463 }
11464 },
11465 onClick: (event) => {
11466 if (!hasPossibleBulkAction) {
11467 return;
11468 }
11469 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11470 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11471 onChangeSelection(
11472 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11473 );
11474 }
11475 },
11476 children: [
11477 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11478 DataViewsSelectionCheckbox,
11479 {
11480 item,
11481 selection,
11482 onChangeSelection,
11483 getItemId,
11484 titleField,
11485 disabled: !hasPossibleBulkAction
11486 }
11487 ) }) }),
11488 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11489 column_primary_default,
11490 {
11491 item,
11492 level,
11493 titleField: showTitle ? titleField : void 0,
11494 mediaField: showMedia ? mediaField : void 0,
11495 descriptionField: showDescription ? descriptionField : void 0,
11496 isItemClickable,
11497 onClickItem,
11498 renderItemLink
11499 }
11500 ) }),
11501 columns.map((column) => {
11502 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11503 const field = fields.find((f2) => f2.id === column);
11504 const effectiveAlign = getEffectiveAlign(align, field?.type);
11505 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11506 "td",
11507 {
11508 style: {
11509 width,
11510 maxWidth,
11511 minWidth
11512 },
11513 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11514 TableColumnField,
11515 {
11516 fields,
11517 item,
11518 column,
11519 align: effectiveAlign
11520 }
11521 )
11522 },
11523 column
11524 );
11525 }),
11526 !!actions?.length && // Disable reason: we are not making the element interactive,
11527 // but preventing any click events from bubbling up to the
11528 // table row. This allows us to add a click handler to the row
11529 // itself (to toggle row selection) without erroneously
11530 // intercepting click events from ItemActions.
11531 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11532 "td",
11533 {
11534 className: clsx_default("dataviews-view-table__actions-column", {
11535 "dataviews-view-table__actions-column--sticky": true,
11536 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11537 }),
11538 onClick: (e2) => e2.stopPropagation(),
11539 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ItemActions, { item, actions })
11540 }
11541 )
11542 ]
11543 }
11544 );
11545 }
11546 function ViewTable({
11547 actions,
11548 data,
11549 fields,
11550 getItemId,
11551 getItemLevel,
11552 isLoading = false,
11553 onChangeView,
11554 onChangeSelection,
11555 selection,
11556 setOpenedFilter,
11557 onClickItem,
11558 isItemClickable,
11559 renderItemLink,
11560 view,
11561 className,
11562 empty
11563 }) {
11564 const { containerRef } = (0, import_element27.useContext)(dataviews_context_default);
11565 const isDelayedLoading = useDelayedLoading(isLoading);
11566 const headerMenuRefs = (0, import_element27.useRef)(/* @__PURE__ */ new Map());
11567 const headerMenuToFocusRef = (0, import_element27.useRef)(void 0);
11568 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element27.useState)();
11569 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element27.useState)(null);
11570 (0, import_element27.useEffect)(() => {
11571 if (headerMenuToFocusRef.current) {
11572 headerMenuToFocusRef.current.focus();
11573 headerMenuToFocusRef.current = void 0;
11574 }
11575 });
11576 const tableNoticeId = (0, import_element27.useId)();
11577 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11578 scrollContainerRef: containerRef,
11579 enabledHorizontal: !!actions?.length
11580 });
11581 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11582 if (nextHeaderMenuToFocus) {
11583 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11584 setNextHeaderMenuToFocus(void 0);
11585 return;
11586 }
11587 const onHide = (field) => {
11588 const hidden = headerMenuRefs.current.get(field.id);
11589 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11590 setNextHeaderMenuToFocus(fallback?.node);
11591 };
11592 const handleHeaderContextMenu = (event) => {
11593 event.preventDefault();
11594 event.stopPropagation();
11595 const virtualAnchor = {
11596 getBoundingClientRect: () => ({
11597 x: event.clientX,
11598 y: event.clientY,
11599 top: event.clientY,
11600 left: event.clientX,
11601 right: event.clientX,
11602 bottom: event.clientY,
11603 width: 0,
11604 height: 0,
11605 toJSON: () => ({})
11606 })
11607 };
11608 window.requestAnimationFrame(() => {
11609 setContextMenuAnchor(virtualAnchor);
11610 });
11611 };
11612 const hasData = !!data?.length;
11613 const titleField = fields.find((field) => field.id === view.titleField);
11614 const mediaField = fields.find((field) => field.id === view.mediaField);
11615 const descriptionField = fields.find(
11616 (field) => field.id === view.descriptionField
11617 );
11618 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11619 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11620 const { showTitle = true, showMedia = true, showDescription = true } = view;
11621 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11622 const columns = view.fields ?? [];
11623 const headerMenuRef = (column, index2) => (node) => {
11624 if (node) {
11625 headerMenuRefs.current.set(column, {
11626 node,
11627 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11628 });
11629 } else {
11630 headerMenuRefs.current.delete(column);
11631 }
11632 };
11633 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11634 const isRtl = (0, import_i18n9.isRTL)();
11635 if (!hasData) {
11636 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11637 "div",
11638 {
11639 className: clsx_default("dataviews-no-results", {
11640 "is-refreshing": isDelayedLoading
11641 }),
11642 id: tableNoticeId,
11643 children: empty
11644 }
11645 );
11646 }
11647 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
11648 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11649 "table",
11650 {
11651 className: clsx_default("dataviews-view-table", className, {
11652 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11653 view.layout.density
11654 ),
11655 "has-bulk-actions": hasBulkActions,
11656 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11657 }),
11658 "aria-busy": isLoading,
11659 "aria-describedby": tableNoticeId,
11660 role: isInfiniteScroll ? "feed" : void 0,
11661 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11662 children: [
11663 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("colgroup", { children: [
11664 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11665 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11666 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11667 "col",
11668 {
11669 className: clsx_default(
11670 `dataviews-view-table__col-${column}`,
11671 {
11672 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11673 }
11674 )
11675 },
11676 `col-${column}`
11677 )),
11678 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-actions" })
11679 ] }),
11680 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11681 import_components6.Popover,
11682 {
11683 anchor: contextMenuAnchor,
11684 onClose: () => setContextMenuAnchor(null),
11685 placement: "bottom-start",
11686 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropertiesSection, { showLabel: false })
11687 }
11688 ),
11689 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11690 "thead",
11691 {
11692 className: clsx_default({
11693 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11694 }),
11695 onContextMenu: handleHeaderContextMenu,
11696 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11697 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11698 "th",
11699 {
11700 className: "dataviews-view-table__checkbox-column",
11701 scope: "col",
11702 onContextMenu: handleHeaderContextMenu,
11703 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11704 BulkSelectionCheckbox,
11705 {
11706 selection,
11707 onChangeSelection,
11708 data,
11709 actions,
11710 getItemId
11711 }
11712 )
11713 }
11714 ),
11715 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11716 column_header_menu_default,
11717 {
11718 ref: headerMenuRef(
11719 titleField.id,
11720 0
11721 ),
11722 fieldId: titleField.id,
11723 view,
11724 fields,
11725 onChangeView,
11726 onHide,
11727 setOpenedFilter,
11728 canMove: false,
11729 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
11730 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
11731 }
11732 ) }),
11733 columns.map((column, index2) => {
11734 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11735 const field = fields.find(
11736 (f2) => f2.id === column
11737 );
11738 const effectiveAlign = getEffectiveAlign(
11739 align,
11740 field?.type
11741 );
11742 const canInsertOrMove = view.layout?.enableMoving ?? true;
11743 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11744 "th",
11745 {
11746 style: {
11747 width,
11748 maxWidth,
11749 minWidth,
11750 textAlign: effectiveAlign
11751 },
11752 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
11753 scope: "col",
11754 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11755 column_header_menu_default,
11756 {
11757 ref: headerMenuRef(column, index2),
11758 fieldId: column,
11759 view,
11760 fields,
11761 onChangeView,
11762 onHide,
11763 setOpenedFilter,
11764 canMove: canInsertOrMove,
11765 canInsertLeft: canInsertOrMove,
11766 canInsertRight: canInsertOrMove
11767 }
11768 )
11769 },
11770 column
11771 );
11772 }),
11773 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11774 "th",
11775 {
11776 className: clsx_default(
11777 "dataviews-view-table__actions-column",
11778 {
11779 "dataviews-view-table__actions-column--sticky": true,
11780 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
11781 }
11782 ),
11783 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
11784 }
11785 )
11786 ] })
11787 }
11788 ),
11789 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
11790 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tbody", { children: [
11791 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11792 "td",
11793 {
11794 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
11795 className: "dataviews-view-table__group-header-cell",
11796 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
11797 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
11798 (0, import_i18n9.__)("%1$s: %2$s"),
11799 groupField.label,
11800 groupName
11801 )
11802 }
11803 ) }),
11804 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11805 TableRow,
11806 {
11807 item,
11808 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11809 hasBulkActions,
11810 actions,
11811 fields,
11812 id: getItemId(item) || index2.toString(),
11813 view,
11814 titleField,
11815 mediaField,
11816 descriptionField,
11817 selection,
11818 getItemId,
11819 onChangeSelection,
11820 onClickItem,
11821 renderItemLink,
11822 isItemClickable,
11823 isActionsColumnSticky: !isHorizontalScrollEnd
11824 },
11825 getItemId(item)
11826 ))
11827 ] }, `group-${groupName}`)
11828 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11829 TableRow,
11830 {
11831 item,
11832 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11833 hasBulkActions,
11834 actions,
11835 fields,
11836 id: getItemId(item) || index2.toString(),
11837 view,
11838 titleField,
11839 mediaField,
11840 descriptionField,
11841 selection,
11842 getItemId,
11843 onChangeSelection,
11844 onClickItem,
11845 renderItemLink,
11846 isItemClickable,
11847 isActionsColumnSticky: !isHorizontalScrollEnd,
11848 posinset: isInfiniteScroll ? index2 + 1 : void 0
11849 },
11850 getItemId(item)
11851 )) })
11852 ]
11853 }
11854 ),
11855 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components6.Spinner, {}) }) })
11856 ] });
11857 }
11858 var table_default = ViewTable;
11859
11860 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
11861 var import_components9 = __toESM(require_components(), 1);
11862 var import_i18n12 = __toESM(require_i18n(), 1);
11863
11864 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11865 var import_components8 = __toESM(require_components(), 1);
11866 var import_i18n11 = __toESM(require_i18n(), 1);
11867 var import_compose3 = __toESM(require_compose(), 1);
11868 var import_keycodes2 = __toESM(require_keycodes(), 1);
11869 var import_element31 = __toESM(require_element(), 1);
11870
11871 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
11872 var import_components7 = __toESM(require_components(), 1);
11873 var import_i18n10 = __toESM(require_i18n(), 1);
11874 var import_element28 = __toESM(require_element(), 1);
11875 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11876 var imageSizes = [
11877 {
11878 value: 120,
11879 breakpoint: 1
11880 },
11881 {
11882 value: 170,
11883 breakpoint: 1
11884 },
11885 {
11886 value: 230,
11887 breakpoint: 1
11888 },
11889 {
11890 value: 290,
11891 breakpoint: 1112
11892 // at minimum image width, 4 images display at this container size
11893 },
11894 {
11895 value: 350,
11896 breakpoint: 1636
11897 // at minimum image width, 6 images display at this container size
11898 },
11899 {
11900 value: 430,
11901 breakpoint: 588
11902 // at minimum image width, 2 images display at this container size
11903 }
11904 ];
11905 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
11906 function useGridColumns() {
11907 const context = (0, import_element28.useContext)(dataviews_context_default);
11908 const view = context.view;
11909 return (0, import_element28.useMemo)(() => {
11910 const containerWidth = context.containerWidth;
11911 const gap = 32;
11912 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
11913 const columns = Math.floor(
11914 (containerWidth + gap) / (previewSize + gap)
11915 );
11916 return Math.max(1, columns);
11917 }, [context.containerWidth, view.layout?.previewSize]);
11918 }
11919
11920 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
11921 var import_element29 = __toESM(require_element(), 1);
11922 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11923 var GridItems = (0, import_element29.forwardRef)(({ className, previewSize, ...props }, ref) => {
11924 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11925 "div",
11926 {
11927 ref,
11928 className: clsx_default("dataviews-view-grid-items", className),
11929 style: {
11930 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
11931 },
11932 ...props
11933 }
11934 );
11935 });
11936
11937 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
11938 var import_element30 = __toESM(require_element(), 1);
11939 function useIntersectionObserver(elementRef, posinset) {
11940 const { intersectionObserver } = (0, import_element30.useContext)(dataviews_context_default);
11941 (0, import_element30.useEffect)(() => {
11942 const element = elementRef.current;
11943 if (!element || posinset === void 0 || !intersectionObserver) {
11944 return;
11945 }
11946 intersectionObserver.observe(element);
11947 return () => {
11948 intersectionObserver.unobserve(element);
11949 };
11950 }, [elementRef, intersectionObserver, posinset]);
11951 }
11952 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
11953 const hasData = !!data?.length;
11954 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
11955 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
11956 }
11957
11958 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11959 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11960 var { Badge: WCBadge } = unlock3(import_components8.privateApis);
11961 function chunk(array, size4) {
11962 const chunks = [];
11963 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
11964 chunks.push(array.slice(i2, i2 + size4));
11965 }
11966 return chunks;
11967 }
11968 var GridItem = (0, import_element31.forwardRef)(
11969 function GridItem2({
11970 view,
11971 selection,
11972 onChangeSelection,
11973 onClickItem,
11974 isItemClickable,
11975 renderItemLink,
11976 getItemId,
11977 item,
11978 actions,
11979 mediaField,
11980 titleField,
11981 descriptionField,
11982 regularFields,
11983 badgeFields,
11984 hasBulkActions,
11985 config,
11986 posinset,
11987 setsize,
11988 ...props
11989 }, forwardedRef) {
11990 const {
11991 showTitle = true,
11992 showMedia = true,
11993 showDescription = true
11994 } = view;
11995 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
11996 const id = getItemId(item);
11997 const elementRef = (0, import_element31.useRef)(null);
11998 const setRefs = (0, import_element31.useCallback)(
11999 (node) => {
12000 elementRef.current = node;
12001 if (typeof forwardedRef === "function") {
12002 forwardedRef(node);
12003 } else if (forwardedRef) {
12004 forwardedRef.current = node;
12005 }
12006 },
12007 [forwardedRef]
12008 );
12009 useIntersectionObserver(elementRef, posinset);
12010 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
12011 const isSelected2 = selection.includes(id);
12012 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
12013 const rendersMediaField = showMedia && mediaField?.render;
12014 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12015 mediaField.render,
12016 {
12017 item,
12018 field: mediaField,
12019 config
12020 }
12021 ) : mediaPlaceholder;
12022 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(titleField.render, { item, field: titleField }) : null;
12023 let mediaA11yProps;
12024 let titleA11yProps;
12025 if (isItemClickable(item) && onClickItem) {
12026 if (renderedTitleField) {
12027 mediaA11yProps = {
12028 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
12029 };
12030 titleA11yProps = {
12031 id: `dataviews-view-grid__title-field-${instanceId}`
12032 };
12033 } else {
12034 mediaA11yProps = {
12035 "aria-label": (0, import_i18n11.__)("Navigate to item")
12036 };
12037 }
12038 }
12039 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12040 Stack,
12041 {
12042 direction: "column",
12043 ...props,
12044 ref: setRefs,
12045 "aria-setsize": setsize,
12046 "aria-posinset": posinset,
12047 className: clsx_default(
12048 props.className,
12049 "dataviews-view-grid__row__gridcell",
12050 "dataviews-view-grid__card",
12051 {
12052 "is-selected": hasBulkAction && isSelected2
12053 }
12054 ),
12055 onClickCapture: (event) => {
12056 props.onClickCapture?.(event);
12057 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
12058 event.stopPropagation();
12059 event.preventDefault();
12060 if (!hasBulkAction) {
12061 return;
12062 }
12063 onChangeSelection(
12064 isSelected2 ? selection.filter(
12065 (itemId) => id !== itemId
12066 ) : [...selection, id]
12067 );
12068 }
12069 },
12070 children: [
12071 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12072 ItemClickWrapper,
12073 {
12074 item,
12075 isItemClickable,
12076 onClickItem,
12077 renderItemLink,
12078 className: clsx_default("dataviews-view-grid__media", {
12079 "dataviews-view-grid__media--placeholder": !rendersMediaField
12080 }),
12081 ...mediaA11yProps,
12082 children: renderedMediaField
12083 }
12084 ),
12085 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12086 DataViewsSelectionCheckbox,
12087 {
12088 item,
12089 selection,
12090 onChangeSelection,
12091 getItemId,
12092 titleField,
12093 disabled: !hasBulkAction
12094 }
12095 ),
12096 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12097 ItemActions,
12098 {
12099 item,
12100 actions,
12101 isCompact: true
12102 }
12103 ) }),
12104 showTitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12105 ItemClickWrapper,
12106 {
12107 item,
12108 isItemClickable,
12109 onClickItem,
12110 renderItemLink,
12111 className: "dataviews-view-grid__title-field dataviews-title-field",
12112 ...titleA11yProps,
12113 title: titleField?.getValueFormatted({
12114 item,
12115 field: titleField
12116 }) || void 0,
12117 children: renderedTitleField
12118 }
12119 ) }),
12120 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Stack, { direction: "column", gap: "xs", children: [
12121 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12122 descriptionField.render,
12123 {
12124 item,
12125 field: descriptionField
12126 }
12127 ),
12128 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12129 Stack,
12130 {
12131 direction: "row",
12132 className: "dataviews-view-grid__badge-fields",
12133 gap: "sm",
12134 wrap: "wrap",
12135 align: "top",
12136 justify: "flex-start",
12137 children: badgeFields.map((field) => {
12138 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12139 WCBadge,
12140 {
12141 className: "dataviews-view-grid__field-value",
12142 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12143 field.render,
12144 {
12145 item,
12146 field
12147 }
12148 )
12149 },
12150 field.id
12151 );
12152 })
12153 }
12154 ),
12155 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12156 Stack,
12157 {
12158 direction: "column",
12159 className: "dataviews-view-grid__fields",
12160 gap: "xs",
12161 children: regularFields.map((field) => {
12162 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12163 import_components8.Flex,
12164 {
12165 className: "dataviews-view-grid__field",
12166 gap: 1,
12167 justify: "flex-start",
12168 expanded: true,
12169 style: { height: "auto" },
12170 direction: "row",
12171 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
12172 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(tooltip_exports.Root, { children: [
12173 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12174 tooltip_exports.Trigger,
12175 {
12176 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12177 }
12178 ),
12179 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(tooltip_exports.Popup, { children: field.label })
12180 ] }),
12181 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12182 import_components8.FlexItem,
12183 {
12184 className: "dataviews-view-grid__field-value",
12185 style: { maxHeight: "none" },
12186 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12187 field.render,
12188 {
12189 item,
12190 field
12191 }
12192 )
12193 }
12194 )
12195 ] })
12196 },
12197 field.id
12198 );
12199 })
12200 }
12201 )
12202 ] })
12203 ]
12204 }
12205 );
12206 }
12207 );
12208 function CompositeGrid({
12209 data,
12210 isInfiniteScroll,
12211 className,
12212 inert,
12213 isLoading,
12214 view,
12215 fields,
12216 selection,
12217 onChangeSelection,
12218 onClickItem,
12219 isItemClickable,
12220 renderItemLink,
12221 getItemId,
12222 actions
12223 }) {
12224 const { paginationInfo, resizeObserverRef } = (0, import_element31.useContext)(dataviews_context_default);
12225 const gridColumns = useGridColumns();
12226 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12227 const titleField = fields.find(
12228 (field) => field.id === view?.titleField
12229 );
12230 const mediaField = fields.find(
12231 (field) => field.id === view?.mediaField
12232 );
12233 const descriptionField = fields.find(
12234 (field) => field.id === view?.descriptionField
12235 );
12236 const otherFields = view.fields ?? [];
12237 const { regularFields, badgeFields } = otherFields.reduce(
12238 (accumulator, fieldId) => {
12239 const field = fields.find((f2) => f2.id === fieldId);
12240 if (!field) {
12241 return accumulator;
12242 }
12243 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12244 accumulator[key].push(field);
12245 return accumulator;
12246 },
12247 { regularFields: [], badgeFields: [] }
12248 );
12249 const size4 = "900px";
12250 const totalRows = Math.ceil(data.length / gridColumns);
12251 const placeholdersNeeded = usePlaceholdersNeeded(
12252 data,
12253 isInfiniteScroll,
12254 gridColumns
12255 );
12256 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, {
12257 // Render infinite scroll layout (no rows, feed semantics)
12258 children: [
12259 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12260 import_components8.Composite,
12261 {
12262 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12263 GridItems,
12264 {
12265 className: clsx_default(
12266 "dataviews-view-grid-infinite-scroll",
12267 className,
12268 {
12269 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12270 "compact",
12271 "comfortable"
12272 ].includes(view.layout.density)
12273 }
12274 ),
12275 previewSize: view.layout?.previewSize,
12276 "aria-busy": isLoading,
12277 ref: resizeObserverRef
12278 }
12279 ),
12280 role: "feed",
12281 focusWrap: true,
12282 inert,
12283 children: [
12284 Array.from({ length: placeholdersNeeded }).map(
12285 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12286 import_components8.Composite.Item,
12287 {
12288 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12289 Stack,
12290 {
12291 ...props,
12292 direction: "column",
12293 role: "article",
12294 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12295 }
12296 ),
12297 "aria-hidden": true,
12298 tabIndex: -1
12299 },
12300 `placeholder-${index2}`
12301 )
12302 ),
12303 data.map((item) => {
12304 const itemId = getItemId(item);
12305 const stablePosition = item.position;
12306 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12307 import_components8.Composite.Item,
12308 {
12309 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12310 GridItem,
12311 {
12312 ...props,
12313 id: itemId,
12314 role: "article",
12315 view,
12316 selection,
12317 onChangeSelection,
12318 onClickItem,
12319 isItemClickable,
12320 renderItemLink,
12321 getItemId,
12322 item,
12323 actions,
12324 mediaField,
12325 titleField,
12326 descriptionField,
12327 regularFields,
12328 badgeFields,
12329 hasBulkActions,
12330 posinset: stablePosition,
12331 setsize: paginationInfo.totalItems,
12332 config: {
12333 sizes: size4
12334 }
12335 }
12336 )
12337 },
12338 itemId
12339 );
12340 })
12341 ]
12342 }
12343 ),
12344 // Render standard grid layout (with rows, grid semantics)
12345 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12346 import_components8.Composite,
12347 {
12348 role: "grid",
12349 className: clsx_default("dataviews-view-grid", className, {
12350 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12351 view.layout.density
12352 )
12353 }),
12354 focusWrap: true,
12355 "aria-busy": isLoading,
12356 "aria-rowcount": totalRows,
12357 ref: resizeObserverRef,
12358 inert,
12359 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12360 import_components8.Composite.Row,
12361 {
12362 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12363 "div",
12364 {
12365 role: "row",
12366 "aria-rowindex": i2 + 1,
12367 "aria-label": (0, import_i18n11.sprintf)(
12368 /* translators: %d: The row number in the grid */
12369 (0, import_i18n11.__)("Row %d"),
12370 i2 + 1
12371 ),
12372 className: "dataviews-view-grid__row",
12373 style: {
12374 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12375 }
12376 }
12377 ),
12378 children: row.map((item) => {
12379 const itemId = getItemId(item);
12380 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12381 import_components8.Composite.Item,
12382 {
12383 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12384 GridItem,
12385 {
12386 ...props,
12387 id: itemId,
12388 role: "gridcell",
12389 view,
12390 selection,
12391 onChangeSelection,
12392 onClickItem,
12393 isItemClickable,
12394 renderItemLink,
12395 getItemId,
12396 item,
12397 actions,
12398 mediaField,
12399 titleField,
12400 descriptionField,
12401 regularFields,
12402 badgeFields,
12403 hasBulkActions,
12404 config: {
12405 sizes: size4
12406 }
12407 }
12408 )
12409 },
12410 itemId
12411 );
12412 })
12413 },
12414 i2
12415 ))
12416 }
12417 )
12418 ]
12419 });
12420 }
12421
12422 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12423 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
12424 function ViewGrid({
12425 actions,
12426 data,
12427 fields,
12428 getItemId,
12429 isLoading,
12430 onChangeSelection,
12431 onClickItem,
12432 isItemClickable,
12433 renderItemLink,
12434 selection,
12435 view,
12436 className,
12437 empty
12438 }) {
12439 const isDelayedLoading = useDelayedLoading(!!isLoading);
12440 const hasData = !!data?.length;
12441 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12442 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12443 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12444 if (!hasData) {
12445 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12446 "div",
12447 {
12448 className: clsx_default("dataviews-no-results", {
12449 "is-refreshing": isDelayedLoading
12450 }),
12451 children: empty
12452 }
12453 );
12454 }
12455 const gridProps = {
12456 className: clsx_default(className, {
12457 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12458 }),
12459 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12460 isLoading,
12461 view,
12462 fields,
12463 selection,
12464 onChangeSelection,
12465 onClickItem,
12466 isItemClickable,
12467 renderItemLink,
12468 getItemId,
12469 actions
12470 };
12471 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, {
12472 // Render multiple groups.
12473 children: [
12474 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12475 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
12476 Stack,
12477 {
12478 direction: "column",
12479 gap: "sm",
12480 children: [
12481 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
12482 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12483 (0, import_i18n12.__)("%1$s: %2$s"),
12484 groupField.label,
12485 groupName
12486 ) }),
12487 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12488 CompositeGrid,
12489 {
12490 ...gridProps,
12491 data: groupItems,
12492 isInfiniteScroll: false
12493 }
12494 )
12495 ]
12496 },
12497 groupName
12498 )
12499 ) }),
12500 // Render a single grid with all data.
12501 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12502 CompositeGrid,
12503 {
12504 ...gridProps,
12505 data,
12506 isInfiniteScroll: !!isInfiniteScroll
12507 }
12508 ),
12509 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components9.Spinner, {}) })
12510 ]
12511 });
12512 }
12513 var grid_default = ViewGrid;
12514
12515 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12516 var import_compose4 = __toESM(require_compose(), 1);
12517 var import_components10 = __toESM(require_components(), 1);
12518 var import_element32 = __toESM(require_element(), 1);
12519 var import_i18n13 = __toESM(require_i18n(), 1);
12520 var import_data6 = __toESM(require_data(), 1);
12521 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
12522 var { Menu: Menu3 } = unlock3(import_components10.privateApis);
12523 function generateItemWrapperCompositeId(idPrefix) {
12524 return `${idPrefix}-item-wrapper`;
12525 }
12526 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12527 return `${idPrefix}-primary-action-${primaryActionId}`;
12528 }
12529 function generateDropdownTriggerCompositeId(idPrefix) {
12530 return `${idPrefix}-dropdown`;
12531 }
12532 function PrimaryActionGridCell({
12533 idPrefix,
12534 primaryAction,
12535 item
12536 }) {
12537 const registry = (0, import_data6.useRegistry)();
12538 const [isModalOpen, setIsModalOpen] = (0, import_element32.useState)(false);
12539 const compositeItemId = generatePrimaryActionCompositeId(
12540 idPrefix,
12541 primaryAction.id
12542 );
12543 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12544 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12545 import_components10.Composite.Item,
12546 {
12547 id: compositeItemId,
12548 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12549 import_components10.Button,
12550 {
12551 disabled: !!primaryAction.disabled,
12552 accessibleWhenDisabled: true,
12553 text: label,
12554 size: "small",
12555 onClick: () => setIsModalOpen(true)
12556 }
12557 ),
12558 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12559 ActionModal,
12560 {
12561 action: primaryAction,
12562 items: [item],
12563 closeModal: () => setIsModalOpen(false)
12564 }
12565 )
12566 }
12567 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12568 import_components10.Composite.Item,
12569 {
12570 id: compositeItemId,
12571 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12572 import_components10.Button,
12573 {
12574 disabled: !!primaryAction.disabled,
12575 accessibleWhenDisabled: true,
12576 size: "small",
12577 onClick: () => {
12578 primaryAction.callback([item], { registry });
12579 },
12580 children: label
12581 }
12582 )
12583 }
12584 ) }, primaryAction.id);
12585 }
12586 function ListItem({
12587 view,
12588 actions,
12589 idPrefix,
12590 isSelected: isSelected2,
12591 item,
12592 titleField,
12593 mediaField,
12594 descriptionField,
12595 onSelect,
12596 otherFields,
12597 onDropdownTriggerKeyDown,
12598 posinset
12599 }) {
12600 const {
12601 showTitle = true,
12602 showMedia = true,
12603 showDescription = true,
12604 infiniteScrollEnabled
12605 } = view;
12606 const itemRef = (0, import_element32.useRef)(null);
12607 const labelId = `${idPrefix}-label`;
12608 const descriptionId = `${idPrefix}-description`;
12609 const registry = (0, import_data6.useRegistry)();
12610 const [isHovered, setIsHovered] = (0, import_element32.useState)(false);
12611 const [activeModalAction, setActiveModalAction] = (0, import_element32.useState)(
12612 null
12613 );
12614 const handleHover = ({ type }) => {
12615 const isHover = type === "mouseenter";
12616 setIsHovered(isHover);
12617 };
12618 const { paginationInfo } = (0, import_element32.useContext)(dataviews_context_default);
12619 (0, import_element32.useEffect)(() => {
12620 if (isSelected2) {
12621 itemRef.current?.scrollIntoView({
12622 behavior: "auto",
12623 block: "nearest",
12624 inline: "nearest"
12625 });
12626 }
12627 }, [isSelected2]);
12628 const { primaryAction, eligibleActions } = (0, import_element32.useMemo)(() => {
12629 const _eligibleActions = actions.filter(
12630 (action) => !action.isEligible || action.isEligible(item)
12631 );
12632 const _primaryActions = _eligibleActions.filter(
12633 (action) => action.isPrimary
12634 );
12635 return {
12636 primaryAction: _primaryActions[0],
12637 eligibleActions: _eligibleActions
12638 };
12639 }, [actions, item]);
12640 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12641 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12642 mediaField.render,
12643 {
12644 item,
12645 field: mediaField,
12646 config: { sizes: "52px" }
12647 }
12648 ) }) : null;
12649 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField }) : null;
12650 const renderDescription = showDescription && descriptionField?.render;
12651 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12652 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12653 Stack,
12654 {
12655 direction: "row",
12656 gap: "md",
12657 className: "dataviews-view-list__item-actions",
12658 children: [
12659 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12660 PrimaryActionGridCell,
12661 {
12662 idPrefix,
12663 primaryAction,
12664 item
12665 }
12666 ),
12667 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { role: "gridcell", children: [
12668 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Menu3, { placement: "bottom-end", children: [
12669 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12670 Menu3.TriggerButton,
12671 {
12672 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12673 import_components10.Composite.Item,
12674 {
12675 id: generateDropdownTriggerCompositeId(
12676 idPrefix
12677 ),
12678 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12679 import_components10.Button,
12680 {
12681 size: "small",
12682 icon: more_vertical_default,
12683 label: (0, import_i18n13.__)("Actions"),
12684 accessibleWhenDisabled: true,
12685 disabled: !actions.length,
12686 onKeyDown: onDropdownTriggerKeyDown
12687 }
12688 )
12689 }
12690 )
12691 }
12692 ),
12693 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12694 ActionsMenuGroup,
12695 {
12696 actions: eligibleActions,
12697 item,
12698 registry,
12699 setActiveModalAction
12700 }
12701 ) })
12702 ] }),
12703 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12704 ActionModal,
12705 {
12706 action: activeModalAction,
12707 items: [item],
12708 closeModal: () => setActiveModalAction(null)
12709 }
12710 )
12711 ] })
12712 ]
12713 }
12714 );
12715 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12716 import_components10.Composite.Row,
12717 {
12718 ref: itemRef,
12719 render: (
12720 /* aria-posinset breaks Composite.Row if passed to it directly. */
12721 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12722 "div",
12723 {
12724 "aria-posinset": posinset,
12725 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
12726 }
12727 )
12728 ),
12729 role: infiniteScrollEnabled ? "article" : "row",
12730 className: clsx_default({
12731 "is-selected": isSelected2,
12732 "is-hovered": isHovered
12733 }),
12734 onMouseEnter: handleHover,
12735 onMouseLeave: handleHover,
12736 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12737 Stack,
12738 {
12739 direction: "row",
12740 className: "dataviews-view-list__item-wrapper",
12741 children: [
12742 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12743 import_components10.Composite.Item,
12744 {
12745 id: generateItemWrapperCompositeId(idPrefix),
12746 "aria-pressed": isSelected2,
12747 "aria-labelledby": labelId,
12748 "aria-describedby": descriptionId,
12749 className: "dataviews-view-list__item",
12750 onClick: () => onSelect(item)
12751 }
12752 ) }),
12753 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12754 Stack,
12755 {
12756 direction: "row",
12757 gap: "md",
12758 justify: "start",
12759 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
12760 style: { flex: 1, minWidth: 0 },
12761 children: [
12762 renderedMediaField,
12763 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12764 Stack,
12765 {
12766 direction: "column",
12767 gap: "xs",
12768 className: "dataviews-view-list__field-wrapper",
12769 children: [
12770 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", align: "center", children: [
12771 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12772 "div",
12773 {
12774 className: "dataviews-title-field dataviews-view-list__title-field",
12775 id: labelId,
12776 children: renderedTitleField
12777 }
12778 ),
12779 usedActions
12780 ] }),
12781 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12782 descriptionField.render,
12783 {
12784 item,
12785 field: descriptionField
12786 }
12787 ) }),
12788 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12789 "div",
12790 {
12791 className: "dataviews-view-list__fields",
12792 id: descriptionId,
12793 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12794 "div",
12795 {
12796 className: "dataviews-view-list__field",
12797 children: [
12798 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12799 VisuallyHidden,
12800 {
12801 className: "dataviews-view-list__field-label",
12802 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", {}),
12803 children: field.label
12804 }
12805 ),
12806 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12807 field.render,
12808 {
12809 item,
12810 field
12811 }
12812 ) })
12813 ]
12814 },
12815 field.id
12816 ))
12817 }
12818 )
12819 ]
12820 }
12821 )
12822 ]
12823 }
12824 )
12825 ]
12826 }
12827 )
12828 }
12829 );
12830 }
12831 function isDefined2(item) {
12832 return !!item;
12833 }
12834 function ViewList(props) {
12835 const {
12836 actions,
12837 data,
12838 fields,
12839 getItemId,
12840 isLoading,
12841 onChangeSelection,
12842 selection,
12843 view,
12844 className,
12845 empty
12846 } = props;
12847 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
12848 const isDelayedLoading = useDelayedLoading(!!isLoading);
12849 const selectedItem = data?.findLast(
12850 (item) => selection.includes(getItemId(item))
12851 );
12852 const titleField = fields.find((field) => field.id === view.titleField);
12853 const mediaField = fields.find((field) => field.id === view.mediaField);
12854 const descriptionField = fields.find(
12855 (field) => field.id === view.descriptionField
12856 );
12857 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
12858 const onSelect = (item) => onChangeSelection([getItemId(item)]);
12859 const generateCompositeItemIdPrefix = (0, import_element32.useCallback)(
12860 (item) => `${baseId}-${getItemId(item)}`,
12861 [baseId, getItemId]
12862 );
12863 const isActiveCompositeItem = (0, import_element32.useCallback)(
12864 (item, idToCheck) => {
12865 return idToCheck.startsWith(
12866 generateCompositeItemIdPrefix(item)
12867 );
12868 },
12869 [generateCompositeItemIdPrefix]
12870 );
12871 const [activeCompositeId, setActiveCompositeId] = (0, import_element32.useState)(void 0);
12872 const compositeRef = (0, import_element32.useRef)(null);
12873 (0, import_element32.useEffect)(() => {
12874 if (selectedItem) {
12875 setActiveCompositeId(
12876 generateItemWrapperCompositeId(
12877 generateCompositeItemIdPrefix(selectedItem)
12878 )
12879 );
12880 }
12881 }, [selectedItem, generateCompositeItemIdPrefix]);
12882 const activeItemIndex = data.findIndex(
12883 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
12884 );
12885 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
12886 const isActiveIdInList = activeItemIndex !== -1;
12887 const selectCompositeItem = (0, import_element32.useCallback)(
12888 (targetIndex, generateCompositeId) => {
12889 const clampedIndex = Math.min(
12890 data.length - 1,
12891 Math.max(0, targetIndex)
12892 );
12893 if (!data[clampedIndex]) {
12894 return;
12895 }
12896 const itemIdPrefix = generateCompositeItemIdPrefix(
12897 data[clampedIndex]
12898 );
12899 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
12900 setActiveCompositeId(targetCompositeItemId);
12901 if (compositeRef.current?.contains(
12902 compositeRef.current.ownerDocument.activeElement
12903 )) {
12904 document.getElementById(targetCompositeItemId)?.focus();
12905 }
12906 },
12907 [data, generateCompositeItemIdPrefix]
12908 );
12909 (0, import_element32.useEffect)(() => {
12910 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
12911 if (!isActiveIdInList && wasActiveIdInList) {
12912 selectCompositeItem(
12913 previousActiveItemIndex,
12914 generateItemWrapperCompositeId
12915 );
12916 }
12917 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
12918 const onDropdownTriggerKeyDown = (0, import_element32.useCallback)(
12919 (event) => {
12920 if (event.key === "ArrowDown") {
12921 event.preventDefault();
12922 selectCompositeItem(
12923 activeItemIndex + 1,
12924 generateDropdownTriggerCompositeId
12925 );
12926 }
12927 if (event.key === "ArrowUp") {
12928 event.preventDefault();
12929 selectCompositeItem(
12930 activeItemIndex - 1,
12931 generateDropdownTriggerCompositeId
12932 );
12933 }
12934 },
12935 [selectCompositeItem, activeItemIndex]
12936 );
12937 const hasData = !!data?.length;
12938 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
12939 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
12940 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12941 if (!hasData) {
12942 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12943 "div",
12944 {
12945 className: clsx_default("dataviews-no-results", {
12946 "is-refreshing": isDelayedLoading
12947 }),
12948 children: empty
12949 }
12950 );
12951 }
12952 if (hasData && groupField && dataByGroup) {
12953 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12954 import_components10.Composite,
12955 {
12956 ref: compositeRef,
12957 id: `${baseId}`,
12958 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
12959 className: "dataviews-view-list__group",
12960 role: "grid",
12961 activeId: activeCompositeId,
12962 setActiveId: setActiveCompositeId,
12963 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12964 Stack,
12965 {
12966 direction: "column",
12967 gap: "lg",
12968 className: clsx_default("dataviews-view-list", className),
12969 children: Array.from(dataByGroup.entries()).map(
12970 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12971 Stack,
12972 {
12973 direction: "column",
12974 gap: "sm",
12975 children: [
12976 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12977 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12978 (0, import_i18n13.__)("%1$s: %2$s"),
12979 groupField.label,
12980 groupName
12981 ) }),
12982 groupItems.map((item) => {
12983 const id = generateCompositeItemIdPrefix(item);
12984 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12985 ListItem,
12986 {
12987 view,
12988 idPrefix: id,
12989 actions,
12990 item,
12991 isSelected: item === selectedItem,
12992 onSelect,
12993 mediaField,
12994 titleField,
12995 descriptionField,
12996 otherFields,
12997 onDropdownTriggerKeyDown
12998 },
12999 id
13000 );
13001 })
13002 ]
13003 },
13004 groupName
13005 )
13006 )
13007 }
13008 )
13009 }
13010 );
13011 }
13012 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
13013 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13014 import_components10.Composite,
13015 {
13016 ref: compositeRef,
13017 id: baseId,
13018 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
13019 className: clsx_default("dataviews-view-list", className, {
13020 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13021 view.layout.density
13022 ),
13023 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13024 }),
13025 role: view.infiniteScrollEnabled ? "feed" : "grid",
13026 activeId: activeCompositeId,
13027 setActiveId: setActiveCompositeId,
13028 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
13029 children: data.map((item, index2) => {
13030 const id = generateCompositeItemIdPrefix(item);
13031 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
13032 ListItem,
13033 {
13034 view,
13035 idPrefix: id,
13036 actions,
13037 item,
13038 isSelected: item === selectedItem,
13039 onSelect,
13040 mediaField,
13041 titleField,
13042 descriptionField,
13043 otherFields,
13044 onDropdownTriggerKeyDown,
13045 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13046 },
13047 id
13048 );
13049 })
13050 }
13051 ),
13052 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components10.Spinner, {}) })
13053 ] });
13054 }
13055
13056 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13057 var import_components11 = __toESM(require_components(), 1);
13058
13059 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
13060 var import_i18n14 = __toESM(require_i18n(), 1);
13061 var import_element33 = __toESM(require_element(), 1);
13062 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
13063 function ActivityGroup({
13064 groupName,
13065 groupData,
13066 groupField,
13067 showLabel = true,
13068 children
13069 }) {
13070 const groupHeader = showLabel ? (0, import_element33.createInterpolateElement)(
13071 // translators: %s: The label of the field e.g. "Status".
13072 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
13073 {
13074 groupName: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
13075 groupField.render,
13076 {
13077 item: groupData[0],
13078 field: groupField
13079 }
13080 )
13081 }
13082 ) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(groupField.render, { item: groupData[0], field: groupField });
13083 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
13084 Stack,
13085 {
13086 direction: "column",
13087 className: "dataviews-view-activity__group",
13088 children: [
13089 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
13090 children
13091 ]
13092 },
13093 groupName
13094 );
13095 }
13096
13097 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
13098 var import_element34 = __toESM(require_element(), 1);
13099 var import_data7 = __toESM(require_data(), 1);
13100 var import_compose5 = __toESM(require_compose(), 1);
13101 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
13102 function ActivityItem(props) {
13103 const {
13104 view,
13105 actions,
13106 item,
13107 titleField,
13108 mediaField,
13109 descriptionField,
13110 otherFields,
13111 posinset,
13112 onClickItem,
13113 renderItemLink,
13114 isItemClickable
13115 } = props;
13116 const {
13117 showTitle = true,
13118 showMedia = true,
13119 showDescription = true,
13120 infiniteScrollEnabled
13121 } = view;
13122 const itemRef = (0, import_element34.useRef)(null);
13123 const registry = (0, import_data7.useRegistry)();
13124 const { paginationInfo } = (0, import_element34.useContext)(dataviews_context_default);
13125 const { primaryActions, eligibleActions } = (0, import_element34.useMemo)(() => {
13126 const _eligibleActions = actions.filter(
13127 (action) => !action.isEligible || action.isEligible(item)
13128 );
13129 const _primaryActions = _eligibleActions.filter(
13130 (action) => action.isPrimary
13131 );
13132 return {
13133 primaryActions: _primaryActions,
13134 eligibleActions: _eligibleActions
13135 };
13136 }, [actions, item]);
13137 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
13138 const density = view.layout?.density ?? "balanced";
13139 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13140 mediaField.render,
13141 {
13142 item,
13143 field: mediaField,
13144 config: {
13145 sizes: density === "comfortable" ? "32px" : "24px"
13146 }
13147 }
13148 ) : null;
13149 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13150 "span",
13151 {
13152 className: "dataviews-view-activity__item-bullet",
13153 "aria-hidden": "true"
13154 }
13155 ) });
13156 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(titleField.render, { item, field: titleField }) : null;
13157 const verticalGap = (0, import_element34.useMemo)(() => {
13158 switch (density) {
13159 case "comfortable":
13160 return "md";
13161 default:
13162 return "sm";
13163 }
13164 }, [density]);
13165 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13166 "div",
13167 {
13168 ref: itemRef,
13169 role: infiniteScrollEnabled ? "article" : void 0,
13170 "aria-posinset": posinset,
13171 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13172 className: clsx_default(
13173 "dataviews-view-activity__item",
13174 density === "compact" && "is-compact",
13175 density === "balanced" && "is-balanced",
13176 density === "comfortable" && "is-comfortable"
13177 ),
13178 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13179 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13180 Stack,
13181 {
13182 direction: "column",
13183 gap: "xs",
13184 align: "center",
13185 className: "dataviews-view-activity__item-type",
13186 children: renderedMediaField
13187 }
13188 ),
13189 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13190 Stack,
13191 {
13192 direction: "column",
13193 gap: verticalGap,
13194 align: "flex-start",
13195 className: "dataviews-view-activity__item-content",
13196 children: [
13197 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13198 ItemClickWrapper,
13199 {
13200 item,
13201 isItemClickable,
13202 onClickItem,
13203 renderItemLink,
13204 className: "dataviews-view-activity__item-title",
13205 children: renderedTitleField
13206 }
13207 ),
13208 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13209 descriptionField.render,
13210 {
13211 item,
13212 field: descriptionField
13213 }
13214 ) }),
13215 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13216 "div",
13217 {
13218 className: "dataviews-view-activity__item-field",
13219 children: [
13220 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13221 VisuallyHidden,
13222 {
13223 className: "dataviews-view-activity__item-field-label",
13224 render: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", {}),
13225 children: field.label
13226 }
13227 ),
13228 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13229 field.render,
13230 {
13231 item,
13232 field
13233 }
13234 ) })
13235 ]
13236 },
13237 field.id
13238 )) }),
13239 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13240 PrimaryActions,
13241 {
13242 item,
13243 actions: primaryActions,
13244 registry,
13245 buttonVariant: "secondary"
13246 }
13247 )
13248 ]
13249 }
13250 ),
13251 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13252 // there if there are any actions at all.
13253 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13254 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13255 ItemActions,
13256 {
13257 item,
13258 actions: eligibleActions,
13259 isCompact: true
13260 }
13261 ) })
13262 ] })
13263 }
13264 );
13265 }
13266 var activity_item_default = ActivityItem;
13267
13268 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13269 var import_react6 = __toESM(require_react(), 1);
13270 function isDefined3(item) {
13271 return !!item;
13272 }
13273 function ActivityItems(props) {
13274 const { data, fields, getItemId, view } = props;
13275 const titleField = fields.find((field) => field.id === view.titleField);
13276 const mediaField = fields.find((field) => field.id === view.mediaField);
13277 const descriptionField = fields.find(
13278 (field) => field.id === view.descriptionField
13279 );
13280 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13281 return data.map((item, index2) => {
13282 return /* @__PURE__ */ (0, import_react6.createElement)(
13283 activity_item_default,
13284 {
13285 ...props,
13286 key: getItemId(item),
13287 item,
13288 mediaField,
13289 titleField,
13290 descriptionField,
13291 otherFields,
13292 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13293 }
13294 );
13295 });
13296 }
13297
13298 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13299 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13300 function ViewActivity(props) {
13301 const { empty, data, fields, isLoading, view, className } = props;
13302 const isDelayedLoading = useDelayedLoading(!!isLoading);
13303 const hasData = !!data?.length;
13304 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13305 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13306 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13307 if (!hasData) {
13308 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13309 "div",
13310 {
13311 className: clsx_default("dataviews-no-results", {
13312 "is-refreshing": isDelayedLoading
13313 }),
13314 children: empty
13315 }
13316 );
13317 }
13318 const isInert = !isInfiniteScroll && !!isLoading;
13319 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13320 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13321 });
13322 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13323 if (hasData && groupField && dataByGroup) {
13324 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13325 Stack,
13326 {
13327 direction: "column",
13328 gap: "sm",
13329 className: wrapperClassName,
13330 inert: isInert ? "true" : void 0,
13331 children: groupedEntries.map(
13332 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13333 ActivityGroup,
13334 {
13335 groupName,
13336 groupData,
13337 groupField,
13338 showLabel: view.groupBy?.showLabel !== false,
13339 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13340 ActivityItems,
13341 {
13342 ...props,
13343 data: groupData
13344 }
13345 )
13346 },
13347 groupName
13348 )
13349 )
13350 }
13351 );
13352 }
13353 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
13354 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13355 "div",
13356 {
13357 className: wrapperClassName,
13358 role: view.infiniteScrollEnabled ? "feed" : void 0,
13359 inert: isInert ? "true" : void 0,
13360 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ActivityItems, { ...props })
13361 }
13362 ),
13363 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components11.Spinner, {}) })
13364 ] });
13365 }
13366
13367 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13368 var import_components14 = __toESM(require_components(), 1);
13369 var import_i18n17 = __toESM(require_i18n(), 1);
13370 var import_compose6 = __toESM(require_compose(), 1);
13371 var import_element37 = __toESM(require_element(), 1);
13372
13373 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13374 var import_components13 = __toESM(require_components(), 1);
13375 var import_data8 = __toESM(require_data(), 1);
13376 var import_element36 = __toESM(require_element(), 1);
13377 var import_i18n16 = __toESM(require_i18n(), 1);
13378
13379 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13380 var import_components12 = __toESM(require_components(), 1);
13381 var import_element35 = __toESM(require_element(), 1);
13382 var import_i18n15 = __toESM(require_i18n(), 1);
13383 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13384 function DataViewsPagination() {
13385 const {
13386 view,
13387 onChangeView,
13388 paginationInfo: { totalItems = 0, totalPages }
13389 } = (0, import_element35.useContext)(dataviews_context_default);
13390 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13391 return null;
13392 }
13393 const currentPage = view.page ?? 1;
13394 const pageSelectOptions = Array.from(Array(totalPages)).map(
13395 (_, i2) => {
13396 const page = i2 + 1;
13397 return {
13398 value: page.toString(),
13399 label: page.toString(),
13400 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
13401 // translators: 1: current page number. 2: total number of pages.
13402 (0, import_i18n15.__)("Page %1$d of %2$d"),
13403 currentPage,
13404 totalPages
13405 ) : page.toString()
13406 };
13407 }
13408 );
13409 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
13410 Stack,
13411 {
13412 direction: "row",
13413 className: "dataviews-pagination",
13414 justify: "end",
13415 align: "center",
13416 gap: "xl",
13417 children: [
13418 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13419 Stack,
13420 {
13421 direction: "row",
13422 justify: "flex-start",
13423 align: "center",
13424 gap: "xs",
13425 className: "dataviews-pagination__page-select",
13426 children: (0, import_element35.createInterpolateElement)(
13427 (0, import_i18n15.sprintf)(
13428 // translators: 1: Current page number, 2: Total number of pages.
13429 (0, import_i18n15._x)(
13430 "<div>Page</div>%1$s<div>of %2$d</div>",
13431 "paging"
13432 ),
13433 "<CurrentPage />",
13434 totalPages
13435 ),
13436 {
13437 div: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { "aria-hidden": true }),
13438 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13439 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13440 import_components12.SelectControl,
13441 {
13442 "aria-label": (0, import_i18n15.__)("Current page"),
13443 value: currentPage.toString(),
13444 options: pageSelectOptions,
13445 onChange: (newValue) => {
13446 onChangeView({
13447 ...view,
13448 page: +newValue
13449 });
13450 },
13451 size: "small",
13452 variant: "minimal"
13453 }
13454 )
13455 }
13456 )
13457 }
13458 ),
13459 /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13460 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13461 import_components12.Button,
13462 {
13463 onClick: () => onChangeView({
13464 ...view,
13465 page: currentPage - 1
13466 }),
13467 disabled: currentPage === 1,
13468 accessibleWhenDisabled: true,
13469 label: (0, import_i18n15.__)("Previous page"),
13470 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
13471 showTooltip: true,
13472 size: "compact",
13473 tooltipPosition: "top"
13474 }
13475 ),
13476 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13477 import_components12.Button,
13478 {
13479 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13480 disabled: currentPage >= totalPages,
13481 accessibleWhenDisabled: true,
13482 label: (0, import_i18n15.__)("Next page"),
13483 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
13484 showTooltip: true,
13485 size: "compact",
13486 tooltipPosition: "top"
13487 }
13488 )
13489 ] })
13490 ]
13491 }
13492 );
13493 }
13494 var dataviews_pagination_default = (0, import_element35.memo)(DataViewsPagination);
13495
13496 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13497 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13498 function useIsMultiselectPicker(actions) {
13499 return (0, import_element36.useMemo)(() => {
13500 return actions?.every((action) => action.supportsBulk);
13501 }, [actions]);
13502 }
13503
13504 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13505 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13506 var { Badge: WCBadge2 } = unlock3(import_components14.privateApis);
13507 function GridItem3({
13508 view,
13509 multiselect,
13510 selection,
13511 onChangeSelection,
13512 getItemId,
13513 item,
13514 mediaField,
13515 titleField,
13516 descriptionField,
13517 regularFields,
13518 badgeFields,
13519 config,
13520 posinset,
13521 setsize
13522 }) {
13523 const { showTitle = true, showMedia = true, showDescription = true } = view;
13524 const id = getItemId(item);
13525 const elementRef = (0, import_element37.useRef)(null);
13526 const isSelected2 = selection.includes(id);
13527 useIntersectionObserver(elementRef, posinset);
13528 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13529 mediaField.render,
13530 {
13531 item,
13532 field: mediaField,
13533 config
13534 }
13535 ) : null;
13536 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
13537 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13538 import_components14.Composite.Item,
13539 {
13540 ref: elementRef,
13541 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
13542 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", children, ...props }),
13543 role: "option",
13544 "aria-posinset": posinset,
13545 "aria-setsize": setsize,
13546 className: clsx_default("dataviews-view-picker-grid__card", {
13547 "is-selected": isSelected2
13548 }),
13549 "aria-selected": isSelected2,
13550 onClick: () => {
13551 if (isSelected2) {
13552 onChangeSelection(
13553 selection.filter((itemId) => id !== itemId)
13554 );
13555 } else {
13556 const newSelection = multiselect ? [...selection, id] : [id];
13557 onChangeSelection(newSelection);
13558 }
13559 },
13560 children: [
13561 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13562 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13563 DataViewsSelectionCheckbox,
13564 {
13565 item,
13566 selection,
13567 onChangeSelection,
13568 getItemId,
13569 titleField,
13570 disabled: false,
13571 "aria-hidden": true,
13572 tabIndex: -1
13573 }
13574 ),
13575 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13576 Stack,
13577 {
13578 direction: "row",
13579 justify: "space-between",
13580 className: "dataviews-view-picker-grid__title-actions",
13581 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13582 }
13583 ),
13584 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13585 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13586 descriptionField.render,
13587 {
13588 item,
13589 field: descriptionField
13590 }
13591 ),
13592 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13593 Stack,
13594 {
13595 direction: "row",
13596 className: "dataviews-view-picker-grid__badge-fields",
13597 gap: "sm",
13598 wrap: "wrap",
13599 align: "top",
13600 justify: "flex-start",
13601 children: badgeFields.map((field) => {
13602 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13603 WCBadge2,
13604 {
13605 className: "dataviews-view-picker-grid__field-value",
13606 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13607 field.render,
13608 {
13609 item,
13610 field
13611 }
13612 )
13613 },
13614 field.id
13615 );
13616 })
13617 }
13618 ),
13619 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13620 Stack,
13621 {
13622 direction: "column",
13623 className: "dataviews-view-picker-grid__fields",
13624 gap: "xs",
13625 children: regularFields.map((field) => {
13626 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13627 import_components14.Flex,
13628 {
13629 className: "dataviews-view-picker-grid__field",
13630 gap: 1,
13631 justify: "flex-start",
13632 expanded: true,
13633 style: { height: "auto" },
13634 direction: "row",
13635 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
13636 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13637 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13638 import_components14.FlexItem,
13639 {
13640 className: "dataviews-view-picker-grid__field-value",
13641 style: { maxHeight: "none" },
13642 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13643 field.render,
13644 {
13645 item,
13646 field
13647 }
13648 )
13649 }
13650 )
13651 ] })
13652 },
13653 field.id
13654 );
13655 })
13656 }
13657 )
13658 ] })
13659 ]
13660 },
13661 id
13662 );
13663 }
13664 function GridGroup({
13665 groupName,
13666 groupField,
13667 showLabel = true,
13668 children
13669 }) {
13670 const headerId = (0, import_compose6.useInstanceId)(
13671 GridGroup,
13672 "dataviews-view-picker-grid-group__header"
13673 );
13674 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13675 Stack,
13676 {
13677 direction: "column",
13678 gap: "sm",
13679 role: "group",
13680 "aria-labelledby": headerId,
13681 children: [
13682 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13683 "h3",
13684 {
13685 className: "dataviews-view-picker-grid-group__header",
13686 id: headerId,
13687 children: showLabel ? (0, import_i18n17.sprintf)(
13688 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13689 (0, import_i18n17.__)("%1$s: %2$s"),
13690 groupField.label,
13691 groupName
13692 ) : groupName
13693 }
13694 ),
13695 children
13696 ]
13697 },
13698 groupName
13699 );
13700 }
13701 function ViewPickerGrid({
13702 actions,
13703 data,
13704 fields,
13705 getItemId,
13706 isLoading,
13707 onChangeSelection,
13708 selection,
13709 view,
13710 className,
13711 empty
13712 }) {
13713 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element37.useContext)(dataviews_context_default);
13714 const titleField = fields.find(
13715 (field) => field.id === view?.titleField
13716 );
13717 const mediaField = fields.find(
13718 (field) => field.id === view?.mediaField
13719 );
13720 const descriptionField = fields.find(
13721 (field) => field.id === view?.descriptionField
13722 );
13723 const otherFields = view.fields ?? [];
13724 const { regularFields, badgeFields } = otherFields.reduce(
13725 (accumulator, fieldId) => {
13726 const field = fields.find((f2) => f2.id === fieldId);
13727 if (!field) {
13728 return accumulator;
13729 }
13730 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
13731 accumulator[key].push(field);
13732 return accumulator;
13733 },
13734 { regularFields: [], badgeFields: [] }
13735 );
13736 const hasData = !!data?.length;
13737 const usedPreviewSize = view.layout?.previewSize;
13738 const isMultiselect = useIsMultiselectPicker(actions);
13739 const size4 = "900px";
13740 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13741 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13742 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
13743 const currentPage = view?.page ?? 1;
13744 const perPage = view?.perPage ?? 0;
13745 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
13746 const gridColumns = useGridColumns();
13747 const placeholdersNeeded = usePlaceholdersNeeded(
13748 data,
13749 isInfiniteScroll,
13750 gridColumns
13751 );
13752 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
13753 // Render multiple groups.
13754 children: [
13755 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13756 import_components14.Composite,
13757 {
13758 virtualFocus: true,
13759 orientation: "horizontal",
13760 role: "listbox",
13761 "aria-multiselectable": isMultiselect,
13762 className: clsx_default(
13763 "dataviews-view-picker-grid",
13764 className,
13765 {
13766 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13767 view.layout.density
13768 )
13769 }
13770 ),
13771 "aria-label": itemListLabel,
13772 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13773 Stack,
13774 {
13775 direction: "column",
13776 gap: "lg",
13777 children,
13778 ...props
13779 }
13780 ),
13781 children: Array.from(dataByGroup.entries()).map(
13782 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13783 GridGroup,
13784 {
13785 groupName,
13786 groupField,
13787 showLabel: view.groupBy?.showLabel !== false,
13788 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13789 GridItems,
13790 {
13791 previewSize: usedPreviewSize,
13792 style: {
13793 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
13794 },
13795 "aria-busy": isLoading,
13796 ref: resizeObserverRef,
13797 children: groupItems.map((item) => {
13798 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
13799 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13800 GridItem3,
13801 {
13802 view,
13803 multiselect: isMultiselect,
13804 selection,
13805 onChangeSelection,
13806 getItemId,
13807 item,
13808 mediaField,
13809 titleField,
13810 descriptionField,
13811 regularFields,
13812 badgeFields,
13813 config: {
13814 sizes: size4
13815 },
13816 posinset: posInSet,
13817 setsize: setSize
13818 },
13819 getItemId(item)
13820 );
13821 })
13822 }
13823 )
13824 },
13825 groupName
13826 )
13827 )
13828 }
13829 ),
13830 // Render a single grid with all data.
13831 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13832 import_components14.Composite,
13833 {
13834 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13835 GridItems,
13836 {
13837 className: clsx_default(
13838 "dataviews-view-picker-grid",
13839 className,
13840 {
13841 [`has-${view.layout?.density}-density`]: view.layout?.density && [
13842 "compact",
13843 "comfortable"
13844 ].includes(view.layout.density)
13845 }
13846 ),
13847 previewSize: usedPreviewSize,
13848 "aria-busy": isLoading,
13849 ref: resizeObserverRef
13850 }
13851 ),
13852 virtualFocus: true,
13853 orientation: "horizontal",
13854 role: "listbox",
13855 "aria-multiselectable": isMultiselect,
13856 "aria-label": itemListLabel,
13857 children: [
13858 Array.from({ length: placeholdersNeeded }).map(
13859 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13860 import_components14.Composite.Item,
13861 {
13862 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13863 Stack,
13864 {
13865 direction: "column",
13866 children,
13867 ...props
13868 }
13869 ),
13870 role: "option",
13871 "aria-hidden": true,
13872 tabIndex: -1,
13873 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
13874 },
13875 `placeholder-${index2}`
13876 )
13877 ),
13878 data.map((item) => {
13879 const posinset = item.position;
13880 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13881 GridItem3,
13882 {
13883 view,
13884 multiselect: isMultiselect,
13885 selection,
13886 onChangeSelection,
13887 getItemId,
13888 item,
13889 mediaField,
13890 titleField,
13891 descriptionField,
13892 regularFields,
13893 badgeFields,
13894 config: {
13895 sizes: size4
13896 },
13897 posinset,
13898 setsize: setSize
13899 },
13900 getItemId(item)
13901 );
13902 })
13903 ]
13904 }
13905 ),
13906 // Render empty state.
13907 !hasData && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13908 "div",
13909 {
13910 className: clsx_default({
13911 "dataviews-loading": isLoading,
13912 "dataviews-no-results": !isLoading
13913 }),
13914 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) }) : empty
13915 }
13916 ),
13917 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) })
13918 ]
13919 });
13920 }
13921 var picker_grid_default = ViewPickerGrid;
13922
13923 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
13924 var import_i18n18 = __toESM(require_i18n(), 1);
13925 var import_components15 = __toESM(require_components(), 1);
13926 var import_element38 = __toESM(require_element(), 1);
13927 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13928 function TableColumnField2({
13929 item,
13930 fields,
13931 column,
13932 align
13933 }) {
13934 const field = fields.find((f2) => f2.id === column);
13935 if (!field) {
13936 return null;
13937 }
13938 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
13939 "dataviews-view-table__cell-align-end": align === "end",
13940 "dataviews-view-table__cell-align-center": align === "center"
13941 });
13942 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(field.render, { item, field }) });
13943 }
13944 function TableRow2({
13945 item,
13946 fields,
13947 id,
13948 view,
13949 titleField,
13950 mediaField,
13951 descriptionField,
13952 selection,
13953 getItemId,
13954 onChangeSelection,
13955 multiselect,
13956 posinset
13957 }) {
13958 const { paginationInfo } = (0, import_element38.useContext)(dataviews_context_default);
13959 const isSelected2 = selection.includes(id);
13960 const [isHovered, setIsHovered] = (0, import_element38.useState)(false);
13961 const elementRef = (0, import_element38.useRef)(null);
13962 useIntersectionObserver(elementRef, posinset);
13963 const {
13964 showTitle = true,
13965 showMedia = true,
13966 showDescription = true,
13967 infiniteScrollEnabled
13968 } = view;
13969 const handleMouseEnter = () => {
13970 setIsHovered(true);
13971 };
13972 const handleMouseLeave = () => {
13973 setIsHovered(false);
13974 };
13975 const columns = view.fields ?? [];
13976 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13977 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13978 import_components15.Composite.Item,
13979 {
13980 ref: elementRef,
13981 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13982 "tr",
13983 {
13984 className: clsx_default("dataviews-view-table__row", {
13985 "is-selected": isSelected2,
13986 "is-hovered": isHovered
13987 }),
13988 onMouseEnter: handleMouseEnter,
13989 onMouseLeave: handleMouseLeave,
13990 children,
13991 ...props
13992 }
13993 ),
13994 "aria-selected": isSelected2,
13995 "aria-setsize": paginationInfo.totalItems || void 0,
13996 "aria-posinset": posinset,
13997 role: infiniteScrollEnabled ? "article" : "option",
13998 onMouseDown: (event) => {
13999 if (event.button !== 0) {
14000 return;
14001 }
14002 event.currentTarget.parentElement?.focus({
14003 preventScroll: true
14004 });
14005 },
14006 onClick: () => {
14007 if (isSelected2) {
14008 onChangeSelection(
14009 selection.filter((itemId) => id !== itemId)
14010 );
14011 } else {
14012 const newSelection = multiselect ? [...selection, id] : [id];
14013 onChangeSelection(newSelection);
14014 }
14015 },
14016 children: [
14017 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14018 "td",
14019 {
14020 className: "dataviews-view-table__checkbox-column",
14021 role: "presentation",
14022 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14023 DataViewsSelectionCheckbox,
14024 {
14025 item,
14026 selection,
14027 onChangeSelection,
14028 getItemId,
14029 titleField,
14030 disabled: false,
14031 "aria-hidden": true,
14032 tabIndex: -1
14033 }
14034 ) })
14035 }
14036 ),
14037 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14038 "td",
14039 {
14040 role: "presentation",
14041 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14042 column_primary_default,
14043 {
14044 item,
14045 titleField: showTitle ? titleField : void 0,
14046 mediaField: showMedia ? mediaField : void 0,
14047 descriptionField: showDescription ? descriptionField : void 0,
14048 isItemClickable: () => false
14049 }
14050 )
14051 }
14052 ),
14053 columns.map((column) => {
14054 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14055 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14056 "td",
14057 {
14058 style: {
14059 width,
14060 maxWidth,
14061 minWidth
14062 },
14063 role: "presentation",
14064 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14065 TableColumnField2,
14066 {
14067 fields,
14068 item,
14069 column,
14070 align
14071 }
14072 )
14073 },
14074 column
14075 );
14076 })
14077 ]
14078 },
14079 id
14080 );
14081 }
14082 function ViewPickerTable({
14083 actions,
14084 data,
14085 fields,
14086 getItemId,
14087 isLoading = false,
14088 onChangeView,
14089 onChangeSelection,
14090 selection,
14091 setOpenedFilter,
14092 view,
14093 className,
14094 empty
14095 }) {
14096 const headerMenuRefs = (0, import_element38.useRef)(/* @__PURE__ */ new Map());
14097 const headerMenuToFocusRef = (0, import_element38.useRef)(void 0);
14098 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element38.useState)();
14099 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
14100 (0, import_element38.useEffect)(() => {
14101 if (headerMenuToFocusRef.current) {
14102 headerMenuToFocusRef.current.focus();
14103 headerMenuToFocusRef.current = void 0;
14104 }
14105 });
14106 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14107 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14108 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
14109 const tableNoticeId = (0, import_element38.useId)();
14110 if (nextHeaderMenuToFocus) {
14111 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
14112 setNextHeaderMenuToFocus(void 0);
14113 return;
14114 }
14115 const onHide = (field) => {
14116 const hidden = headerMenuRefs.current.get(field.id);
14117 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
14118 setNextHeaderMenuToFocus(fallback?.node);
14119 };
14120 const hasData = !!data?.length;
14121 const titleField = fields.find((field) => field.id === view.titleField);
14122 const mediaField = fields.find((field) => field.id === view.mediaField);
14123 const descriptionField = fields.find(
14124 (field) => field.id === view.descriptionField
14125 );
14126 const { showTitle = true, showMedia = true, showDescription = true } = view;
14127 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
14128 const columns = view.fields ?? [];
14129 const headerMenuRef = (column, index2) => (node) => {
14130 if (node) {
14131 headerMenuRefs.current.set(column, {
14132 node,
14133 fallback: columns[index2 > 0 ? index2 - 1 : 1]
14134 });
14135 } else {
14136 headerMenuRefs.current.delete(column);
14137 }
14138 };
14139 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
14140 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14141 "table",
14142 {
14143 className: clsx_default(
14144 "dataviews-view-table",
14145 "dataviews-view-picker-table",
14146 className,
14147 {
14148 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
14149 view.layout.density
14150 )
14151 }
14152 ),
14153 "aria-busy": isLoading,
14154 "aria-describedby": tableNoticeId,
14155 role: isInfiniteScroll ? "feed" : "listbox",
14156 children: [
14157 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14158 "tr",
14159 {
14160 className: "dataviews-view-table__row",
14161 role: "presentation",
14162 children: [
14163 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14164 BulkSelectionCheckbox,
14165 {
14166 selection,
14167 onChangeSelection,
14168 data,
14169 actions,
14170 getItemId,
14171 disableSelectAll: isInfiniteScroll
14172 }
14173 ) }),
14174 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14175 column_header_menu_default,
14176 {
14177 ref: headerMenuRef(
14178 titleField.id,
14179 0
14180 ),
14181 fieldId: titleField.id,
14182 view,
14183 fields,
14184 onChangeView,
14185 onHide,
14186 setOpenedFilter,
14187 canMove: false
14188 }
14189 ) }),
14190 columns.map((column, index2) => {
14191 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14192 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14193 "th",
14194 {
14195 style: {
14196 width,
14197 maxWidth,
14198 minWidth,
14199 textAlign: align
14200 },
14201 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14202 scope: "col",
14203 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14204 column_header_menu_default,
14205 {
14206 ref: headerMenuRef(column, index2),
14207 fieldId: column,
14208 view,
14209 fields,
14210 onChangeView,
14211 onHide,
14212 setOpenedFilter,
14213 canMove: view.layout?.enableMoving ?? true
14214 }
14215 )
14216 },
14217 column
14218 );
14219 })
14220 ]
14221 }
14222 ) }),
14223 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14224 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14225 import_components15.Composite,
14226 {
14227 virtualFocus: true,
14228 orientation: "vertical",
14229 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "group" }),
14230 children: [
14231 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14232 "tr",
14233 {
14234 className: "dataviews-view-table__group-header-row",
14235 role: "presentation",
14236 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14237 "td",
14238 {
14239 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14240 className: "dataviews-view-table__group-header-cell",
14241 role: "presentation",
14242 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
14243 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14244 (0, import_i18n18.__)("%1$s: %2$s"),
14245 groupField.label,
14246 groupName
14247 )
14248 }
14249 )
14250 }
14251 ),
14252 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14253 TableRow2,
14254 {
14255 item,
14256 fields,
14257 id: getItemId(item) || index2.toString(),
14258 view,
14259 titleField,
14260 mediaField,
14261 descriptionField,
14262 selection,
14263 getItemId,
14264 onChangeSelection,
14265 multiselect: isMultiselect
14266 },
14267 getItemId(item)
14268 ))
14269 ]
14270 },
14271 `group-${groupName}`
14272 )
14273 ) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14274 import_components15.Composite,
14275 {
14276 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "presentation" }),
14277 virtualFocus: true,
14278 orientation: "vertical",
14279 children: hasData && data.map((item, index2) => {
14280 const itemId = getItemId(item);
14281 const posinset = item.position;
14282 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14283 TableRow2,
14284 {
14285 item,
14286 fields,
14287 id: itemId || index2.toString(),
14288 view,
14289 titleField,
14290 mediaField,
14291 descriptionField,
14292 selection,
14293 getItemId,
14294 onChangeSelection,
14295 multiselect: isMultiselect,
14296 posinset
14297 },
14298 itemId
14299 );
14300 })
14301 }
14302 )
14303 ]
14304 }
14305 ),
14306 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14307 "div",
14308 {
14309 className: clsx_default({
14310 "dataviews-loading": isLoading,
14311 "dataviews-no-results": !hasData && !isLoading
14312 }),
14313 id: tableNoticeId,
14314 children: [
14315 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) }) : empty),
14316 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) })
14317 ]
14318 }
14319 )
14320 ] });
14321 }
14322 var picker_table_default = ViewPickerTable;
14323
14324 // packages/dataviews/build-module/components/dataviews-layouts/picker-activity/index.mjs
14325 var import_components16 = __toESM(require_components(), 1);
14326 var import_element39 = __toESM(require_element(), 1);
14327 var import_compose7 = __toESM(require_compose(), 1);
14328 var import_i18n19 = __toESM(require_i18n(), 1);
14329 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
14330 function isDefined4(item) {
14331 return !!item;
14332 }
14333 function PickerActivityItem({
14334 view,
14335 multiselect,
14336 selection,
14337 onChangeSelection,
14338 getItemId,
14339 item,
14340 titleField,
14341 mediaField,
14342 descriptionField,
14343 otherFields,
14344 posinset,
14345 setsize
14346 }) {
14347 const elementRef = (0, import_element39.useRef)(null);
14348 useIntersectionObserver(elementRef, posinset);
14349 const { showTitle = true, showMedia = true, showDescription = true } = view;
14350 const id = getItemId(item);
14351 const isSelected2 = selection.includes(id);
14352 const density = view.layout?.density ?? "balanced";
14353 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14354 mediaField.render,
14355 {
14356 item,
14357 field: mediaField,
14358 config: {
14359 sizes: density === "comfortable" ? "32px" : "24px"
14360 }
14361 }
14362 ) : null;
14363 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14364 "span",
14365 {
14366 className: "dataviews-view-picker-activity__item-bullet",
14367 "aria-hidden": "true"
14368 }
14369 ) });
14370 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(titleField.render, { item, field: titleField }) : null;
14371 const renderedDescriptionField = showDescription && descriptionField?.render ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(descriptionField.render, { item, field: descriptionField }) : null;
14372 const verticalGap = (0, import_element39.useMemo)(() => {
14373 switch (density) {
14374 case "comfortable":
14375 return "md";
14376 default:
14377 return "sm";
14378 }
14379 }, [density]);
14380 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14381 import_components16.Composite.Item,
14382 {
14383 ref: elementRef,
14384 role: "option",
14385 "aria-label": titleField ? titleField.getValue({ item }) || void 0 : void 0,
14386 "aria-posinset": posinset,
14387 "aria-setsize": setsize,
14388 "aria-selected": isSelected2,
14389 className: clsx_default(
14390 "dataviews-view-picker-activity__item",
14391 density === "compact" && "is-compact",
14392 density === "balanced" && "is-balanced",
14393 density === "comfortable" && "is-comfortable",
14394 isSelected2 && "is-selected"
14395 ),
14396 onClick: () => {
14397 if (isSelected2) {
14398 onChangeSelection(
14399 selection.filter((itemId) => id !== itemId)
14400 );
14401 } else {
14402 const newSelection = multiselect ? [...selection, id] : [id];
14403 onChangeSelection(newSelection);
14404 }
14405 },
14406 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", {}),
14407 children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
14408 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14409 Stack,
14410 {
14411 direction: "column",
14412 gap: "xs",
14413 align: "center",
14414 className: "dataviews-view-picker-activity__item-type",
14415 children: renderedMediaField
14416 }
14417 ),
14418 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14419 Stack,
14420 {
14421 direction: "column",
14422 gap: verticalGap,
14423 align: "flex-start",
14424 className: "dataviews-view-picker-activity__item-content",
14425 children: [
14426 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-title", children: renderedTitleField }),
14427 renderedDescriptionField && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-description", children: renderedDescriptionField }),
14428 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-view-picker-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14429 "div",
14430 {
14431 className: "dataviews-view-picker-activity__item-field",
14432 children: [
14433 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14434 VisuallyHidden,
14435 {
14436 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", {}),
14437 className: "dataviews-view-picker-activity__item-field-label",
14438 children: field.label
14439 }
14440 ),
14441 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-view-picker-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14442 field.render,
14443 {
14444 item,
14445 field
14446 }
14447 ) })
14448 ]
14449 },
14450 field.id
14451 )) })
14452 ]
14453 }
14454 )
14455 ] })
14456 }
14457 );
14458 }
14459 function PickerActivityGroup({
14460 groupName,
14461 groupField,
14462 showLabel = true,
14463 children
14464 }) {
14465 const headerId = (0, import_compose7.useInstanceId)(
14466 PickerActivityGroup,
14467 "dataviews-view-picker-activity-group__header"
14468 );
14469 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14470 Stack,
14471 {
14472 direction: "column",
14473 role: "group",
14474 "aria-labelledby": headerId,
14475 className: "dataviews-view-picker-activity-group",
14476 children: [
14477 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14478 "h3",
14479 {
14480 className: "dataviews-view-picker-activity-group__header",
14481 id: headerId,
14482 children: showLabel ? (0, import_i18n19.sprintf)(
14483 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14484 (0, import_i18n19.__)("%1$s: %2$s"),
14485 groupField.label,
14486 groupName
14487 ) : groupName
14488 }
14489 ),
14490 children
14491 ]
14492 }
14493 );
14494 }
14495 function ViewPickerActivity({
14496 data,
14497 fields,
14498 getItemId,
14499 isLoading,
14500 onChangeSelection,
14501 selection,
14502 view,
14503 actions,
14504 className,
14505 empty
14506 }) {
14507 const { itemListLabel, paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
14508 const isMultiselect = useIsMultiselectPicker(actions);
14509 const titleField = fields.find(
14510 (field) => field.id === view?.titleField
14511 );
14512 const mediaField = fields.find(
14513 (field) => field.id === view?.mediaField
14514 );
14515 const descriptionField = fields.find(
14516 (field) => field.id === view?.descriptionField
14517 );
14518 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined4);
14519 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
14520 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
14521 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
14522 const setsize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
14523 const hasData = !!data?.length;
14524 const isGrouped = !!(groupField && dataByGroup);
14525 const renderItem = (item) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14526 PickerActivityItem,
14527 {
14528 view,
14529 multiselect: isMultiselect,
14530 selection,
14531 onChangeSelection,
14532 getItemId,
14533 item,
14534 titleField,
14535 mediaField,
14536 descriptionField,
14537 otherFields,
14538 posinset: item.position,
14539 setsize
14540 },
14541 getItemId(item)
14542 );
14543 if (!hasData) {
14544 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14545 "div",
14546 {
14547 className: clsx_default({
14548 "dataviews-loading": isLoading,
14549 "dataviews-no-results": !isLoading
14550 }),
14551 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) }) : empty
14552 }
14553 );
14554 }
14555 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
14556 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14557 import_components16.Composite,
14558 {
14559 virtualFocus: true,
14560 orientation: "vertical",
14561 role: "listbox",
14562 "aria-multiselectable": isMultiselect,
14563 "aria-label": itemListLabel,
14564 "aria-busy": isLoading,
14565 render: isGrouped ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Stack, { direction: "column", gap: "sm" }) : void 0,
14566 className: clsx_default(
14567 "dataviews-view-picker-activity",
14568 className
14569 ),
14570 children: isGrouped && dataByGroup ? Array.from(dataByGroup.entries()).map(
14571 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14572 PickerActivityGroup,
14573 {
14574 groupName,
14575 groupField,
14576 showLabel: view.groupBy?.showLabel !== false,
14577 children: groupItems.map(renderItem)
14578 },
14579 groupName
14580 )
14581 ) : data.map(renderItem)
14582 }
14583 ),
14584 isLoading && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components16.Spinner, {}) })
14585 ] });
14586 }
14587
14588 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14589 var import_components17 = __toESM(require_components(), 1);
14590 var import_i18n20 = __toESM(require_i18n(), 1);
14591 var import_element40 = __toESM(require_element(), 1);
14592 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
14593 function DensityPicker() {
14594 const context = (0, import_element40.useContext)(dataviews_context_default);
14595 const view = context.view;
14596 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
14597 import_components17.__experimentalToggleGroupControl,
14598 {
14599 size: "__unstable-large",
14600 label: (0, import_i18n20.__)("Density"),
14601 value: view.layout?.density || "balanced",
14602 onChange: (value) => {
14603 context.onChangeView({
14604 ...view,
14605 layout: {
14606 ...view.layout,
14607 density: value
14608 }
14609 });
14610 },
14611 isBlock: true,
14612 children: [
14613 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14614 import_components17.__experimentalToggleGroupControlOption,
14615 {
14616 value: "comfortable",
14617 label: (0, import_i18n20._x)(
14618 "Comfortable",
14619 "Density option for DataView layout"
14620 )
14621 },
14622 "comfortable"
14623 ),
14624 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14625 import_components17.__experimentalToggleGroupControlOption,
14626 {
14627 value: "balanced",
14628 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
14629 },
14630 "balanced"
14631 ),
14632 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14633 import_components17.__experimentalToggleGroupControlOption,
14634 {
14635 value: "compact",
14636 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
14637 },
14638 "compact"
14639 )
14640 ]
14641 }
14642 );
14643 }
14644
14645 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14646 var import_components18 = __toESM(require_components(), 1);
14647 var import_i18n21 = __toESM(require_i18n(), 1);
14648 var import_element41 = __toESM(require_element(), 1);
14649 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14650 var imageSizes2 = [
14651 {
14652 value: 120,
14653 breakpoint: 1
14654 },
14655 {
14656 value: 170,
14657 breakpoint: 1
14658 },
14659 {
14660 value: 230,
14661 breakpoint: 1
14662 },
14663 {
14664 value: 290,
14665 breakpoint: 1112
14666 // at minimum image width, 4 images display at this container size
14667 },
14668 {
14669 value: 350,
14670 breakpoint: 1636
14671 // at minimum image width, 6 images display at this container size
14672 },
14673 {
14674 value: 430,
14675 breakpoint: 588
14676 // at minimum image width, 2 images display at this container size
14677 }
14678 ];
14679 function PreviewSizePicker() {
14680 const context = (0, import_element41.useContext)(dataviews_context_default);
14681 const view = context.view;
14682 const breakValues = imageSizes2.filter((size4) => {
14683 return context.containerWidth >= size4.breakpoint;
14684 });
14685 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14686 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14687 const marks = breakValues.map((size4, index2) => {
14688 return {
14689 value: index2
14690 };
14691 });
14692 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
14693 import_components18.RangeControl,
14694 {
14695 __next40pxDefaultSize: true,
14696 showTooltip: false,
14697 label: (0, import_i18n21.__)("Preview size"),
14698 value: previewSizeToUse,
14699 min: 0,
14700 max: breakValues.length - 1,
14701 withInputField: false,
14702 onChange: (value = 0) => {
14703 context.onChangeView({
14704 ...view,
14705 layout: {
14706 ...view.layout,
14707 previewSize: breakValues[value].value
14708 }
14709 });
14710 },
14711 step: 1,
14712 marks
14713 }
14714 );
14715 }
14716
14717 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14718 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
14719 function GridConfigOptions() {
14720 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(import_jsx_runtime63.Fragment, { children: [
14721 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DensityPicker, {}),
14722 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(PreviewSizePicker, {})
14723 ] });
14724 }
14725
14726 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14727 var VIEW_LAYOUTS = [
14728 {
14729 type: LAYOUT_TABLE,
14730 label: (0, import_i18n22.__)("Table"),
14731 component: table_default,
14732 icon: block_table_default,
14733 viewConfigOptions: DensityPicker
14734 },
14735 {
14736 type: LAYOUT_GRID,
14737 label: (0, import_i18n22.__)("Grid"),
14738 component: grid_default,
14739 icon: category_default,
14740 viewConfigOptions: GridConfigOptions
14741 },
14742 {
14743 type: LAYOUT_LIST,
14744 label: (0, import_i18n22.__)("List"),
14745 component: ViewList,
14746 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14747 viewConfigOptions: DensityPicker
14748 },
14749 {
14750 type: LAYOUT_ACTIVITY,
14751 label: (0, import_i18n22.__)("Activity"),
14752 component: ViewActivity,
14753 icon: scheduled_default,
14754 viewConfigOptions: DensityPicker
14755 },
14756 {
14757 type: LAYOUT_PICKER_GRID,
14758 label: (0, import_i18n22.__)("Grid"),
14759 component: picker_grid_default,
14760 icon: category_default,
14761 viewConfigOptions: GridConfigOptions,
14762 isPicker: true
14763 },
14764 {
14765 type: LAYOUT_PICKER_TABLE,
14766 label: (0, import_i18n22.__)("Table"),
14767 component: picker_table_default,
14768 icon: block_table_default,
14769 viewConfigOptions: DensityPicker,
14770 isPicker: true
14771 },
14772 {
14773 type: LAYOUT_PICKER_ACTIVITY,
14774 label: (0, import_i18n22.__)("Activity"),
14775 component: ViewPickerActivity,
14776 icon: scheduled_default,
14777 viewConfigOptions: DensityPicker,
14778 isPicker: true
14779 }
14780 ];
14781
14782 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14783 var import_element49 = __toESM(require_element(), 1);
14784
14785 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14786 var import_components21 = __toESM(require_components(), 1);
14787 var import_i18n25 = __toESM(require_i18n(), 1);
14788 var import_element46 = __toESM(require_element(), 1);
14789
14790 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14791 function noop4(..._) {
14792 }
14793 function applyState(argument, currentValue) {
14794 if (isUpdater(argument)) {
14795 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14796 return argument(value);
14797 }
14798 return argument;
14799 }
14800 function isUpdater(argument) {
14801 return typeof argument === "function";
14802 }
14803 function isLazyValue(value) {
14804 return typeof value === "function";
14805 }
14806 function hasOwnProperty(object, prop) {
14807 if (typeof Object.hasOwn === "function") {
14808 return Object.hasOwn(object, prop);
14809 }
14810 return Object.prototype.hasOwnProperty.call(object, prop);
14811 }
14812 function chain(...fns) {
14813 return (...args) => {
14814 for (const fn of fns) {
14815 if (typeof fn === "function") {
14816 fn(...args);
14817 }
14818 }
14819 };
14820 }
14821 function normalizeString(str) {
14822 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14823 }
14824 function omit2(object, keys) {
14825 const result = { ...object };
14826 for (const key of keys) {
14827 if (hasOwnProperty(result, key)) {
14828 delete result[key];
14829 }
14830 }
14831 return result;
14832 }
14833 function pick(object, paths) {
14834 const result = {};
14835 for (const key of paths) {
14836 if (hasOwnProperty(object, key)) {
14837 result[key] = object[key];
14838 }
14839 }
14840 return result;
14841 }
14842 function identity(value) {
14843 return value;
14844 }
14845 function invariant(condition, message2) {
14846 if (condition) return;
14847 if (typeof message2 !== "string") throw new Error("Invariant failed");
14848 throw new Error(message2);
14849 }
14850 function getKeys(obj) {
14851 return Object.keys(obj);
14852 }
14853 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14854 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14855 if (result == null) return false;
14856 return !result;
14857 }
14858 function disabledFromProps(props) {
14859 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14860 }
14861 function removeUndefinedValues(obj) {
14862 const result = {};
14863 for (const key in obj) {
14864 if (obj[key] !== void 0) {
14865 result[key] = obj[key];
14866 }
14867 }
14868 return result;
14869 }
14870 function defaultValue(...values) {
14871 for (const value of values) {
14872 if (value !== void 0) return value;
14873 }
14874 return void 0;
14875 }
14876
14877 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14878 var import_react7 = __toESM(require_react(), 1);
14879 function setRef(ref, value) {
14880 if (typeof ref === "function") {
14881 ref(value);
14882 } else if (ref) {
14883 ref.current = value;
14884 }
14885 }
14886 function isValidElementWithRef(element) {
14887 if (!element) return false;
14888 if (!(0, import_react7.isValidElement)(element)) return false;
14889 if ("ref" in element.props) return true;
14890 if ("ref" in element) return true;
14891 return false;
14892 }
14893 function getRefProperty(element) {
14894 if (!isValidElementWithRef(element)) return null;
14895 const props = { ...element.props };
14896 return props.ref || element.ref;
14897 }
14898 function mergeProps2(base, overrides) {
14899 const props = { ...base };
14900 for (const key in overrides) {
14901 if (!hasOwnProperty(overrides, key)) continue;
14902 if (key === "className") {
14903 const prop = "className";
14904 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14905 continue;
14906 }
14907 if (key === "style") {
14908 const prop = "style";
14909 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14910 continue;
14911 }
14912 const overrideValue = overrides[key];
14913 if (typeof overrideValue === "function" && key.startsWith("on")) {
14914 const baseValue = base[key];
14915 if (typeof baseValue === "function") {
14916 props[key] = (...args) => {
14917 overrideValue(...args);
14918 baseValue(...args);
14919 };
14920 continue;
14921 }
14922 }
14923 props[key] = overrideValue;
14924 }
14925 return props;
14926 }
14927
14928 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14929 var canUseDOM = checkIsBrowser();
14930 function checkIsBrowser() {
14931 var _a;
14932 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14933 }
14934 function getDocument(node) {
14935 if (!node) return document;
14936 if ("self" in node) return node.document;
14937 return node.ownerDocument || document;
14938 }
14939 function getActiveElement(node, activeDescendant = false) {
14940 var _a;
14941 const { activeElement: activeElement2 } = getDocument(node);
14942 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14943 return null;
14944 }
14945 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14946 return getActiveElement(
14947 activeElement2.contentDocument.body,
14948 activeDescendant
14949 );
14950 }
14951 if (activeDescendant) {
14952 const id = activeElement2.getAttribute("aria-activedescendant");
14953 if (id) {
14954 const element = getDocument(activeElement2).getElementById(id);
14955 if (element) {
14956 return element;
14957 }
14958 }
14959 }
14960 return activeElement2;
14961 }
14962 function contains2(parent, child) {
14963 return parent === child || parent.contains(child);
14964 }
14965 function isFrame(element) {
14966 return element.tagName === "IFRAME";
14967 }
14968 function isButton(element) {
14969 const tagName = element.tagName.toLowerCase();
14970 if (tagName === "button") return true;
14971 if (tagName === "input" && element.type) {
14972 return buttonInputTypes.indexOf(element.type) !== -1;
14973 }
14974 return false;
14975 }
14976 var buttonInputTypes = [
14977 "button",
14978 "color",
14979 "file",
14980 "image",
14981 "reset",
14982 "submit"
14983 ];
14984 function isVisible(element) {
14985 if (typeof element.checkVisibility === "function") {
14986 return element.checkVisibility();
14987 }
14988 const htmlElement = element;
14989 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
14990 }
14991 function isTextField(element) {
14992 try {
14993 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
14994 const isTextArea = element.tagName === "TEXTAREA";
14995 return isTextInput || isTextArea || false;
14996 } catch (_error) {
14997 return false;
14998 }
14999 }
15000 function isTextbox(element) {
15001 return element.isContentEditable || isTextField(element);
15002 }
15003 function getTextboxValue(element) {
15004 if (isTextField(element)) {
15005 return element.value;
15006 }
15007 if (element.isContentEditable) {
15008 const range = getDocument(element).createRange();
15009 range.selectNodeContents(element);
15010 return range.toString();
15011 }
15012 return "";
15013 }
15014 function getTextboxSelection(element) {
15015 let start = 0;
15016 let end = 0;
15017 if (isTextField(element)) {
15018 start = element.selectionStart || 0;
15019 end = element.selectionEnd || 0;
15020 } else if (element.isContentEditable) {
15021 const selection = getDocument(element).getSelection();
15022 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
15023 const range = selection.getRangeAt(0);
15024 const nextRange = range.cloneRange();
15025 nextRange.selectNodeContents(element);
15026 nextRange.setEnd(range.startContainer, range.startOffset);
15027 start = nextRange.toString().length;
15028 nextRange.setEnd(range.endContainer, range.endOffset);
15029 end = nextRange.toString().length;
15030 }
15031 }
15032 return { start, end };
15033 }
15034 function getPopupRole(element, fallback) {
15035 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
15036 const role = element == null ? void 0 : element.getAttribute("role");
15037 if (role && allowedPopupRoles.indexOf(role) !== -1) {
15038 return role;
15039 }
15040 return fallback;
15041 }
15042 function getScrollingElement(element) {
15043 if (!element) return null;
15044 const isScrollableOverflow = (overflow) => {
15045 if (overflow === "auto") return true;
15046 if (overflow === "scroll") return true;
15047 return false;
15048 };
15049 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
15050 const { overflowY } = getComputedStyle(element);
15051 if (isScrollableOverflow(overflowY)) return element;
15052 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
15053 const { overflowX } = getComputedStyle(element);
15054 if (isScrollableOverflow(overflowX)) return element;
15055 }
15056 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
15057 }
15058 function setSelectionRange(element, ...args) {
15059 if (/text|search|password|tel|url/i.test(element.type)) {
15060 element.setSelectionRange(...args);
15061 }
15062 }
15063 function sortBasedOnDOMPosition(items, getElement) {
15064 const pairs = items.map((item, index2) => [index2, item]);
15065 let isOrderDifferent = false;
15066 pairs.sort(([indexA, a2], [indexB, b2]) => {
15067 const elementA = getElement(a2);
15068 const elementB = getElement(b2);
15069 if (elementA === elementB) return 0;
15070 if (!elementA || !elementB) return 0;
15071 if (isElementPreceding(elementA, elementB)) {
15072 if (indexA > indexB) {
15073 isOrderDifferent = true;
15074 }
15075 return -1;
15076 }
15077 if (indexA < indexB) {
15078 isOrderDifferent = true;
15079 }
15080 return 1;
15081 });
15082 if (isOrderDifferent) {
15083 return pairs.map(([_, item]) => item);
15084 }
15085 return items;
15086 }
15087 function isElementPreceding(a2, b2) {
15088 return Boolean(
15089 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
15090 );
15091 }
15092
15093 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
15094 function isTouchDevice() {
15095 return canUseDOM && !!navigator.maxTouchPoints;
15096 }
15097 function isApple() {
15098 if (!canUseDOM) return false;
15099 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
15100 }
15101 function isSafari2() {
15102 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
15103 }
15104 function isFirefox2() {
15105 return canUseDOM && /firefox\//i.test(navigator.userAgent);
15106 }
15107
15108 // node_modules/@ariakit/core/esm/utils/events.js
15109 function isPortalEvent(event) {
15110 return Boolean(
15111 event.currentTarget && !contains2(event.currentTarget, event.target)
15112 );
15113 }
15114 function isSelfTarget(event) {
15115 return event.target === event.currentTarget;
15116 }
15117 function isOpeningInNewTab(event) {
15118 const element = event.currentTarget;
15119 if (!element) return false;
15120 const isAppleDevice = isApple();
15121 if (isAppleDevice && !event.metaKey) return false;
15122 if (!isAppleDevice && !event.ctrlKey) return false;
15123 const tagName = element.tagName.toLowerCase();
15124 if (tagName === "a") return true;
15125 if (tagName === "button" && element.type === "submit") return true;
15126 if (tagName === "input" && element.type === "submit") return true;
15127 return false;
15128 }
15129 function isDownloading(event) {
15130 const element = event.currentTarget;
15131 if (!element) return false;
15132 const tagName = element.tagName.toLowerCase();
15133 if (!event.altKey) return false;
15134 if (tagName === "a") return true;
15135 if (tagName === "button" && element.type === "submit") return true;
15136 if (tagName === "input" && element.type === "submit") return true;
15137 return false;
15138 }
15139 function fireBlurEvent(element, eventInit) {
15140 const event = new FocusEvent("blur", eventInit);
15141 const defaultAllowed = element.dispatchEvent(event);
15142 const bubbleInit = { ...eventInit, bubbles: true };
15143 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
15144 return defaultAllowed;
15145 }
15146 function fireKeyboardEvent(element, type, eventInit) {
15147 const event = new KeyboardEvent(type, eventInit);
15148 return element.dispatchEvent(event);
15149 }
15150 function fireClickEvent(element, eventInit) {
15151 const event = new MouseEvent("click", eventInit);
15152 return element.dispatchEvent(event);
15153 }
15154 function isFocusEventOutside(event, container) {
15155 const containerElement = container || event.currentTarget;
15156 const relatedTarget = event.relatedTarget;
15157 return !relatedTarget || !contains2(containerElement, relatedTarget);
15158 }
15159 function queueBeforeEvent(element, type, callback, timeout) {
15160 const createTimer = (callback2) => {
15161 if (timeout) {
15162 const timerId2 = setTimeout(callback2, timeout);
15163 return () => clearTimeout(timerId2);
15164 }
15165 const timerId = requestAnimationFrame(callback2);
15166 return () => cancelAnimationFrame(timerId);
15167 };
15168 const cancelTimer = createTimer(() => {
15169 element.removeEventListener(type, callSync, true);
15170 callback();
15171 });
15172 const callSync = () => {
15173 cancelTimer();
15174 callback();
15175 };
15176 element.addEventListener(type, callSync, { once: true, capture: true });
15177 return cancelTimer;
15178 }
15179 function addGlobalEventListener(type, listener, options, scope = window) {
15180 const children = [];
15181 try {
15182 scope.document.addEventListener(type, listener, options);
15183 for (const frame of Array.from(scope.frames)) {
15184 children.push(addGlobalEventListener(type, listener, options, frame));
15185 }
15186 } catch (e2) {
15187 }
15188 const removeEventListener = () => {
15189 try {
15190 scope.document.removeEventListener(type, listener, options);
15191 } catch (e2) {
15192 }
15193 for (const remove of children) {
15194 remove();
15195 }
15196 };
15197 return removeEventListener;
15198 }
15199
15200 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
15201 var React48 = __toESM(require_react(), 1);
15202 var import_react8 = __toESM(require_react(), 1);
15203 var _React = { ...React48 };
15204 var useReactId = _React.useId;
15205 var useReactDeferredValue = _React.useDeferredValue;
15206 var useReactInsertionEffect = _React.useInsertionEffect;
15207 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
15208 function useInitialValue(value) {
15209 const [initialValue] = (0, import_react8.useState)(value);
15210 return initialValue;
15211 }
15212 function useLiveRef(value) {
15213 const ref = (0, import_react8.useRef)(value);
15214 useSafeLayoutEffect(() => {
15215 ref.current = value;
15216 });
15217 return ref;
15218 }
15219 function useEvent(callback) {
15220 const ref = (0, import_react8.useRef)(() => {
15221 throw new Error("Cannot call an event handler while rendering.");
15222 });
15223 if (useReactInsertionEffect) {
15224 useReactInsertionEffect(() => {
15225 ref.current = callback;
15226 });
15227 } else {
15228 ref.current = callback;
15229 }
15230 return (0, import_react8.useCallback)((...args) => {
15231 var _a;
15232 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
15233 }, []);
15234 }
15235 function useTransactionState(callback) {
15236 const [state, setState] = (0, import_react8.useState)(null);
15237 useSafeLayoutEffect(() => {
15238 if (state == null) return;
15239 if (!callback) return;
15240 let prevState = null;
15241 callback((prev) => {
15242 prevState = prev;
15243 return state;
15244 });
15245 return () => {
15246 callback(prevState);
15247 };
15248 }, [state, callback]);
15249 return [state, setState];
15250 }
15251 function useMergeRefs(...refs) {
15252 return (0, import_react8.useMemo)(() => {
15253 if (!refs.some(Boolean)) return;
15254 return (value) => {
15255 for (const ref of refs) {
15256 setRef(ref, value);
15257 }
15258 };
15259 }, refs);
15260 }
15261 function useId4(defaultId) {
15262 if (useReactId) {
15263 const reactId = useReactId();
15264 if (defaultId) return defaultId;
15265 return reactId;
15266 }
15267 const [id, setId] = (0, import_react8.useState)(defaultId);
15268 useSafeLayoutEffect(() => {
15269 if (defaultId || id) return;
15270 const random = Math.random().toString(36).slice(2, 8);
15271 setId(`id-${random}`);
15272 }, [defaultId, id]);
15273 return defaultId || id;
15274 }
15275 function useTagName(refOrElement, type) {
15276 const stringOrUndefined = (type2) => {
15277 if (typeof type2 !== "string") return;
15278 return type2;
15279 };
15280 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
15281 useSafeLayoutEffect(() => {
15282 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15283 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
15284 }, [refOrElement, type]);
15285 return tagName;
15286 }
15287 function useAttribute(refOrElement, attributeName, defaultValue2) {
15288 const initialValue = useInitialValue(defaultValue2);
15289 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
15290 (0, import_react8.useEffect)(() => {
15291 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
15292 if (!element) return;
15293 const callback = () => {
15294 const value = element.getAttribute(attributeName);
15295 setAttribute(value == null ? initialValue : value);
15296 };
15297 const observer = new MutationObserver(callback);
15298 observer.observe(element, { attributeFilter: [attributeName] });
15299 callback();
15300 return () => observer.disconnect();
15301 }, [refOrElement, attributeName, initialValue]);
15302 return attribute;
15303 }
15304 function useUpdateEffect(effect, deps) {
15305 const mounted = (0, import_react8.useRef)(false);
15306 (0, import_react8.useEffect)(() => {
15307 if (mounted.current) {
15308 return effect();
15309 }
15310 mounted.current = true;
15311 }, deps);
15312 (0, import_react8.useEffect)(
15313 () => () => {
15314 mounted.current = false;
15315 },
15316 []
15317 );
15318 }
15319 function useUpdateLayoutEffect(effect, deps) {
15320 const mounted = (0, import_react8.useRef)(false);
15321 useSafeLayoutEffect(() => {
15322 if (mounted.current) {
15323 return effect();
15324 }
15325 mounted.current = true;
15326 }, deps);
15327 useSafeLayoutEffect(
15328 () => () => {
15329 mounted.current = false;
15330 },
15331 []
15332 );
15333 }
15334 function useForceUpdate() {
15335 return (0, import_react8.useReducer)(() => [], []);
15336 }
15337 function useBooleanEvent(booleanOrCallback) {
15338 return useEvent(
15339 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
15340 );
15341 }
15342 function useWrapElement(props, callback, deps = []) {
15343 const wrapElement = (0, import_react8.useCallback)(
15344 (element) => {
15345 if (props.wrapElement) {
15346 element = props.wrapElement(element);
15347 }
15348 return callback(element);
15349 },
15350 [...deps, props.wrapElement]
15351 );
15352 return { ...props, wrapElement };
15353 }
15354 function useMetadataProps(props, key, value) {
15355 const parent = props.onLoadedMetadataCapture;
15356 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
15357 return Object.assign(() => {
15358 }, { ...parent, [key]: value });
15359 }, [parent, key, value]);
15360 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
15361 }
15362 var hasInstalledGlobalEventListeners = false;
15363 function useIsMouseMoving() {
15364 (0, import_react8.useEffect)(() => {
15365 if (hasInstalledGlobalEventListeners) return;
15366 addGlobalEventListener("mousemove", setMouseMoving, true);
15367 addGlobalEventListener("mousedown", resetMouseMoving, true);
15368 addGlobalEventListener("mouseup", resetMouseMoving, true);
15369 addGlobalEventListener("keydown", resetMouseMoving, true);
15370 addGlobalEventListener("scroll", resetMouseMoving, true);
15371 hasInstalledGlobalEventListeners = true;
15372 }, []);
15373 const isMouseMoving = useEvent(() => mouseMoving);
15374 return isMouseMoving;
15375 }
15376 var mouseMoving = false;
15377 var previousScreenX = 0;
15378 var previousScreenY = 0;
15379 function hasMouseMovement(event) {
15380 const movementX = event.movementX || event.screenX - previousScreenX;
15381 const movementY = event.movementY || event.screenY - previousScreenY;
15382 previousScreenX = event.screenX;
15383 previousScreenY = event.screenY;
15384 return movementX || movementY || false;
15385 }
15386 function setMouseMoving(event) {
15387 if (!hasMouseMovement(event)) return;
15388 mouseMoving = true;
15389 }
15390 function resetMouseMoving() {
15391 mouseMoving = false;
15392 }
15393
15394 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
15395 var React49 = __toESM(require_react(), 1);
15396 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
15397 function forwardRef22(render4) {
15398 const Role = React49.forwardRef(
15399 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15400 (props, ref) => render4({ ...props, ref })
15401 );
15402 Role.displayName = render4.displayName || render4.name;
15403 return Role;
15404 }
15405 function memo22(Component, propsAreEqual) {
15406 return React49.memo(Component, propsAreEqual);
15407 }
15408 function createElement3(Type, props) {
15409 const { wrapElement, render: render4, ...rest } = props;
15410 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
15411 let element;
15412 if (React49.isValidElement(render4)) {
15413 const renderProps = {
15414 // @ts-ignore Incompatible with React 19 types. Ignore for now.
15415 ...render4.props,
15416 ref: mergedRef
15417 };
15418 element = React49.cloneElement(render4, mergeProps2(rest, renderProps));
15419 } else if (render4) {
15420 element = render4(rest);
15421 } else {
15422 element = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Type, { ...rest });
15423 }
15424 if (wrapElement) {
15425 return wrapElement(element);
15426 }
15427 return element;
15428 }
15429 function createHook(useProps) {
15430 const useRole = (props = {}) => {
15431 return useProps(props);
15432 };
15433 useRole.displayName = useProps.name;
15434 return useRole;
15435 }
15436 function createStoreContext(providers = [], scopedProviders = []) {
15437 const context = React49.createContext(void 0);
15438 const scopedContext = React49.createContext(void 0);
15439 const useContext210 = () => React49.useContext(context);
15440 const useScopedContext = (onlyScoped = false) => {
15441 const scoped = React49.useContext(scopedContext);
15442 const store = useContext210();
15443 if (onlyScoped) return scoped;
15444 return scoped || store;
15445 };
15446 const useProviderContext = () => {
15447 const scoped = React49.useContext(scopedContext);
15448 const store = useContext210();
15449 if (scoped && scoped === store) return;
15450 return store;
15451 };
15452 const ContextProvider = (props) => {
15453 return providers.reduceRight(
15454 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, { ...props, children }),
15455 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(context.Provider, { ...props })
15456 );
15457 };
15458 const ScopedContextProvider = (props) => {
15459 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15460 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Provider2, { ...props, children }),
15461 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(scopedContext.Provider, { ...props })
15462 ) });
15463 };
15464 return {
15465 context,
15466 scopedContext,
15467 useContext: useContext210,
15468 useScopedContext,
15469 useProviderContext,
15470 ContextProvider,
15471 ScopedContextProvider
15472 };
15473 }
15474
15475 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15476 var ctx = createStoreContext();
15477 var useCollectionContext = ctx.useContext;
15478 var useCollectionScopedContext = ctx.useScopedContext;
15479 var useCollectionProviderContext = ctx.useProviderContext;
15480 var CollectionContextProvider = ctx.ContextProvider;
15481 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15482
15483 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15484 var import_react9 = __toESM(require_react(), 1);
15485 var ctx2 = createStoreContext(
15486 [CollectionContextProvider],
15487 [CollectionScopedContextProvider]
15488 );
15489 var useCompositeContext = ctx2.useContext;
15490 var useCompositeScopedContext = ctx2.useScopedContext;
15491 var useCompositeProviderContext = ctx2.useProviderContext;
15492 var CompositeContextProvider = ctx2.ContextProvider;
15493 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15494 var CompositeItemContext = (0, import_react9.createContext)(
15495 void 0
15496 );
15497 var CompositeRowContext = (0, import_react9.createContext)(
15498 void 0
15499 );
15500
15501 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15502 function findFirstEnabledItem(items, excludeId) {
15503 return items.find((item) => {
15504 if (excludeId) {
15505 return !item.disabled && item.id !== excludeId;
15506 }
15507 return !item.disabled;
15508 });
15509 }
15510 function getEnabledItem(store, id) {
15511 if (!id) return null;
15512 return store.item(id) || null;
15513 }
15514 function groupItemsByRows(items) {
15515 const rows = [];
15516 for (const item of items) {
15517 const row = rows.find((currentRow) => {
15518 var _a;
15519 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15520 });
15521 if (row) {
15522 row.push(item);
15523 } else {
15524 rows.push([item]);
15525 }
15526 }
15527 return rows;
15528 }
15529 function selectTextField(element, collapseToEnd = false) {
15530 if (isTextField(element)) {
15531 element.setSelectionRange(
15532 collapseToEnd ? element.value.length : 0,
15533 element.value.length
15534 );
15535 } else if (element.isContentEditable) {
15536 const selection = getDocument(element).getSelection();
15537 selection == null ? void 0 : selection.selectAllChildren(element);
15538 if (collapseToEnd) {
15539 selection == null ? void 0 : selection.collapseToEnd();
15540 }
15541 }
15542 }
15543 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15544 function focusSilently(element) {
15545 element[FOCUS_SILENTLY] = true;
15546 element.focus({ preventScroll: true });
15547 }
15548 function silentlyFocused(element) {
15549 const isSilentlyFocused = element[FOCUS_SILENTLY];
15550 delete element[FOCUS_SILENTLY];
15551 return isSilentlyFocused;
15552 }
15553 function isItem(store, element, exclude) {
15554 if (!element) return false;
15555 if (element === exclude) return false;
15556 const item = store.item(element.id);
15557 if (!item) return false;
15558 if (exclude && item.element === exclude) return false;
15559 return true;
15560 }
15561
15562 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15563 var import_react10 = __toESM(require_react(), 1);
15564 var TagName = "div";
15565 var useCollectionItem = createHook(
15566 function useCollectionItem2({
15567 store,
15568 shouldRegisterItem = true,
15569 getItem = identity,
15570 // @ts-expect-error This prop may come from a collection renderer.
15571 element,
15572 ...props
15573 }) {
15574 const context = useCollectionContext();
15575 store = store || context;
15576 const id = useId4(props.id);
15577 const ref = (0, import_react10.useRef)(element);
15578 (0, import_react10.useEffect)(() => {
15579 const element2 = ref.current;
15580 if (!id) return;
15581 if (!element2) return;
15582 if (!shouldRegisterItem) return;
15583 const item = getItem({ id, element: element2 });
15584 return store == null ? void 0 : store.renderItem(item);
15585 }, [id, shouldRegisterItem, getItem, store]);
15586 props = {
15587 ...props,
15588 ref: useMergeRefs(ref, props.ref)
15589 };
15590 return removeUndefinedValues(props);
15591 }
15592 );
15593 var CollectionItem = forwardRef22(function CollectionItem2(props) {
15594 const htmlProps = useCollectionItem(props);
15595 return createElement3(TagName, htmlProps);
15596 });
15597
15598 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15599 var import_react11 = __toESM(require_react(), 1);
15600 var FocusableContext = (0, import_react11.createContext)(true);
15601
15602 // node_modules/@ariakit/core/esm/utils/focus.js
15603 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'])";
15604 function isFocusable(element) {
15605 if (!element.matches(selector)) return false;
15606 if (!isVisible(element)) return false;
15607 if (element.closest("[inert]")) return false;
15608 return true;
15609 }
15610 function getClosestFocusable(element) {
15611 while (element && !isFocusable(element)) {
15612 element = element.closest(selector);
15613 }
15614 return element || null;
15615 }
15616 function hasFocus(element) {
15617 const activeElement2 = getActiveElement(element);
15618 if (!activeElement2) return false;
15619 if (activeElement2 === element) return true;
15620 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15621 if (!activeDescendant) return false;
15622 return activeDescendant === element.id;
15623 }
15624 function hasFocusWithin(element) {
15625 const activeElement2 = getActiveElement(element);
15626 if (!activeElement2) return false;
15627 if (contains2(element, activeElement2)) return true;
15628 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15629 if (!activeDescendant) return false;
15630 if (!("id" in element)) return false;
15631 if (activeDescendant === element.id) return true;
15632 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15633 }
15634 function focusIfNeeded(element) {
15635 if (!hasFocusWithin(element) && isFocusable(element)) {
15636 element.focus();
15637 }
15638 }
15639 function focusIntoView(element, options) {
15640 if (!("scrollIntoView" in element)) {
15641 element.focus();
15642 } else {
15643 element.focus({ preventScroll: true });
15644 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15645 }
15646 }
15647
15648 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15649 var import_react12 = __toESM(require_react(), 1);
15650 var TagName2 = "div";
15651 var isSafariBrowser = isSafari2();
15652 var alwaysFocusVisibleInputTypes = [
15653 "text",
15654 "search",
15655 "url",
15656 "tel",
15657 "email",
15658 "password",
15659 "number",
15660 "date",
15661 "month",
15662 "week",
15663 "time",
15664 "datetime",
15665 "datetime-local"
15666 ];
15667 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15668 function markSafariFocusAncestor(element, value) {
15669 if (!element) return;
15670 element[safariFocusAncestorSymbol] = value;
15671 }
15672 function isAlwaysFocusVisible(element) {
15673 const { tagName, readOnly, type } = element;
15674 if (tagName === "TEXTAREA" && !readOnly) return true;
15675 if (tagName === "SELECT" && !readOnly) return true;
15676 if (tagName === "INPUT" && !readOnly) {
15677 return alwaysFocusVisibleInputTypes.includes(type);
15678 }
15679 if (element.isContentEditable) return true;
15680 const role = element.getAttribute("role");
15681 if (role === "combobox" && element.dataset.name) {
15682 return true;
15683 }
15684 return false;
15685 }
15686 function getLabels(element) {
15687 if ("labels" in element) {
15688 return element.labels;
15689 }
15690 return null;
15691 }
15692 function isNativeCheckboxOrRadio(element) {
15693 const tagName = element.tagName.toLowerCase();
15694 if (tagName === "input" && element.type) {
15695 return element.type === "radio" || element.type === "checkbox";
15696 }
15697 return false;
15698 }
15699 function isNativeTabbable(tagName) {
15700 if (!tagName) return true;
15701 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15702 }
15703 function supportsDisabledAttribute(tagName) {
15704 if (!tagName) return true;
15705 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15706 }
15707 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15708 if (!focusable2) {
15709 return tabIndexProp;
15710 }
15711 if (trulyDisabled) {
15712 if (nativeTabbable && !supportsDisabled) {
15713 return -1;
15714 }
15715 return;
15716 }
15717 if (nativeTabbable) {
15718 return tabIndexProp;
15719 }
15720 return tabIndexProp || 0;
15721 }
15722 function useDisableEvent(onEvent, disabled2) {
15723 return useEvent((event) => {
15724 onEvent == null ? void 0 : onEvent(event);
15725 if (event.defaultPrevented) return;
15726 if (disabled2) {
15727 event.stopPropagation();
15728 event.preventDefault();
15729 }
15730 });
15731 }
15732 var hasInstalledGlobalEventListeners2 = false;
15733 var isKeyboardModality = true;
15734 function onGlobalMouseDown(event) {
15735 const target = event.target;
15736 if (target && "hasAttribute" in target) {
15737 if (!target.hasAttribute("data-focus-visible")) {
15738 isKeyboardModality = false;
15739 }
15740 }
15741 }
15742 function onGlobalKeyDown(event) {
15743 if (event.metaKey) return;
15744 if (event.ctrlKey) return;
15745 if (event.altKey) return;
15746 isKeyboardModality = true;
15747 }
15748 var useFocusable = createHook(
15749 function useFocusable2({
15750 focusable: focusable2 = true,
15751 accessibleWhenDisabled,
15752 autoFocus,
15753 onFocusVisible,
15754 ...props
15755 }) {
15756 const ref = (0, import_react12.useRef)(null);
15757 (0, import_react12.useEffect)(() => {
15758 if (!focusable2) return;
15759 if (hasInstalledGlobalEventListeners2) return;
15760 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15761 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15762 hasInstalledGlobalEventListeners2 = true;
15763 }, [focusable2]);
15764 if (isSafariBrowser) {
15765 (0, import_react12.useEffect)(() => {
15766 if (!focusable2) return;
15767 const element = ref.current;
15768 if (!element) return;
15769 if (!isNativeCheckboxOrRadio(element)) return;
15770 const labels = getLabels(element);
15771 if (!labels) return;
15772 const onMouseUp = () => queueMicrotask(() => element.focus());
15773 for (const label of labels) {
15774 label.addEventListener("mouseup", onMouseUp);
15775 }
15776 return () => {
15777 for (const label of labels) {
15778 label.removeEventListener("mouseup", onMouseUp);
15779 }
15780 };
15781 }, [focusable2]);
15782 }
15783 const disabled2 = focusable2 && disabledFromProps(props);
15784 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15785 const [focusVisible, setFocusVisible] = (0, import_react12.useState)(false);
15786 (0, import_react12.useEffect)(() => {
15787 if (!focusable2) return;
15788 if (trulyDisabled && focusVisible) {
15789 setFocusVisible(false);
15790 }
15791 }, [focusable2, trulyDisabled, focusVisible]);
15792 (0, import_react12.useEffect)(() => {
15793 if (!focusable2) return;
15794 if (!focusVisible) return;
15795 const element = ref.current;
15796 if (!element) return;
15797 if (typeof IntersectionObserver === "undefined") return;
15798 const observer = new IntersectionObserver(() => {
15799 if (!isFocusable(element)) {
15800 setFocusVisible(false);
15801 }
15802 });
15803 observer.observe(element);
15804 return () => observer.disconnect();
15805 }, [focusable2, focusVisible]);
15806 const onKeyPressCapture = useDisableEvent(
15807 props.onKeyPressCapture,
15808 disabled2
15809 );
15810 const onMouseDownCapture = useDisableEvent(
15811 props.onMouseDownCapture,
15812 disabled2
15813 );
15814 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15815 const onMouseDownProp = props.onMouseDown;
15816 const onMouseDown = useEvent((event) => {
15817 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15818 if (event.defaultPrevented) return;
15819 if (!focusable2) return;
15820 const element = event.currentTarget;
15821 if (!isSafariBrowser) return;
15822 if (isPortalEvent(event)) return;
15823 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15824 let receivedFocus = false;
15825 const onFocus = () => {
15826 receivedFocus = true;
15827 };
15828 const options = { capture: true, once: true };
15829 element.addEventListener("focusin", onFocus, options);
15830 const focusableContainer = getClosestFocusable(element.parentElement);
15831 markSafariFocusAncestor(focusableContainer, true);
15832 queueBeforeEvent(element, "mouseup", () => {
15833 element.removeEventListener("focusin", onFocus, true);
15834 markSafariFocusAncestor(focusableContainer, false);
15835 if (receivedFocus) return;
15836 focusIfNeeded(element);
15837 });
15838 });
15839 const handleFocusVisible = (event, currentTarget) => {
15840 if (currentTarget) {
15841 event.currentTarget = currentTarget;
15842 }
15843 if (!focusable2) return;
15844 const element = event.currentTarget;
15845 if (!element) return;
15846 if (!hasFocus(element)) return;
15847 onFocusVisible == null ? void 0 : onFocusVisible(event);
15848 if (event.defaultPrevented) return;
15849 element.dataset.focusVisible = "true";
15850 setFocusVisible(true);
15851 };
15852 const onKeyDownCaptureProp = props.onKeyDownCapture;
15853 const onKeyDownCapture = useEvent((event) => {
15854 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15855 if (event.defaultPrevented) return;
15856 if (!focusable2) return;
15857 if (focusVisible) return;
15858 if (event.metaKey) return;
15859 if (event.altKey) return;
15860 if (event.ctrlKey) return;
15861 if (!isSelfTarget(event)) return;
15862 const element = event.currentTarget;
15863 const applyFocusVisible = () => handleFocusVisible(event, element);
15864 queueBeforeEvent(element, "focusout", applyFocusVisible);
15865 });
15866 const onFocusCaptureProp = props.onFocusCapture;
15867 const onFocusCapture = useEvent((event) => {
15868 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15869 if (event.defaultPrevented) return;
15870 if (!focusable2) return;
15871 if (!isSelfTarget(event)) {
15872 setFocusVisible(false);
15873 return;
15874 }
15875 const element = event.currentTarget;
15876 const applyFocusVisible = () => handleFocusVisible(event, element);
15877 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15878 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15879 } else {
15880 setFocusVisible(false);
15881 }
15882 });
15883 const onBlurProp = props.onBlur;
15884 const onBlur = useEvent((event) => {
15885 onBlurProp == null ? void 0 : onBlurProp(event);
15886 if (!focusable2) return;
15887 if (!isFocusEventOutside(event)) return;
15888 event.currentTarget.removeAttribute("data-focus-visible");
15889 setFocusVisible(false);
15890 });
15891 const autoFocusOnShow = (0, import_react12.useContext)(FocusableContext);
15892 const autoFocusRef = useEvent((element) => {
15893 if (!focusable2) return;
15894 if (!autoFocus) return;
15895 if (!element) return;
15896 if (!autoFocusOnShow) return;
15897 queueMicrotask(() => {
15898 if (hasFocus(element)) return;
15899 if (!isFocusable(element)) return;
15900 element.focus();
15901 });
15902 });
15903 const tagName = useTagName(ref);
15904 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15905 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15906 const styleProp = props.style;
15907 const style = (0, import_react12.useMemo)(() => {
15908 if (trulyDisabled) {
15909 return { pointerEvents: "none", ...styleProp };
15910 }
15911 return styleProp;
15912 }, [trulyDisabled, styleProp]);
15913 props = {
15914 "data-focus-visible": focusable2 && focusVisible || void 0,
15915 "data-autofocus": autoFocus || void 0,
15916 "aria-disabled": disabled2 || void 0,
15917 ...props,
15918 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15919 style,
15920 tabIndex: getTabIndex2(
15921 focusable2,
15922 trulyDisabled,
15923 nativeTabbable,
15924 supportsDisabled,
15925 props.tabIndex
15926 ),
15927 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15928 // TODO: Test Focusable contentEditable.
15929 contentEditable: disabled2 ? void 0 : props.contentEditable,
15930 onKeyPressCapture,
15931 onClickCapture,
15932 onMouseDownCapture,
15933 onMouseDown,
15934 onKeyDownCapture,
15935 onFocusCapture,
15936 onBlur
15937 };
15938 return removeUndefinedValues(props);
15939 }
15940 );
15941 var Focusable = forwardRef22(function Focusable2(props) {
15942 const htmlProps = useFocusable(props);
15943 return createElement3(TagName2, htmlProps);
15944 });
15945
15946 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15947 var import_react13 = __toESM(require_react(), 1);
15948 var TagName3 = "button";
15949 function isNativeClick(event) {
15950 if (!event.isTrusted) return false;
15951 const element = event.currentTarget;
15952 if (event.key === "Enter") {
15953 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15954 }
15955 if (event.key === " ") {
15956 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
15957 }
15958 return false;
15959 }
15960 var symbol = /* @__PURE__ */ Symbol("command");
15961 var useCommand = createHook(
15962 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
15963 const ref = (0, import_react13.useRef)(null);
15964 const [isNativeButton, setIsNativeButton] = (0, import_react13.useState)(false);
15965 (0, import_react13.useEffect)(() => {
15966 if (!ref.current) return;
15967 setIsNativeButton(isButton(ref.current));
15968 }, []);
15969 const [active, setActive] = (0, import_react13.useState)(false);
15970 const activeRef = (0, import_react13.useRef)(false);
15971 const disabled2 = disabledFromProps(props);
15972 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
15973 const onKeyDownProp = props.onKeyDown;
15974 const onKeyDown = useEvent((event) => {
15975 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
15976 const element = event.currentTarget;
15977 if (event.defaultPrevented) return;
15978 if (isDuplicate) return;
15979 if (disabled2) return;
15980 if (!isSelfTarget(event)) return;
15981 if (isTextField(element)) return;
15982 if (element.isContentEditable) return;
15983 const isEnter = clickOnEnter && event.key === "Enter";
15984 const isSpace = clickOnSpace && event.key === " ";
15985 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
15986 const shouldPreventSpace = event.key === " " && !clickOnSpace;
15987 if (shouldPreventEnter || shouldPreventSpace) {
15988 event.preventDefault();
15989 return;
15990 }
15991 if (isEnter || isSpace) {
15992 const nativeClick = isNativeClick(event);
15993 if (isEnter) {
15994 if (!nativeClick) {
15995 event.preventDefault();
15996 const { view, ...eventInit } = event;
15997 const click = () => fireClickEvent(element, eventInit);
15998 if (isFirefox2()) {
15999 queueBeforeEvent(element, "keyup", click);
16000 } else {
16001 queueMicrotask(click);
16002 }
16003 }
16004 } else if (isSpace) {
16005 activeRef.current = true;
16006 if (!nativeClick) {
16007 event.preventDefault();
16008 setActive(true);
16009 }
16010 }
16011 }
16012 });
16013 const onKeyUpProp = props.onKeyUp;
16014 const onKeyUp = useEvent((event) => {
16015 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
16016 if (event.defaultPrevented) return;
16017 if (isDuplicate) return;
16018 if (disabled2) return;
16019 if (event.metaKey) return;
16020 const isSpace = clickOnSpace && event.key === " ";
16021 if (activeRef.current && isSpace) {
16022 activeRef.current = false;
16023 if (!isNativeClick(event)) {
16024 event.preventDefault();
16025 setActive(false);
16026 const element = event.currentTarget;
16027 const { view, ...eventInit } = event;
16028 queueMicrotask(() => fireClickEvent(element, eventInit));
16029 }
16030 }
16031 });
16032 props = {
16033 "data-active": active || void 0,
16034 type: isNativeButton ? "button" : void 0,
16035 ...metadataProps,
16036 ...props,
16037 ref: useMergeRefs(ref, props.ref),
16038 onKeyDown,
16039 onKeyUp
16040 };
16041 props = useFocusable(props);
16042 return props;
16043 }
16044 );
16045 var Command = forwardRef22(function Command2(props) {
16046 const htmlProps = useCommand(props);
16047 return createElement3(TagName3, htmlProps);
16048 });
16049
16050 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
16051 function getInternal(store, key) {
16052 const internals = store.__unstableInternals;
16053 invariant(internals, "Invalid store");
16054 return internals[key];
16055 }
16056 function createStore(initialState, ...stores) {
16057 let state = initialState;
16058 let prevStateBatch = state;
16059 let lastUpdate = /* @__PURE__ */ Symbol();
16060 let destroy = noop4;
16061 const instances = /* @__PURE__ */ new Set();
16062 const updatedKeys = /* @__PURE__ */ new Set();
16063 const setups = /* @__PURE__ */ new Set();
16064 const listeners = /* @__PURE__ */ new Set();
16065 const batchListeners = /* @__PURE__ */ new Set();
16066 const disposables = /* @__PURE__ */ new WeakMap();
16067 const listenerKeys = /* @__PURE__ */ new WeakMap();
16068 const storeSetup = (callback) => {
16069 setups.add(callback);
16070 return () => setups.delete(callback);
16071 };
16072 const storeInit = () => {
16073 const initialized = instances.size;
16074 const instance = /* @__PURE__ */ Symbol();
16075 instances.add(instance);
16076 const maybeDestroy = () => {
16077 instances.delete(instance);
16078 if (instances.size) return;
16079 destroy();
16080 };
16081 if (initialized) return maybeDestroy;
16082 const desyncs = getKeys(state).map(
16083 (key) => chain(
16084 ...stores.map((store) => {
16085 var _a;
16086 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
16087 if (!storeState) return;
16088 if (!hasOwnProperty(storeState, key)) return;
16089 return sync(store, [key], (state2) => {
16090 setState(
16091 key,
16092 state2[key],
16093 // @ts-expect-error - Not public API. This is just to prevent
16094 // infinite loops.
16095 true
16096 );
16097 });
16098 })
16099 )
16100 );
16101 const teardowns = [];
16102 for (const setup2 of setups) {
16103 teardowns.push(setup2());
16104 }
16105 const cleanups = stores.map(init);
16106 destroy = chain(...desyncs, ...teardowns, ...cleanups);
16107 return maybeDestroy;
16108 };
16109 const sub = (keys, listener, set2 = listeners) => {
16110 set2.add(listener);
16111 listenerKeys.set(listener, keys);
16112 return () => {
16113 var _a;
16114 (_a = disposables.get(listener)) == null ? void 0 : _a();
16115 disposables.delete(listener);
16116 listenerKeys.delete(listener);
16117 set2.delete(listener);
16118 };
16119 };
16120 const storeSubscribe = (keys, listener) => sub(keys, listener);
16121 const storeSync = (keys, listener) => {
16122 disposables.set(listener, listener(state, state));
16123 return sub(keys, listener);
16124 };
16125 const storeBatch = (keys, listener) => {
16126 disposables.set(listener, listener(state, prevStateBatch));
16127 return sub(keys, listener, batchListeners);
16128 };
16129 const storePick = (keys) => createStore(pick(state, keys), finalStore);
16130 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
16131 const getState = () => state;
16132 const setState = (key, value, fromStores = false) => {
16133 var _a;
16134 if (!hasOwnProperty(state, key)) return;
16135 const nextValue = applyState(value, state[key]);
16136 if (nextValue === state[key]) return;
16137 if (!fromStores) {
16138 for (const store of stores) {
16139 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
16140 }
16141 }
16142 const prevState = state;
16143 state = { ...state, [key]: nextValue };
16144 const thisUpdate = /* @__PURE__ */ Symbol();
16145 lastUpdate = thisUpdate;
16146 updatedKeys.add(key);
16147 const run = (listener, prev, uKeys) => {
16148 var _a2;
16149 const keys = listenerKeys.get(listener);
16150 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
16151 if (!keys || keys.some(updated)) {
16152 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
16153 disposables.set(listener, listener(state, prev));
16154 }
16155 };
16156 for (const listener of listeners) {
16157 run(listener, prevState);
16158 }
16159 queueMicrotask(() => {
16160 if (lastUpdate !== thisUpdate) return;
16161 const snapshot = state;
16162 for (const listener of batchListeners) {
16163 run(listener, prevStateBatch, updatedKeys);
16164 }
16165 prevStateBatch = snapshot;
16166 updatedKeys.clear();
16167 });
16168 };
16169 const finalStore = {
16170 getState,
16171 setState,
16172 __unstableInternals: {
16173 setup: storeSetup,
16174 init: storeInit,
16175 subscribe: storeSubscribe,
16176 sync: storeSync,
16177 batch: storeBatch,
16178 pick: storePick,
16179 omit: storeOmit
16180 }
16181 };
16182 return finalStore;
16183 }
16184 function setup(store, ...args) {
16185 if (!store) return;
16186 return getInternal(store, "setup")(...args);
16187 }
16188 function init(store, ...args) {
16189 if (!store) return;
16190 return getInternal(store, "init")(...args);
16191 }
16192 function subscribe(store, ...args) {
16193 if (!store) return;
16194 return getInternal(store, "subscribe")(...args);
16195 }
16196 function sync(store, ...args) {
16197 if (!store) return;
16198 return getInternal(store, "sync")(...args);
16199 }
16200 function batch(store, ...args) {
16201 if (!store) return;
16202 return getInternal(store, "batch")(...args);
16203 }
16204 function omit22(store, ...args) {
16205 if (!store) return;
16206 return getInternal(store, "omit")(...args);
16207 }
16208 function pick2(store, ...args) {
16209 if (!store) return;
16210 return getInternal(store, "pick")(...args);
16211 }
16212 function mergeStore(...stores) {
16213 var _a;
16214 const initialState = {};
16215 for (const store2 of stores) {
16216 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
16217 if (nextState) {
16218 Object.assign(initialState, nextState);
16219 }
16220 }
16221 const store = createStore(initialState, ...stores);
16222 return Object.assign({}, ...stores, store);
16223 }
16224 function throwOnConflictingProps(props, store) {
16225 if (false) return;
16226 if (!store) return;
16227 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
16228 var _a;
16229 const stateKey = key.replace("default", "");
16230 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
16231 });
16232 if (!defaultKeys.length) return;
16233 const storeState = store.getState();
16234 const conflictingProps = defaultKeys.filter(
16235 (key) => hasOwnProperty(storeState, key)
16236 );
16237 if (!conflictingProps.length) return;
16238 throw new Error(
16239 `Passing a store prop in conjunction with a default state is not supported.
16240
16241 const store = useSelectStore();
16242 <SelectProvider store={store} defaultValue="Apple" />
16243 ^ ^
16244
16245 Instead, pass the default state to the topmost store:
16246
16247 const store = useSelectStore({ defaultValue: "Apple" });
16248 <SelectProvider store={store} />
16249
16250 See https://github.com/ariakit/ariakit/pull/2745 for more details.
16251
16252 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
16253 `
16254 );
16255 }
16256
16257 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
16258 var React50 = __toESM(require_react(), 1);
16259 var import_shim2 = __toESM(require_shim(), 1);
16260 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
16261 var noopSubscribe = () => () => {
16262 };
16263 function useStoreState(store, keyOrSelector = identity) {
16264 const storeSubscribe = React50.useCallback(
16265 (callback) => {
16266 if (!store) return noopSubscribe();
16267 return subscribe(store, null, callback);
16268 },
16269 [store]
16270 );
16271 const getSnapshot = () => {
16272 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
16273 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
16274 const state = store == null ? void 0 : store.getState();
16275 if (selector2) return selector2(state);
16276 if (!state) return;
16277 if (!key) return;
16278 if (!hasOwnProperty(state, key)) return;
16279 return state[key];
16280 };
16281 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16282 }
16283 function useStoreStateObject(store, object) {
16284 const objRef = React50.useRef(
16285 {}
16286 );
16287 const storeSubscribe = React50.useCallback(
16288 (callback) => {
16289 if (!store) return noopSubscribe();
16290 return subscribe(store, null, callback);
16291 },
16292 [store]
16293 );
16294 const getSnapshot = () => {
16295 const state = store == null ? void 0 : store.getState();
16296 let updated = false;
16297 const obj = objRef.current;
16298 for (const prop in object) {
16299 const keyOrSelector = object[prop];
16300 if (typeof keyOrSelector === "function") {
16301 const value = keyOrSelector(state);
16302 if (value !== obj[prop]) {
16303 obj[prop] = value;
16304 updated = true;
16305 }
16306 }
16307 if (typeof keyOrSelector === "string") {
16308 if (!state) continue;
16309 if (!hasOwnProperty(state, keyOrSelector)) continue;
16310 const value = state[keyOrSelector];
16311 if (value !== obj[prop]) {
16312 obj[prop] = value;
16313 updated = true;
16314 }
16315 }
16316 }
16317 if (updated) {
16318 objRef.current = { ...obj };
16319 }
16320 return objRef.current;
16321 };
16322 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
16323 }
16324 function useStoreProps(store, props, key, setKey) {
16325 const value = hasOwnProperty(props, key) ? props[key] : void 0;
16326 const setValue = setKey ? props[setKey] : void 0;
16327 const propsRef = useLiveRef({ value, setValue });
16328 useSafeLayoutEffect(() => {
16329 return sync(store, [key], (state, prev) => {
16330 const { value: value2, setValue: setValue2 } = propsRef.current;
16331 if (!setValue2) return;
16332 if (state[key] === prev[key]) return;
16333 if (state[key] === value2) return;
16334 setValue2(state[key]);
16335 });
16336 }, [store, key]);
16337 useSafeLayoutEffect(() => {
16338 if (value === void 0) return;
16339 store.setState(key, value);
16340 return batch(store, [key], () => {
16341 if (value === void 0) return;
16342 store.setState(key, value);
16343 });
16344 });
16345 }
16346 function useStore2(createStore2, props) {
16347 const [store, setStore] = React50.useState(() => createStore2(props));
16348 useSafeLayoutEffect(() => init(store), [store]);
16349 const useState210 = React50.useCallback(
16350 (keyOrSelector) => useStoreState(store, keyOrSelector),
16351 [store]
16352 );
16353 const memoizedStore = React50.useMemo(
16354 () => ({ ...store, useState: useState210 }),
16355 [store, useState210]
16356 );
16357 const updateStore = useEvent(() => {
16358 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
16359 });
16360 return [memoizedStore, updateStore];
16361 }
16362
16363 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
16364 var import_react14 = __toESM(require_react(), 1);
16365 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
16366 var TagName4 = "button";
16367 function isEditableElement(element) {
16368 if (isTextbox(element)) return true;
16369 return element.tagName === "INPUT" && !isButton(element);
16370 }
16371 function getNextPageOffset(scrollingElement, pageUp = false) {
16372 const height = scrollingElement.clientHeight;
16373 const { top } = scrollingElement.getBoundingClientRect();
16374 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
16375 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
16376 if (scrollingElement.tagName === "HTML") {
16377 return pageOffset + scrollingElement.scrollTop;
16378 }
16379 return pageOffset;
16380 }
16381 function getItemOffset(itemElement, pageUp = false) {
16382 const { top } = itemElement.getBoundingClientRect();
16383 if (pageUp) {
16384 return top + itemElement.clientHeight;
16385 }
16386 return top;
16387 }
16388 function findNextPageItemId(element, store, next, pageUp = false) {
16389 var _a;
16390 if (!store) return;
16391 if (!next) return;
16392 const { renderedItems } = store.getState();
16393 const scrollingElement = getScrollingElement(element);
16394 if (!scrollingElement) return;
16395 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
16396 let id;
16397 let prevDifference;
16398 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
16399 const previousId = id;
16400 id = next(i2);
16401 if (!id) break;
16402 if (id === previousId) continue;
16403 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
16404 if (!itemElement) continue;
16405 const itemOffset = getItemOffset(itemElement, pageUp);
16406 const difference = itemOffset - nextPageOffset;
16407 const absDifference = Math.abs(difference);
16408 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
16409 if (prevDifference !== void 0 && prevDifference < absDifference) {
16410 id = previousId;
16411 }
16412 break;
16413 }
16414 prevDifference = absDifference;
16415 }
16416 return id;
16417 }
16418 function targetIsAnotherItem(event, store) {
16419 if (isSelfTarget(event)) return false;
16420 return isItem(store, event.target);
16421 }
16422 var useCompositeItem = createHook(
16423 function useCompositeItem2({
16424 store,
16425 rowId: rowIdProp,
16426 preventScrollOnKeyDown = false,
16427 moveOnKeyPress = true,
16428 tabbable: tabbable2 = false,
16429 getItem: getItemProp,
16430 "aria-setsize": ariaSetSizeProp,
16431 "aria-posinset": ariaPosInSetProp,
16432 ...props
16433 }) {
16434 const context = useCompositeContext();
16435 store = store || context;
16436 const id = useId4(props.id);
16437 const ref = (0, import_react14.useRef)(null);
16438 const row = (0, import_react14.useContext)(CompositeRowContext);
16439 const disabled2 = disabledFromProps(props);
16440 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16441 const {
16442 rowId,
16443 baseElement,
16444 isActiveItem,
16445 ariaSetSize,
16446 ariaPosInSet,
16447 isTabbable
16448 } = useStoreStateObject(store, {
16449 rowId(state) {
16450 if (rowIdProp) return rowIdProp;
16451 if (!state) return;
16452 if (!(row == null ? void 0 : row.baseElement)) return;
16453 if (row.baseElement !== state.baseElement) return;
16454 return row.id;
16455 },
16456 baseElement(state) {
16457 return (state == null ? void 0 : state.baseElement) || void 0;
16458 },
16459 isActiveItem(state) {
16460 return !!state && state.activeId === id;
16461 },
16462 ariaSetSize(state) {
16463 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16464 if (!state) return;
16465 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16466 if (row.baseElement !== state.baseElement) return;
16467 return row.ariaSetSize;
16468 },
16469 ariaPosInSet(state) {
16470 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16471 if (!state) return;
16472 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16473 if (row.baseElement !== state.baseElement) return;
16474 const itemsInRow = state.renderedItems.filter(
16475 (item) => item.rowId === rowId
16476 );
16477 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16478 },
16479 isTabbable(state) {
16480 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16481 if (state.virtualFocus) return false;
16482 if (tabbable2) return true;
16483 if (state.activeId === null) return false;
16484 const item = store == null ? void 0 : store.item(state.activeId);
16485 if (item == null ? void 0 : item.disabled) return true;
16486 if (!(item == null ? void 0 : item.element)) return true;
16487 return state.activeId === id;
16488 }
16489 });
16490 const getItem = (0, import_react14.useCallback)(
16491 (item) => {
16492 var _a;
16493 const nextItem = {
16494 ...item,
16495 id: id || item.id,
16496 rowId,
16497 disabled: !!trulyDisabled,
16498 children: (_a = item.element) == null ? void 0 : _a.textContent
16499 };
16500 if (getItemProp) {
16501 return getItemProp(nextItem);
16502 }
16503 return nextItem;
16504 },
16505 [id, rowId, trulyDisabled, getItemProp]
16506 );
16507 const onFocusProp = props.onFocus;
16508 const hasFocusedComposite = (0, import_react14.useRef)(false);
16509 const onFocus = useEvent((event) => {
16510 onFocusProp == null ? void 0 : onFocusProp(event);
16511 if (event.defaultPrevented) return;
16512 if (isPortalEvent(event)) return;
16513 if (!id) return;
16514 if (!store) return;
16515 if (targetIsAnotherItem(event, store)) return;
16516 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16517 store.setActiveId(id);
16518 if (isTextbox(event.currentTarget)) {
16519 selectTextField(event.currentTarget);
16520 }
16521 if (!virtualFocus) return;
16522 if (!isSelfTarget(event)) return;
16523 if (isEditableElement(event.currentTarget)) return;
16524 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16525 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16526 event.currentTarget.scrollIntoView({
16527 block: "nearest",
16528 inline: "nearest"
16529 });
16530 }
16531 hasFocusedComposite.current = true;
16532 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16533 if (fromComposite) {
16534 focusSilently(baseElement2);
16535 } else {
16536 baseElement2.focus();
16537 }
16538 });
16539 const onBlurCaptureProp = props.onBlurCapture;
16540 const onBlurCapture = useEvent((event) => {
16541 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16542 if (event.defaultPrevented) return;
16543 const state = store == null ? void 0 : store.getState();
16544 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16545 hasFocusedComposite.current = false;
16546 event.preventDefault();
16547 event.stopPropagation();
16548 }
16549 });
16550 const onKeyDownProp = props.onKeyDown;
16551 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16552 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16553 const onKeyDown = useEvent((event) => {
16554 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16555 if (event.defaultPrevented) return;
16556 if (!isSelfTarget(event)) return;
16557 if (!store) return;
16558 const { currentTarget } = event;
16559 const state = store.getState();
16560 const item = store.item(id);
16561 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16562 const isVertical = state.orientation !== "horizontal";
16563 const isHorizontal = state.orientation !== "vertical";
16564 const canHomeEnd = () => {
16565 if (isGrid2) return true;
16566 if (isHorizontal) return true;
16567 if (!state.baseElement) return true;
16568 if (!isTextField(state.baseElement)) return true;
16569 return false;
16570 };
16571 const keyMap = {
16572 ArrowUp: (isGrid2 || isVertical) && store.up,
16573 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16574 ArrowDown: (isGrid2 || isVertical) && store.down,
16575 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16576 Home: () => {
16577 if (!canHomeEnd()) return;
16578 if (!isGrid2 || event.ctrlKey) {
16579 return store == null ? void 0 : store.first();
16580 }
16581 return store == null ? void 0 : store.previous(-1);
16582 },
16583 End: () => {
16584 if (!canHomeEnd()) return;
16585 if (!isGrid2 || event.ctrlKey) {
16586 return store == null ? void 0 : store.last();
16587 }
16588 return store == null ? void 0 : store.next(-1);
16589 },
16590 PageUp: () => {
16591 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16592 },
16593 PageDown: () => {
16594 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16595 }
16596 };
16597 const action = keyMap[event.key];
16598 if (action) {
16599 if (isTextbox(currentTarget)) {
16600 const selection = getTextboxSelection(currentTarget);
16601 const isLeft = isHorizontal && event.key === "ArrowLeft";
16602 const isRight = isHorizontal && event.key === "ArrowRight";
16603 const isUp = isVertical && event.key === "ArrowUp";
16604 const isDown = isVertical && event.key === "ArrowDown";
16605 if (isRight || isDown) {
16606 const { length: valueLength } = getTextboxValue(currentTarget);
16607 if (selection.end !== valueLength) return;
16608 } else if ((isLeft || isUp) && selection.start !== 0) return;
16609 }
16610 const nextId = action();
16611 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16612 if (!moveOnKeyPressProp(event)) return;
16613 event.preventDefault();
16614 store.move(nextId);
16615 }
16616 }
16617 });
16618 const providerValue = (0, import_react14.useMemo)(
16619 () => ({ id, baseElement }),
16620 [id, baseElement]
16621 );
16622 props = useWrapElement(
16623 props,
16624 (element) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16625 [providerValue]
16626 );
16627 props = {
16628 id,
16629 "data-active-item": isActiveItem || void 0,
16630 ...props,
16631 ref: useMergeRefs(ref, props.ref),
16632 tabIndex: isTabbable ? props.tabIndex : -1,
16633 onFocus,
16634 onBlurCapture,
16635 onKeyDown
16636 };
16637 props = useCommand(props);
16638 props = useCollectionItem({
16639 store,
16640 ...props,
16641 getItem,
16642 shouldRegisterItem: id ? props.shouldRegisterItem : false
16643 });
16644 return removeUndefinedValues({
16645 ...props,
16646 "aria-setsize": ariaSetSize,
16647 "aria-posinset": ariaPosInSet
16648 });
16649 }
16650 );
16651 var CompositeItem = memo22(
16652 forwardRef22(function CompositeItem2(props) {
16653 const htmlProps = useCompositeItem(props);
16654 return createElement3(TagName4, htmlProps);
16655 })
16656 );
16657
16658 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16659 function toArray(arg) {
16660 if (Array.isArray(arg)) {
16661 return arg;
16662 }
16663 return typeof arg !== "undefined" ? [arg] : [];
16664 }
16665 function flatten2DArray(array) {
16666 const flattened = [];
16667 for (const row of array) {
16668 flattened.push(...row);
16669 }
16670 return flattened;
16671 }
16672 function reverseArray(array) {
16673 return array.slice().reverse();
16674 }
16675
16676 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16677 var import_react15 = __toESM(require_react(), 1);
16678 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
16679 var TagName5 = "div";
16680 function isGrid(items) {
16681 return items.some((item) => !!item.rowId);
16682 }
16683 function isPrintableKey(event) {
16684 const target = event.target;
16685 if (target && !isTextField(target)) return false;
16686 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16687 }
16688 function isModifierKey(event) {
16689 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16690 }
16691 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16692 return useEvent((event) => {
16693 var _a;
16694 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16695 if (event.defaultPrevented) return;
16696 if (event.isPropagationStopped()) return;
16697 if (!isSelfTarget(event)) return;
16698 if (isModifierKey(event)) return;
16699 if (isPrintableKey(event)) return;
16700 const state = store.getState();
16701 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16702 if (!activeElement2) return;
16703 const { view, ...eventInit } = event;
16704 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16705 if (activeElement2 !== previousElement) {
16706 activeElement2.focus();
16707 }
16708 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16709 event.preventDefault();
16710 }
16711 if (event.currentTarget.contains(activeElement2)) {
16712 event.stopPropagation();
16713 }
16714 });
16715 }
16716 function findFirstEnabledItemInTheLastRow(items) {
16717 return findFirstEnabledItem(
16718 flatten2DArray(reverseArray(groupItemsByRows(items)))
16719 );
16720 }
16721 function useScheduleFocus(store) {
16722 const [scheduled, setScheduled] = (0, import_react15.useState)(false);
16723 const schedule = (0, import_react15.useCallback)(() => setScheduled(true), []);
16724 const activeItem = store.useState(
16725 (state) => getEnabledItem(store, state.activeId)
16726 );
16727 (0, import_react15.useEffect)(() => {
16728 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16729 if (!scheduled) return;
16730 if (!activeElement2) return;
16731 setScheduled(false);
16732 activeElement2.focus({ preventScroll: true });
16733 }, [activeItem, scheduled]);
16734 return schedule;
16735 }
16736 var useComposite = createHook(
16737 function useComposite2({
16738 store,
16739 composite = true,
16740 focusOnMove = composite,
16741 moveOnKeyPress = true,
16742 ...props
16743 }) {
16744 const context = useCompositeProviderContext();
16745 store = store || context;
16746 invariant(
16747 store,
16748 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16749 );
16750 const ref = (0, import_react15.useRef)(null);
16751 const previousElementRef = (0, import_react15.useRef)(null);
16752 const scheduleFocus = useScheduleFocus(store);
16753 const moves = store.useState("moves");
16754 const [, setBaseElement] = useTransactionState(
16755 composite ? store.setBaseElement : null
16756 );
16757 (0, import_react15.useEffect)(() => {
16758 var _a;
16759 if (!store) return;
16760 if (!moves) return;
16761 if (!composite) return;
16762 if (!focusOnMove) return;
16763 const { activeId: activeId2 } = store.getState();
16764 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16765 if (!itemElement) return;
16766 focusIntoView(itemElement);
16767 }, [store, moves, composite, focusOnMove]);
16768 useSafeLayoutEffect(() => {
16769 if (!store) return;
16770 if (!moves) return;
16771 if (!composite) return;
16772 const { baseElement, activeId: activeId2 } = store.getState();
16773 const isSelfAcive = activeId2 === null;
16774 if (!isSelfAcive) return;
16775 if (!baseElement) return;
16776 const previousElement = previousElementRef.current;
16777 previousElementRef.current = null;
16778 if (previousElement) {
16779 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16780 }
16781 if (!hasFocus(baseElement)) {
16782 baseElement.focus();
16783 }
16784 }, [store, moves, composite]);
16785 const activeId = store.useState("activeId");
16786 const virtualFocus = store.useState("virtualFocus");
16787 useSafeLayoutEffect(() => {
16788 var _a;
16789 if (!store) return;
16790 if (!composite) return;
16791 if (!virtualFocus) return;
16792 const previousElement = previousElementRef.current;
16793 previousElementRef.current = null;
16794 if (!previousElement) return;
16795 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16796 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16797 if (relatedTarget === previousElement) return;
16798 fireBlurEvent(previousElement, { relatedTarget });
16799 }, [store, activeId, virtualFocus, composite]);
16800 const onKeyDownCapture = useKeyboardEventProxy(
16801 store,
16802 props.onKeyDownCapture,
16803 previousElementRef
16804 );
16805 const onKeyUpCapture = useKeyboardEventProxy(
16806 store,
16807 props.onKeyUpCapture,
16808 previousElementRef
16809 );
16810 const onFocusCaptureProp = props.onFocusCapture;
16811 const onFocusCapture = useEvent((event) => {
16812 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16813 if (event.defaultPrevented) return;
16814 if (!store) return;
16815 const { virtualFocus: virtualFocus2 } = store.getState();
16816 if (!virtualFocus2) return;
16817 const previousActiveElement = event.relatedTarget;
16818 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16819 if (isSelfTarget(event) && isSilentlyFocused) {
16820 event.stopPropagation();
16821 previousElementRef.current = previousActiveElement;
16822 }
16823 });
16824 const onFocusProp = props.onFocus;
16825 const onFocus = useEvent((event) => {
16826 onFocusProp == null ? void 0 : onFocusProp(event);
16827 if (event.defaultPrevented) return;
16828 if (!composite) return;
16829 if (!store) return;
16830 const { relatedTarget } = event;
16831 const { virtualFocus: virtualFocus2 } = store.getState();
16832 if (virtualFocus2) {
16833 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16834 queueMicrotask(scheduleFocus);
16835 }
16836 } else if (isSelfTarget(event)) {
16837 store.setActiveId(null);
16838 }
16839 });
16840 const onBlurCaptureProp = props.onBlurCapture;
16841 const onBlurCapture = useEvent((event) => {
16842 var _a;
16843 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16844 if (event.defaultPrevented) return;
16845 if (!store) return;
16846 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16847 if (!virtualFocus2) return;
16848 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16849 const nextActiveElement = event.relatedTarget;
16850 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16851 const previousElement = previousElementRef.current;
16852 previousElementRef.current = null;
16853 if (isSelfTarget(event) && nextActiveElementIsItem) {
16854 if (nextActiveElement === activeElement2) {
16855 if (previousElement && previousElement !== nextActiveElement) {
16856 fireBlurEvent(previousElement, event);
16857 }
16858 } else if (activeElement2) {
16859 fireBlurEvent(activeElement2, event);
16860 } else if (previousElement) {
16861 fireBlurEvent(previousElement, event);
16862 }
16863 event.stopPropagation();
16864 } else {
16865 const targetIsItem = isItem(store, event.target);
16866 if (!targetIsItem && activeElement2) {
16867 fireBlurEvent(activeElement2, event);
16868 }
16869 }
16870 });
16871 const onKeyDownProp = props.onKeyDown;
16872 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16873 const onKeyDown = useEvent((event) => {
16874 var _a;
16875 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16876 if (event.nativeEvent.isComposing) return;
16877 if (event.defaultPrevented) return;
16878 if (!store) return;
16879 if (!isSelfTarget(event)) return;
16880 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16881 const activeItem = getEnabledItem(store, activeId2);
16882 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16883 const isVertical = orientation !== "horizontal";
16884 const isHorizontal = orientation !== "vertical";
16885 const grid = isGrid(renderedItems);
16886 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16887 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16888 const up = () => {
16889 if (grid) {
16890 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16891 return item == null ? void 0 : item.id;
16892 }
16893 return store == null ? void 0 : store.last();
16894 };
16895 const keyMap = {
16896 ArrowUp: (grid || isVertical) && up,
16897 ArrowRight: (grid || isHorizontal) && store.first,
16898 ArrowDown: (grid || isVertical) && store.first,
16899 ArrowLeft: (grid || isHorizontal) && store.last,
16900 Home: store.first,
16901 End: store.last,
16902 PageUp: store.first,
16903 PageDown: store.last
16904 };
16905 const action = keyMap[event.key];
16906 if (action) {
16907 const id = action();
16908 if (id !== void 0) {
16909 if (!moveOnKeyPressProp(event)) return;
16910 event.preventDefault();
16911 store.move(id);
16912 }
16913 }
16914 });
16915 props = useWrapElement(
16916 props,
16917 (element) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(CompositeContextProvider, { value: store, children: element }),
16918 [store]
16919 );
16920 const activeDescendant = store.useState((state) => {
16921 var _a;
16922 if (!store) return;
16923 if (!composite) return;
16924 if (!state.virtualFocus) return;
16925 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16926 });
16927 props = {
16928 "aria-activedescendant": activeDescendant,
16929 ...props,
16930 ref: useMergeRefs(ref, setBaseElement, props.ref),
16931 onKeyDownCapture,
16932 onKeyUpCapture,
16933 onFocusCapture,
16934 onFocus,
16935 onBlurCapture,
16936 onKeyDown
16937 };
16938 const focusable2 = store.useState(
16939 (state) => composite && (state.virtualFocus || state.activeId === null)
16940 );
16941 props = useFocusable({ focusable: focusable2, ...props });
16942 return props;
16943 }
16944 );
16945 var Composite6 = forwardRef22(function Composite22(props) {
16946 const htmlProps = useComposite(props);
16947 return createElement3(TagName5, htmlProps);
16948 });
16949
16950 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
16951 var ctx3 = createStoreContext();
16952 var useDisclosureContext = ctx3.useContext;
16953 var useDisclosureScopedContext = ctx3.useScopedContext;
16954 var useDisclosureProviderContext = ctx3.useProviderContext;
16955 var DisclosureContextProvider = ctx3.ContextProvider;
16956 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
16957
16958 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
16959 var import_react16 = __toESM(require_react(), 1);
16960 var ctx4 = createStoreContext(
16961 [DisclosureContextProvider],
16962 [DisclosureScopedContextProvider]
16963 );
16964 var useDialogContext = ctx4.useContext;
16965 var useDialogScopedContext = ctx4.useScopedContext;
16966 var useDialogProviderContext = ctx4.useProviderContext;
16967 var DialogContextProvider = ctx4.ContextProvider;
16968 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
16969 var DialogHeadingContext = (0, import_react16.createContext)(void 0);
16970 var DialogDescriptionContext = (0, import_react16.createContext)(void 0);
16971
16972 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
16973 var import_react17 = __toESM(require_react(), 1);
16974 var import_react_dom4 = __toESM(require_react_dom(), 1);
16975 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
16976 var TagName6 = "div";
16977 function afterTimeout(timeoutMs, cb) {
16978 const timeoutId = setTimeout(cb, timeoutMs);
16979 return () => clearTimeout(timeoutId);
16980 }
16981 function afterPaint2(cb) {
16982 let raf = requestAnimationFrame(() => {
16983 raf = requestAnimationFrame(cb);
16984 });
16985 return () => cancelAnimationFrame(raf);
16986 }
16987 function parseCSSTime(...times) {
16988 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
16989 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
16990 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
16991 if (currentTime > longestTime) return currentTime;
16992 return longestTime;
16993 }, 0);
16994 }
16995 function isHidden(mounted, hidden, alwaysVisible) {
16996 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
16997 }
16998 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
16999 const context = useDisclosureProviderContext();
17000 store = store || context;
17001 invariant(
17002 store,
17003 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
17004 );
17005 const ref = (0, import_react17.useRef)(null);
17006 const id = useId4(props.id);
17007 const [transition, setTransition] = (0, import_react17.useState)(null);
17008 const open = store.useState("open");
17009 const mounted = store.useState("mounted");
17010 const animated = store.useState("animated");
17011 const contentElement = store.useState("contentElement");
17012 const otherElement = useStoreState(store.disclosure, "contentElement");
17013 useSafeLayoutEffect(() => {
17014 if (!ref.current) return;
17015 store == null ? void 0 : store.setContentElement(ref.current);
17016 }, [store]);
17017 useSafeLayoutEffect(() => {
17018 let previousAnimated;
17019 store == null ? void 0 : store.setState("animated", (animated2) => {
17020 previousAnimated = animated2;
17021 return true;
17022 });
17023 return () => {
17024 if (previousAnimated === void 0) return;
17025 store == null ? void 0 : store.setState("animated", previousAnimated);
17026 };
17027 }, [store]);
17028 useSafeLayoutEffect(() => {
17029 if (!animated) return;
17030 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
17031 setTransition(null);
17032 return;
17033 }
17034 return afterPaint2(() => {
17035 setTransition(open ? "enter" : mounted ? "leave" : null);
17036 });
17037 }, [animated, contentElement, open, mounted]);
17038 useSafeLayoutEffect(() => {
17039 if (!store) return;
17040 if (!animated) return;
17041 if (!transition) return;
17042 if (!contentElement) return;
17043 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
17044 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
17045 if (transition === "leave" && open) return;
17046 if (transition === "enter" && !open) return;
17047 if (typeof animated === "number") {
17048 const timeout2 = animated;
17049 return afterTimeout(timeout2, stopAnimationSync);
17050 }
17051 const {
17052 transitionDuration,
17053 animationDuration,
17054 transitionDelay,
17055 animationDelay
17056 } = getComputedStyle(contentElement);
17057 const {
17058 transitionDuration: transitionDuration2 = "0",
17059 animationDuration: animationDuration2 = "0",
17060 transitionDelay: transitionDelay2 = "0",
17061 animationDelay: animationDelay2 = "0"
17062 } = otherElement ? getComputedStyle(otherElement) : {};
17063 const delay = parseCSSTime(
17064 transitionDelay,
17065 animationDelay,
17066 transitionDelay2,
17067 animationDelay2
17068 );
17069 const duration = parseCSSTime(
17070 transitionDuration,
17071 animationDuration,
17072 transitionDuration2,
17073 animationDuration2
17074 );
17075 const timeout = delay + duration;
17076 if (!timeout) {
17077 if (transition === "enter") {
17078 store.setState("animated", false);
17079 }
17080 stopAnimation();
17081 return;
17082 }
17083 const frameRate = 1e3 / 60;
17084 const maxTimeout = Math.max(timeout - frameRate, 0);
17085 return afterTimeout(maxTimeout, stopAnimationSync);
17086 }, [store, animated, contentElement, otherElement, open, transition]);
17087 props = useWrapElement(
17088 props,
17089 (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DialogScopedContextProvider, { value: store, children: element }),
17090 [store]
17091 );
17092 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
17093 const styleProp = props.style;
17094 const style = (0, import_react17.useMemo)(() => {
17095 if (hidden) {
17096 return { ...styleProp, display: "none" };
17097 }
17098 return styleProp;
17099 }, [hidden, styleProp]);
17100 props = {
17101 id,
17102 "data-open": open || void 0,
17103 "data-enter": transition === "enter" || void 0,
17104 "data-leave": transition === "leave" || void 0,
17105 hidden,
17106 ...props,
17107 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
17108 style
17109 };
17110 return removeUndefinedValues(props);
17111 });
17112 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
17113 const htmlProps = useDisclosureContent(props);
17114 return createElement3(TagName6, htmlProps);
17115 });
17116 var DisclosureContent = forwardRef22(function DisclosureContent2({
17117 unmountOnHide,
17118 ...props
17119 }) {
17120 const context = useDisclosureProviderContext();
17121 const store = props.store || context;
17122 const mounted = useStoreState(
17123 store,
17124 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
17125 );
17126 if (mounted === false) return null;
17127 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DisclosureContentImpl, { ...props });
17128 });
17129
17130 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
17131 function createDisclosureStore(props = {}) {
17132 const store = mergeStore(
17133 props.store,
17134 omit22(props.disclosure, ["contentElement", "disclosureElement"])
17135 );
17136 throwOnConflictingProps(props, store);
17137 const syncState = store == null ? void 0 : store.getState();
17138 const open = defaultValue(
17139 props.open,
17140 syncState == null ? void 0 : syncState.open,
17141 props.defaultOpen,
17142 false
17143 );
17144 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
17145 const initialState = {
17146 open,
17147 animated,
17148 animating: !!animated && open,
17149 mounted: open,
17150 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
17151 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
17152 };
17153 const disclosure = createStore(initialState, store);
17154 setup(
17155 disclosure,
17156 () => sync(disclosure, ["animated", "animating"], (state) => {
17157 if (state.animated) return;
17158 disclosure.setState("animating", false);
17159 })
17160 );
17161 setup(
17162 disclosure,
17163 () => subscribe(disclosure, ["open"], () => {
17164 if (!disclosure.getState().animated) return;
17165 disclosure.setState("animating", true);
17166 })
17167 );
17168 setup(
17169 disclosure,
17170 () => sync(disclosure, ["open", "animating"], (state) => {
17171 disclosure.setState("mounted", state.open || state.animating);
17172 })
17173 );
17174 return {
17175 ...disclosure,
17176 disclosure: props.disclosure,
17177 setOpen: (value) => disclosure.setState("open", value),
17178 show: () => disclosure.setState("open", true),
17179 hide: () => disclosure.setState("open", false),
17180 toggle: () => disclosure.setState("open", (open2) => !open2),
17181 stopAnimation: () => disclosure.setState("animating", false),
17182 setContentElement: (value) => disclosure.setState("contentElement", value),
17183 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
17184 };
17185 }
17186
17187 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
17188 function useDisclosureStoreProps(store, update2, props) {
17189 useUpdateEffect(update2, [props.store, props.disclosure]);
17190 useStoreProps(store, props, "open", "setOpen");
17191 useStoreProps(store, props, "mounted", "setMounted");
17192 useStoreProps(store, props, "animated");
17193 return Object.assign(store, { disclosure: props.disclosure });
17194 }
17195
17196 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
17197 var ctx5 = createStoreContext(
17198 [DialogContextProvider],
17199 [DialogScopedContextProvider]
17200 );
17201 var usePopoverContext = ctx5.useContext;
17202 var usePopoverScopedContext = ctx5.useScopedContext;
17203 var usePopoverProviderContext = ctx5.useProviderContext;
17204 var PopoverContextProvider = ctx5.ContextProvider;
17205 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
17206
17207 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
17208 function getCommonParent(items) {
17209 var _a;
17210 const firstItem = items.find((item) => !!item.element);
17211 const lastItem = [...items].reverse().find((item) => !!item.element);
17212 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
17213 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
17214 const parent = parentElement;
17215 if (lastItem && parent.contains(lastItem.element)) {
17216 return parentElement;
17217 }
17218 parentElement = parentElement.parentElement;
17219 }
17220 return getDocument(parentElement).body;
17221 }
17222 function getPrivateStore(store) {
17223 return store == null ? void 0 : store.__unstablePrivateStore;
17224 }
17225 function createCollectionStore(props = {}) {
17226 var _a;
17227 throwOnConflictingProps(props, props.store);
17228 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17229 const items = defaultValue(
17230 props.items,
17231 syncState == null ? void 0 : syncState.items,
17232 props.defaultItems,
17233 []
17234 );
17235 const itemsMap = new Map(items.map((item) => [item.id, item]));
17236 const initialState = {
17237 items,
17238 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
17239 };
17240 const syncPrivateStore = getPrivateStore(props.store);
17241 const privateStore = createStore(
17242 { items, renderedItems: initialState.renderedItems },
17243 syncPrivateStore
17244 );
17245 const collection = createStore(initialState, props.store);
17246 const sortItems = (renderedItems) => {
17247 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
17248 privateStore.setState("renderedItems", sortedItems);
17249 collection.setState("renderedItems", sortedItems);
17250 };
17251 setup(collection, () => init(privateStore));
17252 setup(privateStore, () => {
17253 return batch(privateStore, ["items"], (state) => {
17254 collection.setState("items", state.items);
17255 });
17256 });
17257 setup(privateStore, () => {
17258 return batch(privateStore, ["renderedItems"], (state) => {
17259 let firstRun = true;
17260 let raf = requestAnimationFrame(() => {
17261 const { renderedItems } = collection.getState();
17262 if (state.renderedItems === renderedItems) return;
17263 sortItems(state.renderedItems);
17264 });
17265 if (typeof IntersectionObserver !== "function") {
17266 return () => cancelAnimationFrame(raf);
17267 }
17268 const ioCallback = () => {
17269 if (firstRun) {
17270 firstRun = false;
17271 return;
17272 }
17273 cancelAnimationFrame(raf);
17274 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
17275 };
17276 const root = getCommonParent(state.renderedItems);
17277 const observer = new IntersectionObserver(ioCallback, { root });
17278 for (const item of state.renderedItems) {
17279 if (!item.element) continue;
17280 observer.observe(item.element);
17281 }
17282 return () => {
17283 cancelAnimationFrame(raf);
17284 observer.disconnect();
17285 };
17286 });
17287 });
17288 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
17289 let prevItem;
17290 setItems((items2) => {
17291 const index2 = items2.findIndex(({ id }) => id === item.id);
17292 const nextItems = items2.slice();
17293 if (index2 !== -1) {
17294 prevItem = items2[index2];
17295 const nextItem = { ...prevItem, ...item };
17296 nextItems[index2] = nextItem;
17297 itemsMap.set(item.id, nextItem);
17298 } else {
17299 nextItems.push(item);
17300 itemsMap.set(item.id, item);
17301 }
17302 return nextItems;
17303 });
17304 const unmergeItem = () => {
17305 setItems((items2) => {
17306 if (!prevItem) {
17307 if (canDeleteFromMap) {
17308 itemsMap.delete(item.id);
17309 }
17310 return items2.filter(({ id }) => id !== item.id);
17311 }
17312 const index2 = items2.findIndex(({ id }) => id === item.id);
17313 if (index2 === -1) return items2;
17314 const nextItems = items2.slice();
17315 nextItems[index2] = prevItem;
17316 itemsMap.set(item.id, prevItem);
17317 return nextItems;
17318 });
17319 };
17320 return unmergeItem;
17321 };
17322 const registerItem = (item) => mergeItem(
17323 item,
17324 (getItems) => privateStore.setState("items", getItems),
17325 true
17326 );
17327 return {
17328 ...collection,
17329 registerItem,
17330 renderItem: (item) => chain(
17331 registerItem(item),
17332 mergeItem(
17333 item,
17334 (getItems) => privateStore.setState("renderedItems", getItems)
17335 )
17336 ),
17337 item: (id) => {
17338 if (!id) return null;
17339 let item = itemsMap.get(id);
17340 if (!item) {
17341 const { items: items2 } = privateStore.getState();
17342 item = items2.find((item2) => item2.id === id);
17343 if (item) {
17344 itemsMap.set(id, item);
17345 }
17346 }
17347 return item || null;
17348 },
17349 // @ts-expect-error Internal
17350 __unstablePrivateStore: privateStore
17351 };
17352 }
17353
17354 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
17355 function useCollectionStoreProps(store, update2, props) {
17356 useUpdateEffect(update2, [props.store]);
17357 useStoreProps(store, props, "items", "setItems");
17358 return store;
17359 }
17360
17361 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
17362 var NULL_ITEM = { id: null };
17363 function findFirstEnabledItem2(items, excludeId) {
17364 return items.find((item) => {
17365 if (excludeId) {
17366 return !item.disabled && item.id !== excludeId;
17367 }
17368 return !item.disabled;
17369 });
17370 }
17371 function getEnabledItems(items, excludeId) {
17372 return items.filter((item) => {
17373 if (excludeId) {
17374 return !item.disabled && item.id !== excludeId;
17375 }
17376 return !item.disabled;
17377 });
17378 }
17379 function getItemsInRow(items, rowId) {
17380 return items.filter((item) => item.rowId === rowId);
17381 }
17382 function flipItems(items, activeId, shouldInsertNullItem = false) {
17383 const index2 = items.findIndex((item) => item.id === activeId);
17384 return [
17385 ...items.slice(index2 + 1),
17386 ...shouldInsertNullItem ? [NULL_ITEM] : [],
17387 ...items.slice(0, index2)
17388 ];
17389 }
17390 function groupItemsByRows2(items) {
17391 const rows = [];
17392 for (const item of items) {
17393 const row = rows.find((currentRow) => {
17394 var _a;
17395 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
17396 });
17397 if (row) {
17398 row.push(item);
17399 } else {
17400 rows.push([item]);
17401 }
17402 }
17403 return rows;
17404 }
17405 function getMaxRowLength(array) {
17406 let maxLength = 0;
17407 for (const { length } of array) {
17408 if (length > maxLength) {
17409 maxLength = length;
17410 }
17411 }
17412 return maxLength;
17413 }
17414 function createEmptyItem(rowId) {
17415 return {
17416 id: "__EMPTY_ITEM__",
17417 disabled: true,
17418 rowId
17419 };
17420 }
17421 function normalizeRows(rows, activeId, focusShift) {
17422 const maxLength = getMaxRowLength(rows);
17423 for (const row of rows) {
17424 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17425 const item = row[i2];
17426 if (!item || focusShift && item.disabled) {
17427 const isFirst = i2 === 0;
17428 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17429 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17430 }
17431 }
17432 }
17433 return rows;
17434 }
17435 function verticalizeItems(items) {
17436 const rows = groupItemsByRows2(items);
17437 const maxLength = getMaxRowLength(rows);
17438 const verticalized = [];
17439 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17440 for (const row of rows) {
17441 const item = row[i2];
17442 if (item) {
17443 verticalized.push({
17444 ...item,
17445 // If there's no rowId, it means that it's not a grid composite, but
17446 // a single row instead. So, instead of verticalizing it, that is,
17447 // assigning a different rowId based on the column index, we keep it
17448 // undefined so they will be part of the same row. This is useful
17449 // when using up/down on one-dimensional composites.
17450 rowId: item.rowId ? `${i2}` : void 0
17451 });
17452 }
17453 }
17454 }
17455 return verticalized;
17456 }
17457 function createCompositeStore(props = {}) {
17458 var _a;
17459 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17460 const collection = createCollectionStore(props);
17461 const activeId = defaultValue(
17462 props.activeId,
17463 syncState == null ? void 0 : syncState.activeId,
17464 props.defaultActiveId
17465 );
17466 const initialState = {
17467 ...collection.getState(),
17468 id: defaultValue(
17469 props.id,
17470 syncState == null ? void 0 : syncState.id,
17471 `id-${Math.random().toString(36).slice(2, 8)}`
17472 ),
17473 activeId,
17474 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17475 includesBaseElement: defaultValue(
17476 props.includesBaseElement,
17477 syncState == null ? void 0 : syncState.includesBaseElement,
17478 activeId === null
17479 ),
17480 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17481 orientation: defaultValue(
17482 props.orientation,
17483 syncState == null ? void 0 : syncState.orientation,
17484 "both"
17485 ),
17486 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17487 virtualFocus: defaultValue(
17488 props.virtualFocus,
17489 syncState == null ? void 0 : syncState.virtualFocus,
17490 false
17491 ),
17492 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17493 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17494 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17495 };
17496 const composite = createStore(initialState, collection, props.store);
17497 setup(
17498 composite,
17499 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17500 composite.setState("activeId", (activeId2) => {
17501 var _a2;
17502 if (activeId2 !== void 0) return activeId2;
17503 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17504 });
17505 })
17506 );
17507 const getNextId = (direction = "next", options = {}) => {
17508 var _a2, _b;
17509 const defaultState = composite.getState();
17510 const {
17511 skip = 0,
17512 activeId: activeId2 = defaultState.activeId,
17513 focusShift = defaultState.focusShift,
17514 focusLoop = defaultState.focusLoop,
17515 focusWrap = defaultState.focusWrap,
17516 includesBaseElement = defaultState.includesBaseElement,
17517 renderedItems = defaultState.renderedItems,
17518 rtl = defaultState.rtl
17519 } = options;
17520 const isVerticalDirection = direction === "up" || direction === "down";
17521 const isNextDirection = direction === "next" || direction === "down";
17522 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17523 const canShift = focusShift && !skip;
17524 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17525 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17526 );
17527 items = canReverse ? reverseArray(items) : items;
17528 items = isVerticalDirection ? verticalizeItems(items) : items;
17529 if (activeId2 == null) {
17530 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17531 }
17532 const activeItem = items.find((item) => item.id === activeId2);
17533 if (!activeItem) {
17534 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17535 }
17536 const isGrid2 = items.some((item) => item.rowId);
17537 const activeIndex = items.indexOf(activeItem);
17538 const nextItems = items.slice(activeIndex + 1);
17539 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17540 if (skip) {
17541 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17542 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17543 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17544 return nextItem2 == null ? void 0 : nextItem2.id;
17545 }
17546 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17547 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17548 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17549 if (canLoop) {
17550 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17551 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17552 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17553 return nextItem2 == null ? void 0 : nextItem2.id;
17554 }
17555 if (canWrap) {
17556 const nextItem2 = findFirstEnabledItem2(
17557 // We can use nextItems, which contains all the next items, including
17558 // items from other rows, to wrap between rows. However, if there is a
17559 // null item (the composite container), we'll only use the next items in
17560 // the row. So moving next from the last item will focus on the
17561 // composite container. On grid composites, horizontal navigation never
17562 // focuses on the composite container, only vertical.
17563 hasNullItem ? nextItemsInRow : nextItems,
17564 activeId2
17565 );
17566 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17567 return nextId;
17568 }
17569 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17570 if (!nextItem && hasNullItem) {
17571 return null;
17572 }
17573 return nextItem == null ? void 0 : nextItem.id;
17574 };
17575 return {
17576 ...collection,
17577 ...composite,
17578 setBaseElement: (element) => composite.setState("baseElement", element),
17579 setActiveId: (id) => composite.setState("activeId", id),
17580 move: (id) => {
17581 if (id === void 0) return;
17582 composite.setState("activeId", id);
17583 composite.setState("moves", (moves) => moves + 1);
17584 },
17585 first: () => {
17586 var _a2;
17587 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17588 },
17589 last: () => {
17590 var _a2;
17591 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17592 },
17593 next: (options) => {
17594 if (options !== void 0 && typeof options === "number") {
17595 options = { skip: options };
17596 }
17597 return getNextId("next", options);
17598 },
17599 previous: (options) => {
17600 if (options !== void 0 && typeof options === "number") {
17601 options = { skip: options };
17602 }
17603 return getNextId("previous", options);
17604 },
17605 down: (options) => {
17606 if (options !== void 0 && typeof options === "number") {
17607 options = { skip: options };
17608 }
17609 return getNextId("down", options);
17610 },
17611 up: (options) => {
17612 if (options !== void 0 && typeof options === "number") {
17613 options = { skip: options };
17614 }
17615 return getNextId("up", options);
17616 }
17617 };
17618 }
17619
17620 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17621 function useCompositeStoreOptions(props) {
17622 const id = useId4(props.id);
17623 return { id, ...props };
17624 }
17625 function useCompositeStoreProps(store, update2, props) {
17626 store = useCollectionStoreProps(store, update2, props);
17627 useStoreProps(store, props, "activeId", "setActiveId");
17628 useStoreProps(store, props, "includesBaseElement");
17629 useStoreProps(store, props, "virtualFocus");
17630 useStoreProps(store, props, "orientation");
17631 useStoreProps(store, props, "rtl");
17632 useStoreProps(store, props, "focusLoop");
17633 useStoreProps(store, props, "focusWrap");
17634 useStoreProps(store, props, "focusShift");
17635 return store;
17636 }
17637
17638 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17639 var import_react18 = __toESM(require_react(), 1);
17640 var ComboboxListRoleContext = (0, import_react18.createContext)(
17641 void 0
17642 );
17643 var ctx6 = createStoreContext(
17644 [PopoverContextProvider, CompositeContextProvider],
17645 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17646 );
17647 var useComboboxContext = ctx6.useContext;
17648 var useComboboxScopedContext = ctx6.useScopedContext;
17649 var useComboboxProviderContext = ctx6.useProviderContext;
17650 var ComboboxContextProvider = ctx6.ContextProvider;
17651 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17652 var ComboboxItemValueContext = (0, import_react18.createContext)(
17653 void 0
17654 );
17655 var ComboboxItemCheckedContext = (0, import_react18.createContext)(false);
17656
17657 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17658 function createDialogStore(props = {}) {
17659 return createDisclosureStore(props);
17660 }
17661
17662 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17663 function useDialogStoreProps(store, update2, props) {
17664 return useDisclosureStoreProps(store, update2, props);
17665 }
17666
17667 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17668 function createPopoverStore({
17669 popover: otherPopover,
17670 ...props
17671 } = {}) {
17672 const store = mergeStore(
17673 props.store,
17674 omit22(otherPopover, [
17675 "arrowElement",
17676 "anchorElement",
17677 "contentElement",
17678 "popoverElement",
17679 "disclosureElement"
17680 ])
17681 );
17682 throwOnConflictingProps(props, store);
17683 const syncState = store == null ? void 0 : store.getState();
17684 const dialog = createDialogStore({ ...props, store });
17685 const placement = defaultValue(
17686 props.placement,
17687 syncState == null ? void 0 : syncState.placement,
17688 "bottom"
17689 );
17690 const initialState = {
17691 ...dialog.getState(),
17692 placement,
17693 currentPlacement: placement,
17694 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17695 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17696 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17697 rendered: /* @__PURE__ */ Symbol("rendered")
17698 };
17699 const popover = createStore(initialState, dialog, store);
17700 return {
17701 ...dialog,
17702 ...popover,
17703 setAnchorElement: (element) => popover.setState("anchorElement", element),
17704 setPopoverElement: (element) => popover.setState("popoverElement", element),
17705 setArrowElement: (element) => popover.setState("arrowElement", element),
17706 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17707 };
17708 }
17709
17710 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17711 function usePopoverStoreProps(store, update2, props) {
17712 useUpdateEffect(update2, [props.popover]);
17713 useStoreProps(store, props, "placement");
17714 return useDialogStoreProps(store, update2, props);
17715 }
17716
17717 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17718 var TagName7 = "div";
17719 var usePopoverAnchor = createHook(
17720 function usePopoverAnchor2({ store, ...props }) {
17721 const context = usePopoverProviderContext();
17722 store = store || context;
17723 props = {
17724 ...props,
17725 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17726 };
17727 return props;
17728 }
17729 );
17730 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
17731 const htmlProps = usePopoverAnchor(props);
17732 return createElement3(TagName7, htmlProps);
17733 });
17734
17735 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17736 var import_react19 = __toESM(require_react(), 1);
17737 var TagName8 = "div";
17738 function getMouseDestination(event) {
17739 const relatedTarget = event.relatedTarget;
17740 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17741 return relatedTarget;
17742 }
17743 return null;
17744 }
17745 function hoveringInside(event) {
17746 const nextElement = getMouseDestination(event);
17747 if (!nextElement) return false;
17748 return contains2(event.currentTarget, nextElement);
17749 }
17750 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17751 function movingToAnotherItem(event) {
17752 let dest = getMouseDestination(event);
17753 if (!dest) return false;
17754 do {
17755 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17756 dest = dest.parentElement;
17757 } while (dest);
17758 return false;
17759 }
17760 var useCompositeHover = createHook(
17761 function useCompositeHover2({
17762 store,
17763 focusOnHover = true,
17764 blurOnHoverEnd = !!focusOnHover,
17765 ...props
17766 }) {
17767 const context = useCompositeContext();
17768 store = store || context;
17769 invariant(
17770 store,
17771 "CompositeHover must be wrapped in a Composite component."
17772 );
17773 const isMouseMoving = useIsMouseMoving();
17774 const onMouseMoveProp = props.onMouseMove;
17775 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17776 const onMouseMove = useEvent((event) => {
17777 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17778 if (event.defaultPrevented) return;
17779 if (!isMouseMoving()) return;
17780 if (!focusOnHoverProp(event)) return;
17781 if (!hasFocusWithin(event.currentTarget)) {
17782 const baseElement = store == null ? void 0 : store.getState().baseElement;
17783 if (baseElement && !hasFocus(baseElement)) {
17784 baseElement.focus();
17785 }
17786 }
17787 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17788 });
17789 const onMouseLeaveProp = props.onMouseLeave;
17790 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17791 const onMouseLeave = useEvent((event) => {
17792 var _a;
17793 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17794 if (event.defaultPrevented) return;
17795 if (!isMouseMoving()) return;
17796 if (hoveringInside(event)) return;
17797 if (movingToAnotherItem(event)) return;
17798 if (!focusOnHoverProp(event)) return;
17799 if (!blurOnHoverEndProp(event)) return;
17800 store == null ? void 0 : store.setActiveId(null);
17801 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17802 });
17803 const ref = (0, import_react19.useCallback)((element) => {
17804 if (!element) return;
17805 element[symbol2] = true;
17806 }, []);
17807 props = {
17808 ...props,
17809 ref: useMergeRefs(ref, props.ref),
17810 onMouseMove,
17811 onMouseLeave
17812 };
17813 return removeUndefinedValues(props);
17814 }
17815 );
17816 var CompositeHover = memo22(
17817 forwardRef22(function CompositeHover2(props) {
17818 const htmlProps = useCompositeHover(props);
17819 return createElement3(TagName8, htmlProps);
17820 })
17821 );
17822
17823 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17824 var import_react20 = __toESM(require_react(), 1);
17825 var TagName9 = "input";
17826 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17827 if (!autoSelect) return false;
17828 const firstItem = items.find((item) => !item.disabled && item.value);
17829 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17830 }
17831 function hasCompletionString(value, activeValue) {
17832 if (!activeValue) return false;
17833 if (value == null) return false;
17834 value = normalizeString(value);
17835 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17836 }
17837 function isInputEvent(event) {
17838 return event.type === "input";
17839 }
17840 function isAriaAutoCompleteValue(value) {
17841 return value === "inline" || value === "list" || value === "both" || value === "none";
17842 }
17843 function getDefaultAutoSelectId(items) {
17844 const item = items.find((item2) => {
17845 var _a;
17846 if (item2.disabled) return false;
17847 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17848 });
17849 return item == null ? void 0 : item.id;
17850 }
17851 var useCombobox = createHook(
17852 function useCombobox2({
17853 store,
17854 focusable: focusable2 = true,
17855 autoSelect: autoSelectProp = false,
17856 getAutoSelectId,
17857 setValueOnChange,
17858 showMinLength = 0,
17859 showOnChange,
17860 showOnMouseDown,
17861 showOnClick = showOnMouseDown,
17862 showOnKeyDown,
17863 showOnKeyPress = showOnKeyDown,
17864 blurActiveItemOnClick,
17865 setValueOnClick = true,
17866 moveOnKeyPress = true,
17867 autoComplete = "list",
17868 ...props
17869 }) {
17870 const context = useComboboxProviderContext();
17871 store = store || context;
17872 invariant(
17873 store,
17874 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17875 );
17876 const ref = (0, import_react20.useRef)(null);
17877 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17878 const canAutoSelectRef = (0, import_react20.useRef)(false);
17879 const composingRef = (0, import_react20.useRef)(false);
17880 const autoSelect = store.useState(
17881 (state) => state.virtualFocus && autoSelectProp
17882 );
17883 const inline4 = autoComplete === "inline" || autoComplete === "both";
17884 const [canInline, setCanInline] = (0, import_react20.useState)(inline4);
17885 useUpdateLayoutEffect(() => {
17886 if (!inline4) return;
17887 setCanInline(true);
17888 }, [inline4]);
17889 const storeValue = store.useState("value");
17890 const prevSelectedValueRef = (0, import_react20.useRef)(void 0);
17891 (0, import_react20.useEffect)(() => {
17892 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17893 prevSelectedValueRef.current = prev.selectedValue;
17894 });
17895 }, []);
17896 const inlineActiveValue = store.useState((state) => {
17897 var _a;
17898 if (!inline4) return;
17899 if (!canInline) return;
17900 if (state.activeValue && Array.isArray(state.selectedValue)) {
17901 if (state.selectedValue.includes(state.activeValue)) return;
17902 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17903 }
17904 return state.activeValue;
17905 });
17906 const items = store.useState("renderedItems");
17907 const open = store.useState("open");
17908 const contentElement = store.useState("contentElement");
17909 const value = (0, import_react20.useMemo)(() => {
17910 if (!inline4) return storeValue;
17911 if (!canInline) return storeValue;
17912 const firstItemAutoSelected = isFirstItemAutoSelected(
17913 items,
17914 inlineActiveValue,
17915 autoSelect
17916 );
17917 if (firstItemAutoSelected) {
17918 if (hasCompletionString(storeValue, inlineActiveValue)) {
17919 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17920 return storeValue + slice;
17921 }
17922 return storeValue;
17923 }
17924 return inlineActiveValue || storeValue;
17925 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17926 (0, import_react20.useEffect)(() => {
17927 const element = ref.current;
17928 if (!element) return;
17929 const onCompositeItemMove = () => setCanInline(true);
17930 element.addEventListener("combobox-item-move", onCompositeItemMove);
17931 return () => {
17932 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17933 };
17934 }, []);
17935 (0, import_react20.useEffect)(() => {
17936 if (!inline4) return;
17937 if (!canInline) return;
17938 if (!inlineActiveValue) return;
17939 const firstItemAutoSelected = isFirstItemAutoSelected(
17940 items,
17941 inlineActiveValue,
17942 autoSelect
17943 );
17944 if (!firstItemAutoSelected) return;
17945 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17946 let cleanup = noop4;
17947 queueMicrotask(() => {
17948 const element = ref.current;
17949 if (!element) return;
17950 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17951 const nextStart = storeValue.length;
17952 const nextEnd = inlineActiveValue.length;
17953 setSelectionRange(element, nextStart, nextEnd);
17954 cleanup = () => {
17955 if (!hasFocus(element)) return;
17956 const { start, end } = getTextboxSelection(element);
17957 if (start !== nextStart) return;
17958 if (end !== nextEnd) return;
17959 setSelectionRange(element, prevStart, prevEnd);
17960 };
17961 });
17962 return () => cleanup();
17963 }, [
17964 valueUpdated,
17965 inline4,
17966 canInline,
17967 inlineActiveValue,
17968 items,
17969 autoSelect,
17970 storeValue
17971 ]);
17972 const scrollingElementRef = (0, import_react20.useRef)(null);
17973 const getAutoSelectIdProp = useEvent(getAutoSelectId);
17974 const autoSelectIdRef = (0, import_react20.useRef)(null);
17975 (0, import_react20.useEffect)(() => {
17976 if (!open) return;
17977 if (!contentElement) return;
17978 const scrollingElement = getScrollingElement(contentElement);
17979 if (!scrollingElement) return;
17980 scrollingElementRef.current = scrollingElement;
17981 const onUserScroll = () => {
17982 canAutoSelectRef.current = false;
17983 };
17984 const onScroll = () => {
17985 if (!store) return;
17986 if (!canAutoSelectRef.current) return;
17987 const { activeId } = store.getState();
17988 if (activeId === null) return;
17989 if (activeId === autoSelectIdRef.current) return;
17990 canAutoSelectRef.current = false;
17991 };
17992 const options = { passive: true, capture: true };
17993 scrollingElement.addEventListener("wheel", onUserScroll, options);
17994 scrollingElement.addEventListener("touchmove", onUserScroll, options);
17995 scrollingElement.addEventListener("scroll", onScroll, options);
17996 return () => {
17997 scrollingElement.removeEventListener("wheel", onUserScroll, true);
17998 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
17999 scrollingElement.removeEventListener("scroll", onScroll, true);
18000 };
18001 }, [open, contentElement, store]);
18002 useSafeLayoutEffect(() => {
18003 if (!storeValue) return;
18004 if (composingRef.current) return;
18005 canAutoSelectRef.current = true;
18006 }, [storeValue]);
18007 useSafeLayoutEffect(() => {
18008 if (autoSelect !== "always" && open) return;
18009 canAutoSelectRef.current = open;
18010 }, [autoSelect, open]);
18011 const resetValueOnSelect = store.useState("resetValueOnSelect");
18012 useUpdateEffect(() => {
18013 var _a, _b;
18014 const canAutoSelect = canAutoSelectRef.current;
18015 if (!store) return;
18016 if (!open) return;
18017 if (!canAutoSelect && !resetValueOnSelect) return;
18018 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
18019 if (baseElement && !hasFocus(baseElement)) return;
18020 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
18021 const observer = new MutationObserver(forceValueUpdate);
18022 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
18023 return () => observer.disconnect();
18024 }
18025 if (autoSelect && canAutoSelect) {
18026 const userAutoSelectId = getAutoSelectIdProp(items);
18027 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
18028 autoSelectIdRef.current = autoSelectId;
18029 store.move(autoSelectId != null ? autoSelectId : null);
18030 } else {
18031 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
18032 if (element && "scrollIntoView" in element) {
18033 element.scrollIntoView({ block: "nearest", inline: "nearest" });
18034 }
18035 }
18036 return;
18037 }, [
18038 store,
18039 open,
18040 valueUpdated,
18041 storeValue,
18042 autoSelect,
18043 resetValueOnSelect,
18044 getAutoSelectIdProp,
18045 items
18046 ]);
18047 (0, import_react20.useEffect)(() => {
18048 if (!inline4) return;
18049 const combobox = ref.current;
18050 if (!combobox) return;
18051 const elements = [combobox, contentElement].filter(
18052 (value2) => !!value2
18053 );
18054 const onBlur2 = (event) => {
18055 if (elements.every((el) => isFocusEventOutside(event, el))) {
18056 store == null ? void 0 : store.setValue(value);
18057 }
18058 };
18059 for (const element of elements) {
18060 element.addEventListener("focusout", onBlur2);
18061 }
18062 return () => {
18063 for (const element of elements) {
18064 element.removeEventListener("focusout", onBlur2);
18065 }
18066 };
18067 }, [inline4, contentElement, store, value]);
18068 const canShow = (event) => {
18069 const currentTarget = event.currentTarget;
18070 return currentTarget.value.length >= showMinLength;
18071 };
18072 const onChangeProp = props.onChange;
18073 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
18074 const setValueOnChangeProp = useBooleanEvent(
18075 // If the combobox is combined with tags, the value will be set by the tag
18076 // input component.
18077 setValueOnChange != null ? setValueOnChange : !store.tag
18078 );
18079 const onChange = useEvent((event) => {
18080 onChangeProp == null ? void 0 : onChangeProp(event);
18081 if (event.defaultPrevented) return;
18082 if (!store) return;
18083 const currentTarget = event.currentTarget;
18084 const { value: value2, selectionStart, selectionEnd } = currentTarget;
18085 const nativeEvent = event.nativeEvent;
18086 canAutoSelectRef.current = true;
18087 if (isInputEvent(nativeEvent)) {
18088 if (nativeEvent.isComposing) {
18089 canAutoSelectRef.current = false;
18090 composingRef.current = true;
18091 }
18092 if (inline4) {
18093 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
18094 const caretAtEnd = selectionStart === value2.length;
18095 setCanInline(textInserted && caretAtEnd);
18096 }
18097 }
18098 if (setValueOnChangeProp(event)) {
18099 const isSameValue = value2 === store.getState().value;
18100 store.setValue(value2);
18101 queueMicrotask(() => {
18102 setSelectionRange(currentTarget, selectionStart, selectionEnd);
18103 });
18104 if (inline4 && autoSelect && isSameValue) {
18105 forceValueUpdate();
18106 }
18107 }
18108 if (showOnChangeProp(event)) {
18109 store.show();
18110 }
18111 if (!autoSelect || !canAutoSelectRef.current) {
18112 store.setActiveId(null);
18113 }
18114 });
18115 const onCompositionEndProp = props.onCompositionEnd;
18116 const onCompositionEnd = useEvent((event) => {
18117 canAutoSelectRef.current = true;
18118 composingRef.current = false;
18119 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
18120 if (event.defaultPrevented) return;
18121 if (!autoSelect) return;
18122 forceValueUpdate();
18123 });
18124 const onMouseDownProp = props.onMouseDown;
18125 const blurActiveItemOnClickProp = useBooleanEvent(
18126 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
18127 );
18128 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18129 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
18130 const onMouseDown = useEvent((event) => {
18131 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
18132 if (event.defaultPrevented) return;
18133 if (event.button) return;
18134 if (event.ctrlKey) return;
18135 if (!store) return;
18136 if (blurActiveItemOnClickProp(event)) {
18137 store.setActiveId(null);
18138 }
18139 if (setValueOnClickProp(event)) {
18140 store.setValue(value);
18141 }
18142 if (showOnClickProp(event)) {
18143 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
18144 }
18145 });
18146 const onKeyDownProp = props.onKeyDown;
18147 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
18148 const onKeyDown = useEvent((event) => {
18149 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18150 if (!event.repeat) {
18151 canAutoSelectRef.current = false;
18152 }
18153 if (event.defaultPrevented) return;
18154 if (event.ctrlKey) return;
18155 if (event.altKey) return;
18156 if (event.shiftKey) return;
18157 if (event.metaKey) return;
18158 if (!store) return;
18159 const { open: open2 } = store.getState();
18160 if (open2) return;
18161 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
18162 if (showOnKeyPressProp(event)) {
18163 event.preventDefault();
18164 store.show();
18165 }
18166 }
18167 });
18168 const onBlurProp = props.onBlur;
18169 const onBlur = useEvent((event) => {
18170 canAutoSelectRef.current = false;
18171 onBlurProp == null ? void 0 : onBlurProp(event);
18172 if (event.defaultPrevented) return;
18173 });
18174 const id = useId4(props.id);
18175 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
18176 const isActiveItem = store.useState((state) => state.activeId === null);
18177 props = {
18178 id,
18179 role: "combobox",
18180 "aria-autocomplete": ariaAutoComplete,
18181 "aria-haspopup": getPopupRole(contentElement, "listbox"),
18182 "aria-expanded": open,
18183 "aria-controls": contentElement == null ? void 0 : contentElement.id,
18184 "data-active-item": isActiveItem || void 0,
18185 value,
18186 ...props,
18187 ref: useMergeRefs(ref, props.ref),
18188 onChange,
18189 onCompositionEnd,
18190 onMouseDown,
18191 onKeyDown,
18192 onBlur
18193 };
18194 props = useComposite({
18195 store,
18196 focusable: focusable2,
18197 ...props,
18198 // Enable inline autocomplete when the user moves from the combobox input
18199 // to an item.
18200 moveOnKeyPress: (event) => {
18201 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
18202 if (inline4) setCanInline(true);
18203 return true;
18204 }
18205 });
18206 props = usePopoverAnchor({ store, ...props });
18207 return { autoComplete: "off", ...props };
18208 }
18209 );
18210 var Combobox = forwardRef22(function Combobox2(props) {
18211 const htmlProps = useCombobox(props);
18212 return createElement3(TagName9, htmlProps);
18213 });
18214
18215 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
18216 var import_react21 = __toESM(require_react(), 1);
18217 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
18218 var TagName10 = "div";
18219 function isSelected(storeValue, itemValue) {
18220 if (itemValue == null) return;
18221 if (storeValue == null) return false;
18222 if (Array.isArray(storeValue)) {
18223 return storeValue.includes(itemValue);
18224 }
18225 return storeValue === itemValue;
18226 }
18227 function getItemRole(popupRole) {
18228 var _a;
18229 const itemRoleByPopupRole = {
18230 menu: "menuitem",
18231 listbox: "option",
18232 tree: "treeitem"
18233 };
18234 const key = popupRole;
18235 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
18236 }
18237 var useComboboxItem = createHook(
18238 function useComboboxItem2({
18239 store,
18240 value,
18241 hideOnClick,
18242 setValueOnClick,
18243 selectValueOnClick = true,
18244 resetValueOnSelect,
18245 focusOnHover = false,
18246 moveOnKeyPress = true,
18247 getItem: getItemProp,
18248 ...props
18249 }) {
18250 var _a;
18251 const context = useComboboxScopedContext();
18252 store = store || context;
18253 invariant(
18254 store,
18255 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
18256 );
18257 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
18258 resetValueOnSelectState: "resetValueOnSelect",
18259 multiSelectable(state) {
18260 return Array.isArray(state.selectedValue);
18261 },
18262 selected(state) {
18263 return isSelected(state.selectedValue, value);
18264 }
18265 });
18266 const getItem = (0, import_react21.useCallback)(
18267 (item) => {
18268 const nextItem = { ...item, value };
18269 if (getItemProp) {
18270 return getItemProp(nextItem);
18271 }
18272 return nextItem;
18273 },
18274 [value, getItemProp]
18275 );
18276 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
18277 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
18278 const onClickProp = props.onClick;
18279 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
18280 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
18281 const resetValueOnSelectProp = useBooleanEvent(
18282 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
18283 );
18284 const hideOnClickProp = useBooleanEvent(hideOnClick);
18285 const onClick = useEvent((event) => {
18286 onClickProp == null ? void 0 : onClickProp(event);
18287 if (event.defaultPrevented) return;
18288 if (isDownloading(event)) return;
18289 if (isOpeningInNewTab(event)) return;
18290 if (value != null) {
18291 if (selectValueOnClickProp(event)) {
18292 if (resetValueOnSelectProp(event)) {
18293 store == null ? void 0 : store.resetValue();
18294 }
18295 store == null ? void 0 : store.setSelectedValue((prevValue) => {
18296 if (!Array.isArray(prevValue)) return value;
18297 if (prevValue.includes(value)) {
18298 return prevValue.filter((v2) => v2 !== value);
18299 }
18300 return [...prevValue, value];
18301 });
18302 }
18303 if (setValueOnClickProp(event)) {
18304 store == null ? void 0 : store.setValue(value);
18305 }
18306 }
18307 if (hideOnClickProp(event)) {
18308 store == null ? void 0 : store.hide();
18309 }
18310 });
18311 const onKeyDownProp = props.onKeyDown;
18312 const onKeyDown = useEvent((event) => {
18313 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
18314 if (event.defaultPrevented) return;
18315 const baseElement = store == null ? void 0 : store.getState().baseElement;
18316 if (!baseElement) return;
18317 if (hasFocus(baseElement)) return;
18318 const printable = event.key.length === 1;
18319 if (printable || event.key === "Backspace" || event.key === "Delete") {
18320 queueMicrotask(() => baseElement.focus());
18321 if (isTextField(baseElement)) {
18322 store == null ? void 0 : store.setValue(baseElement.value);
18323 }
18324 }
18325 });
18326 if (multiSelectable && selected != null) {
18327 props = {
18328 "aria-selected": selected,
18329 ...props
18330 };
18331 }
18332 props = useWrapElement(
18333 props,
18334 (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
18335 [value, selected]
18336 );
18337 const popupRole = (0, import_react21.useContext)(ComboboxListRoleContext);
18338 props = {
18339 role: getItemRole(popupRole),
18340 children: value,
18341 ...props,
18342 onClick,
18343 onKeyDown
18344 };
18345 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
18346 props = useCompositeItem({
18347 store,
18348 ...props,
18349 getItem,
18350 // Dispatch a custom event on the combobox input when moving to an item
18351 // with the keyboard so the Combobox component can enable inline
18352 // autocompletion.
18353 moveOnKeyPress: (event) => {
18354 if (!moveOnKeyPressProp(event)) return false;
18355 const moveEvent = new Event("combobox-item-move");
18356 const baseElement = store == null ? void 0 : store.getState().baseElement;
18357 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
18358 return true;
18359 }
18360 });
18361 props = useCompositeHover({ store, focusOnHover, ...props });
18362 return props;
18363 }
18364 );
18365 var ComboboxItem = memo22(
18366 forwardRef22(function ComboboxItem2(props) {
18367 const htmlProps = useComboboxItem(props);
18368 return createElement3(TagName10, htmlProps);
18369 })
18370 );
18371
18372 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
18373 var import_react22 = __toESM(require_react(), 1);
18374 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
18375 var TagName11 = "span";
18376 function normalizeValue(value) {
18377 return normalizeString(value).toLowerCase();
18378 }
18379 function getOffsets(string, values) {
18380 const offsets = [];
18381 for (const value of values) {
18382 let pos = 0;
18383 const length = value.length;
18384 while (string.indexOf(value, pos) !== -1) {
18385 const index2 = string.indexOf(value, pos);
18386 if (index2 !== -1) {
18387 offsets.push([index2, length]);
18388 }
18389 pos = index2 + 1;
18390 }
18391 }
18392 return offsets;
18393 }
18394 function filterOverlappingOffsets(offsets) {
18395 return offsets.filter(([offset4, length], i2, arr) => {
18396 return !arr.some(
18397 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
18398 );
18399 });
18400 }
18401 function sortOffsets(offsets) {
18402 return offsets.sort(([a2], [b2]) => a2 - b2);
18403 }
18404 function splitValue(itemValue, userValue) {
18405 if (!itemValue) return itemValue;
18406 if (!userValue) return itemValue;
18407 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
18408 const parts = [];
18409 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
18410 "span",
18411 {
18412 "data-autocomplete-value": autocomplete ? "" : void 0,
18413 "data-user-value": autocomplete ? void 0 : "",
18414 children: value
18415 },
18416 parts.length
18417 );
18418 const offsets = sortOffsets(
18419 filterOverlappingOffsets(
18420 // Convert userValues into a set to avoid duplicates
18421 getOffsets(normalizeValue(itemValue), new Set(userValues))
18422 )
18423 );
18424 if (!offsets.length) {
18425 parts.push(span(itemValue, true));
18426 return parts;
18427 }
18428 const [firstOffset] = offsets[0];
18429 const values = [
18430 itemValue.slice(0, firstOffset),
18431 ...offsets.flatMap(([offset4, length], i2) => {
18432 var _a;
18433 const value = itemValue.slice(offset4, offset4 + length);
18434 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18435 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18436 return [value, nextValue];
18437 })
18438 ];
18439 values.forEach((value, i2) => {
18440 if (!value) return;
18441 parts.push(span(value, i2 % 2 === 0));
18442 });
18443 return parts;
18444 }
18445 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18446 const context = useComboboxScopedContext();
18447 store = store || context;
18448 const itemContext = (0, import_react22.useContext)(ComboboxItemValueContext);
18449 const itemValue = value != null ? value : itemContext;
18450 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18451 const children = (0, import_react22.useMemo)(() => {
18452 if (!itemValue) return;
18453 if (!inputValue) return itemValue;
18454 return splitValue(itemValue, inputValue);
18455 }, [itemValue, inputValue]);
18456 props = {
18457 children,
18458 ...props
18459 };
18460 return removeUndefinedValues(props);
18461 });
18462 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
18463 const htmlProps = useComboboxItemValue(props);
18464 return createElement3(TagName11, htmlProps);
18465 });
18466
18467 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18468 var TagName12 = "label";
18469 var useComboboxLabel = createHook(
18470 function useComboboxLabel2({ store, ...props }) {
18471 const context = useComboboxProviderContext();
18472 store = store || context;
18473 invariant(
18474 store,
18475 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18476 );
18477 const comboboxId = store.useState((state) => {
18478 var _a;
18479 return (_a = state.baseElement) == null ? void 0 : _a.id;
18480 });
18481 props = {
18482 htmlFor: comboboxId,
18483 ...props
18484 };
18485 return removeUndefinedValues(props);
18486 }
18487 );
18488 var ComboboxLabel = memo22(
18489 forwardRef22(function ComboboxLabel2(props) {
18490 const htmlProps = useComboboxLabel(props);
18491 return createElement3(TagName12, htmlProps);
18492 })
18493 );
18494
18495 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18496 var import_react23 = __toESM(require_react(), 1);
18497 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
18498 var TagName13 = "div";
18499 var useComboboxList = createHook(
18500 function useComboboxList2({ store, alwaysVisible, ...props }) {
18501 const scopedContext = useComboboxScopedContext(true);
18502 const context = useComboboxContext();
18503 store = store || context;
18504 const scopedContextSameStore = !!store && store === scopedContext;
18505 invariant(
18506 store,
18507 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18508 );
18509 const ref = (0, import_react23.useRef)(null);
18510 const id = useId4(props.id);
18511 const mounted = store.useState("mounted");
18512 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18513 const style = hidden ? { ...props.style, display: "none" } : props.style;
18514 const multiSelectable = store.useState(
18515 (state) => Array.isArray(state.selectedValue)
18516 );
18517 const role = useAttribute(ref, "role", props.role);
18518 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18519 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18520 const [hasListboxInside, setHasListboxInside] = (0, import_react23.useState)(false);
18521 const contentElement = store.useState("contentElement");
18522 useSafeLayoutEffect(() => {
18523 if (!mounted) return;
18524 const element = ref.current;
18525 if (!element) return;
18526 if (contentElement !== element) return;
18527 const callback = () => {
18528 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18529 };
18530 const observer = new MutationObserver(callback);
18531 observer.observe(element, {
18532 subtree: true,
18533 childList: true,
18534 attributeFilter: ["role"]
18535 });
18536 callback();
18537 return () => observer.disconnect();
18538 }, [mounted, contentElement]);
18539 if (!hasListboxInside) {
18540 props = {
18541 role: "listbox",
18542 "aria-multiselectable": ariaMultiSelectable,
18543 ...props
18544 };
18545 }
18546 props = useWrapElement(
18547 props,
18548 (element) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18549 [store, role]
18550 );
18551 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18552 props = {
18553 id,
18554 hidden,
18555 ...props,
18556 ref: useMergeRefs(setContentElement, ref, props.ref),
18557 style
18558 };
18559 return removeUndefinedValues(props);
18560 }
18561 );
18562 var ComboboxList = forwardRef22(function ComboboxList2(props) {
18563 const htmlProps = useComboboxList(props);
18564 return createElement3(TagName13, htmlProps);
18565 });
18566
18567 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18568 var import_react24 = __toESM(require_react(), 1);
18569 var TagValueContext = (0, import_react24.createContext)(null);
18570 var TagRemoveIdContext = (0, import_react24.createContext)(
18571 null
18572 );
18573 var ctx7 = createStoreContext(
18574 [CompositeContextProvider],
18575 [CompositeScopedContextProvider]
18576 );
18577 var useTagContext = ctx7.useContext;
18578 var useTagScopedContext = ctx7.useScopedContext;
18579 var useTagProviderContext = ctx7.useProviderContext;
18580 var TagContextProvider = ctx7.ContextProvider;
18581 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18582
18583 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18584 var isTouchSafari = isSafari2() && isTouchDevice();
18585 function createComboboxStore({
18586 tag,
18587 ...props
18588 } = {}) {
18589 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18590 throwOnConflictingProps(props, store);
18591 const tagState = tag == null ? void 0 : tag.getState();
18592 const syncState = store == null ? void 0 : store.getState();
18593 const activeId = defaultValue(
18594 props.activeId,
18595 syncState == null ? void 0 : syncState.activeId,
18596 props.defaultActiveId,
18597 null
18598 );
18599 const composite = createCompositeStore({
18600 ...props,
18601 activeId,
18602 includesBaseElement: defaultValue(
18603 props.includesBaseElement,
18604 syncState == null ? void 0 : syncState.includesBaseElement,
18605 true
18606 ),
18607 orientation: defaultValue(
18608 props.orientation,
18609 syncState == null ? void 0 : syncState.orientation,
18610 "vertical"
18611 ),
18612 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18613 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18614 virtualFocus: defaultValue(
18615 props.virtualFocus,
18616 syncState == null ? void 0 : syncState.virtualFocus,
18617 true
18618 )
18619 });
18620 const popover = createPopoverStore({
18621 ...props,
18622 placement: defaultValue(
18623 props.placement,
18624 syncState == null ? void 0 : syncState.placement,
18625 "bottom-start"
18626 )
18627 });
18628 const value = defaultValue(
18629 props.value,
18630 syncState == null ? void 0 : syncState.value,
18631 props.defaultValue,
18632 ""
18633 );
18634 const selectedValue = defaultValue(
18635 props.selectedValue,
18636 syncState == null ? void 0 : syncState.selectedValue,
18637 tagState == null ? void 0 : tagState.values,
18638 props.defaultSelectedValue,
18639 ""
18640 );
18641 const multiSelectable = Array.isArray(selectedValue);
18642 const initialState = {
18643 ...composite.getState(),
18644 ...popover.getState(),
18645 value,
18646 selectedValue,
18647 resetValueOnSelect: defaultValue(
18648 props.resetValueOnSelect,
18649 syncState == null ? void 0 : syncState.resetValueOnSelect,
18650 multiSelectable
18651 ),
18652 resetValueOnHide: defaultValue(
18653 props.resetValueOnHide,
18654 syncState == null ? void 0 : syncState.resetValueOnHide,
18655 multiSelectable && !tag
18656 ),
18657 activeValue: syncState == null ? void 0 : syncState.activeValue
18658 };
18659 const combobox = createStore(initialState, composite, popover, store);
18660 if (isTouchSafari) {
18661 setup(
18662 combobox,
18663 () => sync(combobox, ["virtualFocus"], () => {
18664 combobox.setState("virtualFocus", false);
18665 })
18666 );
18667 }
18668 setup(combobox, () => {
18669 if (!tag) return;
18670 return chain(
18671 sync(combobox, ["selectedValue"], (state) => {
18672 if (!Array.isArray(state.selectedValue)) return;
18673 tag.setValues(state.selectedValue);
18674 }),
18675 sync(tag, ["values"], (state) => {
18676 combobox.setState("selectedValue", state.values);
18677 })
18678 );
18679 });
18680 setup(
18681 combobox,
18682 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18683 if (!state.resetValueOnHide) return;
18684 if (state.mounted) return;
18685 combobox.setState("value", value);
18686 })
18687 );
18688 setup(
18689 combobox,
18690 () => sync(combobox, ["open"], (state) => {
18691 if (state.open) return;
18692 combobox.setState("activeId", activeId);
18693 combobox.setState("moves", 0);
18694 })
18695 );
18696 setup(
18697 combobox,
18698 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18699 if (state.moves === prevState.moves) {
18700 combobox.setState("activeValue", void 0);
18701 }
18702 })
18703 );
18704 setup(
18705 combobox,
18706 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18707 if (state.moves === prev.moves) return;
18708 const { activeId: activeId2 } = combobox.getState();
18709 const activeItem = composite.item(activeId2);
18710 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18711 })
18712 );
18713 return {
18714 ...popover,
18715 ...composite,
18716 ...combobox,
18717 tag,
18718 setValue: (value2) => combobox.setState("value", value2),
18719 resetValue: () => combobox.setState("value", initialState.value),
18720 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18721 };
18722 }
18723
18724 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18725 function useComboboxStoreOptions(props) {
18726 const tag = useTagContext();
18727 props = {
18728 ...props,
18729 tag: props.tag !== void 0 ? props.tag : tag
18730 };
18731 return useCompositeStoreOptions(props);
18732 }
18733 function useComboboxStoreProps(store, update2, props) {
18734 useUpdateEffect(update2, [props.tag]);
18735 useStoreProps(store, props, "value", "setValue");
18736 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18737 useStoreProps(store, props, "resetValueOnHide");
18738 useStoreProps(store, props, "resetValueOnSelect");
18739 return Object.assign(
18740 useCompositeStoreProps(
18741 usePopoverStoreProps(store, update2, props),
18742 update2,
18743 props
18744 ),
18745 { tag: props.tag }
18746 );
18747 }
18748 function useComboboxStore(props = {}) {
18749 props = useComboboxStoreOptions(props);
18750 const [store, update2] = useStore2(createComboboxStore, props);
18751 return useComboboxStoreProps(store, update2, props);
18752 }
18753
18754 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18755 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
18756 function ComboboxProvider(props = {}) {
18757 const store = useComboboxStore(props);
18758 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18759 }
18760
18761 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18762 var import_remove_accents = __toESM(require_remove_accents(), 1);
18763 var import_compose8 = __toESM(require_compose(), 1);
18764 var import_i18n23 = __toESM(require_i18n(), 1);
18765 var import_element43 = __toESM(require_element(), 1);
18766 var import_components19 = __toESM(require_components(), 1);
18767
18768 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18769 var EMPTY_ARRAY3 = [];
18770 var getCurrentValue = (filterDefinition, currentFilter) => {
18771 if (filterDefinition.singleSelection) {
18772 return currentFilter?.value;
18773 }
18774 if (Array.isArray(currentFilter?.value)) {
18775 return currentFilter.value;
18776 }
18777 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18778 return [currentFilter.value];
18779 }
18780 return EMPTY_ARRAY3;
18781 };
18782
18783 // packages/dataviews/build-module/hooks/use-elements.mjs
18784 var import_element42 = __toESM(require_element(), 1);
18785 var EMPTY_ARRAY4 = [];
18786 function useElements({
18787 elements,
18788 getElements
18789 }) {
18790 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18791 const [records, setRecords] = (0, import_element42.useState)(staticElements);
18792 const [isLoading, setIsLoading] = (0, import_element42.useState)(false);
18793 (0, import_element42.useEffect)(() => {
18794 if (!getElements) {
18795 setRecords(staticElements);
18796 return;
18797 }
18798 let cancelled = false;
18799 setIsLoading(true);
18800 getElements().then((fetchedElements) => {
18801 if (!cancelled) {
18802 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18803 setRecords(dynamicElements);
18804 }
18805 }).catch(() => {
18806 if (!cancelled) {
18807 setRecords(staticElements);
18808 }
18809 }).finally(() => {
18810 if (!cancelled) {
18811 setIsLoading(false);
18812 }
18813 });
18814 return () => {
18815 cancelled = true;
18816 };
18817 }, [getElements, staticElements]);
18818 return {
18819 elements: records,
18820 isLoading
18821 };
18822 }
18823
18824 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18825 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
18826 function normalizeSearchInput(input = "") {
18827 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18828 }
18829 var getNewValue = (filterDefinition, currentFilter, value) => {
18830 if (filterDefinition.singleSelection) {
18831 return value;
18832 }
18833 if (Array.isArray(currentFilter?.value)) {
18834 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18835 }
18836 return [value];
18837 };
18838 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18839 return `${prefix}-${filterElementValue}`;
18840 }
18841 var MultiSelectionOption = ({ selected }) => {
18842 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18843 "span",
18844 {
18845 className: clsx_default(
18846 "dataviews-filters__search-widget-listitem-multi-selection",
18847 { "is-selected": selected }
18848 ),
18849 children: selected && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Icon, { icon: check_default })
18850 }
18851 );
18852 };
18853 var SingleSelectionOption = ({ selected }) => {
18854 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18855 "span",
18856 {
18857 className: clsx_default(
18858 "dataviews-filters__search-widget-listitem-single-selection",
18859 { "is-selected": selected }
18860 )
18861 }
18862 );
18863 };
18864 function ListBox({ view, filter, onChangeView }) {
18865 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
18866 const [activeCompositeId, setActiveCompositeId] = (0, import_element43.useState)(
18867 // When there are one or less operators, the first item is set as active
18868 // (by setting the initial `activeId` to `undefined`).
18869 // With 2 or more operators, the focus is moved on the operators control
18870 // (by setting the initial `activeId` to `null`), meaning that there won't
18871 // be an active item initially. Focus is then managed via the
18872 // `onFocusVisible` callback.
18873 filter.operators?.length === 1 ? void 0 : null
18874 );
18875 const currentFilter = view.filters?.find(
18876 (f2) => f2.field === filter.field
18877 );
18878 const currentValue = getCurrentValue(filter, currentFilter);
18879 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18880 import_components19.Composite,
18881 {
18882 virtualFocus: true,
18883 focusLoop: true,
18884 activeId: activeCompositeId,
18885 setActiveId: setActiveCompositeId,
18886 role: "listbox",
18887 className: "dataviews-filters__search-widget-listbox",
18888 "aria-label": (0, import_i18n23.sprintf)(
18889 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18890 (0, import_i18n23.__)("List of: %1$s"),
18891 filter.name
18892 ),
18893 onFocusVisible: () => {
18894 if (!activeCompositeId && filter.elements.length) {
18895 setActiveCompositeId(
18896 generateFilterElementCompositeItemId(
18897 baseId,
18898 filter.elements[0].value
18899 )
18900 );
18901 }
18902 },
18903 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Composite.Typeahead, {}),
18904 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
18905 import_components19.Composite.Hover,
18906 {
18907 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18908 import_components19.Composite.Item,
18909 {
18910 id: generateFilterElementCompositeItemId(
18911 baseId,
18912 element.value
18913 ),
18914 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18915 "div",
18916 {
18917 "aria-label": element.label,
18918 role: "option",
18919 className: "dataviews-filters__search-widget-listitem"
18920 }
18921 ),
18922 onClick: () => {
18923 const newFilters = currentFilter ? [
18924 ...(view.filters ?? []).map(
18925 (_filter) => {
18926 if (_filter.field === filter.field) {
18927 return {
18928 ..._filter,
18929 operator: currentFilter.operator || filter.operators[0],
18930 value: getNewValue(
18931 filter,
18932 currentFilter,
18933 element.value
18934 )
18935 };
18936 }
18937 return _filter;
18938 }
18939 )
18940 ] : [
18941 ...view.filters ?? [],
18942 {
18943 field: filter.field,
18944 operator: filter.operators[0],
18945 value: getNewValue(
18946 filter,
18947 currentFilter,
18948 element.value
18949 )
18950 }
18951 ];
18952 onChangeView({
18953 ...view,
18954 page: 1,
18955 filters: newFilters
18956 });
18957 }
18958 }
18959 ),
18960 children: [
18961 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18962 SingleSelectionOption,
18963 {
18964 selected: currentValue === element.value
18965 }
18966 ),
18967 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18968 MultiSelectionOption,
18969 {
18970 selected: currentValue.includes(element.value)
18971 }
18972 ),
18973 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18974 "span",
18975 {
18976 className: "dataviews-filters__search-widget-listitem-value",
18977 title: element.label,
18978 children: element.label
18979 }
18980 )
18981 ]
18982 },
18983 element.value
18984 ))
18985 }
18986 );
18987 }
18988 function ComboboxList22({ view, filter, onChangeView }) {
18989 const [searchValue, setSearchValue] = (0, import_element43.useState)("");
18990 const deferredSearchValue = (0, import_element43.useDeferredValue)(searchValue);
18991 const currentFilter = view.filters?.find(
18992 (_filter) => _filter.field === filter.field
18993 );
18994 const currentValue = getCurrentValue(filter, currentFilter);
18995 const matches = (0, import_element43.useMemo)(() => {
18996 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
18997 return filter.elements.filter(
18998 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
18999 );
19000 }, [filter.elements, deferredSearchValue]);
19001 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19002 ComboboxProvider,
19003 {
19004 selectedValue: currentValue,
19005 setSelectedValue: (value) => {
19006 const newFilters = currentFilter ? [
19007 ...(view.filters ?? []).map((_filter) => {
19008 if (_filter.field === filter.field) {
19009 return {
19010 ..._filter,
19011 operator: currentFilter.operator || filter.operators[0],
19012 value
19013 };
19014 }
19015 return _filter;
19016 })
19017 ] : [
19018 ...view.filters ?? [],
19019 {
19020 field: filter.field,
19021 operator: filter.operators[0],
19022 value
19023 }
19024 ];
19025 onChangeView({
19026 ...view,
19027 page: 1,
19028 filters: newFilters
19029 });
19030 },
19031 setValue: setSearchValue,
19032 children: [
19033 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
19034 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
19035 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19036 Combobox,
19037 {
19038 autoSelect: "always",
19039 placeholder: (0, import_i18n23.__)("Search"),
19040 className: "dataviews-filters__search-widget-filter-combobox__input"
19041 }
19042 ),
19043 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Icon, { icon: search_default }) })
19044 ] }),
19045 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19046 ComboboxList,
19047 {
19048 className: "dataviews-filters__search-widget-filter-combobox-list",
19049 alwaysVisible: true,
19050 children: [
19051 matches.map((element) => {
19052 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19053 ComboboxItem,
19054 {
19055 resetValueOnSelect: false,
19056 value: element.value,
19057 className: "dataviews-filters__search-widget-listitem",
19058 hideOnClick: false,
19059 setValueOnClick: false,
19060 focusOnHover: true,
19061 children: [
19062 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19063 SingleSelectionOption,
19064 {
19065 selected: currentValue === element.value
19066 }
19067 ),
19068 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19069 MultiSelectionOption,
19070 {
19071 selected: currentValue.includes(
19072 element.value
19073 )
19074 }
19075 ),
19076 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
19077 "span",
19078 {
19079 className: "dataviews-filters__search-widget-listitem-value",
19080 title: element.label,
19081 children: [
19082 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
19083 ComboboxItemValue,
19084 {
19085 className: "dataviews-filters__search-widget-filter-combobox-item-value",
19086 value: element.label
19087 }
19088 ),
19089 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
19090 ]
19091 }
19092 )
19093 ]
19094 },
19095 element.value
19096 );
19097 }),
19098 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
19099 ]
19100 }
19101 )
19102 ]
19103 }
19104 );
19105 }
19106 function SearchWidget(props) {
19107 const { elements, isLoading } = useElements({
19108 elements: props.filter.elements,
19109 getElements: props.filter.getElements
19110 });
19111 if (isLoading) {
19112 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components19.Spinner, {}) });
19113 }
19114 if (elements.length === 0) {
19115 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
19116 }
19117 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
19118 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
19119 }
19120
19121 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
19122 var import_es6 = __toESM(require_es6(), 1);
19123 var import_compose9 = __toESM(require_compose(), 1);
19124 var import_element44 = __toESM(require_element(), 1);
19125 var import_components20 = __toESM(require_components(), 1);
19126 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
19127 function InputWidget({
19128 filter,
19129 view,
19130 onChangeView,
19131 fields
19132 }) {
19133 const currentFilter = view.filters?.find(
19134 (f2) => f2.field === filter.field
19135 );
19136 const currentValue = getCurrentValue(filter, currentFilter);
19137 const field = (0, import_element44.useMemo)(() => {
19138 const currentField = fields.find((f2) => f2.id === filter.field);
19139 if (currentField) {
19140 return {
19141 ...currentField,
19142 // Deactivate validation for filters.
19143 isValid: {},
19144 // Filter controls are always enabled.
19145 isDisabled: () => false,
19146 // Filter controls are always visible.
19147 isVisible: () => true,
19148 // Configure getValue/setValue as if Item was a plain object.
19149 getValue: ({ item }) => item[currentField.id],
19150 setValue: ({ value }) => ({
19151 [currentField.id]: value
19152 })
19153 };
19154 }
19155 return currentField;
19156 }, [fields, filter.field]);
19157 const data = (0, import_element44.useMemo)(() => {
19158 return (view.filters ?? []).reduce(
19159 (acc, activeFilter) => {
19160 acc[activeFilter.field] = activeFilter.value;
19161 return acc;
19162 },
19163 {}
19164 );
19165 }, [view.filters]);
19166 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
19167 if (!field || !currentFilter) {
19168 return;
19169 }
19170 const nextValue = field.getValue({ item: updatedData });
19171 if ((0, import_es6.default)(nextValue, currentValue)) {
19172 return;
19173 }
19174 onChangeView({
19175 ...view,
19176 filters: (view.filters ?? []).map(
19177 (_filter) => _filter.field === filter.field ? {
19178 ..._filter,
19179 operator: currentFilter.operator || filter.operators[0],
19180 // Consider empty strings as undefined:
19181 //
19182 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
19183 // - empty string as value means "search empty string": returns only the records that have an empty string as value
19184 //
19185 // In practice, this means the filter will not be able to find an empty string as the value.
19186 value: nextValue === "" ? void 0 : nextValue
19187 } : _filter
19188 )
19189 });
19190 });
19191 if (!field || !field.Edit || !currentFilter) {
19192 return null;
19193 }
19194 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
19195 import_components20.Flex,
19196 {
19197 className: "dataviews-filters__user-input-widget",
19198 gap: 2.5,
19199 direction: "column",
19200 children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
19201 field.Edit,
19202 {
19203 hideLabelFromVision: true,
19204 data,
19205 field,
19206 operator: currentFilter.operator,
19207 onChange: handleChange
19208 }
19209 )
19210 }
19211 );
19212 }
19213
19214 // node_modules/date-fns/constants.js
19215 var daysInYear = 365.2425;
19216 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
19217 var minTime = -maxTime;
19218 var millisecondsInWeek = 6048e5;
19219 var millisecondsInDay = 864e5;
19220 var secondsInHour = 3600;
19221 var secondsInDay = secondsInHour * 24;
19222 var secondsInWeek = secondsInDay * 7;
19223 var secondsInYear = secondsInDay * daysInYear;
19224 var secondsInMonth = secondsInYear / 12;
19225 var secondsInQuarter = secondsInMonth * 3;
19226 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
19227
19228 // node_modules/date-fns/constructFrom.js
19229 function constructFrom(date, value) {
19230 if (typeof date === "function") return date(value);
19231 if (date && typeof date === "object" && constructFromSymbol in date)
19232 return date[constructFromSymbol](value);
19233 if (date instanceof Date) return new date.constructor(value);
19234 return new Date(value);
19235 }
19236
19237 // node_modules/date-fns/toDate.js
19238 function toDate(argument, context) {
19239 return constructFrom(context || argument, argument);
19240 }
19241
19242 // node_modules/date-fns/addDays.js
19243 function addDays(date, amount, options) {
19244 const _date = toDate(date, options?.in);
19245 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19246 if (!amount) return _date;
19247 _date.setDate(_date.getDate() + amount);
19248 return _date;
19249 }
19250
19251 // node_modules/date-fns/addMonths.js
19252 function addMonths(date, amount, options) {
19253 const _date = toDate(date, options?.in);
19254 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
19255 if (!amount) {
19256 return _date;
19257 }
19258 const dayOfMonth = _date.getDate();
19259 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
19260 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
19261 const daysInMonth = endOfDesiredMonth.getDate();
19262 if (dayOfMonth >= daysInMonth) {
19263 return endOfDesiredMonth;
19264 } else {
19265 _date.setFullYear(
19266 endOfDesiredMonth.getFullYear(),
19267 endOfDesiredMonth.getMonth(),
19268 dayOfMonth
19269 );
19270 return _date;
19271 }
19272 }
19273
19274 // node_modules/date-fns/_lib/defaultOptions.js
19275 var defaultOptions = {};
19276 function getDefaultOptions() {
19277 return defaultOptions;
19278 }
19279
19280 // node_modules/date-fns/startOfWeek.js
19281 function startOfWeek(date, options) {
19282 const defaultOptions2 = getDefaultOptions();
19283 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
19284 const _date = toDate(date, options?.in);
19285 const day = _date.getDay();
19286 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
19287 _date.setDate(_date.getDate() - diff);
19288 _date.setHours(0, 0, 0, 0);
19289 return _date;
19290 }
19291
19292 // node_modules/date-fns/startOfISOWeek.js
19293 function startOfISOWeek(date, options) {
19294 return startOfWeek(date, { ...options, weekStartsOn: 1 });
19295 }
19296
19297 // node_modules/date-fns/getISOWeekYear.js
19298 function getISOWeekYear(date, options) {
19299 const _date = toDate(date, options?.in);
19300 const year = _date.getFullYear();
19301 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
19302 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
19303 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
19304 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
19305 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
19306 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
19307 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
19308 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
19309 if (_date.getTime() >= startOfNextYear.getTime()) {
19310 return year + 1;
19311 } else if (_date.getTime() >= startOfThisYear.getTime()) {
19312 return year;
19313 } else {
19314 return year - 1;
19315 }
19316 }
19317
19318 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
19319 function getTimezoneOffsetInMilliseconds(date) {
19320 const _date = toDate(date);
19321 const utcDate = new Date(
19322 Date.UTC(
19323 _date.getFullYear(),
19324 _date.getMonth(),
19325 _date.getDate(),
19326 _date.getHours(),
19327 _date.getMinutes(),
19328 _date.getSeconds(),
19329 _date.getMilliseconds()
19330 )
19331 );
19332 utcDate.setUTCFullYear(_date.getFullYear());
19333 return +date - +utcDate;
19334 }
19335
19336 // node_modules/date-fns/_lib/normalizeDates.js
19337 function normalizeDates(context, ...dates) {
19338 const normalize = constructFrom.bind(
19339 null,
19340 context || dates.find((date) => typeof date === "object")
19341 );
19342 return dates.map(normalize);
19343 }
19344
19345 // node_modules/date-fns/startOfDay.js
19346 function startOfDay(date, options) {
19347 const _date = toDate(date, options?.in);
19348 _date.setHours(0, 0, 0, 0);
19349 return _date;
19350 }
19351
19352 // node_modules/date-fns/differenceInCalendarDays.js
19353 function differenceInCalendarDays(laterDate, earlierDate, options) {
19354 const [laterDate_, earlierDate_] = normalizeDates(
19355 options?.in,
19356 laterDate,
19357 earlierDate
19358 );
19359 const laterStartOfDay = startOfDay(laterDate_);
19360 const earlierStartOfDay = startOfDay(earlierDate_);
19361 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
19362 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
19363 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
19364 }
19365
19366 // node_modules/date-fns/startOfISOWeekYear.js
19367 function startOfISOWeekYear(date, options) {
19368 const year = getISOWeekYear(date, options);
19369 const fourthOfJanuary = constructFrom(options?.in || date, 0);
19370 fourthOfJanuary.setFullYear(year, 0, 4);
19371 fourthOfJanuary.setHours(0, 0, 0, 0);
19372 return startOfISOWeek(fourthOfJanuary);
19373 }
19374
19375 // node_modules/date-fns/addWeeks.js
19376 function addWeeks(date, amount, options) {
19377 return addDays(date, amount * 7, options);
19378 }
19379
19380 // node_modules/date-fns/addYears.js
19381 function addYears(date, amount, options) {
19382 return addMonths(date, amount * 12, options);
19383 }
19384
19385 // node_modules/date-fns/isDate.js
19386 function isDate(value) {
19387 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
19388 }
19389
19390 // node_modules/date-fns/isValid.js
19391 function isValid(date) {
19392 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
19393 }
19394
19395 // node_modules/date-fns/startOfMonth.js
19396 function startOfMonth(date, options) {
19397 const _date = toDate(date, options?.in);
19398 _date.setDate(1);
19399 _date.setHours(0, 0, 0, 0);
19400 return _date;
19401 }
19402
19403 // node_modules/date-fns/startOfYear.js
19404 function startOfYear(date, options) {
19405 const date_ = toDate(date, options?.in);
19406 date_.setFullYear(date_.getFullYear(), 0, 1);
19407 date_.setHours(0, 0, 0, 0);
19408 return date_;
19409 }
19410
19411 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
19412 var formatDistanceLocale = {
19413 lessThanXSeconds: {
19414 one: "less than a second",
19415 other: "less than {{count}} seconds"
19416 },
19417 xSeconds: {
19418 one: "1 second",
19419 other: "{{count}} seconds"
19420 },
19421 halfAMinute: "half a minute",
19422 lessThanXMinutes: {
19423 one: "less than a minute",
19424 other: "less than {{count}} minutes"
19425 },
19426 xMinutes: {
19427 one: "1 minute",
19428 other: "{{count}} minutes"
19429 },
19430 aboutXHours: {
19431 one: "about 1 hour",
19432 other: "about {{count}} hours"
19433 },
19434 xHours: {
19435 one: "1 hour",
19436 other: "{{count}} hours"
19437 },
19438 xDays: {
19439 one: "1 day",
19440 other: "{{count}} days"
19441 },
19442 aboutXWeeks: {
19443 one: "about 1 week",
19444 other: "about {{count}} weeks"
19445 },
19446 xWeeks: {
19447 one: "1 week",
19448 other: "{{count}} weeks"
19449 },
19450 aboutXMonths: {
19451 one: "about 1 month",
19452 other: "about {{count}} months"
19453 },
19454 xMonths: {
19455 one: "1 month",
19456 other: "{{count}} months"
19457 },
19458 aboutXYears: {
19459 one: "about 1 year",
19460 other: "about {{count}} years"
19461 },
19462 xYears: {
19463 one: "1 year",
19464 other: "{{count}} years"
19465 },
19466 overXYears: {
19467 one: "over 1 year",
19468 other: "over {{count}} years"
19469 },
19470 almostXYears: {
19471 one: "almost 1 year",
19472 other: "almost {{count}} years"
19473 }
19474 };
19475 var formatDistance = (token, count, options) => {
19476 let result;
19477 const tokenValue = formatDistanceLocale[token];
19478 if (typeof tokenValue === "string") {
19479 result = tokenValue;
19480 } else if (count === 1) {
19481 result = tokenValue.one;
19482 } else {
19483 result = tokenValue.other.replace("{{count}}", count.toString());
19484 }
19485 if (options?.addSuffix) {
19486 if (options.comparison && options.comparison > 0) {
19487 return "in " + result;
19488 } else {
19489 return result + " ago";
19490 }
19491 }
19492 return result;
19493 };
19494
19495 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19496 function buildFormatLongFn(args) {
19497 return (options = {}) => {
19498 const width = options.width ? String(options.width) : args.defaultWidth;
19499 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19500 return format6;
19501 };
19502 }
19503
19504 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19505 var dateFormats = {
19506 full: "EEEE, MMMM do, y",
19507 long: "MMMM do, y",
19508 medium: "MMM d, y",
19509 short: "MM/dd/yyyy"
19510 };
19511 var timeFormats = {
19512 full: "h:mm:ss a zzzz",
19513 long: "h:mm:ss a z",
19514 medium: "h:mm:ss a",
19515 short: "h:mm a"
19516 };
19517 var dateTimeFormats = {
19518 full: "{{date}} 'at' {{time}}",
19519 long: "{{date}} 'at' {{time}}",
19520 medium: "{{date}}, {{time}}",
19521 short: "{{date}}, {{time}}"
19522 };
19523 var formatLong = {
19524 date: buildFormatLongFn({
19525 formats: dateFormats,
19526 defaultWidth: "full"
19527 }),
19528 time: buildFormatLongFn({
19529 formats: timeFormats,
19530 defaultWidth: "full"
19531 }),
19532 dateTime: buildFormatLongFn({
19533 formats: dateTimeFormats,
19534 defaultWidth: "full"
19535 })
19536 };
19537
19538 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19539 var formatRelativeLocale = {
19540 lastWeek: "'last' eeee 'at' p",
19541 yesterday: "'yesterday at' p",
19542 today: "'today at' p",
19543 tomorrow: "'tomorrow at' p",
19544 nextWeek: "eeee 'at' p",
19545 other: "P"
19546 };
19547 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19548
19549 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19550 function buildLocalizeFn(args) {
19551 return (value, options) => {
19552 const context = options?.context ? String(options.context) : "standalone";
19553 let valuesArray;
19554 if (context === "formatting" && args.formattingValues) {
19555 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19556 const width = options?.width ? String(options.width) : defaultWidth;
19557 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19558 } else {
19559 const defaultWidth = args.defaultWidth;
19560 const width = options?.width ? String(options.width) : args.defaultWidth;
19561 valuesArray = args.values[width] || args.values[defaultWidth];
19562 }
19563 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19564 return valuesArray[index2];
19565 };
19566 }
19567
19568 // node_modules/date-fns/locale/en-US/_lib/localize.js
19569 var eraValues = {
19570 narrow: ["B", "A"],
19571 abbreviated: ["BC", "AD"],
19572 wide: ["Before Christ", "Anno Domini"]
19573 };
19574 var quarterValues = {
19575 narrow: ["1", "2", "3", "4"],
19576 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19577 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19578 };
19579 var monthValues = {
19580 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19581 abbreviated: [
19582 "Jan",
19583 "Feb",
19584 "Mar",
19585 "Apr",
19586 "May",
19587 "Jun",
19588 "Jul",
19589 "Aug",
19590 "Sep",
19591 "Oct",
19592 "Nov",
19593 "Dec"
19594 ],
19595 wide: [
19596 "January",
19597 "February",
19598 "March",
19599 "April",
19600 "May",
19601 "June",
19602 "July",
19603 "August",
19604 "September",
19605 "October",
19606 "November",
19607 "December"
19608 ]
19609 };
19610 var dayValues = {
19611 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19612 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19613 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19614 wide: [
19615 "Sunday",
19616 "Monday",
19617 "Tuesday",
19618 "Wednesday",
19619 "Thursday",
19620 "Friday",
19621 "Saturday"
19622 ]
19623 };
19624 var dayPeriodValues = {
19625 narrow: {
19626 am: "a",
19627 pm: "p",
19628 midnight: "mi",
19629 noon: "n",
19630 morning: "morning",
19631 afternoon: "afternoon",
19632 evening: "evening",
19633 night: "night"
19634 },
19635 abbreviated: {
19636 am: "AM",
19637 pm: "PM",
19638 midnight: "midnight",
19639 noon: "noon",
19640 morning: "morning",
19641 afternoon: "afternoon",
19642 evening: "evening",
19643 night: "night"
19644 },
19645 wide: {
19646 am: "a.m.",
19647 pm: "p.m.",
19648 midnight: "midnight",
19649 noon: "noon",
19650 morning: "morning",
19651 afternoon: "afternoon",
19652 evening: "evening",
19653 night: "night"
19654 }
19655 };
19656 var formattingDayPeriodValues = {
19657 narrow: {
19658 am: "a",
19659 pm: "p",
19660 midnight: "mi",
19661 noon: "n",
19662 morning: "in the morning",
19663 afternoon: "in the afternoon",
19664 evening: "in the evening",
19665 night: "at night"
19666 },
19667 abbreviated: {
19668 am: "AM",
19669 pm: "PM",
19670 midnight: "midnight",
19671 noon: "noon",
19672 morning: "in the morning",
19673 afternoon: "in the afternoon",
19674 evening: "in the evening",
19675 night: "at night"
19676 },
19677 wide: {
19678 am: "a.m.",
19679 pm: "p.m.",
19680 midnight: "midnight",
19681 noon: "noon",
19682 morning: "in the morning",
19683 afternoon: "in the afternoon",
19684 evening: "in the evening",
19685 night: "at night"
19686 }
19687 };
19688 var ordinalNumber = (dirtyNumber, _options) => {
19689 const number = Number(dirtyNumber);
19690 const rem100 = number % 100;
19691 if (rem100 > 20 || rem100 < 10) {
19692 switch (rem100 % 10) {
19693 case 1:
19694 return number + "st";
19695 case 2:
19696 return number + "nd";
19697 case 3:
19698 return number + "rd";
19699 }
19700 }
19701 return number + "th";
19702 };
19703 var localize = {
19704 ordinalNumber,
19705 era: buildLocalizeFn({
19706 values: eraValues,
19707 defaultWidth: "wide"
19708 }),
19709 quarter: buildLocalizeFn({
19710 values: quarterValues,
19711 defaultWidth: "wide",
19712 argumentCallback: (quarter) => quarter - 1
19713 }),
19714 month: buildLocalizeFn({
19715 values: monthValues,
19716 defaultWidth: "wide"
19717 }),
19718 day: buildLocalizeFn({
19719 values: dayValues,
19720 defaultWidth: "wide"
19721 }),
19722 dayPeriod: buildLocalizeFn({
19723 values: dayPeriodValues,
19724 defaultWidth: "wide",
19725 formattingValues: formattingDayPeriodValues,
19726 defaultFormattingWidth: "wide"
19727 })
19728 };
19729
19730 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19731 function buildMatchFn(args) {
19732 return (string, options = {}) => {
19733 const width = options.width;
19734 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19735 const matchResult = string.match(matchPattern);
19736 if (!matchResult) {
19737 return null;
19738 }
19739 const matchedString = matchResult[0];
19740 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19741 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19742 // [TODO] -- I challenge you to fix the type
19743 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19744 );
19745 let value;
19746 value = args.valueCallback ? args.valueCallback(key) : key;
19747 value = options.valueCallback ? (
19748 // [TODO] -- I challenge you to fix the type
19749 options.valueCallback(value)
19750 ) : value;
19751 const rest = string.slice(matchedString.length);
19752 return { value, rest };
19753 };
19754 }
19755 function findKey(object, predicate) {
19756 for (const key in object) {
19757 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19758 return key;
19759 }
19760 }
19761 return void 0;
19762 }
19763 function findIndex(array, predicate) {
19764 for (let key = 0; key < array.length; key++) {
19765 if (predicate(array[key])) {
19766 return key;
19767 }
19768 }
19769 return void 0;
19770 }
19771
19772 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19773 function buildMatchPatternFn(args) {
19774 return (string, options = {}) => {
19775 const matchResult = string.match(args.matchPattern);
19776 if (!matchResult) return null;
19777 const matchedString = matchResult[0];
19778 const parseResult = string.match(args.parsePattern);
19779 if (!parseResult) return null;
19780 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19781 value = options.valueCallback ? options.valueCallback(value) : value;
19782 const rest = string.slice(matchedString.length);
19783 return { value, rest };
19784 };
19785 }
19786
19787 // node_modules/date-fns/locale/en-US/_lib/match.js
19788 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19789 var parseOrdinalNumberPattern = /\d+/i;
19790 var matchEraPatterns = {
19791 narrow: /^(b|a)/i,
19792 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19793 wide: /^(before christ|before common era|anno domini|common era)/i
19794 };
19795 var parseEraPatterns = {
19796 any: [/^b/i, /^(a|c)/i]
19797 };
19798 var matchQuarterPatterns = {
19799 narrow: /^[1234]/i,
19800 abbreviated: /^q[1234]/i,
19801 wide: /^[1234](th|st|nd|rd)? quarter/i
19802 };
19803 var parseQuarterPatterns = {
19804 any: [/1/i, /2/i, /3/i, /4/i]
19805 };
19806 var matchMonthPatterns = {
19807 narrow: /^[jfmasond]/i,
19808 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19809 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19810 };
19811 var parseMonthPatterns = {
19812 narrow: [
19813 /^j/i,
19814 /^f/i,
19815 /^m/i,
19816 /^a/i,
19817 /^m/i,
19818 /^j/i,
19819 /^j/i,
19820 /^a/i,
19821 /^s/i,
19822 /^o/i,
19823 /^n/i,
19824 /^d/i
19825 ],
19826 any: [
19827 /^ja/i,
19828 /^f/i,
19829 /^mar/i,
19830 /^ap/i,
19831 /^may/i,
19832 /^jun/i,
19833 /^jul/i,
19834 /^au/i,
19835 /^s/i,
19836 /^o/i,
19837 /^n/i,
19838 /^d/i
19839 ]
19840 };
19841 var matchDayPatterns = {
19842 narrow: /^[smtwf]/i,
19843 short: /^(su|mo|tu|we|th|fr|sa)/i,
19844 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19845 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19846 };
19847 var parseDayPatterns = {
19848 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19849 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19850 };
19851 var matchDayPeriodPatterns = {
19852 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19853 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19854 };
19855 var parseDayPeriodPatterns = {
19856 any: {
19857 am: /^a/i,
19858 pm: /^p/i,
19859 midnight: /^mi/i,
19860 noon: /^no/i,
19861 morning: /morning/i,
19862 afternoon: /afternoon/i,
19863 evening: /evening/i,
19864 night: /night/i
19865 }
19866 };
19867 var match = {
19868 ordinalNumber: buildMatchPatternFn({
19869 matchPattern: matchOrdinalNumberPattern,
19870 parsePattern: parseOrdinalNumberPattern,
19871 valueCallback: (value) => parseInt(value, 10)
19872 }),
19873 era: buildMatchFn({
19874 matchPatterns: matchEraPatterns,
19875 defaultMatchWidth: "wide",
19876 parsePatterns: parseEraPatterns,
19877 defaultParseWidth: "any"
19878 }),
19879 quarter: buildMatchFn({
19880 matchPatterns: matchQuarterPatterns,
19881 defaultMatchWidth: "wide",
19882 parsePatterns: parseQuarterPatterns,
19883 defaultParseWidth: "any",
19884 valueCallback: (index2) => index2 + 1
19885 }),
19886 month: buildMatchFn({
19887 matchPatterns: matchMonthPatterns,
19888 defaultMatchWidth: "wide",
19889 parsePatterns: parseMonthPatterns,
19890 defaultParseWidth: "any"
19891 }),
19892 day: buildMatchFn({
19893 matchPatterns: matchDayPatterns,
19894 defaultMatchWidth: "wide",
19895 parsePatterns: parseDayPatterns,
19896 defaultParseWidth: "any"
19897 }),
19898 dayPeriod: buildMatchFn({
19899 matchPatterns: matchDayPeriodPatterns,
19900 defaultMatchWidth: "any",
19901 parsePatterns: parseDayPeriodPatterns,
19902 defaultParseWidth: "any"
19903 })
19904 };
19905
19906 // node_modules/date-fns/locale/en-US.js
19907 var enUS = {
19908 code: "en-US",
19909 formatDistance,
19910 formatLong,
19911 formatRelative,
19912 localize,
19913 match,
19914 options: {
19915 weekStartsOn: 0,
19916 firstWeekContainsDate: 1
19917 }
19918 };
19919
19920 // node_modules/date-fns/getDayOfYear.js
19921 function getDayOfYear(date, options) {
19922 const _date = toDate(date, options?.in);
19923 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19924 const dayOfYear = diff + 1;
19925 return dayOfYear;
19926 }
19927
19928 // node_modules/date-fns/getISOWeek.js
19929 function getISOWeek(date, options) {
19930 const _date = toDate(date, options?.in);
19931 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19932 return Math.round(diff / millisecondsInWeek) + 1;
19933 }
19934
19935 // node_modules/date-fns/getWeekYear.js
19936 function getWeekYear(date, options) {
19937 const _date = toDate(date, options?.in);
19938 const year = _date.getFullYear();
19939 const defaultOptions2 = getDefaultOptions();
19940 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19941 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19942 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19943 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19944 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19945 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19946 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19947 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19948 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19949 if (+_date >= +startOfNextYear) {
19950 return year + 1;
19951 } else if (+_date >= +startOfThisYear) {
19952 return year;
19953 } else {
19954 return year - 1;
19955 }
19956 }
19957
19958 // node_modules/date-fns/startOfWeekYear.js
19959 function startOfWeekYear(date, options) {
19960 const defaultOptions2 = getDefaultOptions();
19961 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19962 const year = getWeekYear(date, options);
19963 const firstWeek = constructFrom(options?.in || date, 0);
19964 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19965 firstWeek.setHours(0, 0, 0, 0);
19966 const _date = startOfWeek(firstWeek, options);
19967 return _date;
19968 }
19969
19970 // node_modules/date-fns/getWeek.js
19971 function getWeek(date, options) {
19972 const _date = toDate(date, options?.in);
19973 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19974 return Math.round(diff / millisecondsInWeek) + 1;
19975 }
19976
19977 // node_modules/date-fns/_lib/addLeadingZeros.js
19978 function addLeadingZeros(number, targetLength) {
19979 const sign = number < 0 ? "-" : "";
19980 const output = Math.abs(number).toString().padStart(targetLength, "0");
19981 return sign + output;
19982 }
19983
19984 // node_modules/date-fns/_lib/format/lightFormatters.js
19985 var lightFormatters = {
19986 // Year
19987 y(date, token) {
19988 const signedYear = date.getFullYear();
19989 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19990 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
19991 },
19992 // Month
19993 M(date, token) {
19994 const month = date.getMonth();
19995 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
19996 },
19997 // Day of the month
19998 d(date, token) {
19999 return addLeadingZeros(date.getDate(), token.length);
20000 },
20001 // AM or PM
20002 a(date, token) {
20003 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
20004 switch (token) {
20005 case "a":
20006 case "aa":
20007 return dayPeriodEnumValue.toUpperCase();
20008 case "aaa":
20009 return dayPeriodEnumValue;
20010 case "aaaaa":
20011 return dayPeriodEnumValue[0];
20012 case "aaaa":
20013 default:
20014 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
20015 }
20016 },
20017 // Hour [1-12]
20018 h(date, token) {
20019 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
20020 },
20021 // Hour [0-23]
20022 H(date, token) {
20023 return addLeadingZeros(date.getHours(), token.length);
20024 },
20025 // Minute
20026 m(date, token) {
20027 return addLeadingZeros(date.getMinutes(), token.length);
20028 },
20029 // Second
20030 s(date, token) {
20031 return addLeadingZeros(date.getSeconds(), token.length);
20032 },
20033 // Fraction of second
20034 S(date, token) {
20035 const numberOfDigits = token.length;
20036 const milliseconds = date.getMilliseconds();
20037 const fractionalSeconds = Math.trunc(
20038 milliseconds * Math.pow(10, numberOfDigits - 3)
20039 );
20040 return addLeadingZeros(fractionalSeconds, token.length);
20041 }
20042 };
20043
20044 // node_modules/date-fns/_lib/format/formatters.js
20045 var dayPeriodEnum = {
20046 am: "am",
20047 pm: "pm",
20048 midnight: "midnight",
20049 noon: "noon",
20050 morning: "morning",
20051 afternoon: "afternoon",
20052 evening: "evening",
20053 night: "night"
20054 };
20055 var formatters = {
20056 // Era
20057 G: function(date, token, localize2) {
20058 const era = date.getFullYear() > 0 ? 1 : 0;
20059 switch (token) {
20060 // AD, BC
20061 case "G":
20062 case "GG":
20063 case "GGG":
20064 return localize2.era(era, { width: "abbreviated" });
20065 // A, B
20066 case "GGGGG":
20067 return localize2.era(era, { width: "narrow" });
20068 // Anno Domini, Before Christ
20069 case "GGGG":
20070 default:
20071 return localize2.era(era, { width: "wide" });
20072 }
20073 },
20074 // Year
20075 y: function(date, token, localize2) {
20076 if (token === "yo") {
20077 const signedYear = date.getFullYear();
20078 const year = signedYear > 0 ? signedYear : 1 - signedYear;
20079 return localize2.ordinalNumber(year, { unit: "year" });
20080 }
20081 return lightFormatters.y(date, token);
20082 },
20083 // Local week-numbering year
20084 Y: function(date, token, localize2, options) {
20085 const signedWeekYear = getWeekYear(date, options);
20086 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
20087 if (token === "YY") {
20088 const twoDigitYear = weekYear % 100;
20089 return addLeadingZeros(twoDigitYear, 2);
20090 }
20091 if (token === "Yo") {
20092 return localize2.ordinalNumber(weekYear, { unit: "year" });
20093 }
20094 return addLeadingZeros(weekYear, token.length);
20095 },
20096 // ISO week-numbering year
20097 R: function(date, token) {
20098 const isoWeekYear = getISOWeekYear(date);
20099 return addLeadingZeros(isoWeekYear, token.length);
20100 },
20101 // Extended year. This is a single number designating the year of this calendar system.
20102 // The main difference between `y` and `u` localizers are B.C. years:
20103 // | Year | `y` | `u` |
20104 // |------|-----|-----|
20105 // | AC 1 | 1 | 1 |
20106 // | BC 1 | 1 | 0 |
20107 // | BC 2 | 2 | -1 |
20108 // Also `yy` always returns the last two digits of a year,
20109 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
20110 u: function(date, token) {
20111 const year = date.getFullYear();
20112 return addLeadingZeros(year, token.length);
20113 },
20114 // Quarter
20115 Q: function(date, token, localize2) {
20116 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20117 switch (token) {
20118 // 1, 2, 3, 4
20119 case "Q":
20120 return String(quarter);
20121 // 01, 02, 03, 04
20122 case "QQ":
20123 return addLeadingZeros(quarter, 2);
20124 // 1st, 2nd, 3rd, 4th
20125 case "Qo":
20126 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20127 // Q1, Q2, Q3, Q4
20128 case "QQQ":
20129 return localize2.quarter(quarter, {
20130 width: "abbreviated",
20131 context: "formatting"
20132 });
20133 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20134 case "QQQQQ":
20135 return localize2.quarter(quarter, {
20136 width: "narrow",
20137 context: "formatting"
20138 });
20139 // 1st quarter, 2nd quarter, ...
20140 case "QQQQ":
20141 default:
20142 return localize2.quarter(quarter, {
20143 width: "wide",
20144 context: "formatting"
20145 });
20146 }
20147 },
20148 // Stand-alone quarter
20149 q: function(date, token, localize2) {
20150 const quarter = Math.ceil((date.getMonth() + 1) / 3);
20151 switch (token) {
20152 // 1, 2, 3, 4
20153 case "q":
20154 return String(quarter);
20155 // 01, 02, 03, 04
20156 case "qq":
20157 return addLeadingZeros(quarter, 2);
20158 // 1st, 2nd, 3rd, 4th
20159 case "qo":
20160 return localize2.ordinalNumber(quarter, { unit: "quarter" });
20161 // Q1, Q2, Q3, Q4
20162 case "qqq":
20163 return localize2.quarter(quarter, {
20164 width: "abbreviated",
20165 context: "standalone"
20166 });
20167 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
20168 case "qqqqq":
20169 return localize2.quarter(quarter, {
20170 width: "narrow",
20171 context: "standalone"
20172 });
20173 // 1st quarter, 2nd quarter, ...
20174 case "qqqq":
20175 default:
20176 return localize2.quarter(quarter, {
20177 width: "wide",
20178 context: "standalone"
20179 });
20180 }
20181 },
20182 // Month
20183 M: function(date, token, localize2) {
20184 const month = date.getMonth();
20185 switch (token) {
20186 case "M":
20187 case "MM":
20188 return lightFormatters.M(date, token);
20189 // 1st, 2nd, ..., 12th
20190 case "Mo":
20191 return localize2.ordinalNumber(month + 1, { unit: "month" });
20192 // Jan, Feb, ..., Dec
20193 case "MMM":
20194 return localize2.month(month, {
20195 width: "abbreviated",
20196 context: "formatting"
20197 });
20198 // J, F, ..., D
20199 case "MMMMM":
20200 return localize2.month(month, {
20201 width: "narrow",
20202 context: "formatting"
20203 });
20204 // January, February, ..., December
20205 case "MMMM":
20206 default:
20207 return localize2.month(month, { width: "wide", context: "formatting" });
20208 }
20209 },
20210 // Stand-alone month
20211 L: function(date, token, localize2) {
20212 const month = date.getMonth();
20213 switch (token) {
20214 // 1, 2, ..., 12
20215 case "L":
20216 return String(month + 1);
20217 // 01, 02, ..., 12
20218 case "LL":
20219 return addLeadingZeros(month + 1, 2);
20220 // 1st, 2nd, ..., 12th
20221 case "Lo":
20222 return localize2.ordinalNumber(month + 1, { unit: "month" });
20223 // Jan, Feb, ..., Dec
20224 case "LLL":
20225 return localize2.month(month, {
20226 width: "abbreviated",
20227 context: "standalone"
20228 });
20229 // J, F, ..., D
20230 case "LLLLL":
20231 return localize2.month(month, {
20232 width: "narrow",
20233 context: "standalone"
20234 });
20235 // January, February, ..., December
20236 case "LLLL":
20237 default:
20238 return localize2.month(month, { width: "wide", context: "standalone" });
20239 }
20240 },
20241 // Local week of year
20242 w: function(date, token, localize2, options) {
20243 const week = getWeek(date, options);
20244 if (token === "wo") {
20245 return localize2.ordinalNumber(week, { unit: "week" });
20246 }
20247 return addLeadingZeros(week, token.length);
20248 },
20249 // ISO week of year
20250 I: function(date, token, localize2) {
20251 const isoWeek = getISOWeek(date);
20252 if (token === "Io") {
20253 return localize2.ordinalNumber(isoWeek, { unit: "week" });
20254 }
20255 return addLeadingZeros(isoWeek, token.length);
20256 },
20257 // Day of the month
20258 d: function(date, token, localize2) {
20259 if (token === "do") {
20260 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
20261 }
20262 return lightFormatters.d(date, token);
20263 },
20264 // Day of year
20265 D: function(date, token, localize2) {
20266 const dayOfYear = getDayOfYear(date);
20267 if (token === "Do") {
20268 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
20269 }
20270 return addLeadingZeros(dayOfYear, token.length);
20271 },
20272 // Day of week
20273 E: function(date, token, localize2) {
20274 const dayOfWeek = date.getDay();
20275 switch (token) {
20276 // Tue
20277 case "E":
20278 case "EE":
20279 case "EEE":
20280 return localize2.day(dayOfWeek, {
20281 width: "abbreviated",
20282 context: "formatting"
20283 });
20284 // T
20285 case "EEEEE":
20286 return localize2.day(dayOfWeek, {
20287 width: "narrow",
20288 context: "formatting"
20289 });
20290 // Tu
20291 case "EEEEEE":
20292 return localize2.day(dayOfWeek, {
20293 width: "short",
20294 context: "formatting"
20295 });
20296 // Tuesday
20297 case "EEEE":
20298 default:
20299 return localize2.day(dayOfWeek, {
20300 width: "wide",
20301 context: "formatting"
20302 });
20303 }
20304 },
20305 // Local day of week
20306 e: function(date, token, localize2, options) {
20307 const dayOfWeek = date.getDay();
20308 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20309 switch (token) {
20310 // Numerical value (Nth day of week with current locale or weekStartsOn)
20311 case "e":
20312 return String(localDayOfWeek);
20313 // Padded numerical value
20314 case "ee":
20315 return addLeadingZeros(localDayOfWeek, 2);
20316 // 1st, 2nd, ..., 7th
20317 case "eo":
20318 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20319 case "eee":
20320 return localize2.day(dayOfWeek, {
20321 width: "abbreviated",
20322 context: "formatting"
20323 });
20324 // T
20325 case "eeeee":
20326 return localize2.day(dayOfWeek, {
20327 width: "narrow",
20328 context: "formatting"
20329 });
20330 // Tu
20331 case "eeeeee":
20332 return localize2.day(dayOfWeek, {
20333 width: "short",
20334 context: "formatting"
20335 });
20336 // Tuesday
20337 case "eeee":
20338 default:
20339 return localize2.day(dayOfWeek, {
20340 width: "wide",
20341 context: "formatting"
20342 });
20343 }
20344 },
20345 // Stand-alone local day of week
20346 c: function(date, token, localize2, options) {
20347 const dayOfWeek = date.getDay();
20348 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
20349 switch (token) {
20350 // Numerical value (same as in `e`)
20351 case "c":
20352 return String(localDayOfWeek);
20353 // Padded numerical value
20354 case "cc":
20355 return addLeadingZeros(localDayOfWeek, token.length);
20356 // 1st, 2nd, ..., 7th
20357 case "co":
20358 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
20359 case "ccc":
20360 return localize2.day(dayOfWeek, {
20361 width: "abbreviated",
20362 context: "standalone"
20363 });
20364 // T
20365 case "ccccc":
20366 return localize2.day(dayOfWeek, {
20367 width: "narrow",
20368 context: "standalone"
20369 });
20370 // Tu
20371 case "cccccc":
20372 return localize2.day(dayOfWeek, {
20373 width: "short",
20374 context: "standalone"
20375 });
20376 // Tuesday
20377 case "cccc":
20378 default:
20379 return localize2.day(dayOfWeek, {
20380 width: "wide",
20381 context: "standalone"
20382 });
20383 }
20384 },
20385 // ISO day of week
20386 i: function(date, token, localize2) {
20387 const dayOfWeek = date.getDay();
20388 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
20389 switch (token) {
20390 // 2
20391 case "i":
20392 return String(isoDayOfWeek);
20393 // 02
20394 case "ii":
20395 return addLeadingZeros(isoDayOfWeek, token.length);
20396 // 2nd
20397 case "io":
20398 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
20399 // Tue
20400 case "iii":
20401 return localize2.day(dayOfWeek, {
20402 width: "abbreviated",
20403 context: "formatting"
20404 });
20405 // T
20406 case "iiiii":
20407 return localize2.day(dayOfWeek, {
20408 width: "narrow",
20409 context: "formatting"
20410 });
20411 // Tu
20412 case "iiiiii":
20413 return localize2.day(dayOfWeek, {
20414 width: "short",
20415 context: "formatting"
20416 });
20417 // Tuesday
20418 case "iiii":
20419 default:
20420 return localize2.day(dayOfWeek, {
20421 width: "wide",
20422 context: "formatting"
20423 });
20424 }
20425 },
20426 // AM or PM
20427 a: function(date, token, localize2) {
20428 const hours = date.getHours();
20429 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20430 switch (token) {
20431 case "a":
20432 case "aa":
20433 return localize2.dayPeriod(dayPeriodEnumValue, {
20434 width: "abbreviated",
20435 context: "formatting"
20436 });
20437 case "aaa":
20438 return localize2.dayPeriod(dayPeriodEnumValue, {
20439 width: "abbreviated",
20440 context: "formatting"
20441 }).toLowerCase();
20442 case "aaaaa":
20443 return localize2.dayPeriod(dayPeriodEnumValue, {
20444 width: "narrow",
20445 context: "formatting"
20446 });
20447 case "aaaa":
20448 default:
20449 return localize2.dayPeriod(dayPeriodEnumValue, {
20450 width: "wide",
20451 context: "formatting"
20452 });
20453 }
20454 },
20455 // AM, PM, midnight, noon
20456 b: function(date, token, localize2) {
20457 const hours = date.getHours();
20458 let dayPeriodEnumValue;
20459 if (hours === 12) {
20460 dayPeriodEnumValue = dayPeriodEnum.noon;
20461 } else if (hours === 0) {
20462 dayPeriodEnumValue = dayPeriodEnum.midnight;
20463 } else {
20464 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20465 }
20466 switch (token) {
20467 case "b":
20468 case "bb":
20469 return localize2.dayPeriod(dayPeriodEnumValue, {
20470 width: "abbreviated",
20471 context: "formatting"
20472 });
20473 case "bbb":
20474 return localize2.dayPeriod(dayPeriodEnumValue, {
20475 width: "abbreviated",
20476 context: "formatting"
20477 }).toLowerCase();
20478 case "bbbbb":
20479 return localize2.dayPeriod(dayPeriodEnumValue, {
20480 width: "narrow",
20481 context: "formatting"
20482 });
20483 case "bbbb":
20484 default:
20485 return localize2.dayPeriod(dayPeriodEnumValue, {
20486 width: "wide",
20487 context: "formatting"
20488 });
20489 }
20490 },
20491 // in the morning, in the afternoon, in the evening, at night
20492 B: function(date, token, localize2) {
20493 const hours = date.getHours();
20494 let dayPeriodEnumValue;
20495 if (hours >= 17) {
20496 dayPeriodEnumValue = dayPeriodEnum.evening;
20497 } else if (hours >= 12) {
20498 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20499 } else if (hours >= 4) {
20500 dayPeriodEnumValue = dayPeriodEnum.morning;
20501 } else {
20502 dayPeriodEnumValue = dayPeriodEnum.night;
20503 }
20504 switch (token) {
20505 case "B":
20506 case "BB":
20507 case "BBB":
20508 return localize2.dayPeriod(dayPeriodEnumValue, {
20509 width: "abbreviated",
20510 context: "formatting"
20511 });
20512 case "BBBBB":
20513 return localize2.dayPeriod(dayPeriodEnumValue, {
20514 width: "narrow",
20515 context: "formatting"
20516 });
20517 case "BBBB":
20518 default:
20519 return localize2.dayPeriod(dayPeriodEnumValue, {
20520 width: "wide",
20521 context: "formatting"
20522 });
20523 }
20524 },
20525 // Hour [1-12]
20526 h: function(date, token, localize2) {
20527 if (token === "ho") {
20528 let hours = date.getHours() % 12;
20529 if (hours === 0) hours = 12;
20530 return localize2.ordinalNumber(hours, { unit: "hour" });
20531 }
20532 return lightFormatters.h(date, token);
20533 },
20534 // Hour [0-23]
20535 H: function(date, token, localize2) {
20536 if (token === "Ho") {
20537 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20538 }
20539 return lightFormatters.H(date, token);
20540 },
20541 // Hour [0-11]
20542 K: function(date, token, localize2) {
20543 const hours = date.getHours() % 12;
20544 if (token === "Ko") {
20545 return localize2.ordinalNumber(hours, { unit: "hour" });
20546 }
20547 return addLeadingZeros(hours, token.length);
20548 },
20549 // Hour [1-24]
20550 k: function(date, token, localize2) {
20551 let hours = date.getHours();
20552 if (hours === 0) hours = 24;
20553 if (token === "ko") {
20554 return localize2.ordinalNumber(hours, { unit: "hour" });
20555 }
20556 return addLeadingZeros(hours, token.length);
20557 },
20558 // Minute
20559 m: function(date, token, localize2) {
20560 if (token === "mo") {
20561 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20562 }
20563 return lightFormatters.m(date, token);
20564 },
20565 // Second
20566 s: function(date, token, localize2) {
20567 if (token === "so") {
20568 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20569 }
20570 return lightFormatters.s(date, token);
20571 },
20572 // Fraction of second
20573 S: function(date, token) {
20574 return lightFormatters.S(date, token);
20575 },
20576 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20577 X: function(date, token, _localize) {
20578 const timezoneOffset = date.getTimezoneOffset();
20579 if (timezoneOffset === 0) {
20580 return "Z";
20581 }
20582 switch (token) {
20583 // Hours and optional minutes
20584 case "X":
20585 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20586 // Hours, minutes and optional seconds without `:` delimiter
20587 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20588 // so this token always has the same output as `XX`
20589 case "XXXX":
20590 case "XX":
20591 return formatTimezone(timezoneOffset);
20592 // Hours, minutes and optional seconds with `:` delimiter
20593 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20594 // so this token always has the same output as `XXX`
20595 case "XXXXX":
20596 case "XXX":
20597 // Hours and minutes with `:` delimiter
20598 default:
20599 return formatTimezone(timezoneOffset, ":");
20600 }
20601 },
20602 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20603 x: function(date, token, _localize) {
20604 const timezoneOffset = date.getTimezoneOffset();
20605 switch (token) {
20606 // Hours and optional minutes
20607 case "x":
20608 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20609 // Hours, minutes and optional seconds without `:` delimiter
20610 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20611 // so this token always has the same output as `xx`
20612 case "xxxx":
20613 case "xx":
20614 return formatTimezone(timezoneOffset);
20615 // Hours, minutes and optional seconds with `:` delimiter
20616 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20617 // so this token always has the same output as `xxx`
20618 case "xxxxx":
20619 case "xxx":
20620 // Hours and minutes with `:` delimiter
20621 default:
20622 return formatTimezone(timezoneOffset, ":");
20623 }
20624 },
20625 // Timezone (GMT)
20626 O: function(date, token, _localize) {
20627 const timezoneOffset = date.getTimezoneOffset();
20628 switch (token) {
20629 // Short
20630 case "O":
20631 case "OO":
20632 case "OOO":
20633 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20634 // Long
20635 case "OOOO":
20636 default:
20637 return "GMT" + formatTimezone(timezoneOffset, ":");
20638 }
20639 },
20640 // Timezone (specific non-location)
20641 z: function(date, token, _localize) {
20642 const timezoneOffset = date.getTimezoneOffset();
20643 switch (token) {
20644 // Short
20645 case "z":
20646 case "zz":
20647 case "zzz":
20648 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20649 // Long
20650 case "zzzz":
20651 default:
20652 return "GMT" + formatTimezone(timezoneOffset, ":");
20653 }
20654 },
20655 // Seconds timestamp
20656 t: function(date, token, _localize) {
20657 const timestamp = Math.trunc(+date / 1e3);
20658 return addLeadingZeros(timestamp, token.length);
20659 },
20660 // Milliseconds timestamp
20661 T: function(date, token, _localize) {
20662 return addLeadingZeros(+date, token.length);
20663 }
20664 };
20665 function formatTimezoneShort(offset4, delimiter = "") {
20666 const sign = offset4 > 0 ? "-" : "+";
20667 const absOffset = Math.abs(offset4);
20668 const hours = Math.trunc(absOffset / 60);
20669 const minutes = absOffset % 60;
20670 if (minutes === 0) {
20671 return sign + String(hours);
20672 }
20673 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20674 }
20675 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20676 if (offset4 % 60 === 0) {
20677 const sign = offset4 > 0 ? "-" : "+";
20678 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20679 }
20680 return formatTimezone(offset4, delimiter);
20681 }
20682 function formatTimezone(offset4, delimiter = "") {
20683 const sign = offset4 > 0 ? "-" : "+";
20684 const absOffset = Math.abs(offset4);
20685 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20686 const minutes = addLeadingZeros(absOffset % 60, 2);
20687 return sign + hours + delimiter + minutes;
20688 }
20689
20690 // node_modules/date-fns/_lib/format/longFormatters.js
20691 var dateLongFormatter = (pattern, formatLong2) => {
20692 switch (pattern) {
20693 case "P":
20694 return formatLong2.date({ width: "short" });
20695 case "PP":
20696 return formatLong2.date({ width: "medium" });
20697 case "PPP":
20698 return formatLong2.date({ width: "long" });
20699 case "PPPP":
20700 default:
20701 return formatLong2.date({ width: "full" });
20702 }
20703 };
20704 var timeLongFormatter = (pattern, formatLong2) => {
20705 switch (pattern) {
20706 case "p":
20707 return formatLong2.time({ width: "short" });
20708 case "pp":
20709 return formatLong2.time({ width: "medium" });
20710 case "ppp":
20711 return formatLong2.time({ width: "long" });
20712 case "pppp":
20713 default:
20714 return formatLong2.time({ width: "full" });
20715 }
20716 };
20717 var dateTimeLongFormatter = (pattern, formatLong2) => {
20718 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20719 const datePattern = matchResult[1];
20720 const timePattern = matchResult[2];
20721 if (!timePattern) {
20722 return dateLongFormatter(pattern, formatLong2);
20723 }
20724 let dateTimeFormat;
20725 switch (datePattern) {
20726 case "P":
20727 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20728 break;
20729 case "PP":
20730 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20731 break;
20732 case "PPP":
20733 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20734 break;
20735 case "PPPP":
20736 default:
20737 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20738 break;
20739 }
20740 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20741 };
20742 var longFormatters = {
20743 p: timeLongFormatter,
20744 P: dateTimeLongFormatter
20745 };
20746
20747 // node_modules/date-fns/_lib/protectedTokens.js
20748 var dayOfYearTokenRE = /^D+$/;
20749 var weekYearTokenRE = /^Y+$/;
20750 var throwTokens = ["D", "DD", "YY", "YYYY"];
20751 function isProtectedDayOfYearToken(token) {
20752 return dayOfYearTokenRE.test(token);
20753 }
20754 function isProtectedWeekYearToken(token) {
20755 return weekYearTokenRE.test(token);
20756 }
20757 function warnOrThrowProtectedError(token, format6, input) {
20758 const _message = message(token, format6, input);
20759 console.warn(_message);
20760 if (throwTokens.includes(token)) throw new RangeError(_message);
20761 }
20762 function message(token, format6, input) {
20763 const subject = token[0] === "Y" ? "years" : "days of the month";
20764 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`;
20765 }
20766
20767 // node_modules/date-fns/format.js
20768 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20769 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20770 var escapedStringRegExp = /^'([^]*?)'?$/;
20771 var doubleQuoteRegExp = /''/g;
20772 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20773 function format(date, formatStr, options) {
20774 const defaultOptions2 = getDefaultOptions();
20775 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20776 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20777 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20778 const originalDate = toDate(date, options?.in);
20779 if (!isValid(originalDate)) {
20780 throw new RangeError("Invalid time value");
20781 }
20782 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20783 const firstCharacter = substring[0];
20784 if (firstCharacter === "p" || firstCharacter === "P") {
20785 const longFormatter = longFormatters[firstCharacter];
20786 return longFormatter(substring, locale.formatLong);
20787 }
20788 return substring;
20789 }).join("").match(formattingTokensRegExp).map((substring) => {
20790 if (substring === "''") {
20791 return { isToken: false, value: "'" };
20792 }
20793 const firstCharacter = substring[0];
20794 if (firstCharacter === "'") {
20795 return { isToken: false, value: cleanEscapedString(substring) };
20796 }
20797 if (formatters[firstCharacter]) {
20798 return { isToken: true, value: substring };
20799 }
20800 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20801 throw new RangeError(
20802 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20803 );
20804 }
20805 return { isToken: false, value: substring };
20806 });
20807 if (locale.localize.preprocessor) {
20808 parts = locale.localize.preprocessor(originalDate, parts);
20809 }
20810 const formatterOptions = {
20811 firstWeekContainsDate,
20812 weekStartsOn,
20813 locale
20814 };
20815 return parts.map((part) => {
20816 if (!part.isToken) return part.value;
20817 const token = part.value;
20818 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20819 warnOrThrowProtectedError(token, formatStr, String(date));
20820 }
20821 const formatter = formatters[token[0]];
20822 return formatter(originalDate, token, locale.localize, formatterOptions);
20823 }).join("");
20824 }
20825 function cleanEscapedString(input) {
20826 const matched = input.match(escapedStringRegExp);
20827 if (!matched) {
20828 return input;
20829 }
20830 return matched[1].replace(doubleQuoteRegExp, "'");
20831 }
20832
20833 // node_modules/date-fns/subDays.js
20834 function subDays(date, amount, options) {
20835 return addDays(date, -amount, options);
20836 }
20837
20838 // node_modules/date-fns/subMonths.js
20839 function subMonths(date, amount, options) {
20840 return addMonths(date, -amount, options);
20841 }
20842
20843 // node_modules/date-fns/subWeeks.js
20844 function subWeeks(date, amount, options) {
20845 return addWeeks(date, -amount, options);
20846 }
20847
20848 // node_modules/date-fns/subYears.js
20849 function subYears(date, amount, options) {
20850 return addYears(date, -amount, options);
20851 }
20852
20853 // packages/dataviews/build-module/utils/operators.mjs
20854 var import_i18n24 = __toESM(require_i18n(), 1);
20855 var import_element45 = __toESM(require_element(), 1);
20856 var import_date = __toESM(require_date(), 1);
20857 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
20858 var filterTextWrappers = {
20859 Name: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20860 Value: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20861 };
20862 function getRelativeDate(value, unit) {
20863 switch (unit) {
20864 case "days":
20865 return subDays(/* @__PURE__ */ new Date(), value);
20866 case "weeks":
20867 return subWeeks(/* @__PURE__ */ new Date(), value);
20868 case "months":
20869 return subMonths(/* @__PURE__ */ new Date(), value);
20870 case "years":
20871 return subYears(/* @__PURE__ */ new Date(), value);
20872 default:
20873 return /* @__PURE__ */ new Date();
20874 }
20875 }
20876 var isNoneOperatorDefinition = {
20877 /* translators: DataViews operator name */
20878 label: (0, import_i18n24.__)("Is none of"),
20879 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20880 (0, import_i18n24.sprintf)(
20881 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20882 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20883 filter.name,
20884 activeElements.map((element) => element.label).join(", ")
20885 ),
20886 filterTextWrappers
20887 ),
20888 filter: ((item, field, filterValue) => {
20889 if (!filterValue?.length) {
20890 return true;
20891 }
20892 const fieldValue = field.getValue({ item });
20893 if (Array.isArray(fieldValue)) {
20894 return !filterValue.some(
20895 (fv) => fieldValue.includes(fv)
20896 );
20897 } else if (typeof fieldValue === "string") {
20898 return !filterValue.includes(fieldValue);
20899 }
20900 return false;
20901 }),
20902 selection: "multi"
20903 };
20904 var OPERATORS = [
20905 {
20906 name: OPERATOR_IS_ANY,
20907 /* translators: DataViews operator name */
20908 label: (0, import_i18n24.__)("Includes"),
20909 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20910 (0, import_i18n24.sprintf)(
20911 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20912 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20913 filter.name,
20914 activeElements.map((element) => element.label).join(", ")
20915 ),
20916 filterTextWrappers
20917 ),
20918 filter(item, field, filterValue) {
20919 if (!filterValue?.length) {
20920 return true;
20921 }
20922 const fieldValue = field.getValue({ item });
20923 if (Array.isArray(fieldValue)) {
20924 return filterValue.some(
20925 (fv) => fieldValue.includes(fv)
20926 );
20927 } else if (typeof fieldValue === "string") {
20928 return filterValue.includes(fieldValue);
20929 }
20930 return false;
20931 },
20932 selection: "multi"
20933 },
20934 {
20935 name: OPERATOR_IS_NONE,
20936 ...isNoneOperatorDefinition
20937 },
20938 {
20939 name: OPERATOR_IS_ALL,
20940 /* translators: DataViews operator name */
20941 label: (0, import_i18n24.__)("Includes all"),
20942 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20943 (0, import_i18n24.sprintf)(
20944 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20945 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20946 filter.name,
20947 activeElements.map((element) => element.label).join(", ")
20948 ),
20949 filterTextWrappers
20950 ),
20951 filter(item, field, filterValue) {
20952 if (!filterValue?.length) {
20953 return true;
20954 }
20955 return filterValue.every((value) => {
20956 return field.getValue({ item })?.includes(value);
20957 });
20958 },
20959 selection: "multi"
20960 },
20961 {
20962 name: OPERATOR_IS_NOT_ALL,
20963 ...isNoneOperatorDefinition
20964 },
20965 {
20966 name: OPERATOR_BETWEEN,
20967 /* translators: DataViews operator name */
20968 label: (0, import_i18n24.__)("Between (inc)"),
20969 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20970 (0, import_i18n24.sprintf)(
20971 /* 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". */
20972 (0, import_i18n24.__)(
20973 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20974 ),
20975 filter.name,
20976 activeElements[0].label[0],
20977 activeElements[0].label[1]
20978 ),
20979 filterTextWrappers
20980 ),
20981 filter(item, field, filterValue) {
20982 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20983 return true;
20984 }
20985 const fieldValue = field.getValue({ item });
20986 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
20987 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
20988 }
20989 return false;
20990 },
20991 selection: "custom"
20992 },
20993 {
20994 name: OPERATOR_IN_THE_PAST,
20995 /* translators: DataViews operator name */
20996 label: (0, import_i18n24.__)("In the past"),
20997 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
20998 (0, import_i18n24.sprintf)(
20999 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
21000 (0, import_i18n24.__)(
21001 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
21002 ),
21003 filter.name,
21004 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21005 ),
21006 filterTextWrappers
21007 ),
21008 filter(item, field, filterValue) {
21009 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21010 return true;
21011 }
21012 const targetDate = getRelativeDate(
21013 filterValue.value,
21014 filterValue.unit
21015 );
21016 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21017 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
21018 },
21019 selection: "custom"
21020 },
21021 {
21022 name: OPERATOR_OVER,
21023 /* translators: DataViews operator name */
21024 label: (0, import_i18n24.__)("Over"),
21025 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21026 (0, import_i18n24.sprintf)(
21027 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
21028 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
21029 filter.name,
21030 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
21031 ),
21032 filterTextWrappers
21033 ),
21034 filter(item, field, filterValue) {
21035 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
21036 return true;
21037 }
21038 const targetDate = getRelativeDate(
21039 filterValue.value,
21040 filterValue.unit
21041 );
21042 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
21043 return fieldValue < targetDate;
21044 },
21045 selection: "custom"
21046 },
21047 {
21048 name: OPERATOR_IS,
21049 /* translators: DataViews operator name */
21050 label: (0, import_i18n24.__)("Is"),
21051 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21052 (0, import_i18n24.sprintf)(
21053 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
21054 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21055 filter.name,
21056 activeElements[0].label
21057 ),
21058 filterTextWrappers
21059 ),
21060 filter(item, field, filterValue) {
21061 return filterValue === field.getValue({ item }) || filterValue === void 0;
21062 },
21063 selection: "single"
21064 },
21065 {
21066 name: OPERATOR_IS_NOT,
21067 /* translators: DataViews operator name */
21068 label: (0, import_i18n24.__)("Is not"),
21069 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21070 (0, import_i18n24.sprintf)(
21071 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
21072 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21073 filter.name,
21074 activeElements[0].label
21075 ),
21076 filterTextWrappers
21077 ),
21078 filter(item, field, filterValue) {
21079 return filterValue !== field.getValue({ item });
21080 },
21081 selection: "single"
21082 },
21083 {
21084 name: OPERATOR_LESS_THAN,
21085 /* translators: DataViews operator name */
21086 label: (0, import_i18n24.__)("Less than"),
21087 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21088 (0, import_i18n24.sprintf)(
21089 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
21090 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
21091 filter.name,
21092 activeElements[0].label
21093 ),
21094 filterTextWrappers
21095 ),
21096 filter(item, field, filterValue) {
21097 if (filterValue === void 0) {
21098 return true;
21099 }
21100 const fieldValue = field.getValue({ item });
21101 return fieldValue < filterValue;
21102 },
21103 selection: "single"
21104 },
21105 {
21106 name: OPERATOR_GREATER_THAN,
21107 /* translators: DataViews operator name */
21108 label: (0, import_i18n24.__)("Greater than"),
21109 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21110 (0, import_i18n24.sprintf)(
21111 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
21112 (0, import_i18n24.__)(
21113 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
21114 ),
21115 filter.name,
21116 activeElements[0].label
21117 ),
21118 filterTextWrappers
21119 ),
21120 filter(item, field, filterValue) {
21121 if (filterValue === void 0) {
21122 return true;
21123 }
21124 const fieldValue = field.getValue({ item });
21125 return fieldValue > filterValue;
21126 },
21127 selection: "single"
21128 },
21129 {
21130 name: OPERATOR_LESS_THAN_OR_EQUAL,
21131 /* translators: DataViews operator name */
21132 label: (0, import_i18n24.__)("Less than or equal"),
21133 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21134 (0, import_i18n24.sprintf)(
21135 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
21136 (0, import_i18n24.__)(
21137 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
21138 ),
21139 filter.name,
21140 activeElements[0].label
21141 ),
21142 filterTextWrappers
21143 ),
21144 filter(item, field, filterValue) {
21145 if (filterValue === void 0) {
21146 return true;
21147 }
21148 const fieldValue = field.getValue({ item });
21149 return fieldValue <= filterValue;
21150 },
21151 selection: "single"
21152 },
21153 {
21154 name: OPERATOR_GREATER_THAN_OR_EQUAL,
21155 /* translators: DataViews operator name */
21156 label: (0, import_i18n24.__)("Greater than or equal"),
21157 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21158 (0, import_i18n24.sprintf)(
21159 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
21160 (0, import_i18n24.__)(
21161 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
21162 ),
21163 filter.name,
21164 activeElements[0].label
21165 ),
21166 filterTextWrappers
21167 ),
21168 filter(item, field, filterValue) {
21169 if (filterValue === void 0) {
21170 return true;
21171 }
21172 const fieldValue = field.getValue({ item });
21173 return fieldValue >= filterValue;
21174 },
21175 selection: "single"
21176 },
21177 {
21178 name: OPERATOR_BEFORE,
21179 /* translators: DataViews operator name */
21180 label: (0, import_i18n24.__)("Before"),
21181 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21182 (0, import_i18n24.sprintf)(
21183 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
21184 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
21185 filter.name,
21186 activeElements[0].label
21187 ),
21188 filterTextWrappers
21189 ),
21190 filter(item, field, filterValue) {
21191 if (filterValue === void 0) {
21192 return true;
21193 }
21194 const filterDate = (0, import_date.getDate)(filterValue);
21195 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21196 return fieldDate < filterDate;
21197 },
21198 selection: "single"
21199 },
21200 {
21201 name: OPERATOR_AFTER,
21202 /* translators: DataViews operator name */
21203 label: (0, import_i18n24.__)("After"),
21204 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21205 (0, import_i18n24.sprintf)(
21206 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
21207 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
21208 filter.name,
21209 activeElements[0].label
21210 ),
21211 filterTextWrappers
21212 ),
21213 filter(item, field, filterValue) {
21214 if (filterValue === void 0) {
21215 return true;
21216 }
21217 const filterDate = (0, import_date.getDate)(filterValue);
21218 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21219 return fieldDate > filterDate;
21220 },
21221 selection: "single"
21222 },
21223 {
21224 name: OPERATOR_BEFORE_INC,
21225 /* translators: DataViews operator name */
21226 label: (0, import_i18n24.__)("Before (inc)"),
21227 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21228 (0, import_i18n24.sprintf)(
21229 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
21230 (0, import_i18n24.__)(
21231 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
21232 ),
21233 filter.name,
21234 activeElements[0].label
21235 ),
21236 filterTextWrappers
21237 ),
21238 filter(item, field, filterValue) {
21239 if (filterValue === void 0) {
21240 return true;
21241 }
21242 const filterDate = (0, import_date.getDate)(filterValue);
21243 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21244 return fieldDate <= filterDate;
21245 },
21246 selection: "single"
21247 },
21248 {
21249 name: OPERATOR_AFTER_INC,
21250 /* translators: DataViews operator name */
21251 label: (0, import_i18n24.__)("After (inc)"),
21252 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21253 (0, import_i18n24.sprintf)(
21254 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
21255 (0, import_i18n24.__)(
21256 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
21257 ),
21258 filter.name,
21259 activeElements[0].label
21260 ),
21261 filterTextWrappers
21262 ),
21263 filter(item, field, filterValue) {
21264 if (filterValue === void 0) {
21265 return true;
21266 }
21267 const filterDate = (0, import_date.getDate)(filterValue);
21268 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21269 return fieldDate >= filterDate;
21270 },
21271 selection: "single"
21272 },
21273 {
21274 name: OPERATOR_CONTAINS,
21275 /* translators: DataViews operator name */
21276 label: (0, import_i18n24.__)("Contains"),
21277 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21278 (0, import_i18n24.sprintf)(
21279 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
21280 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
21281 filter.name,
21282 activeElements[0].label
21283 ),
21284 filterTextWrappers
21285 ),
21286 filter(item, field, filterValue) {
21287 if (filterValue === void 0) {
21288 return true;
21289 }
21290 const fieldValue = field.getValue({ item });
21291 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21292 },
21293 selection: "single"
21294 },
21295 {
21296 name: OPERATOR_NOT_CONTAINS,
21297 /* translators: DataViews operator name */
21298 label: (0, import_i18n24.__)("Doesn't contain"),
21299 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21300 (0, import_i18n24.sprintf)(
21301 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
21302 (0, import_i18n24.__)(
21303 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
21304 ),
21305 filter.name,
21306 activeElements[0].label
21307 ),
21308 filterTextWrappers
21309 ),
21310 filter(item, field, filterValue) {
21311 if (filterValue === void 0) {
21312 return true;
21313 }
21314 const fieldValue = field.getValue({ item });
21315 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
21316 },
21317 selection: "single"
21318 },
21319 {
21320 name: OPERATOR_STARTS_WITH,
21321 /* translators: DataViews operator name */
21322 label: (0, import_i18n24.__)("Starts with"),
21323 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21324 (0, import_i18n24.sprintf)(
21325 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
21326 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
21327 filter.name,
21328 activeElements[0].label
21329 ),
21330 filterTextWrappers
21331 ),
21332 filter(item, field, filterValue) {
21333 if (filterValue === void 0) {
21334 return true;
21335 }
21336 const fieldValue = field.getValue({ item });
21337 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
21338 },
21339 selection: "single"
21340 },
21341 {
21342 name: OPERATOR_ON,
21343 /* translators: DataViews operator name */
21344 label: (0, import_i18n24.__)("On"),
21345 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21346 (0, import_i18n24.sprintf)(
21347 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
21348 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
21349 filter.name,
21350 activeElements[0].label
21351 ),
21352 filterTextWrappers
21353 ),
21354 filter(item, field, filterValue) {
21355 if (filterValue === void 0) {
21356 return true;
21357 }
21358 const filterDate = (0, import_date.getDate)(filterValue);
21359 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21360 return filterDate.getTime() === fieldDate.getTime();
21361 },
21362 selection: "single"
21363 },
21364 {
21365 name: OPERATOR_NOT_ON,
21366 /* translators: DataViews operator name */
21367 label: (0, import_i18n24.__)("Not on"),
21368 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
21369 (0, import_i18n24.sprintf)(
21370 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
21371 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
21372 filter.name,
21373 activeElements[0].label
21374 ),
21375 filterTextWrappers
21376 ),
21377 filter(item, field, filterValue) {
21378 if (filterValue === void 0) {
21379 return true;
21380 }
21381 const filterDate = (0, import_date.getDate)(filterValue);
21382 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
21383 return filterDate.getTime() !== fieldDate.getTime();
21384 },
21385 selection: "single"
21386 }
21387 ];
21388 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
21389 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
21390 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
21391 (op) => op.name === name
21392 );
21393 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
21394
21395 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
21396 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
21397 var ENTER = "Enter";
21398 var SPACE = " ";
21399 var FilterText = ({
21400 activeElements,
21401 filterInView,
21402 filter
21403 }) => {
21404 if (activeElements === void 0 || activeElements.length === 0) {
21405 return filter.name;
21406 }
21407 const operator = getOperatorByName(filterInView?.operator);
21408 if (operator !== void 0) {
21409 return operator.filterText(filter, activeElements);
21410 }
21411 return (0, import_i18n25.sprintf)(
21412 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
21413 (0, import_i18n25.__)("Unknown status for %1$s"),
21414 filter.name
21415 );
21416 };
21417 function OperatorSelector({
21418 filter,
21419 view,
21420 onChangeView
21421 }) {
21422 const operatorOptions = filter.operators?.map((operator) => ({
21423 value: operator,
21424 label: getOperatorByName(operator)?.label || operator
21425 }));
21426 const currentFilter = view.filters?.find(
21427 (_filter) => _filter.field === filter.field
21428 );
21429 const value = currentFilter?.operator || filter.operators[0];
21430 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
21431 Stack,
21432 {
21433 direction: "row",
21434 gap: "sm",
21435 justify: "flex-start",
21436 className: "dataviews-filters__summary-operators-container",
21437 align: "center",
21438 children: [
21439 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21440 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21441 import_components21.SelectControl,
21442 {
21443 className: "dataviews-filters__summary-operators-filter-select",
21444 label: (0, import_i18n25.__)("Conditions"),
21445 value,
21446 options: operatorOptions,
21447 onChange: (newValue) => {
21448 const newOperator = newValue;
21449 const currentOperator = currentFilter?.operator;
21450 const newFilters = currentFilter ? [
21451 ...(view.filters ?? []).map(
21452 (_filter) => {
21453 if (_filter.field === filter.field) {
21454 const currentOpSelectionModel = getOperatorByName(
21455 currentOperator
21456 )?.selection;
21457 const newOpSelectionModel = getOperatorByName(
21458 newOperator
21459 )?.selection;
21460 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21461 currentOpSelectionModel,
21462 newOpSelectionModel
21463 ].includes("custom");
21464 return {
21465 ..._filter,
21466 value: shouldResetValue ? void 0 : _filter.value,
21467 operator: newOperator
21468 };
21469 }
21470 return _filter;
21471 }
21472 )
21473 ] : [
21474 ...view.filters ?? [],
21475 {
21476 field: filter.field,
21477 operator: newOperator,
21478 value: void 0
21479 }
21480 ];
21481 onChangeView({
21482 ...view,
21483 page: 1,
21484 filters: newFilters
21485 });
21486 },
21487 size: "small",
21488 variant: "minimal",
21489 hideLabelFromVision: true
21490 }
21491 )
21492 ]
21493 }
21494 );
21495 }
21496 function Filter({
21497 addFilterRef,
21498 openedFilter,
21499 fields,
21500 ...commonProps
21501 }) {
21502 const toggleRef = (0, import_element46.useRef)(null);
21503 const { filter, view, onChangeView } = commonProps;
21504 const filterInView = view.filters?.find(
21505 (f2) => f2.field === filter.field
21506 );
21507 let activeElements = [];
21508 const field = (0, import_element46.useMemo)(() => {
21509 const currentField = fields.find((f2) => f2.id === filter.field);
21510 if (currentField) {
21511 return {
21512 ...currentField,
21513 // Configure getValue as if Item was a plain object.
21514 // See related input-widget.tsx
21515 getValue: ({ item }) => item[currentField.id]
21516 };
21517 }
21518 return currentField;
21519 }, [fields, filter.field]);
21520 const { elements } = useElements({
21521 elements: filter.elements,
21522 getElements: filter.getElements
21523 });
21524 if (elements.length > 0) {
21525 activeElements = elements.filter((element) => {
21526 if (filter.singleSelection) {
21527 return element.value === filterInView?.value;
21528 }
21529 return filterInView?.value?.includes(element.value);
21530 });
21531 } else if (Array.isArray(filterInView?.value)) {
21532 const label = filterInView.value.map((v2) => {
21533 const formattedValue = field?.getValueFormatted({
21534 item: { [field.id]: v2 },
21535 field
21536 });
21537 return formattedValue || String(v2);
21538 });
21539 activeElements = [
21540 {
21541 value: filterInView.value,
21542 // @ts-ignore
21543 label
21544 }
21545 ];
21546 } else if (typeof filterInView?.value === "object") {
21547 activeElements = [
21548 { value: filterInView.value, label: filterInView.value }
21549 ];
21550 } else if (filterInView?.value !== void 0) {
21551 const label = field !== void 0 ? field.getValueFormatted({
21552 item: { [field.id]: filterInView.value },
21553 field
21554 }) : String(filterInView.value);
21555 activeElements = [
21556 {
21557 value: filterInView.value,
21558 label
21559 }
21560 ];
21561 }
21562 const isPrimary = filter.isPrimary;
21563 const isLocked = filterInView?.isLocked;
21564 const hasValues = !isLocked && filterInView?.value !== void 0;
21565 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21566 const resetOrRemoveLabel = isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove");
21567 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21568 import_components21.Dropdown,
21569 {
21570 defaultOpen: openedFilter === filter.field,
21571 contentClassName: "dataviews-filters__summary-popover",
21572 popoverProps: { placement: "bottom-start", role: "dialog" },
21573 onClose: () => {
21574 toggleRef.current?.focus();
21575 },
21576 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21577 /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21578 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21579 tooltip_exports.Trigger,
21580 {
21581 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21582 "div",
21583 {
21584 className: clsx_default(
21585 "dataviews-filters__summary-chip",
21586 {
21587 "has-reset": canResetOrRemove,
21588 "has-values": hasValues,
21589 "is-not-clickable": isLocked
21590 }
21591 ),
21592 role: "button",
21593 tabIndex: isLocked ? -1 : 0,
21594 onClick: () => {
21595 if (!isLocked) {
21596 onToggle();
21597 }
21598 },
21599 onKeyDown: (event) => {
21600 if (!isLocked && [ENTER, SPACE].includes(
21601 event.key
21602 )) {
21603 onToggle();
21604 event.preventDefault();
21605 }
21606 },
21607 "aria-disabled": isLocked,
21608 "aria-pressed": isOpen,
21609 "aria-expanded": isOpen,
21610 ref: toggleRef,
21611 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21612 FilterText,
21613 {
21614 activeElements,
21615 filterInView,
21616 filter
21617 }
21618 )
21619 }
21620 )
21621 }
21622 ),
21623 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: (0, import_i18n25.sprintf)(
21624 /* translators: 1: Filter name. */
21625 (0, import_i18n25.__)("Filter by: %1$s"),
21626 filter.name.toLowerCase()
21627 ) })
21628 ] }),
21629 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(tooltip_exports.Root, { children: [
21630 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21631 tooltip_exports.Trigger,
21632 {
21633 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21634 "button",
21635 {
21636 className: clsx_default(
21637 "dataviews-filters__summary-chip-remove",
21638 { "has-values": hasValues }
21639 ),
21640 "aria-label": resetOrRemoveLabel,
21641 onClick: () => {
21642 onChangeView({
21643 ...view,
21644 page: 1,
21645 filters: view.filters?.filter(
21646 (_filter) => _filter.field !== filter.field
21647 )
21648 });
21649 if (!isPrimary) {
21650 addFilterRef.current?.focus();
21651 } else {
21652 toggleRef.current?.focus();
21653 }
21654 },
21655 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components21.Icon, { icon: close_small_default })
21656 }
21657 )
21658 }
21659 ),
21660 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21661 ] })
21662 ] }),
21663 renderContent: () => {
21664 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21665 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(OperatorSelector, { ...commonProps }),
21666 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21667 SearchWidget,
21668 {
21669 ...commonProps,
21670 filter: {
21671 ...commonProps.filter,
21672 elements
21673 }
21674 }
21675 ) : /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(InputWidget, { ...commonProps, fields })
21676 ] });
21677 }
21678 }
21679 );
21680 }
21681
21682 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21683 var import_components22 = __toESM(require_components(), 1);
21684 var import_i18n26 = __toESM(require_i18n(), 1);
21685 var import_element47 = __toESM(require_element(), 1);
21686 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
21687 var { Menu: Menu4 } = unlock3(import_components22.privateApis);
21688 function AddFilterMenu({
21689 filters,
21690 view,
21691 onChangeView,
21692 setOpenedFilter,
21693 triggerProps
21694 }) {
21695 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21696 return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(Menu4, { children: [
21697 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21698 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21699 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21700 Menu4.Item,
21701 {
21702 onClick: () => {
21703 setOpenedFilter(filter.field);
21704 onChangeView({
21705 ...view,
21706 page: 1,
21707 filters: [
21708 ...view.filters || [],
21709 {
21710 field: filter.field,
21711 value: void 0,
21712 operator: filter.operators[0]
21713 }
21714 ]
21715 });
21716 },
21717 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(Menu4.ItemLabel, { children: filter.name })
21718 },
21719 filter.field
21720 );
21721 }) })
21722 ] });
21723 }
21724 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21725 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21726 return null;
21727 }
21728 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21729 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21730 AddFilterMenu,
21731 {
21732 triggerProps: {
21733 render: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21734 import_components22.Button,
21735 {
21736 accessibleWhenDisabled: true,
21737 size: "compact",
21738 className: "dataviews-filters-button",
21739 variant: "tertiary",
21740 disabled: !inactiveFilters.length,
21741 ref
21742 }
21743 ),
21744 children: (0, import_i18n26.__)("Add filter")
21745 },
21746 ...{ filters, view, onChangeView, setOpenedFilter }
21747 }
21748 );
21749 }
21750 var add_filter_default = (0, import_element47.forwardRef)(AddFilter);
21751
21752 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21753 var import_components23 = __toESM(require_components(), 1);
21754 var import_i18n27 = __toESM(require_i18n(), 1);
21755 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
21756 function ResetFilter({
21757 filters,
21758 view,
21759 onChangeView
21760 }) {
21761 const isPrimary = (field) => filters.some(
21762 (_filter) => _filter.field === field && _filter.isPrimary
21763 );
21764 const isDisabled = !view.search && !view.filters?.some(
21765 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21766 );
21767 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21768 import_components23.Button,
21769 {
21770 disabled: isDisabled,
21771 accessibleWhenDisabled: true,
21772 size: "compact",
21773 variant: "tertiary",
21774 className: "dataviews-filters__reset-button",
21775 onClick: () => {
21776 onChangeView({
21777 ...view,
21778 page: 1,
21779 search: "",
21780 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21781 });
21782 },
21783 children: (0, import_i18n27.__)("Reset")
21784 }
21785 );
21786 }
21787
21788 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21789 var import_element48 = __toESM(require_element(), 1);
21790 function useFilters(fields, view) {
21791 return (0, import_element48.useMemo)(() => {
21792 const filters = [];
21793 fields.forEach((field) => {
21794 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21795 return;
21796 }
21797 const operators = field.filterBy.operators;
21798 const isPrimary = !!field.filterBy?.isPrimary;
21799 const isLocked = view.filters?.some(
21800 (f2) => f2.field === field.id && !!f2.isLocked
21801 ) ?? false;
21802 filters.push({
21803 field: field.id,
21804 name: field.label,
21805 elements: field.elements,
21806 getElements: field.getElements,
21807 hasElements: field.hasElements,
21808 singleSelection: operators.some(
21809 (op) => isSingleSelectionOperator(op)
21810 ),
21811 operators,
21812 isVisible: isLocked || isPrimary || !!view.filters?.some(
21813 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21814 ),
21815 isPrimary,
21816 isLocked
21817 });
21818 });
21819 filters.sort((a2, b2) => {
21820 if (a2.isLocked && !b2.isLocked) {
21821 return -1;
21822 }
21823 if (!a2.isLocked && b2.isLocked) {
21824 return 1;
21825 }
21826 if (a2.isPrimary && !b2.isPrimary) {
21827 return -1;
21828 }
21829 if (!a2.isPrimary && b2.isPrimary) {
21830 return 1;
21831 }
21832 return a2.name.localeCompare(b2.name);
21833 });
21834 return filters;
21835 }, [fields, view]);
21836 }
21837 var use_filters_default = useFilters;
21838
21839 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21840 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
21841 function Filters({ className }) {
21842 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element49.useContext)(dataviews_context_default);
21843 const addFilterRef = (0, import_element49.useRef)(null);
21844 const filters = use_filters_default(fields, view);
21845 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21846 add_filter_default,
21847 {
21848 filters,
21849 view,
21850 onChangeView,
21851 ref: addFilterRef,
21852 setOpenedFilter
21853 },
21854 "add-filter"
21855 );
21856 const visibleFilters = filters.filter((filter) => filter.isVisible);
21857 if (visibleFilters.length === 0) {
21858 return null;
21859 }
21860 const filterComponents = [
21861 ...visibleFilters.map((filter) => {
21862 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21863 Filter,
21864 {
21865 filter,
21866 view,
21867 fields,
21868 onChangeView,
21869 addFilterRef,
21870 openedFilter
21871 },
21872 filter.field
21873 );
21874 }),
21875 addFilter
21876 ];
21877 filterComponents.push(
21878 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21879 ResetFilter,
21880 {
21881 filters,
21882 view,
21883 onChangeView
21884 },
21885 "reset-filters"
21886 )
21887 );
21888 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21889 Stack,
21890 {
21891 direction: "row",
21892 justify: "flex-start",
21893 gap: "sm",
21894 style: { width: "fit-content" },
21895 wrap: "wrap",
21896 className,
21897 children: filterComponents
21898 }
21899 );
21900 }
21901 var filters_default = (0, import_element49.memo)(Filters);
21902
21903 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21904 var import_element50 = __toESM(require_element(), 1);
21905 var import_components24 = __toESM(require_components(), 1);
21906 var import_i18n28 = __toESM(require_i18n(), 1);
21907 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
21908 function FiltersToggle() {
21909 const {
21910 filters,
21911 view,
21912 onChangeView,
21913 setOpenedFilter,
21914 isShowingFilter,
21915 setIsShowingFilter
21916 } = (0, import_element50.useContext)(dataviews_context_default);
21917 const buttonRef = (0, import_element50.useRef)(null);
21918 const onChangeViewWithFilterVisibility = (0, import_element50.useCallback)(
21919 (_view) => {
21920 onChangeView(_view);
21921 setIsShowingFilter(true);
21922 },
21923 [onChangeView, setIsShowingFilter]
21924 );
21925 if (filters.length === 0) {
21926 return null;
21927 }
21928 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21929 const addFilterButtonProps = {
21930 label: (0, import_i18n28.__)("Add filter"),
21931 "aria-expanded": false,
21932 isPressed: false
21933 };
21934 const toggleFiltersButtonProps = {
21935 label: (0, import_i18n28._x)("Filter", "verb"),
21936 "aria-expanded": isShowingFilter,
21937 isPressed: isShowingFilter,
21938 onClick: () => {
21939 if (!isShowingFilter) {
21940 setOpenedFilter(null);
21941 }
21942 setIsShowingFilter(!isShowingFilter);
21943 }
21944 };
21945 const hasPrimaryOrLockedFilters = filters.some(
21946 (filter) => filter.isPrimary || filter.isLocked
21947 );
21948 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
21949 import_components24.Button,
21950 {
21951 ref: buttonRef,
21952 className: "dataviews-filters__visibility-toggle",
21953 size: "compact",
21954 icon: funnel_default,
21955 disabled: hasPrimaryOrLockedFilters,
21956 accessibleWhenDisabled: true,
21957 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21958 }
21959 );
21960 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
21961 AddFilterMenu,
21962 {
21963 filters,
21964 view,
21965 onChangeView: onChangeViewWithFilterVisibility,
21966 setOpenedFilter,
21967 triggerProps: { render: buttonComponent }
21968 }
21969 ) : /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
21970 FilterVisibilityToggle,
21971 {
21972 buttonRef,
21973 filtersCount: view.filters?.length,
21974 children: buttonComponent
21975 }
21976 ) });
21977 }
21978 function FilterVisibilityToggle({
21979 buttonRef,
21980 filtersCount,
21981 children
21982 }) {
21983 (0, import_element50.useEffect)(
21984 () => () => {
21985 buttonRef.current?.focus();
21986 },
21987 [buttonRef]
21988 );
21989 return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_jsx_runtime79.Fragment, { children: [
21990 children,
21991 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
21992 ] });
21993 }
21994 var toggle_default = FiltersToggle;
21995
21996 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
21997 var import_element51 = __toESM(require_element(), 1);
21998 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
21999 function FiltersToggled(props) {
22000 const { isShowingFilter } = (0, import_element51.useContext)(dataviews_context_default);
22001 if (!isShowingFilter) {
22002 return null;
22003 }
22004 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(filters_default, { ...props });
22005 }
22006 var filters_toggled_default = FiltersToggled;
22007
22008 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
22009 var import_element52 = __toESM(require_element(), 1);
22010 var import_components25 = __toESM(require_components(), 1);
22011 var import_i18n29 = __toESM(require_i18n(), 1);
22012 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
22013 function DataViewsLayout({ className }) {
22014 const {
22015 actions = [],
22016 data,
22017 fields,
22018 getItemId,
22019 getItemLevel,
22020 hasInitiallyLoaded,
22021 isLoading,
22022 view,
22023 onChangeView,
22024 selection,
22025 onChangeSelection,
22026 setOpenedFilter,
22027 onClickItem,
22028 isItemClickable,
22029 renderItemLink,
22030 defaultLayouts,
22031 containerRef,
22032 empty = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { children: (0, import_i18n29.__)("No results") })
22033 } = (0, import_element52.useContext)(dataviews_context_default);
22034 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
22035 delay: 200
22036 });
22037 if (!hasInitiallyLoaded) {
22038 if (!isDelayedInitialLoading) {
22039 return null;
22040 }
22041 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components25.Spinner, {}) }) });
22042 }
22043 const ViewComponent = VIEW_LAYOUTS.find(
22044 (v2) => v2.type === view.type && defaultLayouts[v2.type]
22045 )?.component;
22046 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
22047 ViewComponent,
22048 {
22049 className,
22050 actions,
22051 data,
22052 fields,
22053 getItemId,
22054 getItemLevel,
22055 isLoading,
22056 onChangeView,
22057 onChangeSelection,
22058 selection,
22059 setOpenedFilter,
22060 onClickItem,
22061 renderItemLink,
22062 isItemClickable,
22063 view,
22064 empty
22065 }
22066 ) });
22067 }
22068
22069 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
22070 var import_element53 = __toESM(require_element(), 1);
22071 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
22072 var EMPTY_ARRAY5 = [];
22073 function DataViewsFooter() {
22074 const {
22075 view,
22076 paginationInfo: { totalItems = 0, totalPages },
22077 data,
22078 actions = EMPTY_ARRAY5,
22079 isLoading,
22080 hasInitiallyLoaded
22081 } = (0, import_element53.useContext)(dataviews_context_default);
22082 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
22083 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
22084 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
22085 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
22086 return null;
22087 }
22088 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
22089 "div",
22090 {
22091 className: "dataviews-footer",
22092 inert: isRefreshing ? "true" : void 0,
22093 children: /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
22094 Stack,
22095 {
22096 direction: "row",
22097 justify: "end",
22098 align: "center",
22099 className: clsx_default("dataviews-footer__content", {
22100 "is-refreshing": isDelayedRefreshing
22101 }),
22102 gap: "sm",
22103 children: [
22104 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(BulkActionsFooter, {}),
22105 /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(dataviews_pagination_default, {})
22106 ]
22107 }
22108 )
22109 }
22110 );
22111 }
22112
22113 // packages/dataviews/build-module/components/dataviews-search/index.mjs
22114 var import_i18n30 = __toESM(require_i18n(), 1);
22115 var import_element54 = __toESM(require_element(), 1);
22116 var import_components26 = __toESM(require_components(), 1);
22117 var import_compose10 = __toESM(require_compose(), 1);
22118 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
22119 var DataViewsSearch = (0, import_element54.memo)(function Search({ label }) {
22120 const { view, onChangeView } = (0, import_element54.useContext)(dataviews_context_default);
22121 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
22122 view.search
22123 );
22124 (0, import_element54.useEffect)(() => {
22125 if (view.search !== debouncedSearch) {
22126 setSearch(view.search ?? "");
22127 }
22128 }, [view.search, setSearch]);
22129 const onChangeViewRef = (0, import_element54.useRef)(onChangeView);
22130 const viewRef = (0, import_element54.useRef)(view);
22131 (0, import_element54.useEffect)(() => {
22132 onChangeViewRef.current = onChangeView;
22133 viewRef.current = view;
22134 }, [onChangeView, view]);
22135 (0, import_element54.useEffect)(() => {
22136 if (debouncedSearch !== viewRef.current?.search) {
22137 onChangeViewRef.current({
22138 ...viewRef.current,
22139 page: view.page ? 1 : void 0,
22140 startPosition: view.startPosition ? 1 : void 0,
22141 search: debouncedSearch
22142 });
22143 }
22144 }, [debouncedSearch]);
22145 const searchLabel = label || (0, import_i18n30.__)("Search");
22146 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22147 import_components26.SearchControl,
22148 {
22149 className: "dataviews-search",
22150 onChange: setSearch,
22151 value: search,
22152 label: searchLabel,
22153 placeholder: searchLabel,
22154 size: "compact"
22155 }
22156 );
22157 });
22158 var dataviews_search_default = DataViewsSearch;
22159
22160 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
22161 var import_components27 = __toESM(require_components(), 1);
22162 var import_i18n31 = __toESM(require_i18n(), 1);
22163 var import_element55 = __toESM(require_element(), 1);
22164 var import_warning = __toESM(require_warning(), 1);
22165 var import_compose11 = __toESM(require_compose(), 1);
22166 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22167 var { Menu: Menu5 } = unlock3(import_components27.privateApis);
22168 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
22169 className: "dataviews-config__popover",
22170 placement: "bottom-end",
22171 offset: 9
22172 };
22173 function ViewTypeMenu() {
22174 const { view, onChangeView, defaultLayouts } = (0, import_element55.useContext)(dataviews_context_default);
22175 const availableLayouts = Object.keys(defaultLayouts);
22176 if (availableLayouts.length <= 1) {
22177 return null;
22178 }
22179 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
22180 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Menu5, { children: [
22181 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22182 Menu5.TriggerButton,
22183 {
22184 render: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22185 import_components27.Button,
22186 {
22187 size: "compact",
22188 icon: activeView?.icon,
22189 label: (0, import_i18n31.__)("Layout")
22190 }
22191 )
22192 }
22193 ),
22194 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
22195 const config = VIEW_LAYOUTS.find(
22196 (v2) => v2.type === layout
22197 );
22198 if (!config) {
22199 return null;
22200 }
22201 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22202 Menu5.RadioItem,
22203 {
22204 value: layout,
22205 name: "view-actions-available-view",
22206 checked: layout === view.type,
22207 hideOnClick: true,
22208 onChange: (e2) => {
22209 switch (e2.target.value) {
22210 case "list":
22211 case "grid":
22212 case "table":
22213 case "pickerGrid":
22214 case "pickerTable":
22215 case "pickerActivity":
22216 case "activity":
22217 const viewWithoutLayout = { ...view };
22218 if ("layout" in viewWithoutLayout) {
22219 delete viewWithoutLayout.layout;
22220 }
22221 return onChangeView({
22222 ...viewWithoutLayout,
22223 type: e2.target.value,
22224 ...defaultLayouts[e2.target.value]
22225 });
22226 }
22227 (0, import_warning.default)("Invalid dataview");
22228 },
22229 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(Menu5.ItemLabel, { children: config.label })
22230 },
22231 layout
22232 );
22233 }) })
22234 ] });
22235 }
22236 function SortFieldControl() {
22237 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22238 const orderOptions = (0, import_element55.useMemo)(() => {
22239 const sortableFields = fields.filter(
22240 (field) => field.enableSorting !== false
22241 );
22242 return sortableFields.map((field) => {
22243 return {
22244 label: field.label,
22245 value: field.id
22246 };
22247 });
22248 }, [fields]);
22249 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22250 import_components27.SelectControl,
22251 {
22252 __next40pxDefaultSize: true,
22253 label: (0, import_i18n31.__)("Sort by"),
22254 value: view.sort?.field,
22255 options: orderOptions,
22256 onChange: (value) => {
22257 onChangeView({
22258 ...view,
22259 sort: {
22260 direction: view?.sort?.direction || "desc",
22261 field: value
22262 },
22263 showLevels: false
22264 });
22265 }
22266 }
22267 );
22268 }
22269 function SortDirectionControl() {
22270 const { view, fields, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22271 const sortableFields = fields.filter(
22272 (field) => field.enableSorting !== false
22273 );
22274 if (sortableFields.length === 0) {
22275 return null;
22276 }
22277 let value = view.sort?.direction;
22278 if (!value && view.sort?.field) {
22279 value = "desc";
22280 }
22281 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22282 import_components27.__experimentalToggleGroupControl,
22283 {
22284 className: "dataviews-view-config__sort-direction",
22285 __next40pxDefaultSize: true,
22286 isBlock: true,
22287 label: (0, import_i18n31.__)("Order"),
22288 value,
22289 onChange: (newDirection) => {
22290 if (newDirection === "asc" || newDirection === "desc") {
22291 onChangeView({
22292 ...view,
22293 sort: {
22294 direction: newDirection,
22295 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
22296 fields.find(
22297 (field) => field.enableSorting !== false
22298 )?.id || ""
22299 },
22300 showLevels: false
22301 });
22302 return;
22303 }
22304 (0, import_warning.default)("Invalid direction");
22305 },
22306 children: SORTING_DIRECTIONS.map((direction) => {
22307 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22308 import_components27.__experimentalToggleGroupControlOptionIcon,
22309 {
22310 value: direction,
22311 icon: sortIcons[direction],
22312 label: sortLabels[direction]
22313 },
22314 direction
22315 );
22316 })
22317 }
22318 );
22319 }
22320 function ItemsPerPageControl() {
22321 const { view, config, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
22322 const { infiniteScrollEnabled } = view;
22323 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
22324 return null;
22325 }
22326 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22327 import_components27.__experimentalToggleGroupControl,
22328 {
22329 __next40pxDefaultSize: true,
22330 isBlock: true,
22331 label: (0, import_i18n31.__)("Items per page"),
22332 value: view.perPage || 10,
22333 disabled: !view?.sort?.field,
22334 onChange: (newItemsPerPage) => {
22335 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
22336 onChangeView({
22337 ...view,
22338 perPage: newItemsPerPageNumber,
22339 page: 1
22340 });
22341 },
22342 children: config.perPageSizes.map((value) => {
22343 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22344 import_components27.__experimentalToggleGroupControlOption,
22345 {
22346 value,
22347 label: value.toString()
22348 },
22349 value
22350 );
22351 })
22352 }
22353 );
22354 }
22355 function ResetViewButton() {
22356 const { onReset } = (0, import_element55.useContext)(dataviews_context_default);
22357 if (onReset === void 0) {
22358 return null;
22359 }
22360 const isDisabled = onReset === false;
22361 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22362 import_components27.Button,
22363 {
22364 variant: "tertiary",
22365 size: "compact",
22366 disabled: isDisabled,
22367 accessibleWhenDisabled: true,
22368 className: "dataviews-view-config__reset-button",
22369 onClick: () => {
22370 if (typeof onReset === "function") {
22371 onReset();
22372 }
22373 },
22374 children: (0, import_i18n31.__)("Reset view")
22375 }
22376 );
22377 }
22378 function DataviewsViewConfigDropdown() {
22379 const { view, onReset } = (0, import_element55.useContext)(dataviews_context_default);
22380 const popoverId = (0, import_compose11.useInstanceId)(
22381 _DataViewsViewConfig,
22382 "dataviews-view-config-dropdown"
22383 );
22384 const activeLayout = VIEW_LAYOUTS.find(
22385 (layout) => layout.type === view.type
22386 );
22387 const isModified = typeof onReset === "function";
22388 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22389 import_components27.Dropdown,
22390 {
22391 expandOnMobile: true,
22392 popoverProps: {
22393 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
22394 id: popoverId
22395 },
22396 renderToggle: ({ onToggle, isOpen }) => {
22397 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
22398 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22399 import_components27.Button,
22400 {
22401 size: "compact",
22402 icon: cog_default,
22403 label: (0, import_i18n31._x)(
22404 "View options",
22405 "View is used as a noun"
22406 ),
22407 onClick: onToggle,
22408 "aria-expanded": isOpen ? "true" : "false",
22409 "aria-controls": popoverId
22410 }
22411 ),
22412 isModified && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
22413 ] });
22414 },
22415 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22416 import_components27.__experimentalDropdownContentWrapper,
22417 {
22418 paddingSize: "medium",
22419 className: "dataviews-config__popover-content-wrapper",
22420 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22421 Stack,
22422 {
22423 direction: "column",
22424 className: "dataviews-view-config",
22425 gap: "xl",
22426 children: [
22427 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22428 Stack,
22429 {
22430 direction: "row",
22431 justify: "space-between",
22432 align: "center",
22433 className: "dataviews-view-config__header",
22434 children: [
22435 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22436 import_components27.__experimentalHeading,
22437 {
22438 level: 2,
22439 className: "dataviews-settings-section__title",
22440 children: (0, import_i18n31.__)("Appearance")
22441 }
22442 ),
22443 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ResetViewButton, {})
22444 ]
22445 }
22446 ),
22447 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22448 /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
22449 Stack,
22450 {
22451 direction: "row",
22452 gap: "sm",
22453 className: "dataviews-view-config__sort-controls",
22454 children: [
22455 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortFieldControl, {}),
22456 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(SortDirectionControl, {})
22457 ]
22458 }
22459 ),
22460 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(activeLayout.viewConfigOptions, {}),
22461 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ItemsPerPageControl, {}),
22462 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(PropertiesSection, {})
22463 ] })
22464 ]
22465 }
22466 )
22467 }
22468 )
22469 }
22470 );
22471 }
22472 function _DataViewsViewConfig() {
22473 return /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_jsx_runtime84.Fragment, { children: [
22474 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(ViewTypeMenu, {}),
22475 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(DataviewsViewConfigDropdown, {})
22476 ] });
22477 }
22478 var DataViewsViewConfig = (0, import_element55.memo)(_DataViewsViewConfig);
22479 var dataviews_view_config_default = DataViewsViewConfig;
22480
22481 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22482 var import_components28 = __toESM(require_components(), 1);
22483 var import_element56 = __toESM(require_element(), 1);
22484
22485 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22486 function getCustomValidity(isValid2, validity) {
22487 let customValidity;
22488 if (isValid2?.required && validity?.required) {
22489 customValidity = validity?.required?.message ? validity.required : void 0;
22490 } else if (isValid2?.pattern && validity?.pattern) {
22491 customValidity = validity.pattern;
22492 } else if (isValid2?.min && validity?.min) {
22493 customValidity = validity.min;
22494 } else if (isValid2?.max && validity?.max) {
22495 customValidity = validity.max;
22496 } else if (isValid2?.minLength && validity?.minLength) {
22497 customValidity = validity.minLength;
22498 } else if (isValid2?.maxLength && validity?.maxLength) {
22499 customValidity = validity.maxLength;
22500 } else if (isValid2?.elements && validity?.elements) {
22501 customValidity = validity.elements;
22502 } else if (validity?.custom) {
22503 customValidity = validity.custom;
22504 }
22505 return customValidity;
22506 }
22507
22508 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22509 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22510 var { ValidatedCheckboxControl } = unlock3(import_components28.privateApis);
22511 function Checkbox({
22512 field,
22513 onChange,
22514 data,
22515 hideLabelFromVision,
22516 markWhenOptional,
22517 validity
22518 }) {
22519 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22520 const disabled2 = field.isDisabled({ item: data, field });
22521 const onChangeControl = (0, import_element56.useCallback)(() => {
22522 onChange(
22523 setValue({ item: data, value: !getValue({ item: data }) })
22524 );
22525 }, [data, getValue, onChange, setValue]);
22526 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22527 ValidatedCheckboxControl,
22528 {
22529 required: !!field.isValid?.required,
22530 markWhenOptional,
22531 customValidity: getCustomValidity(isValid2, validity),
22532 hidden: hideLabelFromVision,
22533 label,
22534 help: description,
22535 checked: getValue({ item: data }),
22536 onChange: onChangeControl,
22537 disabled: disabled2
22538 }
22539 );
22540 }
22541
22542 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22543 var import_components29 = __toESM(require_components(), 1);
22544 var import_element57 = __toESM(require_element(), 1);
22545 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22546 var { ValidatedComboboxControl } = unlock3(import_components29.privateApis);
22547 function Combobox3({
22548 data,
22549 field,
22550 onChange,
22551 hideLabelFromVision,
22552 validity
22553 }) {
22554 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22555 const value = getValue({ item: data }) ?? "";
22556 const onChangeControl = (0, import_element57.useCallback)(
22557 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22558 [data, onChange, setValue]
22559 );
22560 const { elements, isLoading } = useElements({
22561 elements: field.elements,
22562 getElements: field.getElements
22563 });
22564 if (isLoading) {
22565 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components29.Spinner, {});
22566 }
22567 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22568 ValidatedComboboxControl,
22569 {
22570 required: !!field.isValid?.required,
22571 customValidity: getCustomValidity(isValid2, validity),
22572 label,
22573 value,
22574 help: description,
22575 placeholder,
22576 options: elements,
22577 onChange: onChangeControl,
22578 hideLabelFromVision,
22579 allowReset: true,
22580 expandOnFocus: true
22581 }
22582 );
22583 }
22584
22585 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22586 var import_components31 = __toESM(require_components(), 1);
22587 var import_element60 = __toESM(require_element(), 1);
22588 var import_i18n33 = __toESM(require_i18n(), 1);
22589 var import_date3 = __toESM(require_date(), 1);
22590
22591 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22592 var import_components30 = __toESM(require_components(), 1);
22593 var import_element58 = __toESM(require_element(), 1);
22594 var import_i18n32 = __toESM(require_i18n(), 1);
22595 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22596 var TIME_UNITS_OPTIONS = {
22597 [OPERATOR_IN_THE_PAST]: [
22598 { value: "days", label: (0, import_i18n32.__)("Days") },
22599 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
22600 { value: "months", label: (0, import_i18n32.__)("Months") },
22601 { value: "years", label: (0, import_i18n32.__)("Years") }
22602 ],
22603 [OPERATOR_OVER]: [
22604 { value: "days", label: (0, import_i18n32.__)("Days ago") },
22605 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
22606 { value: "months", label: (0, import_i18n32.__)("Months ago") },
22607 { value: "years", label: (0, import_i18n32.__)("Years ago") }
22608 ]
22609 };
22610 function RelativeDateControl({
22611 className,
22612 data,
22613 field,
22614 onChange,
22615 hideLabelFromVision,
22616 operator
22617 }) {
22618 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22619 const { id, label, description, getValue, setValue } = field;
22620 const disabled2 = field.isDisabled({ item: data, field });
22621 const fieldValue = getValue({ item: data });
22622 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22623 const onChangeValue = (0, import_element58.useCallback)(
22624 (newValue) => onChange(
22625 setValue({
22626 item: data,
22627 value: { value: Number(newValue), unit }
22628 })
22629 ),
22630 [onChange, setValue, data, unit]
22631 );
22632 const onChangeUnit = (0, import_element58.useCallback)(
22633 (newUnit) => onChange(
22634 setValue({
22635 item: data,
22636 value: { value: relValue, unit: newUnit }
22637 })
22638 ),
22639 [onChange, setValue, data, relValue]
22640 );
22641 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22642 import_components30.BaseControl,
22643 {
22644 id,
22645 className: clsx_default(className, "dataviews-controls__relative-date"),
22646 label,
22647 hideLabelFromVision,
22648 help: description,
22649 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22650 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22651 import_components30.__experimentalNumberControl,
22652 {
22653 __next40pxDefaultSize: true,
22654 className: "dataviews-controls__relative-date-number",
22655 spinControls: "none",
22656 min: 1,
22657 step: 1,
22658 value: relValue,
22659 onChange: onChangeValue,
22660 disabled: disabled2
22661 }
22662 ),
22663 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22664 import_components30.SelectControl,
22665 {
22666 className: "dataviews-controls__relative-date-unit",
22667 __next40pxDefaultSize: true,
22668 label: (0, import_i18n32.__)("Unit"),
22669 value: unit,
22670 options,
22671 onChange: onChangeUnit,
22672 hideLabelFromVision: true,
22673 disabled: disabled2
22674 }
22675 )
22676 ] })
22677 }
22678 );
22679 }
22680
22681 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22682 var import_element59 = __toESM(require_element(), 1);
22683 function useDisabledDateMatchers(isValid2, parseDateFn) {
22684 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22685 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22686 const disabledMatchers = (0, import_element59.useMemo)(() => {
22687 const matchers = [];
22688 if (minConstraint) {
22689 const minDate = parseDateFn(minConstraint);
22690 if (minDate) {
22691 matchers.push({ before: minDate });
22692 }
22693 }
22694 if (maxConstraint) {
22695 const maxDate = parseDateFn(maxConstraint);
22696 if (maxDate) {
22697 matchers.push({ after: maxDate });
22698 }
22699 }
22700 return matchers.length > 0 ? matchers : void 0;
22701 }, [minConstraint, maxConstraint, parseDateFn]);
22702 return { minConstraint, maxConstraint, disabledMatchers };
22703 }
22704
22705 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22706 var import_date2 = __toESM(require_date(), 1);
22707 function parseDateTime(dateTimeString) {
22708 if (!dateTimeString) {
22709 return null;
22710 }
22711 const parsed = (0, import_date2.getDate)(dateTimeString);
22712 return parsed && isValid(parsed) ? parsed : null;
22713 }
22714
22715 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22716 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22717 var { DateCalendar, ValidatedInputControl } = unlock3(import_components31.privateApis);
22718 var formatDateTime = (value) => {
22719 if (!value) {
22720 return "";
22721 }
22722 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22723 };
22724 function CalendarDateTimeControl({
22725 data,
22726 field,
22727 onChange,
22728 hideLabelFromVision,
22729 markWhenOptional,
22730 validity,
22731 config
22732 }) {
22733 const { compact } = config || {};
22734 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22735 const disabled2 = field.isDisabled({ item: data, field });
22736 const fieldValue = getValue({ item: data });
22737 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22738 const [calendarMonth, setCalendarMonth] = (0, import_element60.useState)(() => {
22739 const parsedDate = parseDateTime(value);
22740 return parsedDate || /* @__PURE__ */ new Date();
22741 });
22742 const inputControlRef = (0, import_element60.useRef)(null);
22743 const validationTimeoutRef = (0, import_element60.useRef)(void 0);
22744 const previousFocusRef = (0, import_element60.useRef)(null);
22745 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22746 const onChangeCallback = (0, import_element60.useCallback)(
22747 (newValue) => onChange(setValue({ item: data, value: newValue })),
22748 [data, onChange, setValue]
22749 );
22750 (0, import_element60.useEffect)(() => {
22751 return () => {
22752 if (validationTimeoutRef.current) {
22753 clearTimeout(validationTimeoutRef.current);
22754 }
22755 };
22756 }, []);
22757 const onSelectDate = (0, import_element60.useCallback)(
22758 (newDate) => {
22759 let dateTimeValue;
22760 if (newDate) {
22761 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22762 let wpTime;
22763 if (value) {
22764 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22765 } else {
22766 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22767 }
22768 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22769 dateTimeValue = finalDateTime.toISOString();
22770 onChangeCallback(dateTimeValue);
22771 if (validationTimeoutRef.current) {
22772 clearTimeout(validationTimeoutRef.current);
22773 }
22774 } else {
22775 onChangeCallback(void 0);
22776 }
22777 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22778 validationTimeoutRef.current = setTimeout(() => {
22779 if (inputControlRef.current) {
22780 inputControlRef.current.focus();
22781 inputControlRef.current.blur();
22782 onChangeCallback(dateTimeValue);
22783 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22784 previousFocusRef.current.focus();
22785 }
22786 }
22787 }, 0);
22788 },
22789 [onChangeCallback, value]
22790 );
22791 const handleManualDateTimeChange = (0, import_element60.useCallback)(
22792 (newValue) => {
22793 if (newValue) {
22794 const dateTime = (0, import_date3.getDate)(newValue);
22795 onChangeCallback(dateTime.toISOString());
22796 const parsedDate = parseDateTime(dateTime.toISOString());
22797 if (parsedDate) {
22798 setCalendarMonth(parsedDate);
22799 }
22800 } else {
22801 onChangeCallback(void 0);
22802 }
22803 },
22804 [onChangeCallback]
22805 );
22806 const { format: fieldFormat } = field;
22807 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22808 const {
22809 timezone: { string: timezoneString }
22810 } = (0, import_date3.getSettings)();
22811 let displayLabel = label;
22812 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22813 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22814 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22815 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22816 }
22817 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22818 import_components31.BaseControl,
22819 {
22820 id,
22821 label: displayLabel,
22822 help: description,
22823 hideLabelFromVision,
22824 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22825 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22826 ValidatedInputControl,
22827 {
22828 ref: inputControlRef,
22829 __next40pxDefaultSize: true,
22830 required: !!isValid2?.required,
22831 customValidity: getCustomValidity(isValid2, validity),
22832 type: "datetime-local",
22833 label: (0, import_i18n33.__)("Date time"),
22834 hideLabelFromVision: true,
22835 value: formatDateTime(value),
22836 onChange: handleManualDateTimeChange,
22837 disabled: disabled2,
22838 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22839 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22840 }
22841 ),
22842 !compact && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22843 DateCalendar,
22844 {
22845 style: { width: "100%" },
22846 selected: value ? parseDateTime(value) || void 0 : void 0,
22847 onSelect: onSelectDate,
22848 month: calendarMonth,
22849 onMonthChange: setCalendarMonth,
22850 timeZone: timezoneString || void 0,
22851 weekStartsOn,
22852 disabled: disabled2 || disabledMatchers
22853 }
22854 )
22855 ] })
22856 }
22857 );
22858 }
22859 function DateTime({
22860 data,
22861 field,
22862 onChange,
22863 hideLabelFromVision,
22864 markWhenOptional,
22865 operator,
22866 validity,
22867 config
22868 }) {
22869 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22870 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22871 RelativeDateControl,
22872 {
22873 className: "dataviews-controls__datetime",
22874 data,
22875 field,
22876 onChange,
22877 hideLabelFromVision,
22878 operator
22879 }
22880 );
22881 }
22882 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22883 CalendarDateTimeControl,
22884 {
22885 data,
22886 field,
22887 onChange,
22888 hideLabelFromVision,
22889 markWhenOptional,
22890 validity,
22891 config
22892 }
22893 );
22894 }
22895
22896 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22897 var import_components32 = __toESM(require_components(), 1);
22898 var import_element61 = __toESM(require_element(), 1);
22899 var import_i18n34 = __toESM(require_i18n(), 1);
22900 var import_date4 = __toESM(require_date(), 1);
22901 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
22902 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components32.privateApis);
22903 var DATE_PRESETS = [
22904 {
22905 id: "today",
22906 label: (0, import_i18n34.__)("Today"),
22907 getValue: () => (0, import_date4.getDate)(null)
22908 },
22909 {
22910 id: "yesterday",
22911 label: (0, import_i18n34.__)("Yesterday"),
22912 getValue: () => {
22913 const today = (0, import_date4.getDate)(null);
22914 return subDays(today, 1);
22915 }
22916 },
22917 {
22918 id: "past-week",
22919 label: (0, import_i18n34.__)("Past week"),
22920 getValue: () => {
22921 const today = (0, import_date4.getDate)(null);
22922 return subDays(today, 7);
22923 }
22924 },
22925 {
22926 id: "past-month",
22927 label: (0, import_i18n34.__)("Past month"),
22928 getValue: () => {
22929 const today = (0, import_date4.getDate)(null);
22930 return subMonths(today, 1);
22931 }
22932 }
22933 ];
22934 var DATE_RANGE_PRESETS = [
22935 {
22936 id: "last-7-days",
22937 label: (0, import_i18n34.__)("Last 7 days"),
22938 getValue: () => {
22939 const today = (0, import_date4.getDate)(null);
22940 return [subDays(today, 7), today];
22941 }
22942 },
22943 {
22944 id: "last-30-days",
22945 label: (0, import_i18n34.__)("Last 30 days"),
22946 getValue: () => {
22947 const today = (0, import_date4.getDate)(null);
22948 return [subDays(today, 30), today];
22949 }
22950 },
22951 {
22952 id: "month-to-date",
22953 label: (0, import_i18n34.__)("Month to date"),
22954 getValue: () => {
22955 const today = (0, import_date4.getDate)(null);
22956 return [startOfMonth(today), today];
22957 }
22958 },
22959 {
22960 id: "last-year",
22961 label: (0, import_i18n34.__)("Last year"),
22962 getValue: () => {
22963 const today = (0, import_date4.getDate)(null);
22964 return [subYears(today, 1), today];
22965 }
22966 },
22967 {
22968 id: "year-to-date",
22969 label: (0, import_i18n34.__)("Year to date"),
22970 getValue: () => {
22971 const today = (0, import_date4.getDate)(null);
22972 return [startOfYear(today), today];
22973 }
22974 }
22975 ];
22976 var parseDate = (dateString) => {
22977 if (!dateString) {
22978 return null;
22979 }
22980 const parsed = (0, import_date4.getDate)(dateString);
22981 return parsed && isValid(parsed) ? parsed : null;
22982 };
22983 var formatDate = (date) => {
22984 if (!date) {
22985 return "";
22986 }
22987 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
22988 };
22989 function ValidatedDateControl({
22990 field,
22991 validity,
22992 inputRefs,
22993 isTouched,
22994 setIsTouched,
22995 children
22996 }) {
22997 const { isValid: isValid2 } = field;
22998 const [customValidity, setCustomValidity] = (0, import_element61.useState)(void 0);
22999 const validateRefs = (0, import_element61.useCallback)(() => {
23000 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23001 for (const ref of refs) {
23002 const input = ref.current;
23003 if (input && !input.validity.valid) {
23004 setCustomValidity({
23005 type: "invalid",
23006 message: input.validationMessage
23007 });
23008 return;
23009 }
23010 }
23011 setCustomValidity(void 0);
23012 }, [inputRefs]);
23013 (0, import_element61.useEffect)(() => {
23014 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23015 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23016 for (const ref of refs) {
23017 const input = ref.current;
23018 if (input) {
23019 input.setCustomValidity(
23020 result?.type === "invalid" && result.message ? result.message : ""
23021 );
23022 }
23023 }
23024 }, [inputRefs, isValid2, validity]);
23025 (0, import_element61.useEffect)(() => {
23026 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
23027 const handleInvalid = (event) => {
23028 event.preventDefault();
23029 setIsTouched(true);
23030 };
23031 for (const ref of refs) {
23032 ref.current?.addEventListener("invalid", handleInvalid);
23033 }
23034 return () => {
23035 for (const ref of refs) {
23036 ref.current?.removeEventListener("invalid", handleInvalid);
23037 }
23038 };
23039 }, [inputRefs, setIsTouched]);
23040 (0, import_element61.useEffect)(() => {
23041 if (!isTouched) {
23042 return;
23043 }
23044 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
23045 if (result) {
23046 setCustomValidity(result);
23047 } else {
23048 validateRefs();
23049 }
23050 }, [isTouched, isValid2, validity, validateRefs]);
23051 const onBlur = (event) => {
23052 if (isTouched) {
23053 return;
23054 }
23055 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
23056 setIsTouched(true);
23057 }
23058 };
23059 return /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)("div", { onBlur, children: [
23060 children,
23061 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23062 "p",
23063 {
23064 className: clsx_default(
23065 "components-validated-control__indicator",
23066 customValidity.type === "invalid" ? "is-invalid" : void 0
23067 ),
23068 children: [
23069 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23070 import_components32.Icon,
23071 {
23072 className: "components-validated-control__indicator-icon",
23073 icon: error_default,
23074 size: 16,
23075 fill: "currentColor"
23076 }
23077 ),
23078 customValidity.message
23079 ]
23080 }
23081 ) })
23082 ] });
23083 }
23084 function CalendarDateControl({
23085 data,
23086 field,
23087 onChange,
23088 hideLabelFromVision,
23089 markWhenOptional,
23090 validity
23091 }) {
23092 const {
23093 id,
23094 label,
23095 description,
23096 setValue,
23097 getValue,
23098 isValid: isValid2,
23099 format: fieldFormat
23100 } = field;
23101 const disabled2 = field.isDisabled({ item: data, field });
23102 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23103 null
23104 );
23105 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23106 const fieldValue = getValue({ item: data });
23107 const value = typeof fieldValue === "string" ? fieldValue : void 0;
23108 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23109 const parsedDate = parseDate(value);
23110 return parsedDate || /* @__PURE__ */ new Date();
23111 });
23112 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23113 const validityTargetRef = (0, import_element61.useRef)(null);
23114 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23115 const onChangeCallback = (0, import_element61.useCallback)(
23116 (newValue) => onChange(setValue({ item: data, value: newValue })),
23117 [data, onChange, setValue]
23118 );
23119 const onSelectDate = (0, import_element61.useCallback)(
23120 (newDate) => {
23121 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
23122 onChangeCallback(dateValue);
23123 setSelectedPresetId(null);
23124 setIsTouched(true);
23125 },
23126 [onChangeCallback]
23127 );
23128 const handlePresetClick = (0, import_element61.useCallback)(
23129 (preset) => {
23130 const presetDate = preset.getValue();
23131 const dateValue = formatDate(presetDate);
23132 setCalendarMonth(presetDate);
23133 onChangeCallback(dateValue);
23134 setSelectedPresetId(preset.id);
23135 setIsTouched(true);
23136 },
23137 [onChangeCallback]
23138 );
23139 const handleManualDateChange = (0, import_element61.useCallback)(
23140 (newValue) => {
23141 onChangeCallback(newValue);
23142 if (newValue) {
23143 const parsedDate = parseDate(newValue);
23144 if (parsedDate) {
23145 setCalendarMonth(parsedDate);
23146 }
23147 }
23148 setSelectedPresetId(null);
23149 setIsTouched(true);
23150 },
23151 [onChangeCallback]
23152 );
23153 const {
23154 timezone: { string: timezoneString }
23155 } = (0, import_date4.getSettings)();
23156 let displayLabel = label;
23157 if (isValid2?.required && !markWhenOptional) {
23158 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23159 } else if (!isValid2?.required && markWhenOptional) {
23160 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23161 }
23162 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23163 ValidatedDateControl,
23164 {
23165 field,
23166 validity,
23167 inputRefs: validityTargetRef,
23168 isTouched,
23169 setIsTouched,
23170 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23171 import_components32.BaseControl,
23172 {
23173 id,
23174 className: "dataviews-controls__date",
23175 label: displayLabel,
23176 help: description,
23177 hideLabelFromVision,
23178 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23179 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23180 Stack,
23181 {
23182 direction: "row",
23183 gap: "sm",
23184 wrap: "wrap",
23185 justify: "flex-start",
23186 children: [
23187 DATE_PRESETS.map((preset) => {
23188 const isSelected2 = selectedPresetId === preset.id;
23189 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23190 import_components32.Button,
23191 {
23192 className: "dataviews-controls__date-preset",
23193 variant: "tertiary",
23194 isPressed: isSelected2,
23195 size: "small",
23196 disabled: disabled2,
23197 accessibleWhenDisabled: true,
23198 onClick: () => handlePresetClick(preset),
23199 children: preset.label
23200 },
23201 preset.id
23202 );
23203 }),
23204 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23205 import_components32.Button,
23206 {
23207 className: "dataviews-controls__date-preset",
23208 variant: "tertiary",
23209 isPressed: !selectedPresetId,
23210 size: "small",
23211 disabled: !!selectedPresetId || disabled2,
23212 accessibleWhenDisabled: true,
23213 children: (0, import_i18n34.__)("Custom")
23214 }
23215 )
23216 ]
23217 }
23218 ),
23219 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23220 import_components32.__experimentalInputControl,
23221 {
23222 __next40pxDefaultSize: true,
23223 ref: validityTargetRef,
23224 type: "date",
23225 label: (0, import_i18n34.__)("Date"),
23226 hideLabelFromVision: true,
23227 value,
23228 onChange: handleManualDateChange,
23229 required: !!field.isValid?.required,
23230 disabled: disabled2,
23231 min: minConstraint,
23232 max: maxConstraint
23233 }
23234 ),
23235 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23236 DateCalendar2,
23237 {
23238 style: { width: "100%" },
23239 selected: value ? parseDate(value) || void 0 : void 0,
23240 onSelect: onSelectDate,
23241 month: calendarMonth,
23242 onMonthChange: setCalendarMonth,
23243 timeZone: timezoneString || void 0,
23244 weekStartsOn,
23245 disabled: disabled2 || disabledMatchers,
23246 disableNavigation: disabled2
23247 }
23248 )
23249 ] })
23250 }
23251 )
23252 }
23253 );
23254 }
23255 function CalendarDateRangeControl({
23256 data,
23257 field,
23258 onChange,
23259 hideLabelFromVision,
23260 markWhenOptional,
23261 validity
23262 }) {
23263 const {
23264 id,
23265 label,
23266 description,
23267 getValue,
23268 setValue,
23269 isValid: isValid2,
23270 format: fieldFormat
23271 } = field;
23272 const disabled2 = field.isDisabled({ item: data, field });
23273 let value;
23274 const fieldValue = getValue({ item: data });
23275 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
23276 value = fieldValue;
23277 }
23278 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
23279 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
23280 const onChangeCallback = (0, import_element61.useCallback)(
23281 (newValue) => {
23282 onChange(
23283 setValue({
23284 item: data,
23285 value: newValue
23286 })
23287 );
23288 },
23289 [data, onChange, setValue]
23290 );
23291 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
23292 null
23293 );
23294 const selectedRange = (0, import_element61.useMemo)(() => {
23295 if (!value) {
23296 return { from: void 0, to: void 0 };
23297 }
23298 const [from, to] = value;
23299 return {
23300 from: parseDate(from) || void 0,
23301 to: parseDate(to) || void 0
23302 };
23303 }, [value]);
23304 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
23305 return selectedRange.from || /* @__PURE__ */ new Date();
23306 });
23307 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
23308 const fromInputRef = (0, import_element61.useRef)(null);
23309 const toInputRef = (0, import_element61.useRef)(null);
23310 const updateDateRange = (0, import_element61.useCallback)(
23311 (fromDate, toDate2) => {
23312 if (fromDate && toDate2) {
23313 onChangeCallback([
23314 formatDate(fromDate),
23315 formatDate(toDate2)
23316 ]);
23317 } else if (!fromDate && !toDate2) {
23318 onChangeCallback(void 0);
23319 }
23320 },
23321 [onChangeCallback]
23322 );
23323 const onSelectCalendarRange = (0, import_element61.useCallback)(
23324 (newRange) => {
23325 updateDateRange(newRange?.from, newRange?.to);
23326 setSelectedPresetId(null);
23327 setIsTouched(true);
23328 },
23329 [updateDateRange]
23330 );
23331 const handlePresetClick = (0, import_element61.useCallback)(
23332 (preset) => {
23333 const [startDate, endDate] = preset.getValue();
23334 setCalendarMonth(startDate);
23335 updateDateRange(startDate, endDate);
23336 setSelectedPresetId(preset.id);
23337 setIsTouched(true);
23338 },
23339 [updateDateRange]
23340 );
23341 const handleManualDateChange = (0, import_element61.useCallback)(
23342 (fromOrTo, newValue) => {
23343 const [currentFrom, currentTo] = value || [
23344 void 0,
23345 void 0
23346 ];
23347 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
23348 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
23349 updateDateRange(updatedFrom, updatedTo);
23350 if (newValue) {
23351 const parsedDate = parseDate(newValue);
23352 if (parsedDate) {
23353 setCalendarMonth(parsedDate);
23354 }
23355 }
23356 setSelectedPresetId(null);
23357 setIsTouched(true);
23358 },
23359 [value, updateDateRange]
23360 );
23361 const { timezone } = (0, import_date4.getSettings)();
23362 let displayLabel = label;
23363 if (field.isValid?.required && !markWhenOptional) {
23364 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
23365 } else if (!field.isValid?.required && markWhenOptional) {
23366 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
23367 }
23368 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23369 ValidatedDateControl,
23370 {
23371 field,
23372 validity,
23373 inputRefs: [fromInputRef, toInputRef],
23374 isTouched,
23375 setIsTouched,
23376 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23377 import_components32.BaseControl,
23378 {
23379 id,
23380 className: "dataviews-controls__date",
23381 label: displayLabel,
23382 help: description,
23383 hideLabelFromVision,
23384 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "column", gap: "lg", children: [
23385 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23386 Stack,
23387 {
23388 direction: "row",
23389 gap: "sm",
23390 wrap: "wrap",
23391 justify: "flex-start",
23392 children: [
23393 DATE_RANGE_PRESETS.map((preset) => {
23394 const isSelected2 = selectedPresetId === preset.id;
23395 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23396 import_components32.Button,
23397 {
23398 className: "dataviews-controls__date-preset",
23399 variant: "tertiary",
23400 isPressed: isSelected2,
23401 size: "small",
23402 disabled: disabled2,
23403 accessibleWhenDisabled: true,
23404 onClick: () => handlePresetClick(preset),
23405 children: preset.label
23406 },
23407 preset.id
23408 );
23409 }),
23410 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23411 import_components32.Button,
23412 {
23413 className: "dataviews-controls__date-preset",
23414 variant: "tertiary",
23415 isPressed: !selectedPresetId,
23416 size: "small",
23417 accessibleWhenDisabled: true,
23418 disabled: !!selectedPresetId || disabled2,
23419 children: (0, import_i18n34.__)("Custom")
23420 }
23421 )
23422 ]
23423 }
23424 ),
23425 /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(
23426 Stack,
23427 {
23428 direction: "row",
23429 gap: "sm",
23430 justify: "space-between",
23431 className: "dataviews-controls__date-range-inputs",
23432 children: [
23433 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23434 import_components32.__experimentalInputControl,
23435 {
23436 __next40pxDefaultSize: true,
23437 ref: fromInputRef,
23438 type: "date",
23439 label: (0, import_i18n34.__)("From"),
23440 hideLabelFromVision: true,
23441 value: value?.[0],
23442 onChange: (newValue) => handleManualDateChange("from", newValue),
23443 required: !!field.isValid?.required,
23444 disabled: disabled2,
23445 min: minConstraint,
23446 max: maxConstraint
23447 }
23448 ),
23449 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23450 import_components32.__experimentalInputControl,
23451 {
23452 __next40pxDefaultSize: true,
23453 ref: toInputRef,
23454 type: "date",
23455 label: (0, import_i18n34.__)("To"),
23456 hideLabelFromVision: true,
23457 value: value?.[1],
23458 onChange: (newValue) => handleManualDateChange("to", newValue),
23459 required: !!field.isValid?.required,
23460 disabled: disabled2,
23461 min: minConstraint,
23462 max: maxConstraint
23463 }
23464 )
23465 ]
23466 }
23467 ),
23468 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23469 DateRangeCalendar,
23470 {
23471 style: { width: "100%" },
23472 selected: selectedRange,
23473 onSelect: onSelectCalendarRange,
23474 month: calendarMonth,
23475 onMonthChange: setCalendarMonth,
23476 timeZone: timezone.string || void 0,
23477 weekStartsOn,
23478 disabled: disabled2 || disabledMatchers
23479 }
23480 )
23481 ] })
23482 }
23483 )
23484 }
23485 );
23486 }
23487 function DateControl({
23488 data,
23489 field,
23490 onChange,
23491 hideLabelFromVision,
23492 markWhenOptional,
23493 operator,
23494 validity
23495 }) {
23496 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23497 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23498 RelativeDateControl,
23499 {
23500 className: "dataviews-controls__date",
23501 data,
23502 field,
23503 onChange,
23504 hideLabelFromVision,
23505 operator
23506 }
23507 );
23508 }
23509 if (operator === OPERATOR_BETWEEN) {
23510 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23511 CalendarDateRangeControl,
23512 {
23513 data,
23514 field,
23515 onChange,
23516 hideLabelFromVision,
23517 markWhenOptional,
23518 validity
23519 }
23520 );
23521 }
23522 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23523 CalendarDateControl,
23524 {
23525 data,
23526 field,
23527 onChange,
23528 hideLabelFromVision,
23529 markWhenOptional,
23530 validity
23531 }
23532 );
23533 }
23534
23535 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23536 var import_components33 = __toESM(require_components(), 1);
23537 var import_element62 = __toESM(require_element(), 1);
23538 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
23539 var { ValidatedSelectControl } = unlock3(import_components33.privateApis);
23540 function Select({
23541 data,
23542 field,
23543 onChange,
23544 hideLabelFromVision,
23545 markWhenOptional,
23546 validity
23547 }) {
23548 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23549 const disabled2 = field.isDisabled({ item: data, field });
23550 const isMultiple = type === "array";
23551 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23552 const onChangeControl = (0, import_element62.useCallback)(
23553 (newValue) => onChange(setValue({ item: data, value: newValue })),
23554 [data, onChange, setValue]
23555 );
23556 const { elements, isLoading } = useElements({
23557 elements: field.elements,
23558 getElements: field.getElements
23559 });
23560 if (isLoading) {
23561 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_components33.Spinner, {});
23562 }
23563 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
23564 ValidatedSelectControl,
23565 {
23566 required: !!field.isValid?.required,
23567 markWhenOptional,
23568 customValidity: getCustomValidity(isValid2, validity),
23569 label,
23570 value,
23571 help: description,
23572 options: elements,
23573 onChange: onChangeControl,
23574 __next40pxDefaultSize: true,
23575 hideLabelFromVision,
23576 multiple: isMultiple,
23577 disabled: disabled2
23578 }
23579 );
23580 }
23581
23582 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23583 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
23584 var ELEMENTS_THRESHOLD = 10;
23585 function AdaptiveSelect(props) {
23586 const { field } = props;
23587 const { elements } = useElements({
23588 elements: field.elements,
23589 getElements: field.getElements
23590 });
23591 if (elements.length >= ELEMENTS_THRESHOLD) {
23592 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Combobox3, { ...props });
23593 }
23594 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Select, { ...props });
23595 }
23596
23597 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23598 var import_components35 = __toESM(require_components(), 1);
23599
23600 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23601 var import_components34 = __toESM(require_components(), 1);
23602 var import_element63 = __toESM(require_element(), 1);
23603 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23604 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components34.privateApis);
23605 function ValidatedText({
23606 data,
23607 field,
23608 onChange,
23609 hideLabelFromVision,
23610 markWhenOptional,
23611 type,
23612 prefix,
23613 suffix,
23614 validity
23615 }) {
23616 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23617 const value = getValue({ item: data });
23618 const disabled2 = field.isDisabled({ item: data, field });
23619 const onChangeControl = (0, import_element63.useCallback)(
23620 (newValue) => onChange(
23621 setValue({
23622 item: data,
23623 value: newValue
23624 })
23625 ),
23626 [data, setValue, onChange]
23627 );
23628 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23629 ValidatedInputControl2,
23630 {
23631 required: !!isValid2.required,
23632 markWhenOptional,
23633 customValidity: getCustomValidity(isValid2, validity),
23634 label,
23635 placeholder,
23636 value: value ?? "",
23637 help: description,
23638 onChange: onChangeControl,
23639 hideLabelFromVision,
23640 type,
23641 prefix,
23642 suffix,
23643 disabled: disabled2,
23644 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23645 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23646 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23647 __next40pxDefaultSize: true
23648 }
23649 );
23650 }
23651
23652 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23653 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23654 function Email({
23655 data,
23656 field,
23657 onChange,
23658 hideLabelFromVision,
23659 markWhenOptional,
23660 validity
23661 }) {
23662 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23663 ValidatedText,
23664 {
23665 ...{
23666 data,
23667 field,
23668 onChange,
23669 hideLabelFromVision,
23670 markWhenOptional,
23671 validity,
23672 type: "email",
23673 prefix: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.Icon, { icon: envelope_default }) })
23674 }
23675 }
23676 );
23677 }
23678
23679 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23680 var import_components36 = __toESM(require_components(), 1);
23681 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23682 function Telephone({
23683 data,
23684 field,
23685 onChange,
23686 hideLabelFromVision,
23687 markWhenOptional,
23688 validity
23689 }) {
23690 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23691 ValidatedText,
23692 {
23693 ...{
23694 data,
23695 field,
23696 onChange,
23697 hideLabelFromVision,
23698 markWhenOptional,
23699 validity,
23700 type: "tel",
23701 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.Icon, { icon: mobile_default }) })
23702 }
23703 }
23704 );
23705 }
23706
23707 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23708 var import_components37 = __toESM(require_components(), 1);
23709 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23710 function Url({
23711 data,
23712 field,
23713 onChange,
23714 hideLabelFromVision,
23715 markWhenOptional,
23716 validity
23717 }) {
23718 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23719 ValidatedText,
23720 {
23721 ...{
23722 data,
23723 field,
23724 onChange,
23725 hideLabelFromVision,
23726 markWhenOptional,
23727 validity,
23728 type: "url",
23729 prefix: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components37.Icon, { icon: link_default }) })
23730 }
23731 }
23732 );
23733 }
23734
23735 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23736 var import_components38 = __toESM(require_components(), 1);
23737 var import_element64 = __toESM(require_element(), 1);
23738 var import_i18n35 = __toESM(require_i18n(), 1);
23739 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23740 var { ValidatedNumberControl } = unlock3(import_components38.privateApis);
23741 function toNumberOrEmpty(value) {
23742 if (value === "" || value === void 0) {
23743 return "";
23744 }
23745 const number = Number(value);
23746 return Number.isFinite(number) ? number : "";
23747 }
23748 function BetweenControls({
23749 value,
23750 onChange,
23751 hideLabelFromVision,
23752 step
23753 }) {
23754 const [min2 = "", max2 = ""] = value;
23755 const onChangeMin = (0, import_element64.useCallback)(
23756 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23757 [onChange, max2]
23758 );
23759 const onChangeMax = (0, import_element64.useCallback)(
23760 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23761 [onChange, min2]
23762 );
23763 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23764 import_components38.BaseControl,
23765 {
23766 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
23767 children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
23768 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23769 import_components38.__experimentalNumberControl,
23770 {
23771 label: (0, import_i18n35.__)("Min."),
23772 value: min2,
23773 max: max2 ? Number(max2) - step : void 0,
23774 onChange: onChangeMin,
23775 __next40pxDefaultSize: true,
23776 hideLabelFromVision,
23777 step
23778 }
23779 ),
23780 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23781 import_components38.__experimentalNumberControl,
23782 {
23783 label: (0, import_i18n35.__)("Max."),
23784 value: max2,
23785 min: min2 ? Number(min2) + step : void 0,
23786 onChange: onChangeMax,
23787 __next40pxDefaultSize: true,
23788 hideLabelFromVision,
23789 step
23790 }
23791 )
23792 ] })
23793 }
23794 );
23795 }
23796 function ValidatedNumber({
23797 data,
23798 field,
23799 onChange,
23800 hideLabelFromVision,
23801 markWhenOptional,
23802 operator,
23803 validity
23804 }) {
23805 const decimals = field.format?.decimals ?? 0;
23806 const step = Math.pow(10, Math.abs(decimals) * -1);
23807 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23808 const value = getValue({ item: data }) ?? "";
23809 const disabled2 = field.isDisabled({ item: data, field });
23810 const onChangeControl = (0, import_element64.useCallback)(
23811 (newValue) => {
23812 onChange(
23813 setValue({
23814 item: data,
23815 // Do not convert an empty string or undefined to a number,
23816 // otherwise there's a mismatch between the UI control (empty)
23817 // and the data relied by onChange (0).
23818 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23819 })
23820 );
23821 },
23822 [data, onChange, setValue]
23823 );
23824 const onChangeBetweenControls = (0, import_element64.useCallback)(
23825 (newValue) => {
23826 onChange(
23827 setValue({
23828 item: data,
23829 value: newValue
23830 })
23831 );
23832 },
23833 [data, onChange, setValue]
23834 );
23835 if (operator === OPERATOR_BETWEEN) {
23836 let valueBetween = ["", ""];
23837 if (Array.isArray(value) && value.length === 2 && value.every(
23838 (element) => typeof element === "number" || element === ""
23839 )) {
23840 valueBetween = value;
23841 }
23842 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23843 BetweenControls,
23844 {
23845 value: valueBetween,
23846 onChange: onChangeBetweenControls,
23847 hideLabelFromVision,
23848 step
23849 }
23850 );
23851 }
23852 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
23853 ValidatedNumberControl,
23854 {
23855 required: !!isValid2.required,
23856 markWhenOptional,
23857 customValidity: getCustomValidity(isValid2, validity),
23858 label,
23859 help: description,
23860 value,
23861 onChange: onChangeControl,
23862 __next40pxDefaultSize: true,
23863 hideLabelFromVision,
23864 step,
23865 min: isValid2.min ? isValid2.min.constraint : void 0,
23866 max: isValid2.max ? isValid2.max.constraint : void 0,
23867 disabled: disabled2
23868 }
23869 );
23870 }
23871
23872 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23873 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23874 function Integer(props) {
23875 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ValidatedNumber, { ...props });
23876 }
23877
23878 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23879 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23880 function Number2(props) {
23881 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(ValidatedNumber, { ...props });
23882 }
23883
23884 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23885 var import_components39 = __toESM(require_components(), 1);
23886 var import_element65 = __toESM(require_element(), 1);
23887 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23888 var { ValidatedRadioControl } = unlock3(import_components39.privateApis);
23889 function Radio({
23890 data,
23891 field,
23892 onChange,
23893 hideLabelFromVision,
23894 markWhenOptional,
23895 validity
23896 }) {
23897 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23898 const disabled2 = field.isDisabled({ item: data, field });
23899 const { elements, isLoading } = useElements({
23900 elements: field.elements,
23901 getElements: field.getElements
23902 });
23903 const value = getValue({ item: data });
23904 const onChangeControl = (0, import_element65.useCallback)(
23905 (newValue) => onChange(setValue({ item: data, value: newValue })),
23906 [data, onChange, setValue]
23907 );
23908 if (isLoading) {
23909 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components39.Spinner, {});
23910 }
23911 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23912 ValidatedRadioControl,
23913 {
23914 required: !!field.isValid?.required,
23915 markWhenOptional,
23916 customValidity: getCustomValidity(isValid2, validity),
23917 label,
23918 help: description,
23919 onChange: onChangeControl,
23920 options: elements,
23921 selected: value,
23922 hideLabelFromVision,
23923 disabled: disabled2
23924 }
23925 );
23926 }
23927
23928 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23929 var import_element66 = __toESM(require_element(), 1);
23930 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23931 function Text3({
23932 data,
23933 field,
23934 onChange,
23935 hideLabelFromVision,
23936 markWhenOptional,
23937 config,
23938 validity
23939 }) {
23940 const { prefix, suffix } = config || {};
23941 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23942 ValidatedText,
23943 {
23944 ...{
23945 data,
23946 field,
23947 onChange,
23948 hideLabelFromVision,
23949 markWhenOptional,
23950 validity,
23951 prefix: prefix ? (0, import_element66.createElement)(prefix) : void 0,
23952 suffix: suffix ? (0, import_element66.createElement)(suffix) : void 0
23953 }
23954 }
23955 );
23956 }
23957
23958 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23959 var import_components40 = __toESM(require_components(), 1);
23960 var import_element67 = __toESM(require_element(), 1);
23961 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23962 var { ValidatedToggleControl } = unlock3(import_components40.privateApis);
23963 function Toggle({
23964 field,
23965 onChange,
23966 data,
23967 hideLabelFromVision,
23968 markWhenOptional,
23969 validity
23970 }) {
23971 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23972 const disabled2 = field.isDisabled({ item: data, field });
23973 const onChangeControl = (0, import_element67.useCallback)(() => {
23974 onChange(
23975 setValue({ item: data, value: !getValue({ item: data }) })
23976 );
23977 }, [onChange, setValue, data, getValue]);
23978 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23979 ValidatedToggleControl,
23980 {
23981 required: !!isValid2.required,
23982 markWhenOptional,
23983 customValidity: getCustomValidity(isValid2, validity),
23984 hidden: hideLabelFromVision,
23985 label,
23986 help: description,
23987 checked: getValue({ item: data }),
23988 onChange: onChangeControl,
23989 disabled: disabled2
23990 }
23991 );
23992 }
23993
23994 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
23995 var import_components41 = __toESM(require_components(), 1);
23996 var import_element68 = __toESM(require_element(), 1);
23997 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23998 var { ValidatedTextareaControl } = unlock3(import_components41.privateApis);
23999 function Textarea({
24000 data,
24001 field,
24002 onChange,
24003 hideLabelFromVision,
24004 markWhenOptional,
24005 config,
24006 validity
24007 }) {
24008 const { rows = 4 } = config || {};
24009 const disabled2 = field.isDisabled({ item: data, field });
24010 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24011 const value = field.getValue({ item: data });
24012 const onChangeControl = (0, import_element68.useCallback)(
24013 (newValue) => onChange(setValue({ item: data, value: newValue })),
24014 [data, onChange, setValue]
24015 );
24016 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
24017 ValidatedTextareaControl,
24018 {
24019 required: !!isValid2.required,
24020 markWhenOptional,
24021 customValidity: getCustomValidity(isValid2, validity),
24022 label,
24023 placeholder,
24024 value: value ?? "",
24025 help: description,
24026 onChange: onChangeControl,
24027 rows,
24028 disabled: disabled2,
24029 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
24030 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
24031 __next40pxDefaultSize: true,
24032 hideLabelFromVision
24033 }
24034 );
24035 }
24036
24037 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
24038 var import_components42 = __toESM(require_components(), 1);
24039 var import_element69 = __toESM(require_element(), 1);
24040 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
24041 var { ValidatedToggleGroupControl } = unlock3(import_components42.privateApis);
24042 function ToggleGroup({
24043 data,
24044 field,
24045 onChange,
24046 hideLabelFromVision,
24047 markWhenOptional,
24048 validity
24049 }) {
24050 const { getValue, setValue, isValid: isValid2 } = field;
24051 const disabled2 = field.isDisabled({ item: data, field });
24052 const value = getValue({ item: data });
24053 const onChangeControl = (0, import_element69.useCallback)(
24054 (newValue) => onChange(setValue({ item: data, value: newValue })),
24055 [data, onChange, setValue]
24056 );
24057 const { elements, isLoading } = useElements({
24058 elements: field.elements,
24059 getElements: field.getElements
24060 });
24061 if (isLoading) {
24062 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components42.Spinner, {});
24063 }
24064 if (elements.length === 0) {
24065 return null;
24066 }
24067 const selectedOption = elements.find((el) => el.value === value);
24068 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24069 ValidatedToggleGroupControl,
24070 {
24071 required: !!field.isValid?.required,
24072 markWhenOptional,
24073 customValidity: getCustomValidity(isValid2, validity),
24074 __next40pxDefaultSize: true,
24075 isBlock: true,
24076 label: field.label,
24077 help: selectedOption?.description || field.description,
24078 onChange: onChangeControl,
24079 value,
24080 hideLabelFromVision,
24081 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
24082 import_components42.__experimentalToggleGroupControlOption,
24083 {
24084 label: el.label,
24085 value: el.value,
24086 disabled: disabled2
24087 },
24088 el.value
24089 ))
24090 }
24091 );
24092 }
24093
24094 // packages/dataviews/build-module/components/dataform-controls/array.mjs
24095 var import_components43 = __toESM(require_components(), 1);
24096 var import_element70 = __toESM(require_element(), 1);
24097 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
24098 var { ValidatedFormTokenField } = unlock3(import_components43.privateApis);
24099 function ArrayControl({
24100 data,
24101 field,
24102 onChange,
24103 hideLabelFromVision,
24104 markWhenOptional,
24105 validity
24106 }) {
24107 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
24108 const value = getValue({ item: data });
24109 const disabled2 = field.isDisabled({ item: data, field });
24110 const { elements, isLoading } = useElements({
24111 elements: field.elements,
24112 getElements: field.getElements
24113 });
24114 const arrayValueAsElements = (0, import_element70.useMemo)(
24115 () => Array.isArray(value) ? value.map((token) => {
24116 const element = elements?.find(
24117 (suggestion) => suggestion.value === token
24118 );
24119 return element || { value: token, label: token };
24120 }) : [],
24121 [value, elements]
24122 );
24123 const onChangeControl = (0, import_element70.useCallback)(
24124 (tokens) => {
24125 const valueTokens = tokens.map((token) => {
24126 if (typeof token === "object" && "value" in token) {
24127 return token.value;
24128 }
24129 return token;
24130 });
24131 onChange(setValue({ item: data, value: valueTokens }));
24132 },
24133 [onChange, setValue, data]
24134 );
24135 if (isLoading) {
24136 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.Spinner, {});
24137 }
24138 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
24139 ValidatedFormTokenField,
24140 {
24141 required: !!isValid2?.required,
24142 markWhenOptional,
24143 customValidity: getCustomValidity(isValid2, validity),
24144 label: hideLabelFromVision ? void 0 : label,
24145 value: arrayValueAsElements,
24146 onChange: onChangeControl,
24147 placeholder,
24148 suggestions: elements?.map((element) => element.value),
24149 disabled: disabled2,
24150 __experimentalValidateInput: (token) => {
24151 if (field.isValid?.elements && elements) {
24152 return elements.some(
24153 (element) => element.value === token || element.label === token
24154 );
24155 }
24156 return true;
24157 },
24158 __experimentalExpandOnFocus: elements && elements.length > 0,
24159 help: description ?? (field.isValid?.elements ? "" : void 0),
24160 displayTransform: (token) => {
24161 if (typeof token === "object" && "label" in token) {
24162 return token.label;
24163 }
24164 if (typeof token === "string" && elements) {
24165 const element = elements.find(
24166 (el) => el.value === token
24167 );
24168 return element?.label || token;
24169 }
24170 return token;
24171 },
24172 __experimentalRenderItem: ({ item }) => {
24173 if (typeof item === "string" && elements) {
24174 const element = elements.find(
24175 (el) => el.value === item
24176 );
24177 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { children: element?.label || item });
24178 }
24179 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("span", { children: item });
24180 }
24181 }
24182 );
24183 }
24184
24185 // node_modules/colord/index.mjs
24186 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
24187 var t = function(r3) {
24188 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
24189 };
24190 var n = function(r3, t2, n2) {
24191 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
24192 };
24193 var e = function(r3, t2, n2) {
24194 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
24195 };
24196 var u = function(r3) {
24197 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
24198 };
24199 var a = function(r3) {
24200 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
24201 };
24202 var o = function(r3) {
24203 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
24204 };
24205 var i = /^#([0-9a-f]{3,8})$/i;
24206 var s = function(r3) {
24207 var t2 = r3.toString(16);
24208 return t2.length < 2 ? "0" + t2 : t2;
24209 };
24210 var h = function(r3) {
24211 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;
24212 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
24213 };
24214 var b = function(r3) {
24215 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
24216 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
24217 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;
24218 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 };
24219 };
24220 var g = function(r3) {
24221 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
24222 };
24223 var d = function(r3) {
24224 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
24225 };
24226 var f = function(r3) {
24227 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 }));
24228 var t2, n2, e2;
24229 };
24230 var c = function(r3) {
24231 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 };
24232 var t2, n2, e2, u2;
24233 };
24234 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24235 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24236 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24237 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
24238 var y = { string: [[function(r3) {
24239 var t2 = i.exec(r3);
24240 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;
24241 }, "hex"], [function(r3) {
24242 var t2 = v.exec(r3) || m.exec(r3);
24243 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;
24244 }, "rgb"], [function(t2) {
24245 var n2 = l.exec(t2) || p.exec(t2);
24246 if (!n2) return null;
24247 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) });
24248 return f(a2);
24249 }, "hsl"]], object: [[function(r3) {
24250 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
24251 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
24252 }, "rgb"], [function(r3) {
24253 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
24254 if (!t(n2) || !t(e2) || !t(u2)) return null;
24255 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
24256 return f(i2);
24257 }, "hsl"], [function(r3) {
24258 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
24259 if (!t(n2) || !t(a2) || !t(o2)) return null;
24260 var h2 = (function(r4) {
24261 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
24262 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
24263 return b(h2);
24264 }, "hsv"]] };
24265 var N = function(r3, t2) {
24266 for (var n2 = 0; n2 < t2.length; n2++) {
24267 var e2 = t2[n2][0](r3);
24268 if (e2) return [e2, t2[n2][1]];
24269 }
24270 return [null, void 0];
24271 };
24272 var x = function(r3) {
24273 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
24274 };
24275 var M = function(r3, t2) {
24276 var n2 = c(r3);
24277 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
24278 };
24279 var H = function(r3) {
24280 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
24281 };
24282 var $ = function(r3, t2) {
24283 var n2 = c(r3);
24284 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
24285 };
24286 var j = (function() {
24287 function r3(r4) {
24288 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
24289 }
24290 return r3.prototype.isValid = function() {
24291 return null !== this.parsed;
24292 }, r3.prototype.brightness = function() {
24293 return n(H(this.rgba), 2);
24294 }, r3.prototype.isDark = function() {
24295 return H(this.rgba) < 0.5;
24296 }, r3.prototype.isLight = function() {
24297 return H(this.rgba) >= 0.5;
24298 }, r3.prototype.toHex = function() {
24299 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;
24300 var r4, t2, e2, u2, a2, i2;
24301 }, r3.prototype.toRgb = function() {
24302 return o(this.rgba);
24303 }, r3.prototype.toRgbString = function() {
24304 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 + ")";
24305 var r4, t2, n2, e2, u2;
24306 }, r3.prototype.toHsl = function() {
24307 return d(c(this.rgba));
24308 }, r3.prototype.toHslString = function() {
24309 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 + "%)";
24310 var r4, t2, n2, e2, u2;
24311 }, r3.prototype.toHsv = function() {
24312 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
24313 var r4;
24314 }, r3.prototype.invert = function() {
24315 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
24316 var r4;
24317 }, r3.prototype.saturate = function(r4) {
24318 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
24319 }, r3.prototype.desaturate = function(r4) {
24320 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
24321 }, r3.prototype.grayscale = function() {
24322 return w(M(this.rgba, -1));
24323 }, r3.prototype.lighten = function(r4) {
24324 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
24325 }, r3.prototype.darken = function(r4) {
24326 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
24327 }, r3.prototype.rotate = function(r4) {
24328 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
24329 }, r3.prototype.alpha = function(r4) {
24330 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
24331 var t2;
24332 }, r3.prototype.hue = function(r4) {
24333 var t2 = c(this.rgba);
24334 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
24335 }, r3.prototype.isEqual = function(r4) {
24336 return this.toHex() === w(r4).toHex();
24337 }, r3;
24338 })();
24339 var w = function(r3) {
24340 return r3 instanceof j ? r3 : new j(r3);
24341 };
24342
24343 // packages/dataviews/build-module/components/dataform-controls/color.mjs
24344 var import_components44 = __toESM(require_components(), 1);
24345 var import_element71 = __toESM(require_element(), 1);
24346 var import_i18n36 = __toESM(require_i18n(), 1);
24347 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24348 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components44.privateApis);
24349 var ColorPickerDropdown = ({
24350 color,
24351 onColorChange,
24352 disabled: disabled2
24353 }) => {
24354 const validColor = color && w(color).isValid() ? color : "#ffffff";
24355 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24356 import_components44.Dropdown,
24357 {
24358 className: "dataviews-controls__color-picker-dropdown",
24359 popoverProps: { resize: false },
24360 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24361 import_components44.Button,
24362 {
24363 onClick: onToggle,
24364 "aria-label": (0, import_i18n36.__)("Open color picker"),
24365 size: "small",
24366 disabled: disabled2,
24367 accessibleWhenDisabled: true,
24368 icon: () => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
24369 }
24370 ),
24371 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24372 import_components44.ColorPicker,
24373 {
24374 color: validColor,
24375 onChange: onColorChange,
24376 enableAlpha: true
24377 }
24378 ) })
24379 }
24380 );
24381 };
24382 function Color({
24383 data,
24384 field,
24385 onChange,
24386 hideLabelFromVision,
24387 markWhenOptional,
24388 validity
24389 }) {
24390 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
24391 const disabled2 = field.isDisabled({ item: data, field });
24392 const value = field.getValue({ item: data }) || "";
24393 const handleColorChange = (0, import_element71.useCallback)(
24394 (newColor) => {
24395 onChange(setValue({ item: data, value: newColor }));
24396 },
24397 [data, onChange, setValue]
24398 );
24399 const handleInputChange = (0, import_element71.useCallback)(
24400 (newValue) => {
24401 onChange(setValue({ item: data, value: newValue || "" }));
24402 },
24403 [data, onChange, setValue]
24404 );
24405 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24406 ValidatedInputControl3,
24407 {
24408 required: !!field.isValid?.required,
24409 markWhenOptional,
24410 customValidity: getCustomValidity(isValid2, validity),
24411 label,
24412 placeholder,
24413 value,
24414 help: description,
24415 onChange: handleInputChange,
24416 hideLabelFromVision,
24417 type: "text",
24418 disabled: disabled2,
24419 prefix: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24420 ColorPickerDropdown,
24421 {
24422 color: value,
24423 onColorChange: handleColorChange,
24424 disabled: disabled2
24425 }
24426 ) })
24427 }
24428 );
24429 }
24430
24431 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24432 var import_components45 = __toESM(require_components(), 1);
24433 var import_element72 = __toESM(require_element(), 1);
24434 var import_i18n37 = __toESM(require_i18n(), 1);
24435 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24436 function Password({
24437 data,
24438 field,
24439 onChange,
24440 hideLabelFromVision,
24441 markWhenOptional,
24442 validity
24443 }) {
24444 const [isVisible2, setIsVisible] = (0, import_element72.useState)(false);
24445 const disabled2 = field.isDisabled({ item: data, field });
24446 const toggleVisibility = (0, import_element72.useCallback)(() => {
24447 setIsVisible((prev) => !prev);
24448 }, []);
24449 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24450 ValidatedText,
24451 {
24452 ...{
24453 data,
24454 field,
24455 onChange,
24456 hideLabelFromVision,
24457 markWhenOptional,
24458 validity,
24459 type: isVisible2 ? "text" : "password",
24460 suffix: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
24461 import_components45.Button,
24462 {
24463 icon: isVisible2 ? unseen_default : seen_default,
24464 onClick: toggleVisibility,
24465 size: "small",
24466 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
24467 disabled: disabled2,
24468 accessibleWhenDisabled: true
24469 }
24470 ) })
24471 }
24472 }
24473 );
24474 }
24475
24476 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24477 function hasElements(field) {
24478 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24479 }
24480
24481 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24482 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24483 var FORM_CONTROLS = {
24484 adaptiveSelect: AdaptiveSelect,
24485 array: ArrayControl,
24486 checkbox: Checkbox,
24487 color: Color,
24488 combobox: Combobox3,
24489 datetime: DateTime,
24490 date: DateControl,
24491 email: Email,
24492 telephone: Telephone,
24493 url: Url,
24494 integer: Integer,
24495 number: Number2,
24496 password: Password,
24497 radio: Radio,
24498 select: Select,
24499 text: Text3,
24500 toggle: Toggle,
24501 textarea: Textarea,
24502 toggleGroup: ToggleGroup
24503 };
24504 function isEditConfig(value) {
24505 return value && typeof value === "object" && typeof value.control === "string";
24506 }
24507 function createConfiguredControl(config) {
24508 const { control, ...controlConfig } = config;
24509 const BaseControlType = getControlByType(control);
24510 if (BaseControlType === null) {
24511 return null;
24512 }
24513 return function ConfiguredControl(props) {
24514 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(BaseControlType, { ...props, config: controlConfig });
24515 };
24516 }
24517 function getControl(field, fallback) {
24518 if (typeof field.Edit === "function") {
24519 return field.Edit;
24520 }
24521 if (typeof field.Edit === "string") {
24522 return getControlByType(field.Edit);
24523 }
24524 if (isEditConfig(field.Edit)) {
24525 return createConfiguredControl(field.Edit);
24526 }
24527 if (hasElements(field) && field.type !== "array") {
24528 return getControlByType("adaptiveSelect");
24529 }
24530 if (fallback === null) {
24531 return null;
24532 }
24533 return getControlByType(fallback);
24534 }
24535 function getControlByType(type) {
24536 if (Object.keys(FORM_CONTROLS).includes(type)) {
24537 return FORM_CONTROLS[type];
24538 }
24539 return null;
24540 }
24541
24542 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24543 function getFilterBy(field, defaultOperators, validOperators) {
24544 if (field.filterBy === false) {
24545 return false;
24546 }
24547 const operators = field.filterBy?.operators?.filter(
24548 (op) => validOperators.includes(op)
24549 ) ?? defaultOperators;
24550 if (operators.length === 0) {
24551 return false;
24552 }
24553 return {
24554 isPrimary: !!field.filterBy?.isPrimary,
24555 operators
24556 };
24557 }
24558 var get_filter_by_default = getFilterBy;
24559
24560 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24561 var getValueFromId = (id) => ({ item }) => {
24562 const path = id.split(".");
24563 let value = item;
24564 for (const segment of path) {
24565 if (value.hasOwnProperty(segment)) {
24566 value = value[segment];
24567 } else {
24568 value = void 0;
24569 }
24570 }
24571 return value;
24572 };
24573 var get_value_from_id_default = getValueFromId;
24574
24575 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24576 var setValueFromId = (id) => ({ value }) => {
24577 const path = id.split(".");
24578 const result = {};
24579 let current = result;
24580 for (const segment of path.slice(0, -1)) {
24581 current[segment] = {};
24582 current = current[segment];
24583 }
24584 current[path.at(-1)] = value;
24585 return result;
24586 };
24587 var set_value_from_id_default = setValueFromId;
24588
24589 // packages/dataviews/build-module/field-types/email.mjs
24590 var import_i18n38 = __toESM(require_i18n(), 1);
24591
24592 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24593 function RenderFromElements({
24594 item,
24595 field
24596 }) {
24597 const { elements, isLoading } = useElements({
24598 elements: field.elements,
24599 getElements: field.getElements
24600 });
24601 const value = field.getValue({ item });
24602 if (isLoading) {
24603 return value;
24604 }
24605 if (elements.length === 0) {
24606 return value;
24607 }
24608 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24609 }
24610
24611 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24612 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24613 function render({
24614 item,
24615 field
24616 }) {
24617 if (field.hasElements) {
24618 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(RenderFromElements, { item, field });
24619 }
24620 return field.getValueFormatted({ item, field });
24621 }
24622
24623 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24624 var sort_text_default = (a2, b2, direction) => {
24625 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24626 };
24627
24628 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24629 function isValidRequired(item, field) {
24630 const value = field.getValue({ item });
24631 return ![void 0, "", null].includes(value);
24632 }
24633
24634 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24635 function isValidMinLength(item, field) {
24636 if (typeof field.isValid.minLength?.constraint !== "number") {
24637 return false;
24638 }
24639 const value = field.getValue({ item });
24640 if ([void 0, "", null].includes(value)) {
24641 return true;
24642 }
24643 return String(value).length >= field.isValid.minLength.constraint;
24644 }
24645
24646 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24647 function isValidMaxLength(item, field) {
24648 if (typeof field.isValid.maxLength?.constraint !== "number") {
24649 return false;
24650 }
24651 const value = field.getValue({ item });
24652 if ([void 0, "", null].includes(value)) {
24653 return true;
24654 }
24655 return String(value).length <= field.isValid.maxLength.constraint;
24656 }
24657
24658 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24659 function isValidPattern(item, field) {
24660 if (field.isValid.pattern?.constraint === void 0) {
24661 return true;
24662 }
24663 try {
24664 const regexp = new RegExp(field.isValid.pattern.constraint);
24665 const value = field.getValue({ item });
24666 if ([void 0, "", null].includes(value)) {
24667 return true;
24668 }
24669 return regexp.test(String(value));
24670 } catch {
24671 return false;
24672 }
24673 }
24674
24675 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24676 function isValidElements(item, field) {
24677 const elements = field.elements ?? [];
24678 const validValues = elements.map((el) => el.value);
24679 if (validValues.length === 0) {
24680 return true;
24681 }
24682 const value = field.getValue({ item });
24683 return [].concat(value).every((v2) => validValues.includes(v2));
24684 }
24685
24686 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24687 function getValueFormatted({
24688 item,
24689 field
24690 }) {
24691 return field.getValue({ item });
24692 }
24693 var get_value_formatted_default_default = getValueFormatted;
24694
24695 // packages/dataviews/build-module/field-types/email.mjs
24696 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])?)*$/;
24697 function isValidCustom(item, field) {
24698 const value = field.getValue({ item });
24699 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24700 return (0, import_i18n38.__)("Value must be a valid email address.");
24701 }
24702 return null;
24703 }
24704 var email_default = {
24705 type: "email",
24706 render,
24707 Edit: "email",
24708 sort: sort_text_default,
24709 enableSorting: true,
24710 enableGlobalSearch: false,
24711 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24712 validOperators: [
24713 OPERATOR_IS,
24714 OPERATOR_IS_NOT,
24715 OPERATOR_CONTAINS,
24716 OPERATOR_NOT_CONTAINS,
24717 OPERATOR_STARTS_WITH,
24718 // Multiple selection
24719 OPERATOR_IS_ANY,
24720 OPERATOR_IS_NONE,
24721 OPERATOR_IS_ALL,
24722 OPERATOR_IS_NOT_ALL
24723 ],
24724 format: {},
24725 getValueFormatted: get_value_formatted_default_default,
24726 validate: {
24727 required: isValidRequired,
24728 pattern: isValidPattern,
24729 minLength: isValidMinLength,
24730 maxLength: isValidMaxLength,
24731 elements: isValidElements,
24732 custom: isValidCustom
24733 }
24734 };
24735
24736 // packages/dataviews/build-module/field-types/integer.mjs
24737 var import_i18n39 = __toESM(require_i18n(), 1);
24738
24739 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24740 var sort_number_default = (a2, b2, direction) => {
24741 return direction === "asc" ? a2 - b2 : b2 - a2;
24742 };
24743
24744 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24745 function isValidMin(item, field) {
24746 if (typeof field.isValid.min?.constraint !== "number") {
24747 return false;
24748 }
24749 const value = field.getValue({ item });
24750 if ([void 0, "", null].includes(value)) {
24751 return true;
24752 }
24753 return Number(value) >= field.isValid.min.constraint;
24754 }
24755
24756 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24757 function isValidMax(item, field) {
24758 if (typeof field.isValid.max?.constraint !== "number") {
24759 return false;
24760 }
24761 const value = field.getValue({ item });
24762 if ([void 0, "", null].includes(value)) {
24763 return true;
24764 }
24765 return Number(value) <= field.isValid.max.constraint;
24766 }
24767
24768 // packages/dataviews/build-module/field-types/integer.mjs
24769 var format2 = {
24770 separatorThousand: ","
24771 };
24772 function getValueFormatted2({
24773 item,
24774 field
24775 }) {
24776 let value = field.getValue({ item });
24777 if (value === null || value === void 0) {
24778 return "";
24779 }
24780 value = Number(value);
24781 if (!Number.isFinite(value)) {
24782 return String(value);
24783 }
24784 let formatInteger;
24785 if (field.type !== "integer") {
24786 formatInteger = format2;
24787 } else {
24788 formatInteger = field.format;
24789 }
24790 const { separatorThousand } = formatInteger;
24791 const integerValue = Math.trunc(value);
24792 if (!separatorThousand) {
24793 return String(integerValue);
24794 }
24795 return String(integerValue).replace(
24796 /\B(?=(\d{3})+(?!\d))/g,
24797 separatorThousand
24798 );
24799 }
24800 function isValidCustom2(item, field) {
24801 const value = field.getValue({ item });
24802 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24803 return (0, import_i18n39.__)("Value must be an integer.");
24804 }
24805 return null;
24806 }
24807 var integer_default = {
24808 type: "integer",
24809 render,
24810 Edit: "integer",
24811 sort: sort_number_default,
24812 enableSorting: true,
24813 enableGlobalSearch: false,
24814 defaultOperators: [
24815 OPERATOR_IS,
24816 OPERATOR_IS_NOT,
24817 OPERATOR_LESS_THAN,
24818 OPERATOR_GREATER_THAN,
24819 OPERATOR_LESS_THAN_OR_EQUAL,
24820 OPERATOR_GREATER_THAN_OR_EQUAL,
24821 OPERATOR_BETWEEN
24822 ],
24823 validOperators: [
24824 // Single-selection
24825 OPERATOR_IS,
24826 OPERATOR_IS_NOT,
24827 OPERATOR_LESS_THAN,
24828 OPERATOR_GREATER_THAN,
24829 OPERATOR_LESS_THAN_OR_EQUAL,
24830 OPERATOR_GREATER_THAN_OR_EQUAL,
24831 OPERATOR_BETWEEN,
24832 // Multiple-selection
24833 OPERATOR_IS_ANY,
24834 OPERATOR_IS_NONE,
24835 OPERATOR_IS_ALL,
24836 OPERATOR_IS_NOT_ALL
24837 ],
24838 format: format2,
24839 getValueFormatted: getValueFormatted2,
24840 validate: {
24841 required: isValidRequired,
24842 min: isValidMin,
24843 max: isValidMax,
24844 elements: isValidElements,
24845 custom: isValidCustom2
24846 }
24847 };
24848
24849 // packages/dataviews/build-module/field-types/number.mjs
24850 var import_i18n40 = __toESM(require_i18n(), 1);
24851 var format3 = {
24852 separatorThousand: ",",
24853 separatorDecimal: ".",
24854 decimals: 2
24855 };
24856 function getValueFormatted3({
24857 item,
24858 field
24859 }) {
24860 let value = field.getValue({ item });
24861 if (value === null || value === void 0) {
24862 return "";
24863 }
24864 value = Number(value);
24865 if (!Number.isFinite(value)) {
24866 return String(value);
24867 }
24868 let formatNumber;
24869 if (field.type !== "number") {
24870 formatNumber = format3;
24871 } else {
24872 formatNumber = field.format;
24873 }
24874 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24875 const fixedValue = value.toFixed(decimals);
24876 const [integerPart, decimalPart] = fixedValue.split(".");
24877 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24878 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24879 }
24880 function isEmpty2(value) {
24881 return value === "" || value === void 0 || value === null;
24882 }
24883 function isValidCustom3(item, field) {
24884 const value = field.getValue({ item });
24885 if (!isEmpty2(value) && !Number.isFinite(value)) {
24886 return (0, import_i18n40.__)("Value must be a number.");
24887 }
24888 return null;
24889 }
24890 var number_default = {
24891 type: "number",
24892 render,
24893 Edit: "number",
24894 sort: sort_number_default,
24895 enableSorting: true,
24896 enableGlobalSearch: false,
24897 defaultOperators: [
24898 OPERATOR_IS,
24899 OPERATOR_IS_NOT,
24900 OPERATOR_LESS_THAN,
24901 OPERATOR_GREATER_THAN,
24902 OPERATOR_LESS_THAN_OR_EQUAL,
24903 OPERATOR_GREATER_THAN_OR_EQUAL,
24904 OPERATOR_BETWEEN
24905 ],
24906 validOperators: [
24907 // Single-selection
24908 OPERATOR_IS,
24909 OPERATOR_IS_NOT,
24910 OPERATOR_LESS_THAN,
24911 OPERATOR_GREATER_THAN,
24912 OPERATOR_LESS_THAN_OR_EQUAL,
24913 OPERATOR_GREATER_THAN_OR_EQUAL,
24914 OPERATOR_BETWEEN,
24915 // Multiple-selection
24916 OPERATOR_IS_ANY,
24917 OPERATOR_IS_NONE,
24918 OPERATOR_IS_ALL,
24919 OPERATOR_IS_NOT_ALL
24920 ],
24921 format: format3,
24922 getValueFormatted: getValueFormatted3,
24923 validate: {
24924 required: isValidRequired,
24925 min: isValidMin,
24926 max: isValidMax,
24927 elements: isValidElements,
24928 custom: isValidCustom3
24929 }
24930 };
24931
24932 // packages/dataviews/build-module/field-types/text.mjs
24933 var text_default = {
24934 type: "text",
24935 render,
24936 Edit: "text",
24937 sort: sort_text_default,
24938 enableSorting: true,
24939 enableGlobalSearch: false,
24940 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24941 validOperators: [
24942 // Single selection
24943 OPERATOR_IS,
24944 OPERATOR_IS_NOT,
24945 OPERATOR_CONTAINS,
24946 OPERATOR_NOT_CONTAINS,
24947 OPERATOR_STARTS_WITH,
24948 // Multiple selection
24949 OPERATOR_IS_ANY,
24950 OPERATOR_IS_NONE,
24951 OPERATOR_IS_ALL,
24952 OPERATOR_IS_NOT_ALL
24953 ],
24954 format: {},
24955 getValueFormatted: get_value_formatted_default_default,
24956 validate: {
24957 required: isValidRequired,
24958 pattern: isValidPattern,
24959 minLength: isValidMinLength,
24960 maxLength: isValidMaxLength,
24961 elements: isValidElements
24962 }
24963 };
24964
24965 // packages/dataviews/build-module/field-types/datetime.mjs
24966 var import_date7 = __toESM(require_date(), 1);
24967
24968 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24969 var import_date6 = __toESM(require_date(), 1);
24970 function parseDateLike(value) {
24971 if (!value) {
24972 return null;
24973 }
24974 if (!isValid(new Date(value))) {
24975 return null;
24976 }
24977 const parsed = (0, import_date6.getDate)(value);
24978 return parsed && isValid(parsed) ? parsed : null;
24979 }
24980 function validateDateLikeBoundary(item, field, boundary) {
24981 const constraint = field.isValid[boundary]?.constraint;
24982 if (typeof constraint !== "string") {
24983 return false;
24984 }
24985 const value = field.getValue({ item });
24986 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
24987 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
24988 return true;
24989 }
24990 const parsedConstraint = parseDateLike(constraint);
24991 const parsedValue = parseDateLike(String(boundaryValue));
24992 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
24993 }
24994 function isValidMinDate(item, field) {
24995 return validateDateLikeBoundary(item, field, "min");
24996 }
24997 function isValidMaxDate(item, field) {
24998 return validateDateLikeBoundary(item, field, "max");
24999 }
25000
25001 // packages/dataviews/build-module/field-types/datetime.mjs
25002 var format4 = {
25003 datetime: (0, import_date7.getSettings)().formats.datetime,
25004 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
25005 };
25006 function getValueFormatted4({
25007 item,
25008 field
25009 }) {
25010 const value = field.getValue({ item });
25011 if (["", void 0, null].includes(value)) {
25012 return "";
25013 }
25014 let formatDatetime;
25015 if (field.type !== "datetime") {
25016 formatDatetime = format4;
25017 } else {
25018 formatDatetime = field.format;
25019 }
25020 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
25021 }
25022 var sort = (a2, b2, direction) => {
25023 const timeA = new Date(a2).getTime();
25024 const timeB = new Date(b2).getTime();
25025 return direction === "asc" ? timeA - timeB : timeB - timeA;
25026 };
25027 var datetime_default = {
25028 type: "datetime",
25029 render,
25030 Edit: "datetime",
25031 sort,
25032 enableSorting: true,
25033 enableGlobalSearch: false,
25034 defaultOperators: [
25035 OPERATOR_ON,
25036 OPERATOR_NOT_ON,
25037 OPERATOR_BEFORE,
25038 OPERATOR_AFTER,
25039 OPERATOR_BEFORE_INC,
25040 OPERATOR_AFTER_INC,
25041 OPERATOR_IN_THE_PAST,
25042 OPERATOR_OVER
25043 ],
25044 validOperators: [
25045 OPERATOR_ON,
25046 OPERATOR_NOT_ON,
25047 OPERATOR_BEFORE,
25048 OPERATOR_AFTER,
25049 OPERATOR_BEFORE_INC,
25050 OPERATOR_AFTER_INC,
25051 OPERATOR_IN_THE_PAST,
25052 OPERATOR_OVER
25053 ],
25054 format: format4,
25055 getValueFormatted: getValueFormatted4,
25056 validate: {
25057 required: isValidRequired,
25058 elements: isValidElements,
25059 min: isValidMinDate,
25060 max: isValidMaxDate
25061 }
25062 };
25063
25064 // packages/dataviews/build-module/field-types/date.mjs
25065 var import_date8 = __toESM(require_date(), 1);
25066 var format5 = {
25067 date: (0, import_date8.getSettings)().formats.date,
25068 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
25069 };
25070 function getValueFormatted5({
25071 item,
25072 field
25073 }) {
25074 const value = field.getValue({ item });
25075 if (["", void 0, null].includes(value)) {
25076 return "";
25077 }
25078 let formatDate2;
25079 if (field.type !== "date") {
25080 formatDate2 = format5;
25081 } else {
25082 formatDate2 = field.format;
25083 }
25084 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
25085 }
25086 var sort2 = (a2, b2, direction) => {
25087 const timeA = new Date(a2).getTime();
25088 const timeB = new Date(b2).getTime();
25089 return direction === "asc" ? timeA - timeB : timeB - timeA;
25090 };
25091 var date_default = {
25092 type: "date",
25093 render,
25094 Edit: "date",
25095 sort: sort2,
25096 enableSorting: true,
25097 enableGlobalSearch: false,
25098 defaultOperators: [
25099 OPERATOR_ON,
25100 OPERATOR_NOT_ON,
25101 OPERATOR_BEFORE,
25102 OPERATOR_AFTER,
25103 OPERATOR_BEFORE_INC,
25104 OPERATOR_AFTER_INC,
25105 OPERATOR_IN_THE_PAST,
25106 OPERATOR_OVER,
25107 OPERATOR_BETWEEN
25108 ],
25109 validOperators: [
25110 OPERATOR_ON,
25111 OPERATOR_NOT_ON,
25112 OPERATOR_BEFORE,
25113 OPERATOR_AFTER,
25114 OPERATOR_BEFORE_INC,
25115 OPERATOR_AFTER_INC,
25116 OPERATOR_IN_THE_PAST,
25117 OPERATOR_OVER,
25118 OPERATOR_BETWEEN
25119 ],
25120 format: format5,
25121 getValueFormatted: getValueFormatted5,
25122 validate: {
25123 required: isValidRequired,
25124 elements: isValidElements,
25125 min: isValidMinDate,
25126 max: isValidMaxDate
25127 }
25128 };
25129
25130 // packages/dataviews/build-module/field-types/boolean.mjs
25131 var import_i18n41 = __toESM(require_i18n(), 1);
25132
25133 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
25134 function isValidRequiredForBool(item, field) {
25135 const value = field.getValue({ item });
25136 return value === true;
25137 }
25138
25139 // packages/dataviews/build-module/field-types/boolean.mjs
25140 function getValueFormatted6({
25141 item,
25142 field
25143 }) {
25144 const value = field.getValue({ item });
25145 if (value === true) {
25146 return (0, import_i18n41.__)("True");
25147 }
25148 if (value === false) {
25149 return (0, import_i18n41.__)("False");
25150 }
25151 return "";
25152 }
25153 function isValidCustom4(item, field) {
25154 const value = field.getValue({ item });
25155 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
25156 return (0, import_i18n41.__)("Value must be true, false, or undefined");
25157 }
25158 return null;
25159 }
25160 var sort3 = (a2, b2, direction) => {
25161 const boolA = Boolean(a2);
25162 const boolB = Boolean(b2);
25163 if (boolA === boolB) {
25164 return 0;
25165 }
25166 if (direction === "asc") {
25167 return boolA ? 1 : -1;
25168 }
25169 return boolA ? -1 : 1;
25170 };
25171 var boolean_default = {
25172 type: "boolean",
25173 render,
25174 Edit: "checkbox",
25175 sort: sort3,
25176 validate: {
25177 required: isValidRequiredForBool,
25178 elements: isValidElements,
25179 custom: isValidCustom4
25180 },
25181 enableSorting: true,
25182 enableGlobalSearch: false,
25183 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25184 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25185 format: {},
25186 getValueFormatted: getValueFormatted6
25187 };
25188
25189 // packages/dataviews/build-module/field-types/media.mjs
25190 var media_default = {
25191 type: "media",
25192 render: () => null,
25193 Edit: null,
25194 sort: () => 0,
25195 enableSorting: false,
25196 enableGlobalSearch: false,
25197 defaultOperators: [],
25198 validOperators: [],
25199 format: {},
25200 getValueFormatted: get_value_formatted_default_default,
25201 // cannot validate any constraint, so
25202 // the only available validation for the field author
25203 // would be providing a custom validator.
25204 validate: {}
25205 };
25206
25207 // packages/dataviews/build-module/field-types/array.mjs
25208 var import_i18n42 = __toESM(require_i18n(), 1);
25209
25210 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
25211 function isValidRequiredForArray(item, field) {
25212 const value = field.getValue({ item });
25213 return Array.isArray(value) && value.length > 0 && value.every(
25214 (element) => ![void 0, "", null].includes(element)
25215 );
25216 }
25217
25218 // packages/dataviews/build-module/field-types/array.mjs
25219 function getValueFormatted7({
25220 item,
25221 field
25222 }) {
25223 const value = field.getValue({ item });
25224 const arr = Array.isArray(value) ? value : [];
25225 return arr.join(", ");
25226 }
25227 function render2({ item, field }) {
25228 return getValueFormatted7({ item, field });
25229 }
25230 function isValidCustom5(item, field) {
25231 const value = field.getValue({ item });
25232 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
25233 return (0, import_i18n42.__)("Value must be an array.");
25234 }
25235 if (!value.every((v2) => typeof v2 === "string")) {
25236 return (0, import_i18n42.__)("Every value must be a string.");
25237 }
25238 return null;
25239 }
25240 var sort4 = (a2, b2, direction) => {
25241 const arrA = Array.isArray(a2) ? a2 : [];
25242 const arrB = Array.isArray(b2) ? b2 : [];
25243 if (arrA.length !== arrB.length) {
25244 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
25245 }
25246 const joinedA = arrA.join(",");
25247 const joinedB = arrB.join(",");
25248 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
25249 };
25250 var array_default = {
25251 type: "array",
25252 render: render2,
25253 Edit: "array",
25254 sort: sort4,
25255 enableSorting: true,
25256 enableGlobalSearch: false,
25257 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25258 validOperators: [
25259 OPERATOR_IS_ANY,
25260 OPERATOR_IS_NONE,
25261 OPERATOR_IS_ALL,
25262 OPERATOR_IS_NOT_ALL
25263 ],
25264 format: {},
25265 getValueFormatted: getValueFormatted7,
25266 validate: {
25267 required: isValidRequiredForArray,
25268 elements: isValidElements,
25269 custom: isValidCustom5
25270 }
25271 };
25272
25273 // packages/dataviews/build-module/field-types/password.mjs
25274 function getValueFormatted8({
25275 item,
25276 field
25277 }) {
25278 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
25279 }
25280 var password_default = {
25281 type: "password",
25282 render,
25283 Edit: "password",
25284 sort: () => 0,
25285 // Passwords should not be sortable for security reasons
25286 enableSorting: false,
25287 enableGlobalSearch: false,
25288 defaultOperators: [],
25289 validOperators: [],
25290 format: {},
25291 getValueFormatted: getValueFormatted8,
25292 validate: {
25293 required: isValidRequired,
25294 pattern: isValidPattern,
25295 minLength: isValidMinLength,
25296 maxLength: isValidMaxLength,
25297 elements: isValidElements
25298 }
25299 };
25300
25301 // packages/dataviews/build-module/field-types/telephone.mjs
25302 var telephone_default = {
25303 type: "telephone",
25304 render,
25305 Edit: "telephone",
25306 sort: sort_text_default,
25307 enableSorting: true,
25308 enableGlobalSearch: false,
25309 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25310 validOperators: [
25311 OPERATOR_IS,
25312 OPERATOR_IS_NOT,
25313 OPERATOR_CONTAINS,
25314 OPERATOR_NOT_CONTAINS,
25315 OPERATOR_STARTS_WITH,
25316 // Multiple selection
25317 OPERATOR_IS_ANY,
25318 OPERATOR_IS_NONE,
25319 OPERATOR_IS_ALL,
25320 OPERATOR_IS_NOT_ALL
25321 ],
25322 format: {},
25323 getValueFormatted: get_value_formatted_default_default,
25324 validate: {
25325 required: isValidRequired,
25326 pattern: isValidPattern,
25327 minLength: isValidMinLength,
25328 maxLength: isValidMaxLength,
25329 elements: isValidElements
25330 }
25331 };
25332
25333 // packages/dataviews/build-module/field-types/color.mjs
25334 var import_i18n43 = __toESM(require_i18n(), 1);
25335 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
25336 function render3({ item, field }) {
25337 if (field.hasElements) {
25338 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(RenderFromElements, { item, field });
25339 }
25340 const value = get_value_formatted_default_default({ item, field });
25341 if (!value || !w(value).isValid()) {
25342 return value;
25343 }
25344 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
25345 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25346 "div",
25347 {
25348 style: {
25349 width: "16px",
25350 height: "16px",
25351 borderRadius: "50%",
25352 backgroundColor: value,
25353 border: "1px solid #ddd",
25354 flexShrink: 0
25355 }
25356 }
25357 ),
25358 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { children: value })
25359 ] });
25360 }
25361 function isValidCustom6(item, field) {
25362 const value = field.getValue({ item });
25363 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
25364 return (0, import_i18n43.__)("Value must be a valid color.");
25365 }
25366 return null;
25367 }
25368 var sort5 = (a2, b2, direction) => {
25369 const colorA = w(a2);
25370 const colorB = w(b2);
25371 if (!colorA.isValid() && !colorB.isValid()) {
25372 return 0;
25373 }
25374 if (!colorA.isValid()) {
25375 return direction === "asc" ? 1 : -1;
25376 }
25377 if (!colorB.isValid()) {
25378 return direction === "asc" ? -1 : 1;
25379 }
25380 const hslA = colorA.toHsl();
25381 const hslB = colorB.toHsl();
25382 if (hslA.h !== hslB.h) {
25383 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
25384 }
25385 if (hslA.s !== hslB.s) {
25386 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
25387 }
25388 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
25389 };
25390 var color_default = {
25391 type: "color",
25392 render: render3,
25393 Edit: "color",
25394 sort: sort5,
25395 enableSorting: true,
25396 enableGlobalSearch: false,
25397 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25398 validOperators: [
25399 OPERATOR_IS,
25400 OPERATOR_IS_NOT,
25401 OPERATOR_IS_ANY,
25402 OPERATOR_IS_NONE
25403 ],
25404 format: {},
25405 getValueFormatted: get_value_formatted_default_default,
25406 validate: {
25407 required: isValidRequired,
25408 elements: isValidElements,
25409 custom: isValidCustom6
25410 }
25411 };
25412
25413 // packages/dataviews/build-module/field-types/url.mjs
25414 var url_default = {
25415 type: "url",
25416 render,
25417 Edit: "url",
25418 sort: sort_text_default,
25419 enableSorting: true,
25420 enableGlobalSearch: false,
25421 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
25422 validOperators: [
25423 OPERATOR_IS,
25424 OPERATOR_IS_NOT,
25425 OPERATOR_CONTAINS,
25426 OPERATOR_NOT_CONTAINS,
25427 OPERATOR_STARTS_WITH,
25428 // Multiple selection
25429 OPERATOR_IS_ANY,
25430 OPERATOR_IS_NONE,
25431 OPERATOR_IS_ALL,
25432 OPERATOR_IS_NOT_ALL
25433 ],
25434 format: {},
25435 getValueFormatted: get_value_formatted_default_default,
25436 validate: {
25437 required: isValidRequired,
25438 pattern: isValidPattern,
25439 minLength: isValidMinLength,
25440 maxLength: isValidMaxLength,
25441 elements: isValidElements
25442 }
25443 };
25444
25445 // packages/dataviews/build-module/field-types/no-type.mjs
25446 var sort6 = (a2, b2, direction) => {
25447 if (typeof a2 === "number" && typeof b2 === "number") {
25448 return sort_number_default(a2, b2, direction);
25449 }
25450 return sort_text_default(a2, b2, direction);
25451 };
25452 var no_type_default = {
25453 // type: no type for this one
25454 render,
25455 Edit: null,
25456 sort: sort6,
25457 enableSorting: true,
25458 enableGlobalSearch: false,
25459 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25460 validOperators: getAllOperatorNames(),
25461 format: {},
25462 getValueFormatted: get_value_formatted_default_default,
25463 validate: {
25464 required: isValidRequired,
25465 elements: isValidElements
25466 }
25467 };
25468
25469 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25470 function supportsNumericRangeConstraint(type) {
25471 return type === "integer" || type === "number";
25472 }
25473 function supportsDateRangeConstraint(type) {
25474 return type === "date" || type === "datetime";
25475 }
25476 function normalizeRangeRule(value, fieldType, key) {
25477 const validator = fieldType.validate[key];
25478 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25479 return { constraint: value, validate: validator };
25480 }
25481 return void 0;
25482 }
25483 function getIsValid(field, fieldType) {
25484 const rules = field.isValid;
25485 let required;
25486 if (rules?.required === true && fieldType.validate.required !== void 0) {
25487 required = {
25488 constraint: true,
25489 validate: fieldType.validate.required
25490 };
25491 }
25492 let elements;
25493 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25494 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25495 elements = {
25496 constraint: true,
25497 validate: fieldType.validate.elements
25498 };
25499 }
25500 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25501 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25502 const minLengthValue = rules?.minLength;
25503 let minLength;
25504 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25505 minLength = {
25506 constraint: minLengthValue,
25507 validate: fieldType.validate.minLength
25508 };
25509 }
25510 const maxLengthValue = rules?.maxLength;
25511 let maxLength;
25512 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25513 maxLength = {
25514 constraint: maxLengthValue,
25515 validate: fieldType.validate.maxLength
25516 };
25517 }
25518 const patternValue = rules?.pattern;
25519 let pattern;
25520 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25521 pattern = {
25522 constraint: patternValue,
25523 validate: fieldType.validate.pattern
25524 };
25525 }
25526 const custom = rules?.custom ?? fieldType.validate.custom;
25527 return {
25528 required,
25529 elements,
25530 min: min2,
25531 max: max2,
25532 minLength,
25533 maxLength,
25534 pattern,
25535 custom
25536 };
25537 }
25538
25539 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25540 function getFilter(fieldType) {
25541 return fieldType.validOperators.reduce((accumulator, operator) => {
25542 const operatorObj = getOperatorByName(operator);
25543 if (operatorObj?.filter) {
25544 accumulator[operator] = operatorObj.filter;
25545 }
25546 return accumulator;
25547 }, {});
25548 }
25549
25550 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25551 function getFormat(field, fieldType) {
25552 return {
25553 ...fieldType.format,
25554 ...field.format
25555 };
25556 }
25557 var get_format_default = getFormat;
25558
25559 // packages/dataviews/build-module/field-types/index.mjs
25560 function getFieldTypeByName(type) {
25561 const found = [
25562 email_default,
25563 integer_default,
25564 number_default,
25565 text_default,
25566 datetime_default,
25567 date_default,
25568 boolean_default,
25569 media_default,
25570 array_default,
25571 password_default,
25572 telephone_default,
25573 color_default,
25574 url_default
25575 ].find((fieldType) => fieldType?.type === type);
25576 if (!!found) {
25577 return found;
25578 }
25579 return no_type_default;
25580 }
25581 function normalizeFields(fields) {
25582 return fields.map((field) => {
25583 const fieldType = getFieldTypeByName(field.type);
25584 const getValue = field.getValue || get_value_from_id_default(field.id);
25585 const sort7 = function(a2, b2, direction) {
25586 const aValue = getValue({ item: a2 });
25587 const bValue = getValue({ item: b2 });
25588 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25589 };
25590 return {
25591 id: field.id,
25592 label: field.label || field.id,
25593 header: field.header || field.label || field.id,
25594 description: field.description,
25595 placeholder: field.placeholder,
25596 getValue,
25597 setValue: field.setValue || set_value_from_id_default(field.id),
25598 elements: field.elements,
25599 getElements: field.getElements,
25600 hasElements: hasElements(field),
25601 isVisible: field.isVisible,
25602 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25603 enableHiding: field.enableHiding ?? true,
25604 readOnly: field.readOnly ?? false,
25605 // The type provides defaults for the following props
25606 type: fieldType.type,
25607 render: field.render ?? fieldType.render,
25608 Edit: getControl(field, fieldType.Edit),
25609 sort: sort7,
25610 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25611 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25612 isValid: getIsValid(field, fieldType),
25613 filterBy: get_filter_by_default(
25614 field,
25615 fieldType.defaultOperators,
25616 fieldType.validOperators
25617 ),
25618 filter: getFilter(fieldType),
25619 format: get_format_default(field, fieldType),
25620 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25621 };
25622 });
25623 }
25624
25625 // packages/dataviews/build-module/hooks/use-data.mjs
25626 var import_element73 = __toESM(require_element(), 1);
25627 function useData({
25628 view,
25629 data: shownData,
25630 getItemId,
25631 isLoading,
25632 paginationInfo,
25633 selection
25634 }) {
25635 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25636 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element73.useState)(
25637 !isLoading
25638 );
25639 (0, import_element73.useEffect)(() => {
25640 if (!isLoading) {
25641 setHasInitiallyLoaded(true);
25642 }
25643 }, [isLoading]);
25644 const previousDataRef = (0, import_element73.useRef)(shownData);
25645 const previousPaginationInfoRef = (0, import_element73.useRef)(paginationInfo);
25646 (0, import_element73.useEffect)(() => {
25647 if (!isLoading) {
25648 previousDataRef.current = shownData;
25649 previousPaginationInfoRef.current = paginationInfo;
25650 }
25651 }, [shownData, isLoading, paginationInfo]);
25652 const [visibleEntries, setVisibleEntries] = (0, import_element73.useState)([]);
25653 const positionMapRef = (0, import_element73.useRef)(/* @__PURE__ */ new Map());
25654 const allLoadedRecordsRef = (0, import_element73.useRef)([]);
25655 const prevViewParamsRef = (0, import_element73.useRef)({
25656 search: void 0,
25657 filters: void 0,
25658 perPage: void 0
25659 });
25660 const scrollDirectionRef = (0, import_element73.useRef)(void 0);
25661 const prevStartPositionRef = (0, import_element73.useRef)(void 0);
25662 const hasInitializedRef = (0, import_element73.useRef)(false);
25663 const allLoadedRecords = (0, import_element73.useMemo)(() => {
25664 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25665 if (view.startPosition < prevStartPositionRef.current) {
25666 scrollDirectionRef.current = "up";
25667 } else if (view.startPosition > prevStartPositionRef.current) {
25668 scrollDirectionRef.current = "down";
25669 }
25670 }
25671 prevStartPositionRef.current = view.startPosition;
25672 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25673 const prevFiltersKey = prevViewParamsRef.current.filters;
25674 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25675 hasInitializedRef.current = true;
25676 prevViewParamsRef.current = {
25677 search: view.search,
25678 filters: currentFiltersKey,
25679 perPage: view.perPage
25680 };
25681 if (shouldReset) {
25682 positionMapRef.current.clear();
25683 scrollDirectionRef.current = void 0;
25684 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25685 const records = shownData.map((record, index2) => {
25686 const position = startPosition + index2;
25687 positionMapRef.current.set(getItemId(record), position);
25688 return {
25689 ...record,
25690 position
25691 };
25692 });
25693 allLoadedRecordsRef.current = records;
25694 return records;
25695 }
25696 const prev = allLoadedRecordsRef.current;
25697 const shownDataIds = new Set(shownData.map(getItemId));
25698 const scrollDirection = scrollDirectionRef.current;
25699 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25700 const newRecords = shownData.map((record, index2) => {
25701 const itemId = getItemId(record);
25702 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25703 if (position !== void 0) {
25704 positionMapRef.current.set(itemId, position);
25705 }
25706 return {
25707 ...record,
25708 position
25709 };
25710 });
25711 if (newRecords.length === 0) {
25712 return prev;
25713 }
25714 const prevWithoutDuplicates = prev.filter(
25715 (record) => !shownDataIds.has(getItemId(record))
25716 );
25717 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25718 allRecords.sort((a2, b2) => {
25719 const posA = a2.position;
25720 const posB = b2.position;
25721 return posA - posB;
25722 });
25723 let result = allRecords;
25724 if (visibleEntries.length > 0) {
25725 const visibleMin = Math.min(...visibleEntries);
25726 const visibleMax = Math.max(...visibleEntries);
25727 const buffer = 20;
25728 const recordPositions = allRecords.map(
25729 (r3) => r3.position
25730 );
25731 const minRecordPos = Math.min(...recordPositions);
25732 const maxRecordPos = Math.max(...recordPositions);
25733 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25734 if (hasOverlap) {
25735 result = allRecords.filter((record) => {
25736 const itemId = getItemId(record);
25737 const isSelected2 = selection?.includes(itemId);
25738 if (isSelected2) {
25739 return true;
25740 }
25741 const itemPosition = record.position;
25742 if (scrollDirection === "up") {
25743 return itemPosition <= visibleMax + buffer;
25744 } else if (scrollDirection === "down") {
25745 return itemPosition >= visibleMin - buffer;
25746 }
25747 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25748 });
25749 }
25750 }
25751 allLoadedRecordsRef.current = result;
25752 return result;
25753 }, [
25754 shownData,
25755 view.search,
25756 view.filters,
25757 view.perPage,
25758 view.startPosition,
25759 view.infiniteScrollEnabled,
25760 visibleEntries,
25761 selection,
25762 getItemId
25763 ]);
25764 if (!isInfiniteScrollEnabled) {
25765 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25766 return {
25767 data: dataToReturn.map((item) => ({
25768 ...item,
25769 position: void 0
25770 })),
25771 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25772 hasInitiallyLoaded,
25773 setVisibleEntries: void 0
25774 };
25775 }
25776 return {
25777 data: allLoadedRecords,
25778 paginationInfo,
25779 hasInitiallyLoaded,
25780 setVisibleEntries
25781 };
25782 }
25783
25784 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25785 var import_element74 = __toESM(require_element(), 1);
25786 var import_compose12 = __toESM(require_compose(), 1);
25787 function captureAnchorElement(container, anchorElementRef, direction) {
25788 const containerRect = container.getBoundingClientRect();
25789 const centerY = containerRect.top + containerRect.height / 2;
25790 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25791 if (items.length === 0) {
25792 return false;
25793 }
25794 const bestAnchor = items.reduce((best, item) => {
25795 const itemRect = item.getBoundingClientRect();
25796 const itemCenterY = itemRect.top + itemRect.height / 2;
25797 const distance = Math.abs(itemCenterY - centerY);
25798 const bestRect = best.getBoundingClientRect();
25799 const bestCenterY = bestRect.top + bestRect.height / 2;
25800 const bestDistance = Math.abs(bestCenterY - centerY);
25801 return distance < bestDistance ? item : best;
25802 });
25803 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25804 const anchorRect = bestAnchor.getBoundingClientRect();
25805 anchorElementRef.current = {
25806 posinset,
25807 viewportOffset: anchorRect.top - containerRect.top,
25808 direction
25809 };
25810 return true;
25811 }
25812 function useInfiniteScroll({
25813 view,
25814 onChangeView,
25815 isLoading,
25816 paginationInfo,
25817 containerRef,
25818 setVisibleEntries
25819 }) {
25820 const anchorElementRef = (0, import_element74.useRef)(null);
25821 const viewRef = (0, import_element74.useRef)(view);
25822 const isLoadingRef = (0, import_element74.useRef)(isLoading);
25823 const onChangeViewRef = (0, import_element74.useRef)(onChangeView);
25824 const totalItemsRef = (0, import_element74.useRef)(paginationInfo.totalItems);
25825 (0, import_element74.useLayoutEffect)(() => {
25826 viewRef.current = view;
25827 isLoadingRef.current = isLoading;
25828 onChangeViewRef.current = onChangeView;
25829 totalItemsRef.current = paginationInfo.totalItems;
25830 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25831 const intersectionObserverCallback = (0, import_element74.useCallback)(
25832 (entries) => {
25833 if (!setVisibleEntries) {
25834 return;
25835 }
25836 setVisibleEntries((prev) => {
25837 const newVisibleEntries = new Set(prev);
25838 let hasChanged = false;
25839 entries.forEach((entry) => {
25840 const posInSet = Number(
25841 entry.target?.attributes?.getNamedItem(
25842 "aria-posinset"
25843 )?.value
25844 );
25845 if (isNaN(posInSet)) {
25846 return;
25847 }
25848 if (entry.isIntersecting) {
25849 if (!newVisibleEntries.has(posInSet)) {
25850 newVisibleEntries.add(posInSet);
25851 hasChanged = true;
25852 }
25853 } else if (newVisibleEntries.has(posInSet)) {
25854 newVisibleEntries.delete(posInSet);
25855 hasChanged = true;
25856 }
25857 });
25858 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25859 });
25860 },
25861 [setVisibleEntries]
25862 );
25863 (0, import_element74.useLayoutEffect)(() => {
25864 const container = containerRef.current;
25865 const anchor = anchorElementRef.current;
25866 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25867 return;
25868 }
25869 const anchorElement = container.querySelector(
25870 `[aria-posinset="${anchor.posinset}"]`
25871 );
25872 if (anchorElement) {
25873 const containerRect = container.getBoundingClientRect();
25874 const anchorRect = anchorElement.getBoundingClientRect();
25875 const currentOffset = anchorRect.top - containerRect.top;
25876 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25877 if (Math.abs(scrollAdjustment) > 1) {
25878 container.scrollTop += scrollAdjustment;
25879 }
25880 }
25881 anchorElementRef.current = null;
25882 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25883 const intersectionObserverRef = (0, import_element74.useRef)(
25884 null
25885 );
25886 (0, import_element74.useEffect)(() => {
25887 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25888 if (intersectionObserverRef.current) {
25889 intersectionObserverRef.current.disconnect();
25890 intersectionObserverRef.current = null;
25891 }
25892 return;
25893 }
25894 intersectionObserverRef.current = new IntersectionObserver(
25895 intersectionObserverCallback,
25896 { root: null, rootMargin: "0px", threshold: 0.1 }
25897 );
25898 return () => {
25899 if (intersectionObserverRef.current) {
25900 intersectionObserverRef.current.disconnect();
25901 intersectionObserverRef.current = null;
25902 }
25903 };
25904 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25905 (0, import_element74.useEffect)(() => {
25906 if (!view.infiniteScrollEnabled || !containerRef.current) {
25907 return;
25908 }
25909 let lastScrollTop = 0;
25910 const BOTTOM_THRESHOLD = 600;
25911 const TOP_THRESHOLD = 800;
25912 const handleScroll = (0, import_compose12.throttle)((event) => {
25913 const currentView = viewRef.current;
25914 const totalItems = totalItemsRef.current;
25915 const target = event.target;
25916 const scrollTop = target.scrollTop;
25917 const scrollHeight = target.scrollHeight;
25918 const clientHeight = target.clientHeight;
25919 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25920 lastScrollTop = scrollTop;
25921 if (isLoadingRef.current) {
25922 return;
25923 }
25924 const currentStartPosition = currentView.startPosition || 1;
25925 const batchSize = currentView.perPage || 10;
25926 const currentEndPosition = Math.min(
25927 currentStartPosition + batchSize,
25928 totalItems
25929 );
25930 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25931 if (currentEndPosition < totalItems) {
25932 const newStartPosition = currentEndPosition;
25933 captureAnchorElement(target, anchorElementRef, "down");
25934 onChangeViewRef.current({
25935 ...currentView,
25936 startPosition: newStartPosition
25937 });
25938 }
25939 }
25940 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25941 if (currentStartPosition > 1) {
25942 const calculatedStartPosition = currentStartPosition - batchSize;
25943 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25944 captureAnchorElement(target, anchorElementRef, "up");
25945 onChangeViewRef.current({
25946 ...currentView,
25947 startPosition: newStartPosition
25948 });
25949 }
25950 }
25951 }, 50);
25952 const container = containerRef.current;
25953 container.addEventListener("scroll", handleScroll);
25954 return () => {
25955 container.removeEventListener("scroll", handleScroll);
25956 handleScroll.cancel();
25957 };
25958 }, [containerRef, view.infiniteScrollEnabled]);
25959 return {
25960 intersectionObserver: intersectionObserverRef.current
25961 };
25962 }
25963
25964 // packages/dataviews/build-module/dataviews/index.mjs
25965 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25966 var defaultGetItemId = (item) => item.id;
25967 var defaultIsItemClickable = () => true;
25968 var EMPTY_ARRAY6 = [];
25969 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25970 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25971 (viewLayout) => !viewLayout.isPicker
25972 );
25973 function DefaultUI({
25974 header,
25975 search = true,
25976 searchLabel = void 0
25977 }) {
25978 const { view } = (0, import_element75.useContext)(dataviews_context_default);
25979 const isInfiniteScroll = view.infiniteScrollEnabled;
25980 return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(import_jsx_runtime110.Fragment, { children: [
25981 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
25982 Stack,
25983 {
25984 direction: "row",
25985 align: "top",
25986 justify: "space-between",
25987 className: clsx_default("dataviews__view-actions", {
25988 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
25989 }),
25990 gap: "xs",
25991 children: [
25992 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
25993 Stack,
25994 {
25995 direction: "row",
25996 justify: "start",
25997 gap: "sm",
25998 className: "dataviews__search",
25999 children: [
26000 search && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(dataviews_search_default, { label: searchLabel }),
26001 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(toggle_default, {})
26002 ]
26003 }
26004 ),
26005 /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
26006 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(dataviews_view_config_default, {}),
26007 header
26008 ] })
26009 ]
26010 }
26011 ),
26012 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
26013 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(DataViewsLayout, {}),
26014 /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(DataViewsFooter, {})
26015 ] });
26016 }
26017 function DataViews({
26018 view,
26019 onChangeView,
26020 fields,
26021 search = true,
26022 searchLabel = void 0,
26023 actions = EMPTY_ARRAY6,
26024 data,
26025 getItemId = defaultGetItemId,
26026 getItemLevel,
26027 isLoading = false,
26028 paginationInfo,
26029 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
26030 selection: selectionProperty,
26031 onChangeSelection,
26032 onClickItem,
26033 renderItemLink,
26034 isItemClickable = defaultIsItemClickable,
26035 header,
26036 children,
26037 config = { perPageSizes: [10, 20, 50, 100] },
26038 empty,
26039 onReset
26040 }) {
26041 const [selectionState, setSelectionState] = (0, import_element75.useState)([]);
26042 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
26043 const selection = isUncontrolled ? selectionState : selectionProperty;
26044 const {
26045 data: displayData,
26046 paginationInfo: displayPaginationInfo,
26047 hasInitiallyLoaded,
26048 setVisibleEntries
26049 } = useData({
26050 view,
26051 data,
26052 getItemId,
26053 isLoading,
26054 selection,
26055 paginationInfo
26056 });
26057 const containerRef = (0, import_element75.useRef)(null);
26058 const [containerWidth, setContainerWidth] = (0, import_element75.useState)(0);
26059 const resizeObserverRef = (0, import_compose13.useResizeObserver)(
26060 (resizeObserverEntries) => {
26061 setContainerWidth(
26062 resizeObserverEntries[0].borderBoxSize[0].inlineSize
26063 );
26064 },
26065 { box: "border-box" }
26066 );
26067 const [openedFilter, setOpenedFilter] = (0, import_element75.useState)(null);
26068 function setSelectionWithChange(value) {
26069 const newValue = typeof value === "function" ? value(selection) : value;
26070 if (isUncontrolled) {
26071 setSelectionState(newValue);
26072 }
26073 if (onChangeSelection) {
26074 onChangeSelection(newValue);
26075 }
26076 }
26077 const _fields = (0, import_element75.useMemo)(() => normalizeFields(fields), [fields]);
26078 const _selection = (0, import_element75.useMemo)(() => {
26079 if (view.infiniteScrollEnabled) {
26080 return selection;
26081 }
26082 return selection.filter(
26083 (id) => data.some((item) => getItemId(item) === id)
26084 );
26085 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
26086 const filters = use_filters_default(_fields, view);
26087 const hasPrimaryOrLockedFilters = (0, import_element75.useMemo)(
26088 () => (filters || []).some(
26089 (filter) => filter.isPrimary || filter.isLocked
26090 ),
26091 [filters]
26092 );
26093 const [isShowingFilter, setIsShowingFilter] = (0, import_element75.useState)(
26094 hasPrimaryOrLockedFilters
26095 );
26096 const { intersectionObserver } = useInfiniteScroll({
26097 view,
26098 onChangeView,
26099 isLoading,
26100 paginationInfo,
26101 containerRef,
26102 setVisibleEntries
26103 });
26104 (0, import_element75.useEffect)(() => {
26105 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
26106 setIsShowingFilter(true);
26107 }
26108 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
26109 const defaultLayouts = (0, import_element75.useMemo)(
26110 () => Object.fromEntries(
26111 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
26112 return dataViewsLayouts.some(
26113 (viewLayout) => viewLayout.type === layoutType
26114 );
26115 }).map(([key, value]) => [
26116 key,
26117 value === true ? {} : value
26118 ])
26119 ),
26120 [defaultLayoutsProperty]
26121 );
26122 if (!defaultLayouts[view.type]) {
26123 return null;
26124 }
26125 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
26126 dataviews_context_default.Provider,
26127 {
26128 value: {
26129 view,
26130 onChangeView,
26131 fields: _fields,
26132 actions,
26133 data: displayData,
26134 isLoading,
26135 paginationInfo: displayPaginationInfo,
26136 selection: _selection,
26137 onChangeSelection: setSelectionWithChange,
26138 openedFilter,
26139 setOpenedFilter,
26140 getItemId,
26141 getItemLevel,
26142 isItemClickable,
26143 onClickItem,
26144 renderItemLink,
26145 containerWidth,
26146 containerRef,
26147 resizeObserverRef,
26148 defaultLayouts,
26149 filters,
26150 isShowingFilter,
26151 setIsShowingFilter,
26152 config,
26153 empty,
26154 hasInitiallyLoaded,
26155 onReset,
26156 intersectionObserver
26157 },
26158 children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
26159 DefaultUI,
26160 {
26161 header,
26162 search,
26163 searchLabel
26164 }
26165 ) })
26166 }
26167 );
26168 }
26169 var DataViewsSubComponents = DataViews;
26170 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
26171 DataViewsSubComponents.Filters = filters_default;
26172 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
26173 DataViewsSubComponents.FiltersToggle = toggle_default;
26174 DataViewsSubComponents.Layout = DataViewsLayout;
26175 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
26176 DataViewsSubComponents.Pagination = DataViewsPagination;
26177 DataViewsSubComponents.Search = dataviews_search_default;
26178 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
26179 DataViewsSubComponents.Footer = DataViewsFooter;
26180 var dataviews_default = DataViewsSubComponents;
26181
26182 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
26183 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
26184 var import_deprecated = __toESM(require_deprecated(), 1);
26185 function normalizeSearchInput2(input = "") {
26186 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
26187 }
26188 var EMPTY_ARRAY7 = [];
26189 function filterSortAndPaginate(data, view, fields) {
26190 if (!data) {
26191 return {
26192 data: EMPTY_ARRAY7,
26193 paginationInfo: { totalItems: 0, totalPages: 0 }
26194 };
26195 }
26196 const _fields = normalizeFields(fields);
26197 let filteredData = [...data];
26198 if (view.search) {
26199 const normalizedSearch = normalizeSearchInput2(view.search);
26200 filteredData = filteredData.filter((item) => {
26201 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
26202 const fieldValue = field.getValue({ item });
26203 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
26204 return values.some(
26205 (value) => normalizeSearchInput2(String(value)).includes(
26206 normalizedSearch
26207 )
26208 );
26209 });
26210 });
26211 }
26212 if (view.filters && view.filters?.length > 0) {
26213 view.filters.forEach((filter) => {
26214 const field = _fields.find(
26215 (_field) => _field.id === filter.field
26216 );
26217 if (field) {
26218 if (filter.operator === OPERATOR_IS_NOT_ALL) {
26219 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
26220 since: "7.0",
26221 alternative: "'isNone'"
26222 });
26223 }
26224 const handler = field.filter[filter.operator];
26225 if (handler) {
26226 filteredData = filteredData.filter(
26227 (item) => handler(item, field, filter.value)
26228 );
26229 }
26230 }
26231 });
26232 }
26233 const sortByField = view.sort?.field ? _fields.find((field) => {
26234 return field.enableSorting !== false && field.id === view.sort?.field;
26235 }) : null;
26236 const groupByField = view.groupBy?.field ? _fields.find((field) => {
26237 return field.enableSorting !== false && field.id === view.groupBy?.field;
26238 }) : null;
26239 if (sortByField || groupByField) {
26240 filteredData.sort((a2, b2) => {
26241 if (groupByField) {
26242 const groupCompare = groupByField.sort(
26243 a2,
26244 b2,
26245 view.groupBy?.direction ?? "asc"
26246 );
26247 if (groupCompare !== 0) {
26248 return groupCompare;
26249 }
26250 }
26251 if (sortByField) {
26252 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
26253 }
26254 return 0;
26255 });
26256 }
26257 let totalItems = filteredData.length;
26258 let totalPages = 1;
26259 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
26260 const start = view.startPosition - 1;
26261 const end = Math.min(start + view.perPage, totalItems);
26262 filteredData = filteredData?.slice(start, end);
26263 } else if (view.page !== void 0 && view.perPage !== void 0) {
26264 const start = (view.page - 1) * view.perPage;
26265 totalItems = filteredData?.length || 0;
26266 totalPages = Math.ceil(totalItems / view.perPage);
26267 filteredData = filteredData?.slice(start, start + view.perPage);
26268 }
26269 return {
26270 data: filteredData,
26271 paginationInfo: {
26272 totalItems,
26273 totalPages
26274 }
26275 };
26276 }
26277
26278 // packages/admin-ui/build-module/navigable-region/index.mjs
26279 var import_element76 = __toESM(require_element(), 1);
26280 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
26281 var NavigableRegion = (0, import_element76.forwardRef)(
26282 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
26283 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26284 Tag,
26285 {
26286 ref,
26287 className: clsx_default("admin-ui-navigable-region", className),
26288 "aria-label": ariaLabel,
26289 role: "region",
26290 tabIndex: "-1",
26291 ...props,
26292 children
26293 }
26294 );
26295 }
26296 );
26297 NavigableRegion.displayName = "NavigableRegion";
26298 var navigable_region_default = NavigableRegion;
26299
26300 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
26301 var import_components46 = __toESM(require_components(), 1);
26302 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components46.createSlotFill)("SidebarToggle");
26303
26304 // packages/admin-ui/build-module/page/header.mjs
26305 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
26306 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
26307 function getRuntime7() {
26308 const globalScope = globalThis;
26309 if (globalScope.__wpStyleRuntime) {
26310 return globalScope.__wpStyleRuntime;
26311 }
26312 globalScope.__wpStyleRuntime = {
26313 documents: /* @__PURE__ */ new Map(),
26314 styles: /* @__PURE__ */ new Map(),
26315 injectedStyles: /* @__PURE__ */ new WeakMap()
26316 };
26317 if (typeof document !== "undefined") {
26318 registerDocument7(document);
26319 }
26320 return globalScope.__wpStyleRuntime;
26321 }
26322 function documentContainsStyleHash7(targetDocument, hash) {
26323 if (!targetDocument.head) {
26324 return false;
26325 }
26326 for (const style of targetDocument.head.querySelectorAll(
26327 `style[${STYLE_HASH_ATTRIBUTE7}]`
26328 )) {
26329 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
26330 return true;
26331 }
26332 }
26333 return false;
26334 }
26335 function injectStyle7(targetDocument, hash, css) {
26336 if (!targetDocument.head) {
26337 return;
26338 }
26339 const runtime = getRuntime7();
26340 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26341 if (!injectedStyles) {
26342 injectedStyles = /* @__PURE__ */ new Set();
26343 runtime.injectedStyles.set(targetDocument, injectedStyles);
26344 }
26345 if (injectedStyles.has(hash)) {
26346 return;
26347 }
26348 if (documentContainsStyleHash7(targetDocument, hash)) {
26349 injectedStyles.add(hash);
26350 return;
26351 }
26352 const style = targetDocument.createElement("style");
26353 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
26354 style.appendChild(targetDocument.createTextNode(css));
26355 targetDocument.head.appendChild(style);
26356 injectedStyles.add(hash);
26357 }
26358 function registerDocument7(targetDocument) {
26359 const runtime = getRuntime7();
26360 runtime.documents.set(
26361 targetDocument,
26362 (runtime.documents.get(targetDocument) ?? 0) + 1
26363 );
26364 for (const [hash, css] of runtime.styles) {
26365 injectStyle7(targetDocument, hash, css);
26366 }
26367 return () => {
26368 const count = runtime.documents.get(targetDocument);
26369 if (count === void 0) {
26370 return;
26371 }
26372 if (count <= 1) {
26373 runtime.documents.delete(targetDocument);
26374 return;
26375 }
26376 runtime.documents.set(targetDocument, count - 1);
26377 };
26378 }
26379 function registerStyle7(hash, css) {
26380 const runtime = getRuntime7();
26381 runtime.styles.set(hash, css);
26382 for (const targetDocument of runtime.documents.keys()) {
26383 injectStyle7(targetDocument, hash, css);
26384 }
26385 }
26386 if (typeof process === "undefined" || true) {
26387 registerStyle7("683dd16f2c", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
26388 }
26389 var style_default6 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
26390 function Header({
26391 headingLevel = 1,
26392 breadcrumbs,
26393 badges,
26394 visual,
26395 title,
26396 subTitle,
26397 actions,
26398 showSidebarToggle = true
26399 }) {
26400 const HeadingTag = `h${headingLevel}`;
26401 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "column", className: style_default6.header, children: [
26402 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
26403 Stack,
26404 {
26405 className: style_default6["header-content"],
26406 direction: "row",
26407 gap: "sm",
26408 justify: "space-between",
26409 children: [
26410 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
26411 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26412 SidebarToggleSlot,
26413 {
26414 bubblesVirtually: true,
26415 className: style_default6["sidebar-toggle-slot"]
26416 }
26417 ),
26418 visual && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26419 "div",
26420 {
26421 className: style_default6["header-visual"],
26422 "aria-hidden": "true",
26423 children: visual
26424 }
26425 ),
26426 title && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26427 Text,
26428 {
26429 className: style_default6["header-title"],
26430 render: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(HeadingTag, {}),
26431 variant: "heading-lg",
26432 children: title
26433 }
26434 ),
26435 breadcrumbs,
26436 badges
26437 ] }),
26438 actions && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26439 Stack,
26440 {
26441 align: "center",
26442 className: style_default6["header-actions"],
26443 direction: "row",
26444 gap: "sm",
26445 children: actions
26446 }
26447 )
26448 ]
26449 }
26450 ),
26451 subTitle && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26452 Text,
26453 {
26454 render: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("p", {}),
26455 variant: "body-md",
26456 className: style_default6["header-subtitle"],
26457 children: subTitle
26458 }
26459 )
26460 ] });
26461 }
26462
26463 // packages/admin-ui/build-module/page/index.mjs
26464 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
26465 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
26466 function getRuntime8() {
26467 const globalScope = globalThis;
26468 if (globalScope.__wpStyleRuntime) {
26469 return globalScope.__wpStyleRuntime;
26470 }
26471 globalScope.__wpStyleRuntime = {
26472 documents: /* @__PURE__ */ new Map(),
26473 styles: /* @__PURE__ */ new Map(),
26474 injectedStyles: /* @__PURE__ */ new WeakMap()
26475 };
26476 if (typeof document !== "undefined") {
26477 registerDocument8(document);
26478 }
26479 return globalScope.__wpStyleRuntime;
26480 }
26481 function documentContainsStyleHash8(targetDocument, hash) {
26482 if (!targetDocument.head) {
26483 return false;
26484 }
26485 for (const style of targetDocument.head.querySelectorAll(
26486 `style[${STYLE_HASH_ATTRIBUTE8}]`
26487 )) {
26488 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
26489 return true;
26490 }
26491 }
26492 return false;
26493 }
26494 function injectStyle8(targetDocument, hash, css) {
26495 if (!targetDocument.head) {
26496 return;
26497 }
26498 const runtime = getRuntime8();
26499 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26500 if (!injectedStyles) {
26501 injectedStyles = /* @__PURE__ */ new Set();
26502 runtime.injectedStyles.set(targetDocument, injectedStyles);
26503 }
26504 if (injectedStyles.has(hash)) {
26505 return;
26506 }
26507 if (documentContainsStyleHash8(targetDocument, hash)) {
26508 injectedStyles.add(hash);
26509 return;
26510 }
26511 const style = targetDocument.createElement("style");
26512 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
26513 style.appendChild(targetDocument.createTextNode(css));
26514 targetDocument.head.appendChild(style);
26515 injectedStyles.add(hash);
26516 }
26517 function registerDocument8(targetDocument) {
26518 const runtime = getRuntime8();
26519 runtime.documents.set(
26520 targetDocument,
26521 (runtime.documents.get(targetDocument) ?? 0) + 1
26522 );
26523 for (const [hash, css] of runtime.styles) {
26524 injectStyle8(targetDocument, hash, css);
26525 }
26526 return () => {
26527 const count = runtime.documents.get(targetDocument);
26528 if (count === void 0) {
26529 return;
26530 }
26531 if (count <= 1) {
26532 runtime.documents.delete(targetDocument);
26533 return;
26534 }
26535 runtime.documents.set(targetDocument, count - 1);
26536 };
26537 }
26538 function registerStyle8(hash, css) {
26539 const runtime = getRuntime8();
26540 runtime.styles.set(hash, css);
26541 for (const targetDocument of runtime.documents.keys()) {
26542 injectStyle8(targetDocument, hash, css);
26543 }
26544 }
26545 if (typeof process === "undefined" || true) {
26546 registerStyle8("683dd16f2c", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
26547 }
26548 var style_default7 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
26549 function Page({
26550 headingLevel,
26551 breadcrumbs,
26552 badges,
26553 visual,
26554 title,
26555 subTitle,
26556 children,
26557 className,
26558 actions,
26559 ariaLabel,
26560 hasPadding = false,
26561 showSidebarToggle = true
26562 }) {
26563 const classes = clsx_default(style_default7.page, className);
26564 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
26565 return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
26566 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26567 Header,
26568 {
26569 headingLevel,
26570 breadcrumbs,
26571 badges,
26572 visual,
26573 title,
26574 subTitle,
26575 actions,
26576 showSidebarToggle
26577 }
26578 ),
26579 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
26580 "div",
26581 {
26582 className: clsx_default(
26583 style_default7.content,
26584 style_default7["has-padding"]
26585 ),
26586 children
26587 }
26588 ) : children
26589 ] });
26590 }
26591 Page.SidebarToggleFill = SidebarToggleFill;
26592 var page_default = Page;
26593
26594 // routes/pattern-list/stage.tsx
26595 var import_core_data4 = __toESM(require_core_data());
26596 var import_components47 = __toESM(require_components());
26597 var import_data11 = __toESM(require_data());
26598 var import_element79 = __toESM(require_element());
26599 var import_editor = __toESM(require_editor());
26600 var import_patterns3 = __toESM(require_patterns());
26601 var import_i18n48 = __toESM(require_i18n());
26602
26603 // routes/lock-unlock.ts
26604 var import_private_apis4 = __toESM(require_private_apis());
26605 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
26606 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
26607 "@wordpress/routes"
26608 );
26609
26610 // routes/pattern-list/view-utils.ts
26611 var import_i18n44 = __toESM(require_i18n());
26612 var LAYOUT_GRID2 = "grid";
26613 var LAYOUT_TABLE2 = "table";
26614 var DEFAULT_VIEW = {
26615 type: LAYOUT_GRID2,
26616 perPage: 20,
26617 sort: {
26618 field: "title",
26619 direction: "asc"
26620 },
26621 filters: [],
26622 fields: ["sync-status"],
26623 layout: {
26624 badgeFields: ["sync-status"]
26625 },
26626 titleField: "title",
26627 mediaField: "preview"
26628 };
26629 var DEFAULT_VIEWS = [
26630 {
26631 slug: "all",
26632 label: (0, import_i18n44.__)("All patterns")
26633 },
26634 {
26635 slug: "my-patterns",
26636 label: (0, import_i18n44.__)("My patterns")
26637 },
26638 {
26639 slug: "registered",
26640 label: (0, import_i18n44.__)("Registered")
26641 }
26642 ];
26643 var DEFAULT_LAYOUTS2 = {
26644 [LAYOUT_TABLE2]: true,
26645 [LAYOUT_GRID2]: {
26646 layout: {
26647 badgeFields: ["sync-status"]
26648 }
26649 }
26650 };
26651
26652 // routes/pattern-list/fields/preview.tsx
26653 var import_i18n45 = __toESM(require_i18n());
26654 import { Preview } from "@wordpress/lazy-editor";
26655 function PreviewField({ item }) {
26656 return /* @__PURE__ */ React.createElement(
26657 Preview,
26658 {
26659 blocks: item.blocks,
26660 content: item.content,
26661 description: item.description
26662 }
26663 );
26664 }
26665 var previewField = {
26666 label: (0, import_i18n45.__)("Preview"),
26667 id: "preview",
26668 render: PreviewField,
26669 enableSorting: false
26670 };
26671
26672 // routes/pattern-list/fields/sync-status.tsx
26673 var import_i18n46 = __toESM(require_i18n());
26674 var import_patterns = __toESM(require_patterns());
26675 var { PATTERN_SYNC_TYPES } = unlock4(import_patterns.privateApis);
26676 var OPERATOR_IS2 = "is";
26677 var SYNC_FILTERS = [
26678 {
26679 value: PATTERN_SYNC_TYPES.full,
26680 label: (0, import_i18n46._x)("Synced", "pattern (singular)"),
26681 description: (0, import_i18n46.__)("Patterns that are kept in sync across the site.")
26682 },
26683 {
26684 value: PATTERN_SYNC_TYPES.unsynced,
26685 label: (0, import_i18n46._x)("Not synced", "pattern (singular)"),
26686 description: (0, import_i18n46.__)(
26687 "Patterns that can be changed freely without affecting the site."
26688 )
26689 }
26690 ];
26691 var patternStatusField = {
26692 label: (0, import_i18n46.__)("Sync status"),
26693 id: "sync-status",
26694 render: ({ item }) => {
26695 const syncStatus = item.syncStatus;
26696 return /* @__PURE__ */ React.createElement(
26697 "span",
26698 {
26699 className: `routes-pattern-list__field-sync-status-${syncStatus}`
26700 },
26701 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
26702 );
26703 },
26704 elements: SYNC_FILTERS,
26705 filterBy: {
26706 operators: [OPERATOR_IS2],
26707 isPrimary: true
26708 },
26709 enableSorting: false
26710 };
26711
26712 // routes/pattern-list/fields/category.tsx
26713 var import_i18n47 = __toESM(require_i18n());
26714 var import_data9 = __toESM(require_data());
26715 var import_core_data2 = __toESM(require_core_data());
26716 var import_element77 = __toESM(require_element());
26717 var OPERATOR_IS3 = "is";
26718 function CategoryField({ item }) {
26719 const blockPatternCategories = (0, import_data9.useSelect)(
26720 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26721 []
26722 );
26723 const categoryLabels = (0, import_element77.useMemo)(() => {
26724 if (!item.categories || !Array.isArray(item.categories)) {
26725 return [];
26726 }
26727 return item.categories.map((catSlug) => {
26728 const category = blockPatternCategories?.find(
26729 (cat) => cat.name === catSlug
26730 );
26731 return category ? category.label || category.name : null;
26732 }).filter(Boolean);
26733 }, [item.categories, blockPatternCategories]);
26734 if (categoryLabels.length === 0) {
26735 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
26736 }
26737 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
26738 }
26739 function usePatternCategories() {
26740 const userPatternCategories = (0, import_data9.useSelect)(
26741 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
26742 []
26743 );
26744 const blockPatternCategories = (0, import_data9.useSelect)(
26745 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26746 []
26747 );
26748 return (0, import_element77.useMemo)(() => {
26749 const categoryMap = /* @__PURE__ */ new Map();
26750 userPatternCategories?.forEach((cat) => {
26751 if (!categoryMap.has(cat.name)) {
26752 categoryMap.set(cat.name, {
26753 value: cat.name,
26754 label: cat.label || cat.name
26755 });
26756 }
26757 });
26758 blockPatternCategories?.forEach((cat) => {
26759 if (!categoryMap.has(cat.name)) {
26760 categoryMap.set(cat.name, {
26761 value: cat.name,
26762 label: cat.label || cat.name
26763 });
26764 }
26765 });
26766 return Array.from(categoryMap.values()).sort(
26767 (a2, b2) => a2.label.localeCompare(b2.label)
26768 );
26769 }, [userPatternCategories, blockPatternCategories]);
26770 }
26771 function usePatternCategoryField() {
26772 const categories = usePatternCategories();
26773 return {
26774 label: (0, import_i18n47.__)("Category"),
26775 id: "category",
26776 render: CategoryField,
26777 elements: categories,
26778 getValue: ({ item }) => {
26779 return item.categories;
26780 },
26781 filterBy: {
26782 operators: [OPERATOR_IS3],
26783 isPrimary: true
26784 },
26785 enableSorting: false
26786 };
26787 }
26788
26789 // routes/pattern-list/use-patterns.ts
26790 var import_data10 = __toESM(require_data());
26791 var import_core_data3 = __toESM(require_core_data());
26792 var import_element78 = __toESM(require_element());
26793 var import_patterns2 = __toESM(require_patterns());
26794 var import_block_editor = __toESM(require_block_editor());
26795
26796 // routes/pattern-list/utils.ts
26797 var filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name);
26798
26799 // routes/pattern-list/use-patterns.ts
26800 var {
26801 PATTERN_TYPES,
26802 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
26803 EXCLUDED_PATTERN_SOURCES,
26804 PATTERN_DEFAULT_CATEGORY
26805 } = unlock4(import_patterns2.privateApis);
26806 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock4(
26807 import_block_editor.privateApis
26808 );
26809 function normalizeThemePattern(pattern) {
26810 return {
26811 id: pattern.name,
26812 title: pattern.title,
26813 content: pattern.content,
26814 keywords: pattern.keywords || [],
26815 type: PATTERN_TYPES.theme,
26816 // Normalize categories to always be an array of slugs
26817 categories: pattern.categories || [],
26818 // Theme patterns are always unsynced
26819 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
26820 description: pattern.description || ""
26821 };
26822 }
26823 function normalizeUserPattern(pattern, userPatternCategories) {
26824 const categories = [];
26825 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
26826 pattern.wp_pattern_category.forEach((catId) => {
26827 const category = userPatternCategories?.find(
26828 (cat) => cat.id === catId
26829 );
26830 if (category) {
26831 categories.push(category.name);
26832 }
26833 });
26834 }
26835 const numericId = pattern.id;
26836 return {
26837 id: pattern.name || pattern.id.toString(),
26838 _recordId: numericId,
26839 // Keep numeric ID for permissions lookup
26840 keywords: [],
26841 type: PATTERN_TYPES.user,
26842 // Normalize categories to always be an array of slugs
26843 categories,
26844 // Normalize sync status
26845 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
26846 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
26847 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
26848 description: pattern.excerpt?.raw || "",
26849 blocks: pattern.blocks
26850 };
26851 }
26852 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
26853 return unmatchedTerms.filter(
26854 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
26855 (unprocessedTerm) => unprocessedTerm.includes(term)
26856 )
26857 );
26858 };
26859 function getItemSearchRank(item, searchTerm, config) {
26860 const { categoryId, hasCategory, onlyFilterByCategory } = config;
26861 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
26862 if (!rank || onlyFilterByCategory) {
26863 return rank;
26864 }
26865 const normalizedSearchInput = normalizeString2(searchTerm);
26866 const normalizedTitle = normalizeString2(item.title);
26867 if (normalizedSearchInput === normalizedTitle) {
26868 rank += 30;
26869 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
26870 rank += 20;
26871 } else {
26872 const terms = [
26873 item.id,
26874 item.title,
26875 item.description,
26876 ...item.keywords
26877 ].join(" ");
26878 const normalizedSearchTerms = extractWords(normalizedSearchInput);
26879 const unmatchedTerms = removeMatchingTerms(
26880 normalizedSearchTerms,
26881 terms
26882 );
26883 if (unmatchedTerms.length === 0) {
26884 rank += 10;
26885 }
26886 }
26887 return rank;
26888 }
26889 function searchItems(items = [], searchInput = "", config = {}) {
26890 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
26891 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
26892 const searchRankConfig = { ...config, onlyFilterByCategory };
26893 const threshold = onlyFilterByCategory ? 0 : 1;
26894 const rankedItems = items.map((item) => {
26895 return [
26896 item,
26897 getItemSearchRank(item, searchInput, searchRankConfig)
26898 ];
26899 }).filter(([, rank]) => rank > threshold);
26900 if (normalizedSearchTerms.length === 0) {
26901 return rankedItems.map(([item]) => item);
26902 }
26903 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
26904 return rankedItems.map(([item]) => item);
26905 }
26906 var selectThemePatterns = (0, import_data10.createSelector)(
26907 (select2) => {
26908 const { getBlockPatterns } = select2(import_core_data3.store);
26909 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
26910 const restBlockPatterns = getBlockPatterns();
26911 const patterns = (restBlockPatterns || []).filter(
26912 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
26913 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
26914 return {
26915 patterns,
26916 isResolving: isResolvingSelector("getBlockPatterns")
26917 };
26918 },
26919 (select2) => [
26920 select2(import_core_data3.store).getBlockPatterns(),
26921 select2(import_core_data3.store).isResolving("getBlockPatterns")
26922 ]
26923 );
26924 var selectUserPatterns = (0, import_data10.createSelector)(
26925 (select2, syncStatus = void 0, search = "") => {
26926 const {
26927 getEntityRecords,
26928 isResolving: isResolvingSelector,
26929 getUserPatternCategories
26930 } = select2(import_core_data3.store);
26931 const query = { per_page: -1 };
26932 const patternPosts = getEntityRecords(
26933 "postType",
26934 PATTERN_TYPES.user,
26935 query
26936 );
26937 const userPatternCategories = getUserPatternCategories();
26938 let patterns = (patternPosts ?? []).map(
26939 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
26940 );
26941 const isResolving = isResolvingSelector("getEntityRecords", [
26942 "postType",
26943 PATTERN_TYPES.user,
26944 query
26945 ]);
26946 if (syncStatus) {
26947 patterns = patterns.filter(
26948 (pattern) => pattern.syncStatus === syncStatus
26949 );
26950 }
26951 patterns = searchItems(patterns, search, {
26952 // We exit user pattern retrieval early if we aren't in the
26953 // catch-all category for user created patterns, so it has
26954 // to be in the category.
26955 categoryId: PATTERN_DEFAULT_CATEGORY,
26956 hasCategory: () => true
26957 });
26958 return {
26959 patterns,
26960 isResolving,
26961 categories: userPatternCategories
26962 };
26963 },
26964 (select2) => [
26965 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
26966 per_page: -1
26967 }),
26968 select2(import_core_data3.store).isResolving("getEntityRecords", [
26969 "postType",
26970 PATTERN_TYPES.user,
26971 { per_page: -1 }
26972 ]),
26973 select2(import_core_data3.store).getUserPatternCategories()
26974 ]
26975 );
26976 var selectPatterns = (0, import_data10.createSelector)(
26977 (select2, categoryId, syncStatus, search = "") => {
26978 const {
26979 patterns: themePatterns,
26980 isResolving: isResolvingThemePatterns
26981 } = selectThemePatterns(select2);
26982 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
26983 let patterns = [
26984 ...themePatterns || [],
26985 ...userPatterns || []
26986 ];
26987 if (syncStatus) {
26988 patterns = patterns.filter(
26989 (pattern) => pattern.syncStatus === syncStatus
26990 );
26991 }
26992 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26993 patterns = searchItems(patterns, search, {
26994 categoryId,
26995 hasCategory: (item, currentCategory) => {
26996 return item.categories?.includes(currentCategory);
26997 }
26998 });
26999 } else {
27000 patterns = searchItems(patterns, search, {
27001 categoryId: PATTERN_DEFAULT_CATEGORY,
27002 hasCategory: () => true
27003 });
27004 }
27005 return {
27006 patterns,
27007 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
27008 };
27009 },
27010 (select2) => [
27011 selectThemePatterns(select2),
27012 selectUserPatterns(select2)
27013 ]
27014 );
27015 function useAugmentPatternsWithPermissions(patterns) {
27016 const idsAndTypes = (0, import_element78.useMemo)(
27017 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
27018 record.type,
27019 record._recordId,
27020 record.id
27021 ]) ?? [],
27022 [patterns]
27023 );
27024 const permissions = (0, import_data10.useSelect)(
27025 (select2) => {
27026 const { getEntityRecordPermissions } = unlock4(
27027 select2(import_core_data3.store)
27028 );
27029 return idsAndTypes.reduce(
27030 (acc, [type, numericId, stringId]) => {
27031 acc[stringId] = getEntityRecordPermissions(
27032 "postType",
27033 type,
27034 numericId
27035 );
27036 return acc;
27037 },
27038 {}
27039 );
27040 },
27041 [idsAndTypes]
27042 );
27043 return (0, import_element78.useMemo)(
27044 () => patterns?.map((record) => ({
27045 ...record,
27046 permissions: permissions?.[record.id] ?? {}
27047 })) ?? [],
27048 [patterns, permissions]
27049 );
27050 }
27051 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
27052 return (0, import_data10.useSelect)(
27053 (select2) => {
27054 if (postType === PATTERN_TYPES.user) {
27055 const result = selectUserPatterns(select2, syncStatus, search);
27056 let { patterns } = result;
27057 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27058 patterns = patterns.filter(
27059 (pattern) => pattern.categories.includes(categoryId)
27060 );
27061 }
27062 return {
27063 patterns,
27064 isResolving: result.isResolving
27065 };
27066 } else if (postType === PATTERN_TYPES.theme) {
27067 const result = selectThemePatterns(select2);
27068 let { patterns } = result;
27069 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
27070 patterns = patterns.filter(
27071 (pattern) => pattern.categories.includes(categoryId)
27072 );
27073 }
27074 patterns = searchItems(patterns, search, {
27075 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
27076 hasCategory: () => true
27077 });
27078 return {
27079 patterns,
27080 isResolving: result.isResolving
27081 };
27082 }
27083 return selectPatterns(select2, categoryId, syncStatus, search);
27084 },
27085 [categoryId, postType, search, syncStatus]
27086 );
27087 };
27088 var use_patterns_default = usePatterns;
27089
27090 // routes/pattern-list/style.scss
27091 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c329396b1f']")) {
27092 const style = document.createElement("style");
27093 style.setAttribute("data-wp-hash", "c329396b1f");
27094 style.appendChild(document.createTextNode(":root{--wp-block-synced-color:#7a00df;--wp-block-synced-color--rgb:122,0,223;--wp-bound-block-color:var(--wp-block-synced-color);--wp-editor-canvas-background:#ddd;--wp-admin-theme-color:#007cba;--wp-admin-theme-color--rgb:0,124,186;--wp-admin-theme-color-darker-10:#006ba1;--wp-admin-theme-color-darker-10--rgb:0,107,160.5;--wp-admin-theme-color-darker-20:#005a87;--wp-admin-theme-color-darker-20--rgb:0,90,135;--wp-admin-border-width-focus:2px}@media (min-resolution:192dpi){:root{--wp-admin-border-width-focus:1.5px}}.patterns-menu-items__convert-modal{z-index:1000001}.patterns-menu-items__convert-modal [role=dialog]>[role=document]{width:350px}.patterns-menu-items__convert-modal .patterns-menu-items__convert-modal-categories{position:relative}.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list:not(:empty){background-color:#fff;border:1px solid var(--wp-admin-theme-color);border-bottom-left-radius:2px;border-bottom-right-radius:2px;box-shadow:0 0 .5px .5px var(--wp-admin-theme-color);box-sizing:border-box;left:-1px;max-height:96px;min-width:auto;position:absolute;width:calc(100% + 2px);z-index:1}.patterns-create-modal__name-input input[type=text]{margin:0}.patterns-rename-pattern-category-modal__validation-message{color:#cc1818}@media (min-width:782px){.patterns-rename-pattern-category-modal__validation-message{width:320px}}.pattern-overrides-control__allow-overrides-button{justify-content:center;width:100%}.routes-pattern-list__tabs-wrapper{border-bottom:1px solid #f0f0f0;padding:0 24px}.dataviews-view-grid__badge-fields .dataviews-view-grid__field-value:has(.routes-pattern-list__field-sync-status-fully){background:rgba(var(--wp-block-synced-color--rgb),.04);color:var(--wp-block-synced-color)}"));
27095 document.head.appendChild(style);
27096 }
27097
27098 // routes/pattern-list/stage.tsx
27099 var { usePostActions, patternTitleField } = unlock4(import_editor.privateApis);
27100 var { Tabs } = unlock4(import_components47.privateApis);
27101 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock4(import_patterns3.privateApis);
27102 function PatternList() {
27103 const invalidate = useInvalidate();
27104 const { type = "all" } = useParams({
27105 from: "/patterns/list/$type"
27106 });
27107 const navigate = useNavigate();
27108 const searchParams = useSearch({ from: "/patterns/list/$type" });
27109 const postTypeObject = (0, import_data11.useSelect)(
27110 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
27111 []
27112 );
27113 const labels = postTypeObject?.labels;
27114 const canCreateRecord = (0, import_data11.useSelect)(
27115 (select2) => select2(import_core_data4.store).canUser("create", {
27116 kind: "postType",
27117 name: "wp_block"
27118 }),
27119 []
27120 );
27121 const [showPatternModal, setShowPatternModal] = (0, import_element79.useState)(false);
27122 const handleQueryParamsChange = (0, import_element79.useCallback)(
27123 (params) => {
27124 navigate({
27125 search: {
27126 ...searchParams,
27127 ...params
27128 }
27129 });
27130 },
27131 [searchParams, navigate]
27132 );
27133 const { view, isModified, updateView, resetToDefault } = useView({
27134 kind: "postType",
27135 name: "wp_block",
27136 slug: "default-new",
27137 defaultView: DEFAULT_VIEW,
27138 queryParams: searchParams,
27139 onChangeQueryParams: handleQueryParamsChange
27140 });
27141 const onReset = () => {
27142 resetToDefault();
27143 invalidate();
27144 };
27145 const onChangeView = (newView) => {
27146 updateView(newView);
27147 if (newView.type !== view.type) {
27148 invalidate();
27149 }
27150 };
27151 const categoryFilter = (0, import_element79.useMemo)(() => {
27152 const filter = view.filters?.find((f2) => f2.field === "category");
27153 return filter?.value || "all-patterns";
27154 }, [view.filters]);
27155 const syncStatusFilter = (0, import_element79.useMemo)(() => {
27156 const filter = view.filters?.find((f2) => f2.field === "sync-status");
27157 return filter?.value;
27158 }, [view.filters]);
27159 const patternType = (0, import_element79.useMemo)(() => {
27160 if (type === "my-patterns") {
27161 return PATTERN_TYPES2.user;
27162 } else if (type === "registered") {
27163 return PATTERN_TYPES2.theme;
27164 }
27165 return null;
27166 }, [type]);
27167 const { patterns, isResolving } = use_patterns_default(
27168 patternType,
27169 categoryFilter,
27170 {
27171 search: view.search,
27172 syncStatus: syncStatusFilter
27173 }
27174 );
27175 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
27176 const patternCategoryField = usePatternCategoryField();
27177 const fields = (0, import_element79.useMemo)(() => {
27178 const patternFields = [
27179 previewField,
27180 patternTitleField,
27181 patternCategoryField
27182 ];
27183 if (type === "my-patterns" || type === "all") {
27184 patternFields.push(patternStatusField);
27185 }
27186 return patternFields;
27187 }, [type, patternCategoryField]);
27188 const { data: posts, paginationInfo } = (0, import_element79.useMemo)(() => {
27189 const viewWithoutFilters = { ...view };
27190 delete viewWithoutFilters.search;
27191 viewWithoutFilters.filters = [];
27192 return filterSortAndPaginate(
27193 patternsWithPermissions,
27194 viewWithoutFilters,
27195 fields
27196 );
27197 }, [patternsWithPermissions, view, fields]);
27198 const { totalItems, totalPages } = paginationInfo;
27199 const cleanupDeletedPostIdsFromUrl = (0, import_element79.useCallback)(
27200 (deletedItems) => {
27201 const deletedIds = deletedItems.map((item) => item.id);
27202 const currentPostIds = searchParams.postIds || [];
27203 const remainingPostIds = currentPostIds.filter(
27204 (id) => !deletedIds.includes(id)
27205 );
27206 if (remainingPostIds.length !== currentPostIds.length) {
27207 navigate({
27208 search: {
27209 ...searchParams,
27210 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
27211 }
27212 });
27213 } else {
27214 invalidate();
27215 }
27216 },
27217 [invalidate, searchParams, navigate]
27218 );
27219 const postTypeActions = usePostActions({
27220 postType: "wp_block",
27221 context: "list",
27222 onActionPerformed: (actionId, items) => {
27223 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
27224 cleanupDeletedPostIdsFromUrl(items);
27225 }
27226 }
27227 });
27228 const actions = (0, import_element79.useMemo)(() => {
27229 return [
27230 ...postTypeActions?.flatMap((action) => {
27231 if (action.id === "view-post-revisions") {
27232 return [];
27233 }
27234 return [action];
27235 })
27236 ];
27237 }, [postTypeActions]);
27238 const handleTabChange = (0, import_element79.useCallback)(
27239 (typeSlug) => {
27240 navigate({
27241 to: `/patterns/list/${typeSlug}`
27242 });
27243 },
27244 [navigate]
27245 );
27246 if (!postTypeObject) {
27247 return null;
27248 }
27249 const selection = searchParams.postIds ?? [];
27250 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
27251 selection.push(posts[0].id);
27252 }
27253 if (view.type === "list") {
27254 selection.splice(1);
27255 }
27256 return /* @__PURE__ */ React.createElement(
27257 page_default,
27258 {
27259 title: (0, import_i18n48.__)("Patterns"),
27260 headingLevel: 2,
27261 subTitle: (0, import_i18n48.__)(
27262 "Reusable design elements for your site. Create once, use everywhere."
27263 ),
27264 className: "pattern-page",
27265 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
27266 import_components47.Button,
27267 {
27268 variant: "primary",
27269 onClick: () => setShowPatternModal(true),
27270 size: "compact"
27271 },
27272 labels.add_new_item
27273 ),
27274 hasPadding: false
27275 },
27276 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
27277 Tabs,
27278 {
27279 onSelect: handleTabChange,
27280 selectedTabId: type ?? "all"
27281 },
27282 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
27283 (filter) => /* @__PURE__ */ React.createElement(
27284 Tabs.Tab,
27285 {
27286 tabId: filter.slug,
27287 key: filter.slug
27288 },
27289 filter.label
27290 )
27291 ))
27292 )),
27293 /* @__PURE__ */ React.createElement(
27294 dataviews_default,
27295 {
27296 data: posts,
27297 fields,
27298 view,
27299 onChangeView,
27300 actions,
27301 isLoading: isResolving,
27302 paginationInfo: {
27303 totalItems,
27304 totalPages
27305 },
27306 defaultLayouts: DEFAULT_LAYOUTS2,
27307 selection,
27308 onReset: isModified ? onReset : false,
27309 onChangeSelection: (items) => {
27310 navigate({
27311 search: {
27312 ...searchParams,
27313 postIds: items.length > 0 ? items : void 0,
27314 edit: items.length === 0 ? void 0 : searchParams.edit
27315 }
27316 });
27317 },
27318 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
27319 renderItemLink: ({
27320 item,
27321 ...props
27322 }) => /* @__PURE__ */ React.createElement(
27323 Link,
27324 {
27325 to: `/types/wp_block/edit/${encodeURIComponent(
27326 item.id
27327 )}`,
27328 ...props,
27329 onClick: (event) => {
27330 event.stopPropagation();
27331 }
27332 }
27333 )
27334 }
27335 ),
27336 showPatternModal && /* @__PURE__ */ React.createElement(
27337 CreatePatternModal,
27338 {
27339 onClose: () => setShowPatternModal(false),
27340 onSuccess: ({
27341 pattern
27342 }) => {
27343 setShowPatternModal(false);
27344 navigate({
27345 to: `/types/wp_block/edit/${encodeURIComponent(
27346 pattern.id
27347 )}`
27348 });
27349 },
27350 content: []
27351 }
27352 )
27353 );
27354 }
27355 var stage = PatternList;
27356 export {
27357 stage
27358 };
27359 /*! Bundled license information:
27360
27361 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
27362 (**
27363 * @license React
27364 * use-sync-external-store-shim.development.js
27365 *
27366 * Copyright (c) Meta Platforms, Inc. and affiliates.
27367 *
27368 * This source code is licensed under the MIT license found in the
27369 * LICENSE file in the root directory of this source tree.
27370 *)
27371
27372 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
27373 (**
27374 * @license React
27375 * use-sync-external-store-shim/with-selector.development.js
27376 *
27377 * Copyright (c) Meta Platforms, Inc. and affiliates.
27378 *
27379 * This source code is licensed under the MIT license found in the
27380 * LICENSE file in the root directory of this source tree.
27381 *)
27382 */
27383