PluginProbe
Gutenberg / 23.3.2
Gutenberg v23.3.2
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.3.2, at build/routes/pattern-list/content.js

26,958 lines 915.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/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 === React52.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 useLayoutEffect6(
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 React52 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState36 = React52.useState, useEffect31 = React52.useEffect, useLayoutEffect6 = React52.useLayoutEffect, useDebugValue2 = React52.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 !== React52.useSyncExternalStore ? React52.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 React52 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore3 = shim.useSyncExternalStore, useRef44 = React52.useRef, useEffect31 = React52.useEffect, useMemo43 = React52.useMemo, useDebugValue2 = React52.useDebugValue;
180 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector2, isEqual) {
181 var instRef = useRef44(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_element72 = __toESM(require_element(), 1);
1202 var import_compose12 = __toESM(require_compose(), 1);
1203
1204 // node_modules/@base-ui/utils/esm/useStableCallback.js
1205 var React3 = __toESM(require_react(), 1);
1206
1207 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1208 var React2 = __toESM(require_react(), 1);
1209 var UNINITIALIZED = {};
1210 function useRefWithInit(init2, initArg) {
1211 const ref = React2.useRef(UNINITIALIZED);
1212 if (ref.current === UNINITIALIZED) {
1213 ref.current = init2(initArg);
1214 }
1215 return ref;
1216 }
1217
1218 // node_modules/@base-ui/utils/esm/useStableCallback.js
1219 var useInsertionEffect = React3[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
1220 var useSafeInsertionEffect = (
1221 // React 17 doesn't have useInsertionEffect.
1222 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
1223 useInsertionEffect !== React3.useLayoutEffect ? useInsertionEffect : (fn) => fn()
1224 );
1225 function useStableCallback(callback) {
1226 const stable = useRefWithInit(createStableCallback).current;
1227 stable.next = callback;
1228 useSafeInsertionEffect(stable.effect);
1229 return stable.trampoline;
1230 }
1231 function createStableCallback() {
1232 const stable = {
1233 next: void 0,
1234 callback: assertNotCalled,
1235 trampoline: (...args) => stable.callback?.(...args),
1236 effect: () => {
1237 stable.callback = stable.next;
1238 }
1239 };
1240 return stable;
1241 }
1242 function assertNotCalled() {
1243 if (true) {
1244 throw (
1245 /* minify-error-disabled */
1246 new Error("Base UI: Cannot call an event handler while rendering.")
1247 );
1248 }
1249 }
1250
1251 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1252 var React4 = __toESM(require_react(), 1);
1253 var noop = () => {
1254 };
1255 var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;
1256
1257 // node_modules/@base-ui/utils/esm/warn.js
1258 var set;
1259 if (true) {
1260 set = /* @__PURE__ */ new Set();
1261 }
1262 function warn(...messages) {
1263 if (true) {
1264 const messageKey = messages.join(" ");
1265 if (!set.has(messageKey)) {
1266 set.add(messageKey);
1267 console.warn(`Base UI: ${messageKey}`);
1268 }
1269 }
1270 }
1271
1272 // node_modules/@base-ui/react/esm/internals/direction-context/DirectionContext.js
1273 var React5 = __toESM(require_react(), 1);
1274 var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
1275 if (true) DirectionContext.displayName = "DirectionContext";
1276 function useDirection() {
1277 const context = React5.useContext(DirectionContext);
1278 return context?.direction ?? "ltr";
1279 }
1280
1281 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1282 var React8 = __toESM(require_react(), 1);
1283
1284 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1285 function useMergedRefs(a2, b2, c2, d2) {
1286 const forkRef = useRefWithInit(createForkRef).current;
1287 if (didChange(forkRef, a2, b2, c2, d2)) {
1288 update(forkRef, [a2, b2, c2, d2]);
1289 }
1290 return forkRef.callback;
1291 }
1292 function useMergedRefsN(refs) {
1293 const forkRef = useRefWithInit(createForkRef).current;
1294 if (didChangeN(forkRef, refs)) {
1295 update(forkRef, refs);
1296 }
1297 return forkRef.callback;
1298 }
1299 function createForkRef() {
1300 return {
1301 callback: null,
1302 cleanup: null,
1303 refs: []
1304 };
1305 }
1306 function didChange(forkRef, a2, b2, c2, d2) {
1307 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1308 }
1309 function didChangeN(forkRef, newRefs) {
1310 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
1311 }
1312 function update(forkRef, refs) {
1313 forkRef.refs = refs;
1314 if (refs.every((ref) => ref == null)) {
1315 forkRef.callback = null;
1316 return;
1317 }
1318 forkRef.callback = (instance) => {
1319 if (forkRef.cleanup) {
1320 forkRef.cleanup();
1321 forkRef.cleanup = null;
1322 }
1323 if (instance != null) {
1324 const cleanupCallbacks = Array(refs.length).fill(null);
1325 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1326 const ref = refs[i2];
1327 if (ref == null) {
1328 continue;
1329 }
1330 switch (typeof ref) {
1331 case "function": {
1332 const refCleanup = ref(instance);
1333 if (typeof refCleanup === "function") {
1334 cleanupCallbacks[i2] = refCleanup;
1335 }
1336 break;
1337 }
1338 case "object": {
1339 ref.current = instance;
1340 break;
1341 }
1342 default:
1343 }
1344 }
1345 forkRef.cleanup = () => {
1346 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1347 const ref = refs[i2];
1348 if (ref == null) {
1349 continue;
1350 }
1351 switch (typeof ref) {
1352 case "function": {
1353 const cleanupCallback = cleanupCallbacks[i2];
1354 if (typeof cleanupCallback === "function") {
1355 cleanupCallback();
1356 } else {
1357 ref(null);
1358 }
1359 break;
1360 }
1361 case "object": {
1362 ref.current = null;
1363 break;
1364 }
1365 default:
1366 }
1367 }
1368 };
1369 }
1370 };
1371 }
1372
1373 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1374 var React7 = __toESM(require_react(), 1);
1375
1376 // node_modules/@base-ui/utils/esm/reactVersion.js
1377 var React6 = __toESM(require_react(), 1);
1378 var majorVersion = parseInt(React6.version, 10);
1379 function isReactVersionAtLeast(reactVersionToCheck) {
1380 return majorVersion >= reactVersionToCheck;
1381 }
1382
1383 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1384 function getReactElementRef(element) {
1385 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1386 return null;
1387 }
1388 const reactElement = element;
1389 const propsWithRef = reactElement.props;
1390 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1391 }
1392
1393 // node_modules/@base-ui/utils/esm/mergeObjects.js
1394 function mergeObjects(a2, b2) {
1395 if (a2 && !b2) {
1396 return a2;
1397 }
1398 if (!a2 && b2) {
1399 return b2;
1400 }
1401 if (a2 || b2) {
1402 return {
1403 ...a2,
1404 ...b2
1405 };
1406 }
1407 return void 0;
1408 }
1409
1410 // node_modules/@base-ui/utils/esm/empty.js
1411 function NOOP() {
1412 }
1413 var EMPTY_ARRAY = Object.freeze([]);
1414 var EMPTY_OBJECT = Object.freeze({});
1415
1416 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1417 function getStateAttributesProps(state, customMapping) {
1418 const props = {};
1419 for (const key in state) {
1420 const value = state[key];
1421 if (customMapping?.hasOwnProperty(key)) {
1422 const customProps = customMapping[key](value);
1423 if (customProps != null) {
1424 Object.assign(props, customProps);
1425 }
1426 continue;
1427 }
1428 if (value === true) {
1429 props[`data-${key.toLowerCase()}`] = "";
1430 } else if (value) {
1431 props[`data-${key.toLowerCase()}`] = value.toString();
1432 }
1433 }
1434 return props;
1435 }
1436
1437 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1438 function resolveClassName(className, state) {
1439 return typeof className === "function" ? className(state) : className;
1440 }
1441
1442 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1443 function resolveStyle(style, state) {
1444 return typeof style === "function" ? style(state) : style;
1445 }
1446
1447 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1448 var EMPTY_PROPS = {};
1449 function mergeProps(a2, b2, c2, d2, e2) {
1450 if (!c2 && !d2 && !e2 && !a2) {
1451 return createInitialMergedProps(b2);
1452 }
1453 let merged = createInitialMergedProps(a2);
1454 if (b2) {
1455 merged = mergeInto(merged, b2);
1456 }
1457 if (c2) {
1458 merged = mergeInto(merged, c2);
1459 }
1460 if (d2) {
1461 merged = mergeInto(merged, d2);
1462 }
1463 if (e2) {
1464 merged = mergeInto(merged, e2);
1465 }
1466 return merged;
1467 }
1468 function mergePropsN(props) {
1469 if (props.length === 0) {
1470 return EMPTY_PROPS;
1471 }
1472 if (props.length === 1) {
1473 return createInitialMergedProps(props[0]);
1474 }
1475 let merged = createInitialMergedProps(props[0]);
1476 for (let i2 = 1; i2 < props.length; i2 += 1) {
1477 merged = mergeInto(merged, props[i2]);
1478 }
1479 return merged;
1480 }
1481 function createInitialMergedProps(inputProps) {
1482 if (isPropsGetter(inputProps)) {
1483 return {
1484 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1485 };
1486 }
1487 return copyInitialProps(inputProps);
1488 }
1489 function mergeInto(merged, inputProps) {
1490 if (isPropsGetter(inputProps)) {
1491 return resolvePropsGetter(inputProps, merged);
1492 }
1493 return mutablyMergeInto(merged, inputProps);
1494 }
1495 function copyInitialProps(inputProps) {
1496 const copiedProps = {
1497 ...inputProps
1498 };
1499 for (const propName in copiedProps) {
1500 const propValue = copiedProps[propName];
1501 if (isEventHandler(propName, propValue)) {
1502 copiedProps[propName] = wrapEventHandler(propValue);
1503 }
1504 }
1505 return copiedProps;
1506 }
1507 function mutablyMergeInto(mergedProps, externalProps) {
1508 if (!externalProps) {
1509 return mergedProps;
1510 }
1511 for (const propName in externalProps) {
1512 const externalPropValue = externalProps[propName];
1513 switch (propName) {
1514 case "style": {
1515 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1516 break;
1517 }
1518 case "className": {
1519 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1520 break;
1521 }
1522 default: {
1523 if (isEventHandler(propName, externalPropValue)) {
1524 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1525 } else {
1526 mergedProps[propName] = externalPropValue;
1527 }
1528 }
1529 }
1530 }
1531 return mergedProps;
1532 }
1533 function isEventHandler(key, value) {
1534 const code0 = key.charCodeAt(0);
1535 const code1 = key.charCodeAt(1);
1536 const code2 = key.charCodeAt(2);
1537 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1538 }
1539 function isPropsGetter(inputProps) {
1540 return typeof inputProps === "function";
1541 }
1542 function resolvePropsGetter(inputProps, previousProps) {
1543 if (isPropsGetter(inputProps)) {
1544 return inputProps(previousProps);
1545 }
1546 return inputProps ?? EMPTY_PROPS;
1547 }
1548 function mergeEventHandlers(ourHandler, theirHandler) {
1549 if (!theirHandler) {
1550 return ourHandler;
1551 }
1552 if (!ourHandler) {
1553 return wrapEventHandler(theirHandler);
1554 }
1555 return (...args) => {
1556 const event = args[0];
1557 if (isSyntheticEvent(event)) {
1558 const baseUIEvent = event;
1559 makeEventPreventable(baseUIEvent);
1560 const result2 = theirHandler(...args);
1561 if (!baseUIEvent.baseUIHandlerPrevented) {
1562 ourHandler?.(...args);
1563 }
1564 return result2;
1565 }
1566 const result = theirHandler(...args);
1567 ourHandler?.(...args);
1568 return result;
1569 };
1570 }
1571 function wrapEventHandler(handler) {
1572 if (!handler) {
1573 return handler;
1574 }
1575 return (...args) => {
1576 const event = args[0];
1577 if (isSyntheticEvent(event)) {
1578 makeEventPreventable(event);
1579 }
1580 return handler(...args);
1581 };
1582 }
1583 function makeEventPreventable(event) {
1584 event.preventBaseUIHandler = () => {
1585 event.baseUIHandlerPrevented = true;
1586 };
1587 return event;
1588 }
1589 function mergeClassNames(ourClassName, theirClassName) {
1590 if (theirClassName) {
1591 if (ourClassName) {
1592 return theirClassName + " " + ourClassName;
1593 }
1594 return theirClassName;
1595 }
1596 return ourClassName;
1597 }
1598 function isSyntheticEvent(event) {
1599 return event != null && typeof event === "object" && "nativeEvent" in event;
1600 }
1601
1602 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1603 var import_react = __toESM(require_react(), 1);
1604 function useRenderElement(element, componentProps, params = {}) {
1605 const renderProp = componentProps.render;
1606 const outProps = useRenderElementProps(componentProps, params);
1607 if (params.enabled === false) {
1608 return null;
1609 }
1610 const state = params.state ?? EMPTY_OBJECT;
1611 return evaluateRenderProp(element, renderProp, outProps, state);
1612 }
1613 function useRenderElementProps(componentProps, params = {}) {
1614 const {
1615 className: classNameProp,
1616 style: styleProp,
1617 render: renderProp
1618 } = componentProps;
1619 const {
1620 state = EMPTY_OBJECT,
1621 ref,
1622 props,
1623 stateAttributesMapping: stateAttributesMapping3,
1624 enabled = true
1625 } = params;
1626 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1627 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1628 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
1629 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1630 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1631 if (typeof document !== "undefined") {
1632 if (!enabled) {
1633 useMergedRefs(null, null);
1634 } else if (Array.isArray(ref)) {
1635 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1636 } else {
1637 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1638 }
1639 }
1640 if (!enabled) {
1641 return EMPTY_OBJECT;
1642 }
1643 if (className !== void 0) {
1644 outProps.className = mergeClassNames(outProps.className, className);
1645 }
1646 if (style !== void 0) {
1647 outProps.style = mergeObjects(outProps.style, style);
1648 }
1649 return outProps;
1650 }
1651 function resolveRenderFunctionProps(props) {
1652 if (Array.isArray(props)) {
1653 return mergePropsN(props);
1654 }
1655 return mergeProps(void 0, props);
1656 }
1657 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1658 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1659 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1660 function evaluateRenderProp(element, render4, props, state) {
1661 if (render4) {
1662 if (typeof render4 === "function") {
1663 if (true) {
1664 warnIfRenderPropLooksLikeComponent(render4);
1665 }
1666 return render4(props, state);
1667 }
1668 const mergedProps = mergeProps(props, render4.props);
1669 mergedProps.ref = props.ref;
1670 let newElement = render4;
1671 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1672 const children = React8.Children.toArray(render4);
1673 newElement = children[0];
1674 }
1675 if (true) {
1676 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1677 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"));
1678 }
1679 }
1680 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1681 }
1682 if (element) {
1683 if (typeof element === "string") {
1684 return renderTag(element, props);
1685 }
1686 }
1687 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1688 }
1689 function warnIfRenderPropLooksLikeComponent(renderFn) {
1690 const functionName = renderFn.name;
1691 if (functionName.length === 0) {
1692 return;
1693 }
1694 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1695 return;
1696 }
1697 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1698 return;
1699 }
1700 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");
1701 }
1702 function renderTag(Tag, props) {
1703 if (Tag === "button") {
1704 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1705 type: "button",
1706 ...props,
1707 key: props.key
1708 });
1709 }
1710 if (Tag === "img") {
1711 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1712 alt: "",
1713 ...props,
1714 key: props.key
1715 });
1716 }
1717 return /* @__PURE__ */ React8.createElement(Tag, props);
1718 }
1719
1720 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1721 var reason_parts_exports = {};
1722 __export(reason_parts_exports, {
1723 cancelOpen: () => cancelOpen,
1724 chipRemovePress: () => chipRemovePress,
1725 clearPress: () => clearPress,
1726 closePress: () => closePress,
1727 closeWatcher: () => closeWatcher,
1728 decrementPress: () => decrementPress,
1729 disabled: () => disabled,
1730 drag: () => drag,
1731 escapeKey: () => escapeKey,
1732 focusOut: () => focusOut,
1733 imperativeAction: () => imperativeAction,
1734 incrementPress: () => incrementPress,
1735 inputBlur: () => inputBlur,
1736 inputChange: () => inputChange,
1737 inputClear: () => inputClear,
1738 inputPaste: () => inputPaste,
1739 inputPress: () => inputPress,
1740 itemPress: () => itemPress,
1741 keyboard: () => keyboard,
1742 linkPress: () => linkPress,
1743 listNavigation: () => listNavigation,
1744 none: () => none,
1745 outsidePress: () => outsidePress,
1746 pointer: () => pointer,
1747 scrub: () => scrub,
1748 siblingOpen: () => siblingOpen,
1749 swipe: () => swipe,
1750 trackPress: () => trackPress,
1751 triggerFocus: () => triggerFocus,
1752 triggerHover: () => triggerHover,
1753 triggerPress: () => triggerPress,
1754 wheel: () => wheel,
1755 windowResize: () => windowResize
1756 });
1757 var none = "none";
1758 var triggerPress = "trigger-press";
1759 var triggerHover = "trigger-hover";
1760 var triggerFocus = "trigger-focus";
1761 var outsidePress = "outside-press";
1762 var itemPress = "item-press";
1763 var closePress = "close-press";
1764 var linkPress = "link-press";
1765 var clearPress = "clear-press";
1766 var chipRemovePress = "chip-remove-press";
1767 var trackPress = "track-press";
1768 var incrementPress = "increment-press";
1769 var decrementPress = "decrement-press";
1770 var inputChange = "input-change";
1771 var inputClear = "input-clear";
1772 var inputBlur = "input-blur";
1773 var inputPaste = "input-paste";
1774 var inputPress = "input-press";
1775 var focusOut = "focus-out";
1776 var escapeKey = "escape-key";
1777 var closeWatcher = "close-watcher";
1778 var listNavigation = "list-navigation";
1779 var keyboard = "keyboard";
1780 var pointer = "pointer";
1781 var drag = "drag";
1782 var wheel = "wheel";
1783 var scrub = "scrub";
1784 var cancelOpen = "cancel-open";
1785 var siblingOpen = "sibling-open";
1786 var disabled = "disabled";
1787 var imperativeAction = "imperative-action";
1788 var swipe = "swipe";
1789 var windowResize = "window-resize";
1790
1791 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1792 function createChangeEventDetails(reason, event, trigger, customProperties) {
1793 let canceled = false;
1794 let allowPropagation = false;
1795 const custom = customProperties ?? EMPTY_OBJECT;
1796 const details = {
1797 reason,
1798 event: event ?? new Event("base-ui"),
1799 cancel() {
1800 canceled = true;
1801 },
1802 allowPropagation() {
1803 allowPropagation = true;
1804 },
1805 get isCanceled() {
1806 return canceled;
1807 },
1808 get isPropagationAllowed() {
1809 return allowPropagation;
1810 },
1811 trigger,
1812 ...custom
1813 };
1814 return details;
1815 }
1816
1817 // node_modules/@base-ui/utils/esm/useId.js
1818 var React10 = __toESM(require_react(), 1);
1819
1820 // node_modules/@base-ui/utils/esm/safeReact.js
1821 var React9 = __toESM(require_react(), 1);
1822 var SafeReact = {
1823 ...React9
1824 };
1825
1826 // node_modules/@base-ui/utils/esm/useId.js
1827 var globalId = 0;
1828 function useGlobalId(idOverride, prefix = "mui") {
1829 const [defaultId, setDefaultId] = React10.useState(idOverride);
1830 const id = idOverride || defaultId;
1831 React10.useEffect(() => {
1832 if (defaultId == null) {
1833 globalId += 1;
1834 setDefaultId(`${prefix}-${globalId}`);
1835 }
1836 }, [defaultId, prefix]);
1837 return id;
1838 }
1839 var maybeReactUseId = SafeReact.useId;
1840 function useId(idOverride, prefix) {
1841 if (maybeReactUseId !== void 0) {
1842 const reactId = maybeReactUseId();
1843 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1844 }
1845 return useGlobalId(idOverride, prefix);
1846 }
1847
1848 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1849 function useBaseUiId(idOverride) {
1850 return useId(idOverride, "base-ui");
1851 }
1852
1853 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1854 var ReactDOM = __toESM(require_react_dom(), 1);
1855
1856 // node_modules/@base-ui/utils/esm/useOnMount.js
1857 var React11 = __toESM(require_react(), 1);
1858 var EMPTY = [];
1859 function useOnMount(fn) {
1860 React11.useEffect(fn, EMPTY);
1861 }
1862
1863 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1864 var EMPTY2 = null;
1865 var LAST_RAF = globalThis.requestAnimationFrame;
1866 var Scheduler = class {
1867 /* This implementation uses an array as a backing data-structure for frame callbacks.
1868 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1869 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1870 * be much more efficient if there is a call pattern that alterns as
1871 * "request-cancel-request-cancel-…".
1872 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1873 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1874 callbacks = [];
1875 callbacksCount = 0;
1876 nextId = 1;
1877 startId = 1;
1878 isScheduled = false;
1879 tick = (timestamp) => {
1880 this.isScheduled = false;
1881 const currentCallbacks = this.callbacks;
1882 const currentCallbacksCount = this.callbacksCount;
1883 this.callbacks = [];
1884 this.callbacksCount = 0;
1885 this.startId = this.nextId;
1886 if (currentCallbacksCount > 0) {
1887 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1888 currentCallbacks[i2]?.(timestamp);
1889 }
1890 }
1891 };
1892 request(fn) {
1893 const id = this.nextId;
1894 this.nextId += 1;
1895 this.callbacks.push(fn);
1896 this.callbacksCount += 1;
1897 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1898 if (!this.isScheduled || didRAFChange) {
1899 requestAnimationFrame(this.tick);
1900 this.isScheduled = true;
1901 }
1902 return id;
1903 }
1904 cancel(id) {
1905 const index2 = id - this.startId;
1906 if (index2 < 0 || index2 >= this.callbacks.length) {
1907 return;
1908 }
1909 this.callbacks[index2] = null;
1910 this.callbacksCount -= 1;
1911 }
1912 };
1913 var scheduler = new Scheduler();
1914 var AnimationFrame = class _AnimationFrame {
1915 static create() {
1916 return new _AnimationFrame();
1917 }
1918 static request(fn) {
1919 return scheduler.request(fn);
1920 }
1921 static cancel(id) {
1922 return scheduler.cancel(id);
1923 }
1924 currentId = EMPTY2;
1925 /**
1926 * Executes `fn` after `delay`, clearing any previously scheduled call.
1927 */
1928 request(fn) {
1929 this.cancel();
1930 this.currentId = scheduler.request(() => {
1931 this.currentId = EMPTY2;
1932 fn();
1933 });
1934 }
1935 cancel = () => {
1936 if (this.currentId !== EMPTY2) {
1937 scheduler.cancel(this.currentId);
1938 this.currentId = EMPTY2;
1939 }
1940 };
1941 disposeEffect = () => {
1942 return this.cancel;
1943 };
1944 };
1945 function useAnimationFrame() {
1946 const timeout = useRefWithInit(AnimationFrame.create).current;
1947 useOnMount(timeout.disposeEffect);
1948 return timeout;
1949 }
1950
1951 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1952 function resolveRef(maybeRef) {
1953 if (maybeRef == null) {
1954 return maybeRef;
1955 }
1956 return "current" in maybeRef ? maybeRef.current : maybeRef;
1957 }
1958
1959 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1960 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1961 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1962 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1963 return TransitionStatusDataAttributes2;
1964 })({});
1965 var STARTING_HOOK = {
1966 [TransitionStatusDataAttributes.startingStyle]: ""
1967 };
1968 var ENDING_HOOK = {
1969 [TransitionStatusDataAttributes.endingStyle]: ""
1970 };
1971 var transitionStatusMapping = {
1972 transitionStatus(value) {
1973 if (value === "starting") {
1974 return STARTING_HOOK;
1975 }
1976 if (value === "ending") {
1977 return ENDING_HOOK;
1978 }
1979 return null;
1980 }
1981 };
1982
1983 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1984 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1985 const frame = useAnimationFrame();
1986 return useStableCallback((fnToExecute, signal = null) => {
1987 frame.cancel();
1988 const element = resolveRef(elementOrRef);
1989 if (element == null) {
1990 return;
1991 }
1992 const resolvedElement = element;
1993 const done = () => {
1994 ReactDOM.flushSync(fnToExecute);
1995 };
1996 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1997 fnToExecute();
1998 return;
1999 }
2000 function exec() {
2001 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
2002 if (!signal?.aborted) {
2003 done();
2004 }
2005 }).catch(() => {
2006 if (treatAbortedAsFinished) {
2007 if (!signal?.aborted) {
2008 done();
2009 }
2010 return;
2011 }
2012 const currentAnimations = resolvedElement.getAnimations();
2013 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
2014 exec();
2015 }
2016 });
2017 }
2018 if (waitForStartingStyleRemoved) {
2019 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
2020 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2021 frame.request(exec);
2022 return;
2023 }
2024 const attributeObserver = new MutationObserver(() => {
2025 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
2026 attributeObserver.disconnect();
2027 exec();
2028 }
2029 });
2030 attributeObserver.observe(resolvedElement, {
2031 attributes: true,
2032 attributeFilter: [startingStyleAttribute]
2033 });
2034 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
2035 once: true
2036 });
2037 return;
2038 }
2039 frame.request(exec);
2040 });
2041 }
2042
2043 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
2044 var React12 = __toESM(require_react(), 1);
2045 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
2046 const [transitionStatus, setTransitionStatus] = React12.useState(open && enableIdleState ? "idle" : void 0);
2047 const [mounted, setMounted] = React12.useState(open);
2048 if (open && !mounted) {
2049 setMounted(true);
2050 setTransitionStatus("starting");
2051 }
2052 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
2053 setTransitionStatus("ending");
2054 }
2055 if (!open && !mounted && transitionStatus === "ending") {
2056 setTransitionStatus(void 0);
2057 }
2058 useIsoLayoutEffect(() => {
2059 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
2060 const frame = AnimationFrame.request(() => {
2061 setTransitionStatus("ending");
2062 });
2063 return () => {
2064 AnimationFrame.cancel(frame);
2065 };
2066 }
2067 return void 0;
2068 }, [open, mounted, transitionStatus, deferEndingState]);
2069 useIsoLayoutEffect(() => {
2070 if (!open || enableIdleState) {
2071 return void 0;
2072 }
2073 const frame = AnimationFrame.request(() => {
2074 setTransitionStatus(void 0);
2075 });
2076 return () => {
2077 AnimationFrame.cancel(frame);
2078 };
2079 }, [enableIdleState, open]);
2080 useIsoLayoutEffect(() => {
2081 if (!open || !enableIdleState) {
2082 return void 0;
2083 }
2084 if (open && mounted && transitionStatus !== "idle") {
2085 setTransitionStatus("starting");
2086 }
2087 const frame = AnimationFrame.request(() => {
2088 setTransitionStatus("idle");
2089 });
2090 return () => {
2091 AnimationFrame.cancel(frame);
2092 };
2093 }, [enableIdleState, open, mounted, transitionStatus]);
2094 return {
2095 mounted,
2096 setMounted,
2097 transitionStatus
2098 };
2099 }
2100
2101 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2102 function hasWindow() {
2103 return typeof window !== "undefined";
2104 }
2105 function getNodeName(node) {
2106 if (isNode(node)) {
2107 return (node.nodeName || "").toLowerCase();
2108 }
2109 return "#document";
2110 }
2111 function getWindow(node) {
2112 var _node$ownerDocument;
2113 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2114 }
2115 function getDocumentElement(node) {
2116 var _ref;
2117 return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2118 }
2119 function isNode(value) {
2120 if (!hasWindow()) {
2121 return false;
2122 }
2123 return value instanceof Node || value instanceof getWindow(value).Node;
2124 }
2125 function isElement(value) {
2126 if (!hasWindow()) {
2127 return false;
2128 }
2129 return value instanceof Element || value instanceof getWindow(value).Element;
2130 }
2131 function isHTMLElement(value) {
2132 if (!hasWindow()) {
2133 return false;
2134 }
2135 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2136 }
2137 function isShadowRoot(value) {
2138 if (!hasWindow() || typeof ShadowRoot === "undefined") {
2139 return false;
2140 }
2141 return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2142 }
2143 function isOverflowElement(element) {
2144 const {
2145 overflow,
2146 overflowX,
2147 overflowY,
2148 display
2149 } = getComputedStyle2(element);
2150 return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
2151 }
2152 function isTableElement(element) {
2153 return /^(table|td|th)$/.test(getNodeName(element));
2154 }
2155 function isTopLayer(element) {
2156 try {
2157 if (element.matches(":popover-open")) {
2158 return true;
2159 }
2160 } catch (_e) {
2161 }
2162 try {
2163 return element.matches(":modal");
2164 } catch (_e) {
2165 return false;
2166 }
2167 }
2168 var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
2169 var containRe = /paint|layout|strict|content/;
2170 var isNotNone = (value) => !!value && value !== "none";
2171 var isWebKitValue;
2172 function isContainingBlock(elementOrCss) {
2173 const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
2174 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 || "");
2175 }
2176 function getContainingBlock(element) {
2177 let currentNode = getParentNode(element);
2178 while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2179 if (isContainingBlock(currentNode)) {
2180 return currentNode;
2181 } else if (isTopLayer(currentNode)) {
2182 return null;
2183 }
2184 currentNode = getParentNode(currentNode);
2185 }
2186 return null;
2187 }
2188 function isWebKit() {
2189 if (isWebKitValue == null) {
2190 isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
2191 }
2192 return isWebKitValue;
2193 }
2194 function isLastTraversableNode(node) {
2195 return /^(html|body|#document)$/.test(getNodeName(node));
2196 }
2197 function getComputedStyle2(element) {
2198 return getWindow(element).getComputedStyle(element);
2199 }
2200 function getNodeScroll(element) {
2201 if (isElement(element)) {
2202 return {
2203 scrollLeft: element.scrollLeft,
2204 scrollTop: element.scrollTop
2205 };
2206 }
2207 return {
2208 scrollLeft: element.scrollX,
2209 scrollTop: element.scrollY
2210 };
2211 }
2212 function getParentNode(node) {
2213 if (getNodeName(node) === "html") {
2214 return node;
2215 }
2216 const result = (
2217 // Step into the shadow DOM of the parent of a slotted node.
2218 node.assignedSlot || // DOM Element detected.
2219 node.parentNode || // ShadowRoot detected.
2220 isShadowRoot(node) && node.host || // Fallback.
2221 getDocumentElement(node)
2222 );
2223 return isShadowRoot(result) ? result.host : result;
2224 }
2225 function getNearestOverflowAncestor(node) {
2226 const parentNode = getParentNode(node);
2227 if (isLastTraversableNode(parentNode)) {
2228 return node.ownerDocument ? node.ownerDocument.body : node.body;
2229 }
2230 if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2231 return parentNode;
2232 }
2233 return getNearestOverflowAncestor(parentNode);
2234 }
2235 function getOverflowAncestors(node, list, traverseIframes) {
2236 var _node$ownerDocument2;
2237 if (list === void 0) {
2238 list = [];
2239 }
2240 if (traverseIframes === void 0) {
2241 traverseIframes = true;
2242 }
2243 const scrollableAncestor = getNearestOverflowAncestor(node);
2244 const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2245 const win = getWindow(scrollableAncestor);
2246 if (isBody) {
2247 const frameElement = getFrameElement(win);
2248 return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2249 } else {
2250 return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2251 }
2252 }
2253 function getFrameElement(win) {
2254 return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2255 }
2256
2257 // node_modules/@base-ui/utils/esm/detectBrowser.js
2258 var hasNavigator = typeof navigator !== "undefined";
2259 var nav = getNavigatorData();
2260 var platform = getPlatform();
2261 var userAgent = getUserAgent();
2262 var isWebKit2 = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
2263 var isIOS = (
2264 // iPads can claim to be MacIntel
2265 nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
2266 );
2267 var isFirefox = hasNavigator && /firefox/i.test(userAgent);
2268 var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
2269 var isEdge = hasNavigator && /Edg/i.test(userAgent);
2270 var isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
2271 var isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
2272 var isJSDOM = userAgent.includes("jsdom/");
2273 function getNavigatorData() {
2274 if (!hasNavigator) {
2275 return {
2276 platform: "",
2277 maxTouchPoints: -1
2278 };
2279 }
2280 const uaData = navigator.userAgentData;
2281 if (uaData?.platform) {
2282 return {
2283 platform: uaData.platform,
2284 maxTouchPoints: navigator.maxTouchPoints
2285 };
2286 }
2287 return {
2288 platform: navigator.platform ?? "",
2289 maxTouchPoints: navigator.maxTouchPoints ?? -1
2290 };
2291 }
2292 function getUserAgent() {
2293 if (!hasNavigator) {
2294 return "";
2295 }
2296 const uaData = navigator.userAgentData;
2297 if (uaData && Array.isArray(uaData.brands)) {
2298 return uaData.brands.map(({
2299 brand,
2300 version: version2
2301 }) => `${brand}/${version2}`).join(" ");
2302 }
2303 return navigator.userAgent;
2304 }
2305 function getPlatform() {
2306 if (!hasNavigator) {
2307 return "";
2308 }
2309 const uaData = navigator.userAgentData;
2310 if (uaData?.platform) {
2311 return uaData.platform;
2312 }
2313 return navigator.platform ?? "";
2314 }
2315
2316 // node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js
2317 var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
2318 var ACTIVE_KEY = "active";
2319 var SELECTED_KEY = "selected";
2320 var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
2321
2322 // node_modules/@base-ui/react/esm/internals/shadowDom.js
2323 function activeElement(doc) {
2324 let element = doc.activeElement;
2325 while (element?.shadowRoot?.activeElement != null) {
2326 element = element.shadowRoot.activeElement;
2327 }
2328 return element;
2329 }
2330 function contains(parent, child) {
2331 if (!parent || !child) {
2332 return false;
2333 }
2334 const rootNode = child.getRootNode?.();
2335 if (parent.contains(child)) {
2336 return true;
2337 }
2338 if (rootNode && isShadowRoot(rootNode)) {
2339 let next = child;
2340 while (next) {
2341 if (parent === next) {
2342 return true;
2343 }
2344 next = next.parentNode || next.host;
2345 }
2346 }
2347 return false;
2348 }
2349 function getTarget(event) {
2350 if ("composedPath" in event) {
2351 return event.composedPath()[0];
2352 }
2353 return event.target;
2354 }
2355
2356 // node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js
2357 function isTargetInsideEnabledTrigger(target, triggerElements) {
2358 if (!isElement(target)) {
2359 return false;
2360 }
2361 const targetElement = target;
2362 if (triggerElements.hasElement(targetElement)) {
2363 return !targetElement.hasAttribute("data-trigger-disabled");
2364 }
2365 for (const [, trigger] of triggerElements.entries()) {
2366 if (contains(trigger, targetElement)) {
2367 return !trigger.hasAttribute("data-trigger-disabled");
2368 }
2369 }
2370 return false;
2371 }
2372 function isEventTargetWithin(event, node) {
2373 if (node == null) {
2374 return false;
2375 }
2376 if ("composedPath" in event) {
2377 return event.composedPath().includes(node);
2378 }
2379 const eventAgain = event;
2380 return eventAgain.target != null && node.contains(eventAgain.target);
2381 }
2382 function isRootElement(element) {
2383 return element.matches("html,body");
2384 }
2385 function isTypeableElement(element) {
2386 return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
2387 }
2388 function isInteractiveElement(element) {
2389 return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
2390 }
2391 function matchesFocusVisible(element) {
2392 if (!element || isJSDOM) {
2393 return true;
2394 }
2395 try {
2396 return element.matches(":focus-visible");
2397 } catch (_e) {
2398 return true;
2399 }
2400 }
2401
2402 // node_modules/@base-ui/react/esm/floating-ui-react/utils/nodes.js
2403 function getNodeChildren(nodes, id, onlyOpenChildren = true) {
2404 const directChildren = nodes.filter((node) => node.parentId === id);
2405 return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
2406 }
2407
2408 // node_modules/@base-ui/react/esm/floating-ui-react/utils/event.js
2409 function isReactEvent(event) {
2410 return "nativeEvent" in event;
2411 }
2412 function isMouseLikePointerType(pointerType, strict) {
2413 const values = ["mouse", "pen"];
2414 if (!strict) {
2415 values.push("", void 0);
2416 }
2417 return values.includes(pointerType);
2418 }
2419 function isClickLikeEvent(event) {
2420 const type = event.type;
2421 return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
2422 }
2423
2424 // node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2425 var sides = ["top", "right", "bottom", "left"];
2426 var min = Math.min;
2427 var max = Math.max;
2428 var round = Math.round;
2429 var floor = Math.floor;
2430 var createCoords = (v2) => ({
2431 x: v2,
2432 y: v2
2433 });
2434 var oppositeSideMap = {
2435 left: "right",
2436 right: "left",
2437 bottom: "top",
2438 top: "bottom"
2439 };
2440 function clamp(start, value, end) {
2441 return max(start, min(value, end));
2442 }
2443 function evaluate(value, param) {
2444 return typeof value === "function" ? value(param) : value;
2445 }
2446 function getSide(placement) {
2447 return placement.split("-")[0];
2448 }
2449 function getAlignment(placement) {
2450 return placement.split("-")[1];
2451 }
2452 function getOppositeAxis(axis) {
2453 return axis === "x" ? "y" : "x";
2454 }
2455 function getAxisLength(axis) {
2456 return axis === "y" ? "height" : "width";
2457 }
2458 function getSideAxis(placement) {
2459 const firstChar = placement[0];
2460 return firstChar === "t" || firstChar === "b" ? "y" : "x";
2461 }
2462 function getAlignmentAxis(placement) {
2463 return getOppositeAxis(getSideAxis(placement));
2464 }
2465 function getAlignmentSides(placement, rects, rtl) {
2466 if (rtl === void 0) {
2467 rtl = false;
2468 }
2469 const alignment = getAlignment(placement);
2470 const alignmentAxis = getAlignmentAxis(placement);
2471 const length = getAxisLength(alignmentAxis);
2472 let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
2473 if (rects.reference[length] > rects.floating[length]) {
2474 mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
2475 }
2476 return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
2477 }
2478 function getExpandedPlacements(placement) {
2479 const oppositePlacement = getOppositePlacement(placement);
2480 return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
2481 }
2482 function getOppositeAlignmentPlacement(placement) {
2483 return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
2484 }
2485 var lrPlacement = ["left", "right"];
2486 var rlPlacement = ["right", "left"];
2487 var tbPlacement = ["top", "bottom"];
2488 var btPlacement = ["bottom", "top"];
2489 function getSideList(side, isStart, rtl) {
2490 switch (side) {
2491 case "top":
2492 case "bottom":
2493 if (rtl) return isStart ? rlPlacement : lrPlacement;
2494 return isStart ? lrPlacement : rlPlacement;
2495 case "left":
2496 case "right":
2497 return isStart ? tbPlacement : btPlacement;
2498 default:
2499 return [];
2500 }
2501 }
2502 function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
2503 const alignment = getAlignment(placement);
2504 let list = getSideList(getSide(placement), direction === "start", rtl);
2505 if (alignment) {
2506 list = list.map((side) => side + "-" + alignment);
2507 if (flipAlignment) {
2508 list = list.concat(list.map(getOppositeAlignmentPlacement));
2509 }
2510 }
2511 return list;
2512 }
2513 function getOppositePlacement(placement) {
2514 const side = getSide(placement);
2515 return oppositeSideMap[side] + placement.slice(side.length);
2516 }
2517 function expandPaddingObject(padding) {
2518 return {
2519 top: 0,
2520 right: 0,
2521 bottom: 0,
2522 left: 0,
2523 ...padding
2524 };
2525 }
2526 function getPaddingObject(padding) {
2527 return typeof padding !== "number" ? expandPaddingObject(padding) : {
2528 top: padding,
2529 right: padding,
2530 bottom: padding,
2531 left: padding
2532 };
2533 }
2534 function rectToClientRect(rect) {
2535 const {
2536 x: x2,
2537 y: y2,
2538 width,
2539 height
2540 } = rect;
2541 return {
2542 width,
2543 height,
2544 top: y2,
2545 left: x2,
2546 right: x2 + width,
2547 bottom: y2 + height,
2548 x: x2,
2549 y: y2
2550 };
2551 }
2552
2553 // node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
2554 function isHiddenByStyles(styles) {
2555 return styles.visibility === "hidden" || styles.visibility === "collapse";
2556 }
2557 function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
2558 if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
2559 return false;
2560 }
2561 if (typeof element.checkVisibility === "function") {
2562 return element.checkVisibility();
2563 }
2564 return styles.display !== "none" && styles.display !== "contents";
2565 }
2566
2567 // node_modules/@base-ui/utils/esm/owner.js
2568 function ownerDocument(node) {
2569 return node?.ownerDocument || document;
2570 }
2571
2572 // node_modules/@base-ui/react/esm/floating-ui-react/utils/tabbable.js
2573 var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
2574 function getParentElement(element) {
2575 const assignedSlot = element.assignedSlot;
2576 if (assignedSlot) {
2577 return assignedSlot;
2578 }
2579 if (element.parentElement) {
2580 return element.parentElement;
2581 }
2582 const rootNode = element.getRootNode();
2583 return isShadowRoot(rootNode) ? rootNode.host : null;
2584 }
2585 function getDetailsSummary(details) {
2586 for (const child of Array.from(details.children)) {
2587 if (getNodeName(child) === "summary") {
2588 return child;
2589 }
2590 }
2591 return null;
2592 }
2593 function isWithinOpenDetailsSummary(element, details) {
2594 const summary = getDetailsSummary(details);
2595 return !!summary && (element === summary || contains(summary, element));
2596 }
2597 function isFocusableCandidate(element) {
2598 const nodeName = element ? getNodeName(element) : "";
2599 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");
2600 }
2601 function isFocusableElement(element) {
2602 if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
2603 return false;
2604 }
2605 for (let current = element; current; current = getParentElement(current)) {
2606 const isAncestor = current !== element;
2607 const isSlot = getNodeName(current) === "slot";
2608 if (current.hasAttribute("inert")) {
2609 return false;
2610 }
2611 if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
2612 return false;
2613 }
2614 }
2615 return true;
2616 }
2617 function isVisibleInTabbableTree(element, isAncestor) {
2618 const styles = getComputedStyle2(element);
2619 if (!isAncestor) {
2620 return isElementVisible(element, styles);
2621 }
2622 return styles.display !== "none";
2623 }
2624 function getTabIndex(element) {
2625 const tabIndex = element.tabIndex;
2626 if (tabIndex < 0) {
2627 const nodeName = getNodeName(element);
2628 if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
2629 return 0;
2630 }
2631 }
2632 return tabIndex;
2633 }
2634 function getNamedRadioInput(element) {
2635 if (getNodeName(element) !== "input") {
2636 return null;
2637 }
2638 const input = element;
2639 return input.type === "radio" && input.name !== "" ? input : null;
2640 }
2641 function isTabbableRadio(element, candidates) {
2642 const input = getNamedRadioInput(element);
2643 if (!input) {
2644 return true;
2645 }
2646 const checkedRadio = candidates.find((candidate) => {
2647 const radio = getNamedRadioInput(candidate);
2648 return radio?.name === input.name && radio.form === input.form && radio.checked;
2649 });
2650 if (checkedRadio) {
2651 return checkedRadio === input;
2652 }
2653 return candidates.find((candidate) => {
2654 const radio = getNamedRadioInput(candidate);
2655 return radio?.name === input.name && radio.form === input.form;
2656 }) === input;
2657 }
2658 function getComposedChildren(container) {
2659 if (isHTMLElement(container) && getNodeName(container) === "slot") {
2660 const assignedElements = container.assignedElements({
2661 flatten: true
2662 });
2663 if (assignedElements.length > 0) {
2664 return assignedElements;
2665 }
2666 }
2667 if (isHTMLElement(container) && container.shadowRoot) {
2668 return Array.from(container.shadowRoot.children);
2669 }
2670 return Array.from(container.children);
2671 }
2672 function appendCandidates(container, list) {
2673 getComposedChildren(container).forEach((child) => {
2674 if (isFocusableCandidate(child)) {
2675 list.push(child);
2676 }
2677 appendCandidates(child, list);
2678 });
2679 }
2680 function appendMatchingElements(container, selector2, list) {
2681 getComposedChildren(container).forEach((child) => {
2682 if (isHTMLElement(child) && child.matches(selector2)) {
2683 list.push(child);
2684 }
2685 appendMatchingElements(child, selector2, list);
2686 });
2687 }
2688 function focusable(container) {
2689 const candidates = [];
2690 appendCandidates(container, candidates);
2691 return candidates.filter(isFocusableElement);
2692 }
2693 function tabbable(container) {
2694 const candidates = focusable(container);
2695 return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
2696 }
2697 function getTabbableIn(container, dir) {
2698 const list = tabbable(container);
2699 const len = list.length;
2700 if (len === 0) {
2701 return void 0;
2702 }
2703 const active = activeElement(ownerDocument(container));
2704 const index2 = list.indexOf(active);
2705 const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
2706 return list[nextIndex];
2707 }
2708 function getNextTabbable(referenceElement) {
2709 return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
2710 }
2711 function getPreviousTabbable(referenceElement) {
2712 return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
2713 }
2714 function isOutsideEvent(event, container) {
2715 const containerElement = container || event.currentTarget;
2716 const relatedTarget = event.relatedTarget;
2717 return !relatedTarget || !contains(containerElement, relatedTarget);
2718 }
2719 function disableFocusInside(container) {
2720 const tabbableElements = tabbable(container);
2721 tabbableElements.forEach((element) => {
2722 element.dataset.tabindex = element.getAttribute("tabindex") || "";
2723 element.setAttribute("tabindex", "-1");
2724 });
2725 }
2726 function enableFocusInside(container) {
2727 const elements = [];
2728 appendMatchingElements(container, "[data-tabindex]", elements);
2729 elements.forEach((element) => {
2730 const tabindex = element.dataset.tabindex;
2731 delete element.dataset.tabindex;
2732 if (tabindex) {
2733 element.setAttribute("tabindex", tabindex);
2734 } else {
2735 element.removeAttribute("tabindex");
2736 }
2737 });
2738 }
2739
2740 // node_modules/@base-ui/utils/esm/addEventListener.js
2741 function addEventListener(target, type, listener, options) {
2742 target.addEventListener(type, listener, options);
2743 return () => {
2744 target.removeEventListener(type, listener, options);
2745 };
2746 }
2747
2748 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2749 var React13 = __toESM(require_react(), 1);
2750 function useOpenChangeComplete(parameters) {
2751 const {
2752 enabled = true,
2753 open,
2754 ref,
2755 onComplete: onCompleteParam
2756 } = parameters;
2757 const onComplete = useStableCallback(onCompleteParam);
2758 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2759 React13.useEffect(() => {
2760 if (!enabled) {
2761 return void 0;
2762 }
2763 const abortController = new AbortController();
2764 runOnceAnimationsFinish(onComplete, abortController.signal);
2765 return () => {
2766 abortController.abort();
2767 };
2768 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2769 }
2770
2771 // node_modules/@base-ui/utils/esm/useOnFirstRender.js
2772 var React14 = __toESM(require_react(), 1);
2773 function useOnFirstRender(fn) {
2774 const ref = React14.useRef(true);
2775 if (ref.current) {
2776 ref.current = false;
2777 fn();
2778 }
2779 }
2780
2781 // node_modules/@base-ui/utils/esm/useTimeout.js
2782 var EMPTY3 = 0;
2783 var Timeout = class _Timeout {
2784 static create() {
2785 return new _Timeout();
2786 }
2787 currentId = EMPTY3;
2788 /**
2789 * Executes `fn` after `delay`, clearing any previously scheduled call.
2790 */
2791 start(delay, fn) {
2792 this.clear();
2793 this.currentId = setTimeout(() => {
2794 this.currentId = EMPTY3;
2795 fn();
2796 }, delay);
2797 }
2798 isStarted() {
2799 return this.currentId !== EMPTY3;
2800 }
2801 clear = () => {
2802 if (this.currentId !== EMPTY3) {
2803 clearTimeout(this.currentId);
2804 this.currentId = EMPTY3;
2805 }
2806 };
2807 disposeEffect = () => {
2808 return this.clear;
2809 };
2810 };
2811 function useTimeout() {
2812 const timeout = useRefWithInit(Timeout.create).current;
2813 useOnMount(timeout.disposeEffect);
2814 return timeout;
2815 }
2816
2817 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2818 var React15 = __toESM(require_react(), 1);
2819
2820 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverShared.js
2821 function resolveValue(value, pointerType) {
2822 if (pointerType != null && !isMouseLikePointerType(pointerType)) {
2823 return 0;
2824 }
2825 if (typeof value === "function") {
2826 return value();
2827 }
2828 return value;
2829 }
2830 function getDelay(value, prop, pointerType) {
2831 const result = resolveValue(value, pointerType);
2832 if (typeof result === "number") {
2833 return result;
2834 }
2835 return result?.[prop];
2836 }
2837 function getRestMs(value) {
2838 if (typeof value === "function") {
2839 return value();
2840 }
2841 return value;
2842 }
2843 function isClickLikeOpenEvent(openEventType, interactedInside) {
2844 return interactedInside || openEventType === "click" || openEventType === "mousedown";
2845 }
2846
2847 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingDelayGroup.js
2848 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2849 var FloatingDelayGroupContext = /* @__PURE__ */ React15.createContext({
2850 hasProvider: false,
2851 timeoutMs: 0,
2852 delayRef: {
2853 current: 0
2854 },
2855 initialDelayRef: {
2856 current: 0
2857 },
2858 timeout: new Timeout(),
2859 currentIdRef: {
2860 current: null
2861 },
2862 currentContextRef: {
2863 current: null
2864 }
2865 });
2866 if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
2867 function FloatingDelayGroup(props) {
2868 const {
2869 children,
2870 delay,
2871 timeoutMs = 0
2872 } = props;
2873 const delayRef = React15.useRef(delay);
2874 const initialDelayRef = React15.useRef(delay);
2875 const currentIdRef = React15.useRef(null);
2876 const currentContextRef = React15.useRef(null);
2877 const timeout = useTimeout();
2878 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
2879 value: React15.useMemo(() => ({
2880 hasProvider: true,
2881 delayRef,
2882 initialDelayRef,
2883 currentIdRef,
2884 timeoutMs,
2885 currentContextRef,
2886 timeout
2887 }), [timeoutMs, timeout]),
2888 children
2889 });
2890 }
2891 function useDelayGroup(context, options = {
2892 open: false
2893 }) {
2894 const store = "rootStore" in context ? context.rootStore : context;
2895 const floatingId = store.useState("floatingId");
2896 const {
2897 open
2898 } = options;
2899 const groupContext = React15.useContext(FloatingDelayGroupContext);
2900 const {
2901 currentIdRef,
2902 delayRef,
2903 timeoutMs,
2904 initialDelayRef,
2905 currentContextRef,
2906 hasProvider,
2907 timeout
2908 } = groupContext;
2909 const [isInstantPhase, setIsInstantPhase] = React15.useState(false);
2910 useIsoLayoutEffect(() => {
2911 function unset() {
2912 setIsInstantPhase(false);
2913 currentContextRef.current?.setIsInstantPhase(false);
2914 currentIdRef.current = null;
2915 currentContextRef.current = null;
2916 delayRef.current = initialDelayRef.current;
2917 }
2918 if (!currentIdRef.current) {
2919 return void 0;
2920 }
2921 if (!open && currentIdRef.current === floatingId) {
2922 setIsInstantPhase(false);
2923 if (timeoutMs) {
2924 const closingId = floatingId;
2925 timeout.start(timeoutMs, () => {
2926 if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
2927 return;
2928 }
2929 unset();
2930 });
2931 return () => {
2932 timeout.clear();
2933 };
2934 }
2935 unset();
2936 }
2937 return void 0;
2938 }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
2939 useIsoLayoutEffect(() => {
2940 if (!open) {
2941 return;
2942 }
2943 const prevContext = currentContextRef.current;
2944 const prevId = currentIdRef.current;
2945 timeout.clear();
2946 currentContextRef.current = {
2947 onOpenChange: store.setOpen,
2948 setIsInstantPhase
2949 };
2950 currentIdRef.current = floatingId;
2951 delayRef.current = {
2952 open: 0,
2953 close: getDelay(initialDelayRef.current, "close")
2954 };
2955 if (prevId !== null && prevId !== floatingId) {
2956 setIsInstantPhase(true);
2957 prevContext?.setIsInstantPhase(true);
2958 prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
2959 } else {
2960 setIsInstantPhase(false);
2961 prevContext?.setIsInstantPhase(false);
2962 }
2963 }, [open, floatingId, store, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout]);
2964 useIsoLayoutEffect(() => {
2965 return () => {
2966 currentContextRef.current = null;
2967 };
2968 }, [currentContextRef]);
2969 return React15.useMemo(() => ({
2970 hasProvider,
2971 delayRef,
2972 isInstantPhase
2973 }), [hasProvider, delayRef, isInstantPhase]);
2974 }
2975
2976 // node_modules/@base-ui/utils/esm/mergeCleanups.js
2977 function mergeCleanups(...cleanups) {
2978 return () => {
2979 for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
2980 const cleanup = cleanups[i2];
2981 if (cleanup) {
2982 cleanup();
2983 }
2984 }
2985 };
2986 }
2987
2988 // node_modules/@base-ui/utils/esm/useValueAsRef.js
2989 function useValueAsRef(value) {
2990 const latest = useRefWithInit(createLatestRef, value).current;
2991 latest.next = value;
2992 useIsoLayoutEffect(latest.effect);
2993 return latest;
2994 }
2995 function createLatestRef(value) {
2996 const latest = {
2997 current: value,
2998 next: value,
2999 effect: () => {
3000 latest.current = latest.next;
3001 }
3002 };
3003 return latest;
3004 }
3005
3006 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3007 var React16 = __toESM(require_react(), 1);
3008
3009 // node_modules/@base-ui/utils/esm/visuallyHidden.js
3010 var visuallyHiddenBase = {
3011 clipPath: "inset(50%)",
3012 overflow: "hidden",
3013 whiteSpace: "nowrap",
3014 border: 0,
3015 padding: 0,
3016 width: 1,
3017 height: 1,
3018 margin: -1
3019 };
3020 var visuallyHidden = {
3021 ...visuallyHiddenBase,
3022 position: "fixed",
3023 top: 0,
3024 left: 0
3025 };
3026 var visuallyHiddenInput = {
3027 ...visuallyHiddenBase,
3028 position: "absolute"
3029 };
3030
3031 // node_modules/@base-ui/react/esm/utils/FocusGuard.js
3032 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
3033 var FocusGuard = /* @__PURE__ */ React16.forwardRef(function FocusGuard2(props, ref) {
3034 const [role, setRole] = React16.useState();
3035 useIsoLayoutEffect(() => {
3036 if (isSafari) {
3037 setRole("button");
3038 }
3039 }, []);
3040 const restProps = {
3041 tabIndex: 0,
3042 // Role is only for VoiceOver
3043 role
3044 };
3045 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
3046 ...props,
3047 ref,
3048 style: visuallyHidden,
3049 "aria-hidden": role ? void 0 : true,
3050 ...restProps,
3051 "data-base-ui-focus-guard": ""
3052 });
3053 });
3054 if (true) FocusGuard.displayName = "FocusGuard";
3055
3056 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createAttribute.js
3057 function createAttribute(name) {
3058 return `data-base-ui-${name}`;
3059 }
3060
3061 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3062 var React17 = __toESM(require_react(), 1);
3063 var ReactDOM2 = __toESM(require_react_dom(), 1);
3064
3065 // node_modules/@base-ui/react/esm/internals/constants.js
3066 var DISABLED_TRANSITIONS_STYLE = {
3067 style: {
3068 transition: "none"
3069 }
3070 };
3071 var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
3072 var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
3073 var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
3074 var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
3075 var POPUP_COLLISION_AVOIDANCE = {
3076 fallbackAxisSide: "end"
3077 };
3078 var ownerVisuallyHidden = {
3079 clipPath: "inset(50%)",
3080 position: "fixed",
3081 top: 0,
3082 left: 0
3083 };
3084
3085 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingPortal.js
3086 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3087 var PortalContext = /* @__PURE__ */ React17.createContext(null);
3088 if (true) PortalContext.displayName = "PortalContext";
3089 var usePortalContext = () => React17.useContext(PortalContext);
3090 var attr = createAttribute("portal");
3091 function useFloatingPortalNode(props = {}) {
3092 const {
3093 ref,
3094 container: containerProp,
3095 componentProps = EMPTY_OBJECT,
3096 elementProps
3097 } = props;
3098 const uniqueId = useId();
3099 const portalContext = usePortalContext();
3100 const parentPortalNode = portalContext?.portalNode;
3101 const [containerElement, setContainerElement] = React17.useState(null);
3102 const [portalNode, setPortalNode] = React17.useState(null);
3103 const setPortalNodeRef = useStableCallback((node) => {
3104 if (node !== null) {
3105 setPortalNode(node);
3106 }
3107 });
3108 const containerRef = React17.useRef(null);
3109 useIsoLayoutEffect(() => {
3110 if (containerProp === null) {
3111 if (containerRef.current) {
3112 containerRef.current = null;
3113 setPortalNode(null);
3114 setContainerElement(null);
3115 }
3116 return;
3117 }
3118 if (uniqueId == null) {
3119 return;
3120 }
3121 const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
3122 if (resolvedContainer == null) {
3123 if (containerRef.current) {
3124 containerRef.current = null;
3125 setPortalNode(null);
3126 setContainerElement(null);
3127 }
3128 return;
3129 }
3130 if (containerRef.current !== resolvedContainer) {
3131 containerRef.current = resolvedContainer;
3132 setPortalNode(null);
3133 setContainerElement(resolvedContainer);
3134 }
3135 }, [containerProp, parentPortalNode, uniqueId]);
3136 const portalElement = useRenderElement("div", componentProps, {
3137 ref: [ref, setPortalNodeRef],
3138 props: [{
3139 id: uniqueId,
3140 [attr]: ""
3141 }, elementProps]
3142 });
3143 const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
3144 return {
3145 portalNode,
3146 portalSubtree
3147 };
3148 }
3149 var FloatingPortal = /* @__PURE__ */ React17.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
3150 const {
3151 children,
3152 container,
3153 className,
3154 render: render4,
3155 renderGuards,
3156 style,
3157 ...elementProps
3158 } = componentProps;
3159 const {
3160 portalNode,
3161 portalSubtree
3162 } = useFloatingPortalNode({
3163 container,
3164 ref: forwardedRef,
3165 componentProps,
3166 elementProps
3167 });
3168 const beforeOutsideRef = React17.useRef(null);
3169 const afterOutsideRef = React17.useRef(null);
3170 const beforeInsideRef = React17.useRef(null);
3171 const afterInsideRef = React17.useRef(null);
3172 const [focusManagerState, setFocusManagerState] = React17.useState(null);
3173 const focusInsideDisabledRef = React17.useRef(false);
3174 const modal = focusManagerState?.modal;
3175 const open = focusManagerState?.open;
3176 const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
3177 React17.useEffect(() => {
3178 if (!portalNode || modal) {
3179 return void 0;
3180 }
3181 function onFocus(event) {
3182 if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
3183 if (event.type === "focusin") {
3184 if (focusInsideDisabledRef.current) {
3185 enableFocusInside(portalNode);
3186 focusInsideDisabledRef.current = false;
3187 }
3188 } else {
3189 disableFocusInside(portalNode);
3190 focusInsideDisabledRef.current = true;
3191 }
3192 }
3193 }
3194 return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
3195 }, [portalNode, modal]);
3196 React17.useEffect(() => {
3197 if (!portalNode || open !== false) {
3198 return;
3199 }
3200 enableFocusInside(portalNode);
3201 focusInsideDisabledRef.current = false;
3202 }, [open, portalNode]);
3203 const portalContextValue = React17.useMemo(() => ({
3204 beforeOutsideRef,
3205 afterOutsideRef,
3206 beforeInsideRef,
3207 afterInsideRef,
3208 portalNode,
3209 setFocusManagerState
3210 }), [portalNode]);
3211 return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React17.Fragment, {
3212 children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
3213 value: portalContextValue,
3214 children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3215 "data-type": "outside",
3216 ref: beforeOutsideRef,
3217 onFocus: (event) => {
3218 if (isOutsideEvent(event, portalNode)) {
3219 beforeInsideRef.current?.focus();
3220 } else {
3221 const domReference = focusManagerState ? focusManagerState.domReference : null;
3222 const prevTabbable = getPreviousTabbable(domReference);
3223 prevTabbable?.focus();
3224 }
3225 }
3226 }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
3227 "aria-owns": portalNode.id,
3228 style: ownerVisuallyHidden
3229 }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
3230 "data-type": "outside",
3231 ref: afterOutsideRef,
3232 onFocus: (event) => {
3233 if (isOutsideEvent(event, portalNode)) {
3234 afterInsideRef.current?.focus();
3235 } else {
3236 const domReference = focusManagerState ? focusManagerState.domReference : null;
3237 const nextTabbable = getNextTabbable(domReference);
3238 nextTabbable?.focus();
3239 if (focusManagerState?.closeOnFocusOut) {
3240 focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
3241 }
3242 }
3243 }
3244 })]
3245 })]
3246 });
3247 });
3248 if (true) FloatingPortal.displayName = "FloatingPortal";
3249
3250 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3251 var React18 = __toESM(require_react(), 1);
3252
3253 // node_modules/@base-ui/react/esm/floating-ui-react/utils/createEventEmitter.js
3254 function createEventEmitter() {
3255 const map = /* @__PURE__ */ new Map();
3256 return {
3257 emit(event, data) {
3258 map.get(event)?.forEach((listener) => listener(data));
3259 },
3260 on(event, listener) {
3261 if (!map.has(event)) {
3262 map.set(event, /* @__PURE__ */ new Set());
3263 }
3264 map.get(event).add(listener);
3265 },
3266 off(event, listener) {
3267 map.get(event)?.delete(listener);
3268 }
3269 };
3270 }
3271
3272 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingTree.js
3273 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3274 var FloatingNodeContext = /* @__PURE__ */ React18.createContext(null);
3275 if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
3276 var FloatingTreeContext = /* @__PURE__ */ React18.createContext(null);
3277 if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
3278 var useFloatingParentNodeId = () => React18.useContext(FloatingNodeContext)?.id || null;
3279 var useFloatingTree = (externalTree) => {
3280 const contextTree = React18.useContext(FloatingTreeContext);
3281 return externalTree ?? contextTree;
3282 };
3283
3284 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useClientPoint.js
3285 var React19 = __toESM(require_react(), 1);
3286 function createVirtualElement(domElement, data) {
3287 let offsetX = null;
3288 let offsetY = null;
3289 let isAutoUpdateEvent = false;
3290 return {
3291 contextElement: domElement || void 0,
3292 getBoundingClientRect() {
3293 const domRect = domElement?.getBoundingClientRect() || {
3294 width: 0,
3295 height: 0,
3296 x: 0,
3297 y: 0
3298 };
3299 const isXAxis = data.axis === "x" || data.axis === "both";
3300 const isYAxis = data.axis === "y" || data.axis === "both";
3301 const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
3302 let width = domRect.width;
3303 let height = domRect.height;
3304 let x2 = domRect.x;
3305 let y2 = domRect.y;
3306 if (offsetX == null && data.x && isXAxis) {
3307 offsetX = domRect.x - data.x;
3308 }
3309 if (offsetY == null && data.y && isYAxis) {
3310 offsetY = domRect.y - data.y;
3311 }
3312 x2 -= offsetX || 0;
3313 y2 -= offsetY || 0;
3314 width = 0;
3315 height = 0;
3316 if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
3317 width = data.axis === "y" ? domRect.width : 0;
3318 height = data.axis === "x" ? domRect.height : 0;
3319 x2 = isXAxis && data.x != null ? data.x : x2;
3320 y2 = isYAxis && data.y != null ? data.y : y2;
3321 } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
3322 height = data.axis === "x" ? domRect.height : height;
3323 width = data.axis === "y" ? domRect.width : width;
3324 }
3325 isAutoUpdateEvent = true;
3326 return {
3327 width,
3328 height,
3329 x: x2,
3330 y: y2,
3331 top: y2,
3332 right: x2 + width,
3333 bottom: y2 + height,
3334 left: x2
3335 };
3336 }
3337 };
3338 }
3339 function isMouseBasedEvent(event) {
3340 return event != null && event.clientX != null;
3341 }
3342 function useClientPoint(context, props = {}) {
3343 const store = "rootStore" in context ? context.rootStore : context;
3344 const open = store.useState("open");
3345 const floating = store.useState("floatingElement");
3346 const domReference = store.useState("domReferenceElement");
3347 const dataRef = store.context.dataRef;
3348 const {
3349 enabled = true,
3350 axis = "both"
3351 } = props;
3352 const initialRef = React19.useRef(false);
3353 const cleanupListenerRef = React19.useRef(null);
3354 const [pointerType, setPointerType] = React19.useState();
3355 const [reactive, setReactive] = React19.useState([]);
3356 const setReference = useStableCallback((newX, newY, referenceElement) => {
3357 if (initialRef.current) {
3358 return;
3359 }
3360 if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
3361 return;
3362 }
3363 store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
3364 x: newX,
3365 y: newY,
3366 axis,
3367 dataRef,
3368 pointerType
3369 }));
3370 });
3371 const handleReferenceEnterOrMove = useStableCallback((event) => {
3372 if (!open) {
3373 setReference(event.clientX, event.clientY, event.currentTarget);
3374 } else if (!cleanupListenerRef.current) {
3375 setReactive([]);
3376 }
3377 });
3378 const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
3379 const addListener = React19.useCallback(() => {
3380 if (!openCheck || !enabled) {
3381 return void 0;
3382 }
3383 const win = getWindow(floating);
3384 function handleMouseMove(event) {
3385 const target = getTarget(event);
3386 if (!contains(floating, target)) {
3387 setReference(event.clientX, event.clientY);
3388 } else {
3389 cleanupListenerRef.current?.();
3390 cleanupListenerRef.current = null;
3391 }
3392 }
3393 if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
3394 const cleanup = () => {
3395 cleanupListenerRef.current?.();
3396 cleanupListenerRef.current = null;
3397 };
3398 cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
3399 return cleanup;
3400 }
3401 store.set("positionReference", domReference);
3402 return void 0;
3403 }, [openCheck, enabled, floating, dataRef, domReference, store, setReference]);
3404 React19.useEffect(() => {
3405 return addListener();
3406 }, [addListener, reactive]);
3407 React19.useEffect(() => {
3408 if (enabled && !floating) {
3409 initialRef.current = false;
3410 }
3411 }, [enabled, floating]);
3412 React19.useEffect(() => {
3413 if (!enabled && open) {
3414 initialRef.current = true;
3415 }
3416 }, [enabled, open]);
3417 const reference = React19.useMemo(() => {
3418 function setPointerTypeRef(event) {
3419 setPointerType(event.pointerType);
3420 }
3421 return {
3422 onPointerDown: setPointerTypeRef,
3423 onPointerEnter: setPointerTypeRef,
3424 onMouseMove: handleReferenceEnterOrMove,
3425 onMouseEnter: handleReferenceEnterOrMove
3426 };
3427 }, [handleReferenceEnterOrMove]);
3428 return React19.useMemo(() => enabled ? {
3429 reference,
3430 trigger: reference
3431 } : {}, [enabled, reference]);
3432 }
3433
3434 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useDismiss.js
3435 var React20 = __toESM(require_react(), 1);
3436 var bubbleHandlerKeys = {
3437 intentional: "onClick",
3438 sloppy: "onPointerDown"
3439 };
3440 function alwaysFalse() {
3441 return false;
3442 }
3443 function normalizeProp(normalizable) {
3444 return {
3445 escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
3446 outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
3447 };
3448 }
3449 function useDismiss(context, props = {}) {
3450 const store = "rootStore" in context ? context.rootStore : context;
3451 const open = store.useState("open");
3452 const floatingElement = store.useState("floatingElement");
3453 const {
3454 dataRef
3455 } = store.context;
3456 const {
3457 enabled = true,
3458 escapeKey: escapeKey2 = true,
3459 outsidePress: outsidePressProp = true,
3460 outsidePressEvent = "sloppy",
3461 referencePress = alwaysFalse,
3462 referencePressEvent = "sloppy",
3463 bubbles,
3464 externalTree
3465 } = props;
3466 const tree = useFloatingTree(externalTree);
3467 const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
3468 const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
3469 const outsidePressEnabled = outsidePress2 !== false;
3470 const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
3471 const pressStartedInsideRef = React20.useRef(false);
3472 const pressStartPreventedRef = React20.useRef(false);
3473 const suppressNextOutsideClickRef = React20.useRef(false);
3474 const {
3475 escapeKey: escapeKeyBubbles,
3476 outsidePress: outsidePressBubbles
3477 } = normalizeProp(bubbles);
3478 const touchStateRef = React20.useRef(null);
3479 const cancelDismissOnEndTimeout = useTimeout();
3480 const clearInsideReactTreeTimeout = useTimeout();
3481 const clearInsideReactTree = useStableCallback(() => {
3482 clearInsideReactTreeTimeout.clear();
3483 dataRef.current.insideReactTree = false;
3484 });
3485 const isComposingRef = React20.useRef(false);
3486 const currentPointerTypeRef = React20.useRef("");
3487 const isReferencePressEnabled = useStableCallback(referencePress);
3488 const closeOnEscapeKeyDown = useStableCallback((event) => {
3489 if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
3490 return;
3491 }
3492 if (isComposingRef.current) {
3493 return;
3494 }
3495 const nodeId = dataRef.current.floatingContext?.nodeId;
3496 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3497 if (!escapeKeyBubbles) {
3498 if (children.length > 0) {
3499 let shouldDismiss = true;
3500 children.forEach((child) => {
3501 if (child.context?.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3502 shouldDismiss = false;
3503 }
3504 });
3505 if (!shouldDismiss) {
3506 return;
3507 }
3508 }
3509 }
3510 const native = isReactEvent(event) ? event.nativeEvent : event;
3511 const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
3512 store.setOpen(false, eventDetails);
3513 if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
3514 event.stopPropagation();
3515 }
3516 });
3517 const markInsideReactTree = useStableCallback(() => {
3518 dataRef.current.insideReactTree = true;
3519 clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
3520 });
3521 React20.useEffect(() => {
3522 if (!open || !enabled) {
3523 return void 0;
3524 }
3525 dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3526 dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3527 const compositionTimeout = new Timeout();
3528 const preventedPressSuppressionTimeout = new Timeout();
3529 function handleCompositionStart() {
3530 compositionTimeout.clear();
3531 isComposingRef.current = true;
3532 }
3533 function handleCompositionEnd() {
3534 compositionTimeout.start(
3535 // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3536 // Only apply to WebKit for the test to remain 0ms.
3537 isWebKit() ? 5 : 0,
3538 () => {
3539 isComposingRef.current = false;
3540 }
3541 );
3542 }
3543 function suppressImmediateOutsideClickAfterPreventedStart() {
3544 suppressNextOutsideClickRef.current = true;
3545 preventedPressSuppressionTimeout.start(0, () => {
3546 suppressNextOutsideClickRef.current = false;
3547 });
3548 }
3549 function resetPressStartState() {
3550 pressStartedInsideRef.current = false;
3551 pressStartPreventedRef.current = false;
3552 }
3553 function getOutsidePressEvent() {
3554 const type = currentPointerTypeRef.current;
3555 const computedType = type === "pen" || !type ? "mouse" : type;
3556 const outsidePressEventValue = getOutsidePressEventProp();
3557 const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
3558 if (typeof resolved === "string") {
3559 return resolved;
3560 }
3561 return resolved[computedType];
3562 }
3563 function shouldIgnoreEvent(event) {
3564 const computedOutsidePressEvent = getOutsidePressEvent();
3565 return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
3566 }
3567 function isEventWithinFloatingTree(event) {
3568 const nodeId = dataRef.current.floatingContext?.nodeId;
3569 const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
3570 return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement")) || targetIsInsideChildren;
3571 }
3572 function closeOnPressOutside(event) {
3573 if (shouldIgnoreEvent(event)) {
3574 clearInsideReactTree();
3575 return;
3576 }
3577 if (dataRef.current.insideReactTree) {
3578 clearInsideReactTree();
3579 return;
3580 }
3581 const target = getTarget(event);
3582 const inertSelector = `[${createAttribute("inert")}]`;
3583 const targetRoot = isElement(target) ? target.getRootNode() : null;
3584 const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
3585 const triggers = store.context.triggerElements;
3586 if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
3587 return;
3588 }
3589 let targetRootAncestor = isElement(target) ? target : null;
3590 while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
3591 const nextParent = getParentNode(targetRootAncestor);
3592 if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
3593 break;
3594 }
3595 targetRootAncestor = nextParent;
3596 }
3597 if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
3598 !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
3599 // element was injected after the floating element rendered.
3600 markers.every((marker) => !contains(targetRootAncestor, marker))) {
3601 return;
3602 }
3603 if (isHTMLElement(target) && !("touches" in event)) {
3604 const lastTraversableNode = isLastTraversableNode(target);
3605 const style = getComputedStyle2(target);
3606 const scrollRe = /auto|scroll/;
3607 const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3608 const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3609 const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3610 const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3611 const isRTL7 = style.direction === "rtl";
3612 const pressedVerticalScrollbar = canScrollY && (isRTL7 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3613 const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3614 if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3615 return;
3616 }
3617 }
3618 if (isEventWithinFloatingTree(event)) {
3619 return;
3620 }
3621 if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
3622 preventedPressSuppressionTimeout.clear();
3623 suppressNextOutsideClickRef.current = false;
3624 return;
3625 }
3626 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3627 return;
3628 }
3629 const nodeId = dataRef.current.floatingContext?.nodeId;
3630 const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
3631 if (children.length > 0) {
3632 let shouldDismiss = true;
3633 children.forEach((child) => {
3634 if (child.context?.open && !child.context.dataRef.current.__outsidePressBubbles) {
3635 shouldDismiss = false;
3636 }
3637 });
3638 if (!shouldDismiss) {
3639 return;
3640 }
3641 }
3642 store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
3643 clearInsideReactTree();
3644 }
3645 function handlePointerDown(event) {
3646 if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3647 return;
3648 }
3649 closeOnPressOutside(event);
3650 }
3651 function handleTouchStart(event) {
3652 if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3653 return;
3654 }
3655 const touch = event.touches[0];
3656 if (touch) {
3657 touchStateRef.current = {
3658 startTime: Date.now(),
3659 startX: touch.clientX,
3660 startY: touch.clientY,
3661 dismissOnTouchEnd: false,
3662 dismissOnMouseDown: true
3663 };
3664 cancelDismissOnEndTimeout.start(1e3, () => {
3665 if (touchStateRef.current) {
3666 touchStateRef.current.dismissOnTouchEnd = false;
3667 touchStateRef.current.dismissOnMouseDown = false;
3668 }
3669 });
3670 }
3671 }
3672 function addTargetEventListenerOnce(event, listener) {
3673 const target = getTarget(event);
3674 if (!target) {
3675 return;
3676 }
3677 const unsubscribe2 = addEventListener(target, event.type, () => {
3678 listener(event);
3679 unsubscribe2();
3680 });
3681 }
3682 function handleTouchStartCapture(event) {
3683 currentPointerTypeRef.current = "touch";
3684 addTargetEventListenerOnce(event, handleTouchStart);
3685 }
3686 function closeOnPressOutsideCapture(event) {
3687 cancelDismissOnEndTimeout.clear();
3688 if (event.type === "pointerdown") {
3689 currentPointerTypeRef.current = event.pointerType;
3690 }
3691 if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
3692 return;
3693 }
3694 addTargetEventListenerOnce(event, (targetEvent) => {
3695 if (targetEvent.type === "pointerdown") {
3696 handlePointerDown(targetEvent);
3697 } else {
3698 closeOnPressOutside(targetEvent);
3699 }
3700 });
3701 }
3702 function handlePressEndCapture(event) {
3703 if (!pressStartedInsideRef.current) {
3704 return;
3705 }
3706 const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
3707 resetPressStartState();
3708 if (getOutsidePressEvent() !== "intentional") {
3709 return;
3710 }
3711 if (event.type === "pointercancel") {
3712 if (pressStartedInsideDefaultPrevented) {
3713 suppressImmediateOutsideClickAfterPreventedStart();
3714 }
3715 return;
3716 }
3717 if (isEventWithinFloatingTree(event)) {
3718 return;
3719 }
3720 if (pressStartedInsideDefaultPrevented) {
3721 suppressImmediateOutsideClickAfterPreventedStart();
3722 return;
3723 }
3724 if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
3725 return;
3726 }
3727 preventedPressSuppressionTimeout.clear();
3728 suppressNextOutsideClickRef.current = true;
3729 clearInsideReactTree();
3730 }
3731 function handleTouchMove(event) {
3732 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3733 return;
3734 }
3735 const touch = event.touches[0];
3736 if (!touch) {
3737 return;
3738 }
3739 const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
3740 const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
3741 const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
3742 if (distance > 5) {
3743 touchStateRef.current.dismissOnTouchEnd = true;
3744 }
3745 if (distance > 10) {
3746 closeOnPressOutside(event);
3747 cancelDismissOnEndTimeout.clear();
3748 touchStateRef.current = null;
3749 }
3750 }
3751 function handleTouchMoveCapture(event) {
3752 addTargetEventListenerOnce(event, handleTouchMove);
3753 }
3754 function handleTouchEnd(event) {
3755 if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"))) {
3756 return;
3757 }
3758 if (touchStateRef.current.dismissOnTouchEnd) {
3759 closeOnPressOutside(event);
3760 }
3761 cancelDismissOnEndTimeout.clear();
3762 touchStateRef.current = null;
3763 }
3764 function handleTouchEndCapture(event) {
3765 addTargetEventListenerOnce(event, handleTouchEnd);
3766 }
3767 const doc = ownerDocument(floatingElement);
3768 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)));
3769 return () => {
3770 unsubscribe();
3771 compositionTimeout.clear();
3772 preventedPressSuppressionTimeout.clear();
3773 resetPressStartState();
3774 suppressNextOutsideClickRef.current = false;
3775 };
3776 }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, tree, store, cancelDismissOnEndTimeout]);
3777 React20.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
3778 const reference = React20.useMemo(() => ({
3779 onKeyDown: closeOnEscapeKeyDown,
3780 [bubbleHandlerKeys[referencePressEvent]]: (event) => {
3781 if (!isReferencePressEnabled()) {
3782 return;
3783 }
3784 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3785 },
3786 ...referencePressEvent !== "intentional" && {
3787 onClick(event) {
3788 if (!isReferencePressEnabled()) {
3789 return;
3790 }
3791 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
3792 }
3793 }
3794 }), [closeOnEscapeKeyDown, store, referencePressEvent, isReferencePressEnabled]);
3795 const markPressStartedInsideReactTree = useStableCallback((event) => {
3796 if (!open || !enabled || event.button !== 0) {
3797 return;
3798 }
3799 const target = getTarget(event.nativeEvent);
3800 if (!contains(store.select("floatingElement"), target)) {
3801 return;
3802 }
3803 if (!pressStartedInsideRef.current) {
3804 pressStartedInsideRef.current = true;
3805 pressStartPreventedRef.current = false;
3806 }
3807 });
3808 const markInsidePressStartPrevented = useStableCallback((event) => {
3809 if (!open || !enabled) {
3810 return;
3811 }
3812 if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
3813 return;
3814 }
3815 if (pressStartedInsideRef.current) {
3816 pressStartPreventedRef.current = true;
3817 }
3818 });
3819 const floating = React20.useMemo(() => ({
3820 onKeyDown: closeOnEscapeKeyDown,
3821 // `onMouseDown` may be blocked if `event.preventDefault()` is called in
3822 // `onPointerDown`, such as with <NumberField.ScrubArea>.
3823 // See https://github.com/mui/base-ui/pull/3379
3824 onPointerDown: markInsidePressStartPrevented,
3825 onMouseDown: markInsidePressStartPrevented,
3826 onClickCapture: markInsideReactTree,
3827 onMouseDownCapture(event) {
3828 markInsideReactTree();
3829 markPressStartedInsideReactTree(event);
3830 },
3831 onPointerDownCapture(event) {
3832 markInsideReactTree();
3833 markPressStartedInsideReactTree(event);
3834 },
3835 onMouseUpCapture: markInsideReactTree,
3836 onTouchEndCapture: markInsideReactTree,
3837 onTouchMoveCapture: markInsideReactTree
3838 }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
3839 return React20.useMemo(() => enabled ? {
3840 reference,
3841 floating,
3842 trigger: reference
3843 } : {}, [enabled, reference, floating]);
3844 }
3845
3846 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
3847 var React26 = __toESM(require_react(), 1);
3848
3849 // node_modules/@floating-ui/core/dist/floating-ui.core.mjs
3850 function computeCoordsFromPlacement(_ref, placement, rtl) {
3851 let {
3852 reference,
3853 floating
3854 } = _ref;
3855 const sideAxis = getSideAxis(placement);
3856 const alignmentAxis = getAlignmentAxis(placement);
3857 const alignLength = getAxisLength(alignmentAxis);
3858 const side = getSide(placement);
3859 const isVertical = sideAxis === "y";
3860 const commonX = reference.x + reference.width / 2 - floating.width / 2;
3861 const commonY = reference.y + reference.height / 2 - floating.height / 2;
3862 const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
3863 let coords;
3864 switch (side) {
3865 case "top":
3866 coords = {
3867 x: commonX,
3868 y: reference.y - floating.height
3869 };
3870 break;
3871 case "bottom":
3872 coords = {
3873 x: commonX,
3874 y: reference.y + reference.height
3875 };
3876 break;
3877 case "right":
3878 coords = {
3879 x: reference.x + reference.width,
3880 y: commonY
3881 };
3882 break;
3883 case "left":
3884 coords = {
3885 x: reference.x - floating.width,
3886 y: commonY
3887 };
3888 break;
3889 default:
3890 coords = {
3891 x: reference.x,
3892 y: reference.y
3893 };
3894 }
3895 switch (getAlignment(placement)) {
3896 case "start":
3897 coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
3898 break;
3899 case "end":
3900 coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
3901 break;
3902 }
3903 return coords;
3904 }
3905 async function detectOverflow(state, options) {
3906 var _await$platform$isEle;
3907 if (options === void 0) {
3908 options = {};
3909 }
3910 const {
3911 x: x2,
3912 y: y2,
3913 platform: platform3,
3914 rects,
3915 elements,
3916 strategy
3917 } = state;
3918 const {
3919 boundary = "clippingAncestors",
3920 rootBoundary = "viewport",
3921 elementContext = "floating",
3922 altBoundary = false,
3923 padding = 0
3924 } = evaluate(options, state);
3925 const paddingObject = getPaddingObject(padding);
3926 const altContext = elementContext === "floating" ? "reference" : "floating";
3927 const element = elements[altBoundary ? altContext : elementContext];
3928 const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
3929 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)),
3930 boundary,
3931 rootBoundary,
3932 strategy
3933 }));
3934 const rect = elementContext === "floating" ? {
3935 x: x2,
3936 y: y2,
3937 width: rects.floating.width,
3938 height: rects.floating.height
3939 } : rects.reference;
3940 const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating));
3941 const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
3942 x: 1,
3943 y: 1
3944 } : {
3945 x: 1,
3946 y: 1
3947 };
3948 const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
3949 elements,
3950 rect,
3951 offsetParent,
3952 strategy
3953 }) : rect);
3954 return {
3955 top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
3956 bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
3957 left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
3958 right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
3959 };
3960 }
3961 var MAX_RESET_COUNT = 50;
3962 var computePosition = async (reference, floating, config) => {
3963 const {
3964 placement = "bottom",
3965 strategy = "absolute",
3966 middleware = [],
3967 platform: platform3
3968 } = config;
3969 const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
3970 ...platform3,
3971 detectOverflow
3972 };
3973 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
3974 let rects = await platform3.getElementRects({
3975 reference,
3976 floating,
3977 strategy
3978 });
3979 let {
3980 x: x2,
3981 y: y2
3982 } = computeCoordsFromPlacement(rects, placement, rtl);
3983 let statefulPlacement = placement;
3984 let resetCount = 0;
3985 const middlewareData = {};
3986 for (let i2 = 0; i2 < middleware.length; i2++) {
3987 const currentMiddleware = middleware[i2];
3988 if (!currentMiddleware) {
3989 continue;
3990 }
3991 const {
3992 name,
3993 fn
3994 } = currentMiddleware;
3995 const {
3996 x: nextX,
3997 y: nextY,
3998 data,
3999 reset
4000 } = await fn({
4001 x: x2,
4002 y: y2,
4003 initialPlacement: placement,
4004 placement: statefulPlacement,
4005 strategy,
4006 middlewareData,
4007 rects,
4008 platform: platformWithDetectOverflow,
4009 elements: {
4010 reference,
4011 floating
4012 }
4013 });
4014 x2 = nextX != null ? nextX : x2;
4015 y2 = nextY != null ? nextY : y2;
4016 middlewareData[name] = {
4017 ...middlewareData[name],
4018 ...data
4019 };
4020 if (reset && resetCount < MAX_RESET_COUNT) {
4021 resetCount++;
4022 if (typeof reset === "object") {
4023 if (reset.placement) {
4024 statefulPlacement = reset.placement;
4025 }
4026 if (reset.rects) {
4027 rects = reset.rects === true ? await platform3.getElementRects({
4028 reference,
4029 floating,
4030 strategy
4031 }) : reset.rects;
4032 }
4033 ({
4034 x: x2,
4035 y: y2
4036 } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
4037 }
4038 i2 = -1;
4039 }
4040 }
4041 return {
4042 x: x2,
4043 y: y2,
4044 placement: statefulPlacement,
4045 strategy,
4046 middlewareData
4047 };
4048 };
4049 var flip = function(options) {
4050 if (options === void 0) {
4051 options = {};
4052 }
4053 return {
4054 name: "flip",
4055 options,
4056 async fn(state) {
4057 var _middlewareData$arrow, _middlewareData$flip;
4058 const {
4059 placement,
4060 middlewareData,
4061 rects,
4062 initialPlacement,
4063 platform: platform3,
4064 elements
4065 } = state;
4066 const {
4067 mainAxis: checkMainAxis = true,
4068 crossAxis: checkCrossAxis = true,
4069 fallbackPlacements: specifiedFallbackPlacements,
4070 fallbackStrategy = "bestFit",
4071 fallbackAxisSideDirection = "none",
4072 flipAlignment = true,
4073 ...detectOverflowOptions
4074 } = evaluate(options, state);
4075 if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4076 return {};
4077 }
4078 const side = getSide(placement);
4079 const initialSideAxis = getSideAxis(initialPlacement);
4080 const isBasePlacement = getSide(initialPlacement) === initialPlacement;
4081 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4082 const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
4083 const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
4084 if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
4085 fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
4086 }
4087 const placements2 = [initialPlacement, ...fallbackPlacements];
4088 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4089 const overflows = [];
4090 let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
4091 if (checkMainAxis) {
4092 overflows.push(overflow[side]);
4093 }
4094 if (checkCrossAxis) {
4095 const sides2 = getAlignmentSides(placement, rects, rtl);
4096 overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
4097 }
4098 overflowsData = [...overflowsData, {
4099 placement,
4100 overflows
4101 }];
4102 if (!overflows.every((side2) => side2 <= 0)) {
4103 var _middlewareData$flip2, _overflowsData$filter;
4104 const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
4105 const nextPlacement = placements2[nextIndex];
4106 if (nextPlacement) {
4107 const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
4108 if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
4109 // overflows the main axis.
4110 overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
4111 return {
4112 data: {
4113 index: nextIndex,
4114 overflows: overflowsData
4115 },
4116 reset: {
4117 placement: nextPlacement
4118 }
4119 };
4120 }
4121 }
4122 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;
4123 if (!resetPlacement) {
4124 switch (fallbackStrategy) {
4125 case "bestFit": {
4126 var _overflowsData$filter2;
4127 const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
4128 if (hasFallbackAxisSideDirection) {
4129 const currentSideAxis = getSideAxis(d2.placement);
4130 return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
4131 // reading directions favoring greater width.
4132 currentSideAxis === "y";
4133 }
4134 return true;
4135 }).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];
4136 if (placement2) {
4137 resetPlacement = placement2;
4138 }
4139 break;
4140 }
4141 case "initialPlacement":
4142 resetPlacement = initialPlacement;
4143 break;
4144 }
4145 }
4146 if (placement !== resetPlacement) {
4147 return {
4148 reset: {
4149 placement: resetPlacement
4150 }
4151 };
4152 }
4153 }
4154 return {};
4155 }
4156 };
4157 };
4158 function getSideOffsets(overflow, rect) {
4159 return {
4160 top: overflow.top - rect.height,
4161 right: overflow.right - rect.width,
4162 bottom: overflow.bottom - rect.height,
4163 left: overflow.left - rect.width
4164 };
4165 }
4166 function isAnySideFullyClipped(overflow) {
4167 return sides.some((side) => overflow[side] >= 0);
4168 }
4169 var hide = function(options) {
4170 if (options === void 0) {
4171 options = {};
4172 }
4173 return {
4174 name: "hide",
4175 options,
4176 async fn(state) {
4177 const {
4178 rects,
4179 platform: platform3
4180 } = state;
4181 const {
4182 strategy = "referenceHidden",
4183 ...detectOverflowOptions
4184 } = evaluate(options, state);
4185 switch (strategy) {
4186 case "referenceHidden": {
4187 const overflow = await platform3.detectOverflow(state, {
4188 ...detectOverflowOptions,
4189 elementContext: "reference"
4190 });
4191 const offsets = getSideOffsets(overflow, rects.reference);
4192 return {
4193 data: {
4194 referenceHiddenOffsets: offsets,
4195 referenceHidden: isAnySideFullyClipped(offsets)
4196 }
4197 };
4198 }
4199 case "escaped": {
4200 const overflow = await platform3.detectOverflow(state, {
4201 ...detectOverflowOptions,
4202 altBoundary: true
4203 });
4204 const offsets = getSideOffsets(overflow, rects.floating);
4205 return {
4206 data: {
4207 escapedOffsets: offsets,
4208 escaped: isAnySideFullyClipped(offsets)
4209 }
4210 };
4211 }
4212 default: {
4213 return {};
4214 }
4215 }
4216 }
4217 };
4218 };
4219 var originSides = /* @__PURE__ */ new Set(["left", "top"]);
4220 async function convertValueToCoords(state, options) {
4221 const {
4222 placement,
4223 platform: platform3,
4224 elements
4225 } = state;
4226 const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
4227 const side = getSide(placement);
4228 const alignment = getAlignment(placement);
4229 const isVertical = getSideAxis(placement) === "y";
4230 const mainAxisMulti = originSides.has(side) ? -1 : 1;
4231 const crossAxisMulti = rtl && isVertical ? -1 : 1;
4232 const rawValue = evaluate(options, state);
4233 let {
4234 mainAxis,
4235 crossAxis,
4236 alignmentAxis
4237 } = typeof rawValue === "number" ? {
4238 mainAxis: rawValue,
4239 crossAxis: 0,
4240 alignmentAxis: null
4241 } : {
4242 mainAxis: rawValue.mainAxis || 0,
4243 crossAxis: rawValue.crossAxis || 0,
4244 alignmentAxis: rawValue.alignmentAxis
4245 };
4246 if (alignment && typeof alignmentAxis === "number") {
4247 crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
4248 }
4249 return isVertical ? {
4250 x: crossAxis * crossAxisMulti,
4251 y: mainAxis * mainAxisMulti
4252 } : {
4253 x: mainAxis * mainAxisMulti,
4254 y: crossAxis * crossAxisMulti
4255 };
4256 }
4257 var offset = function(options) {
4258 if (options === void 0) {
4259 options = 0;
4260 }
4261 return {
4262 name: "offset",
4263 options,
4264 async fn(state) {
4265 var _middlewareData$offse, _middlewareData$arrow;
4266 const {
4267 x: x2,
4268 y: y2,
4269 placement,
4270 middlewareData
4271 } = state;
4272 const diffCoords = await convertValueToCoords(state, options);
4273 if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
4274 return {};
4275 }
4276 return {
4277 x: x2 + diffCoords.x,
4278 y: y2 + diffCoords.y,
4279 data: {
4280 ...diffCoords,
4281 placement
4282 }
4283 };
4284 }
4285 };
4286 };
4287 var shift = function(options) {
4288 if (options === void 0) {
4289 options = {};
4290 }
4291 return {
4292 name: "shift",
4293 options,
4294 async fn(state) {
4295 const {
4296 x: x2,
4297 y: y2,
4298 placement,
4299 platform: platform3
4300 } = state;
4301 const {
4302 mainAxis: checkMainAxis = true,
4303 crossAxis: checkCrossAxis = false,
4304 limiter = {
4305 fn: (_ref) => {
4306 let {
4307 x: x3,
4308 y: y3
4309 } = _ref;
4310 return {
4311 x: x3,
4312 y: y3
4313 };
4314 }
4315 },
4316 ...detectOverflowOptions
4317 } = evaluate(options, state);
4318 const coords = {
4319 x: x2,
4320 y: y2
4321 };
4322 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4323 const crossAxis = getSideAxis(getSide(placement));
4324 const mainAxis = getOppositeAxis(crossAxis);
4325 let mainAxisCoord = coords[mainAxis];
4326 let crossAxisCoord = coords[crossAxis];
4327 if (checkMainAxis) {
4328 const minSide = mainAxis === "y" ? "top" : "left";
4329 const maxSide = mainAxis === "y" ? "bottom" : "right";
4330 const min2 = mainAxisCoord + overflow[minSide];
4331 const max2 = mainAxisCoord - overflow[maxSide];
4332 mainAxisCoord = clamp(min2, mainAxisCoord, max2);
4333 }
4334 if (checkCrossAxis) {
4335 const minSide = crossAxis === "y" ? "top" : "left";
4336 const maxSide = crossAxis === "y" ? "bottom" : "right";
4337 const min2 = crossAxisCoord + overflow[minSide];
4338 const max2 = crossAxisCoord - overflow[maxSide];
4339 crossAxisCoord = clamp(min2, crossAxisCoord, max2);
4340 }
4341 const limitedCoords = limiter.fn({
4342 ...state,
4343 [mainAxis]: mainAxisCoord,
4344 [crossAxis]: crossAxisCoord
4345 });
4346 return {
4347 ...limitedCoords,
4348 data: {
4349 x: limitedCoords.x - x2,
4350 y: limitedCoords.y - y2,
4351 enabled: {
4352 [mainAxis]: checkMainAxis,
4353 [crossAxis]: checkCrossAxis
4354 }
4355 }
4356 };
4357 }
4358 };
4359 };
4360 var limitShift = function(options) {
4361 if (options === void 0) {
4362 options = {};
4363 }
4364 return {
4365 options,
4366 fn(state) {
4367 const {
4368 x: x2,
4369 y: y2,
4370 placement,
4371 rects,
4372 middlewareData
4373 } = state;
4374 const {
4375 offset: offset4 = 0,
4376 mainAxis: checkMainAxis = true,
4377 crossAxis: checkCrossAxis = true
4378 } = evaluate(options, state);
4379 const coords = {
4380 x: x2,
4381 y: y2
4382 };
4383 const crossAxis = getSideAxis(placement);
4384 const mainAxis = getOppositeAxis(crossAxis);
4385 let mainAxisCoord = coords[mainAxis];
4386 let crossAxisCoord = coords[crossAxis];
4387 const rawOffset = evaluate(offset4, state);
4388 const computedOffset = typeof rawOffset === "number" ? {
4389 mainAxis: rawOffset,
4390 crossAxis: 0
4391 } : {
4392 mainAxis: 0,
4393 crossAxis: 0,
4394 ...rawOffset
4395 };
4396 if (checkMainAxis) {
4397 const len = mainAxis === "y" ? "height" : "width";
4398 const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
4399 const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
4400 if (mainAxisCoord < limitMin) {
4401 mainAxisCoord = limitMin;
4402 } else if (mainAxisCoord > limitMax) {
4403 mainAxisCoord = limitMax;
4404 }
4405 }
4406 if (checkCrossAxis) {
4407 var _middlewareData$offse, _middlewareData$offse2;
4408 const len = mainAxis === "y" ? "width" : "height";
4409 const isOriginSide = originSides.has(getSide(placement));
4410 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);
4411 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);
4412 if (crossAxisCoord < limitMin) {
4413 crossAxisCoord = limitMin;
4414 } else if (crossAxisCoord > limitMax) {
4415 crossAxisCoord = limitMax;
4416 }
4417 }
4418 return {
4419 [mainAxis]: mainAxisCoord,
4420 [crossAxis]: crossAxisCoord
4421 };
4422 }
4423 };
4424 };
4425 var size = function(options) {
4426 if (options === void 0) {
4427 options = {};
4428 }
4429 return {
4430 name: "size",
4431 options,
4432 async fn(state) {
4433 var _state$middlewareData, _state$middlewareData2;
4434 const {
4435 placement,
4436 rects,
4437 platform: platform3,
4438 elements
4439 } = state;
4440 const {
4441 apply = () => {
4442 },
4443 ...detectOverflowOptions
4444 } = evaluate(options, state);
4445 const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
4446 const side = getSide(placement);
4447 const alignment = getAlignment(placement);
4448 const isYAxis = getSideAxis(placement) === "y";
4449 const {
4450 width,
4451 height
4452 } = rects.floating;
4453 let heightSide;
4454 let widthSide;
4455 if (side === "top" || side === "bottom") {
4456 heightSide = side;
4457 widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
4458 } else {
4459 widthSide = side;
4460 heightSide = alignment === "end" ? "top" : "bottom";
4461 }
4462 const maximumClippingHeight = height - overflow.top - overflow.bottom;
4463 const maximumClippingWidth = width - overflow.left - overflow.right;
4464 const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
4465 const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
4466 const noShift = !state.middlewareData.shift;
4467 let availableHeight = overflowAvailableHeight;
4468 let availableWidth = overflowAvailableWidth;
4469 if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
4470 availableWidth = maximumClippingWidth;
4471 }
4472 if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
4473 availableHeight = maximumClippingHeight;
4474 }
4475 if (noShift && !alignment) {
4476 const xMin = max(overflow.left, 0);
4477 const xMax = max(overflow.right, 0);
4478 const yMin = max(overflow.top, 0);
4479 const yMax = max(overflow.bottom, 0);
4480 if (isYAxis) {
4481 availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
4482 } else {
4483 availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
4484 }
4485 }
4486 await apply({
4487 ...state,
4488 availableWidth,
4489 availableHeight
4490 });
4491 const nextDimensions = await platform3.getDimensions(elements.floating);
4492 if (width !== nextDimensions.width || height !== nextDimensions.height) {
4493 return {
4494 reset: {
4495 rects: true
4496 }
4497 };
4498 }
4499 return {};
4500 }
4501 };
4502 };
4503
4504 // node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
4505 function getCssDimensions(element) {
4506 const css = getComputedStyle2(element);
4507 let width = parseFloat(css.width) || 0;
4508 let height = parseFloat(css.height) || 0;
4509 const hasOffset = isHTMLElement(element);
4510 const offsetWidth = hasOffset ? element.offsetWidth : width;
4511 const offsetHeight = hasOffset ? element.offsetHeight : height;
4512 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
4513 if (shouldFallback) {
4514 width = offsetWidth;
4515 height = offsetHeight;
4516 }
4517 return {
4518 width,
4519 height,
4520 $: shouldFallback
4521 };
4522 }
4523 function unwrapElement(element) {
4524 return !isElement(element) ? element.contextElement : element;
4525 }
4526 function getScale(element) {
4527 const domElement = unwrapElement(element);
4528 if (!isHTMLElement(domElement)) {
4529 return createCoords(1);
4530 }
4531 const rect = domElement.getBoundingClientRect();
4532 const {
4533 width,
4534 height,
4535 $: $2
4536 } = getCssDimensions(domElement);
4537 let x2 = ($2 ? round(rect.width) : rect.width) / width;
4538 let y2 = ($2 ? round(rect.height) : rect.height) / height;
4539 if (!x2 || !Number.isFinite(x2)) {
4540 x2 = 1;
4541 }
4542 if (!y2 || !Number.isFinite(y2)) {
4543 y2 = 1;
4544 }
4545 return {
4546 x: x2,
4547 y: y2
4548 };
4549 }
4550 var noOffsets = /* @__PURE__ */ createCoords(0);
4551 function getVisualOffsets(element) {
4552 const win = getWindow(element);
4553 if (!isWebKit() || !win.visualViewport) {
4554 return noOffsets;
4555 }
4556 return {
4557 x: win.visualViewport.offsetLeft,
4558 y: win.visualViewport.offsetTop
4559 };
4560 }
4561 function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
4562 if (isFixed === void 0) {
4563 isFixed = false;
4564 }
4565 if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
4566 return false;
4567 }
4568 return isFixed;
4569 }
4570 function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
4571 if (includeScale === void 0) {
4572 includeScale = false;
4573 }
4574 if (isFixedStrategy === void 0) {
4575 isFixedStrategy = false;
4576 }
4577 const clientRect = element.getBoundingClientRect();
4578 const domElement = unwrapElement(element);
4579 let scale = createCoords(1);
4580 if (includeScale) {
4581 if (offsetParent) {
4582 if (isElement(offsetParent)) {
4583 scale = getScale(offsetParent);
4584 }
4585 } else {
4586 scale = getScale(element);
4587 }
4588 }
4589 const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
4590 let x2 = (clientRect.left + visualOffsets.x) / scale.x;
4591 let y2 = (clientRect.top + visualOffsets.y) / scale.y;
4592 let width = clientRect.width / scale.x;
4593 let height = clientRect.height / scale.y;
4594 if (domElement) {
4595 const win = getWindow(domElement);
4596 const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
4597 let currentWin = win;
4598 let currentIFrame = getFrameElement(currentWin);
4599 while (currentIFrame && offsetParent && offsetWin !== currentWin) {
4600 const iframeScale = getScale(currentIFrame);
4601 const iframeRect = currentIFrame.getBoundingClientRect();
4602 const css = getComputedStyle2(currentIFrame);
4603 const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
4604 const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
4605 x2 *= iframeScale.x;
4606 y2 *= iframeScale.y;
4607 width *= iframeScale.x;
4608 height *= iframeScale.y;
4609 x2 += left;
4610 y2 += top;
4611 currentWin = getWindow(currentIFrame);
4612 currentIFrame = getFrameElement(currentWin);
4613 }
4614 }
4615 return rectToClientRect({
4616 width,
4617 height,
4618 x: x2,
4619 y: y2
4620 });
4621 }
4622 function getWindowScrollBarX(element, rect) {
4623 const leftScroll = getNodeScroll(element).scrollLeft;
4624 if (!rect) {
4625 return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
4626 }
4627 return rect.left + leftScroll;
4628 }
4629 function getHTMLOffset(documentElement, scroll) {
4630 const htmlRect = documentElement.getBoundingClientRect();
4631 const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
4632 const y2 = htmlRect.top + scroll.scrollTop;
4633 return {
4634 x: x2,
4635 y: y2
4636 };
4637 }
4638 function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
4639 let {
4640 elements,
4641 rect,
4642 offsetParent,
4643 strategy
4644 } = _ref;
4645 const isFixed = strategy === "fixed";
4646 const documentElement = getDocumentElement(offsetParent);
4647 const topLayer = elements ? isTopLayer(elements.floating) : false;
4648 if (offsetParent === documentElement || topLayer && isFixed) {
4649 return rect;
4650 }
4651 let scroll = {
4652 scrollLeft: 0,
4653 scrollTop: 0
4654 };
4655 let scale = createCoords(1);
4656 const offsets = createCoords(0);
4657 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4658 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4659 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4660 scroll = getNodeScroll(offsetParent);
4661 }
4662 if (isOffsetParentAnElement) {
4663 const offsetRect = getBoundingClientRect(offsetParent);
4664 scale = getScale(offsetParent);
4665 offsets.x = offsetRect.x + offsetParent.clientLeft;
4666 offsets.y = offsetRect.y + offsetParent.clientTop;
4667 }
4668 }
4669 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4670 return {
4671 width: rect.width * scale.x,
4672 height: rect.height * scale.y,
4673 x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
4674 y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
4675 };
4676 }
4677 function getClientRects(element) {
4678 return Array.from(element.getClientRects());
4679 }
4680 function getDocumentRect(element) {
4681 const html = getDocumentElement(element);
4682 const scroll = getNodeScroll(element);
4683 const body = element.ownerDocument.body;
4684 const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
4685 const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
4686 let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
4687 const y2 = -scroll.scrollTop;
4688 if (getComputedStyle2(body).direction === "rtl") {
4689 x2 += max(html.clientWidth, body.clientWidth) - width;
4690 }
4691 return {
4692 width,
4693 height,
4694 x: x2,
4695 y: y2
4696 };
4697 }
4698 var SCROLLBAR_MAX = 25;
4699 function getViewportRect(element, strategy) {
4700 const win = getWindow(element);
4701 const html = getDocumentElement(element);
4702 const visualViewport = win.visualViewport;
4703 let width = html.clientWidth;
4704 let height = html.clientHeight;
4705 let x2 = 0;
4706 let y2 = 0;
4707 if (visualViewport) {
4708 width = visualViewport.width;
4709 height = visualViewport.height;
4710 const visualViewportBased = isWebKit();
4711 if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
4712 x2 = visualViewport.offsetLeft;
4713 y2 = visualViewport.offsetTop;
4714 }
4715 }
4716 const windowScrollbarX = getWindowScrollBarX(html);
4717 if (windowScrollbarX <= 0) {
4718 const doc = html.ownerDocument;
4719 const body = doc.body;
4720 const bodyStyles = getComputedStyle(body);
4721 const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
4722 const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
4723 if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
4724 width -= clippingStableScrollbarWidth;
4725 }
4726 } else if (windowScrollbarX <= SCROLLBAR_MAX) {
4727 width += windowScrollbarX;
4728 }
4729 return {
4730 width,
4731 height,
4732 x: x2,
4733 y: y2
4734 };
4735 }
4736 function getInnerBoundingClientRect(element, strategy) {
4737 const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
4738 const top = clientRect.top + element.clientTop;
4739 const left = clientRect.left + element.clientLeft;
4740 const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
4741 const width = element.clientWidth * scale.x;
4742 const height = element.clientHeight * scale.y;
4743 const x2 = left * scale.x;
4744 const y2 = top * scale.y;
4745 return {
4746 width,
4747 height,
4748 x: x2,
4749 y: y2
4750 };
4751 }
4752 function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
4753 let rect;
4754 if (clippingAncestor === "viewport") {
4755 rect = getViewportRect(element, strategy);
4756 } else if (clippingAncestor === "document") {
4757 rect = getDocumentRect(getDocumentElement(element));
4758 } else if (isElement(clippingAncestor)) {
4759 rect = getInnerBoundingClientRect(clippingAncestor, strategy);
4760 } else {
4761 const visualOffsets = getVisualOffsets(element);
4762 rect = {
4763 x: clippingAncestor.x - visualOffsets.x,
4764 y: clippingAncestor.y - visualOffsets.y,
4765 width: clippingAncestor.width,
4766 height: clippingAncestor.height
4767 };
4768 }
4769 return rectToClientRect(rect);
4770 }
4771 function hasFixedPositionAncestor(element, stopNode) {
4772 const parentNode = getParentNode(element);
4773 if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
4774 return false;
4775 }
4776 return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
4777 }
4778 function getClippingElementAncestors(element, cache) {
4779 const cachedResult = cache.get(element);
4780 if (cachedResult) {
4781 return cachedResult;
4782 }
4783 let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
4784 let currentContainingBlockComputedStyle = null;
4785 const elementIsFixed = getComputedStyle2(element).position === "fixed";
4786 let currentNode = elementIsFixed ? getParentNode(element) : element;
4787 while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
4788 const computedStyle = getComputedStyle2(currentNode);
4789 const currentNodeIsContaining = isContainingBlock(currentNode);
4790 if (!currentNodeIsContaining && computedStyle.position === "fixed") {
4791 currentContainingBlockComputedStyle = null;
4792 }
4793 const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
4794 if (shouldDropCurrentNode) {
4795 result = result.filter((ancestor) => ancestor !== currentNode);
4796 } else {
4797 currentContainingBlockComputedStyle = computedStyle;
4798 }
4799 currentNode = getParentNode(currentNode);
4800 }
4801 cache.set(element, result);
4802 return result;
4803 }
4804 function getClippingRect(_ref) {
4805 let {
4806 element,
4807 boundary,
4808 rootBoundary,
4809 strategy
4810 } = _ref;
4811 const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
4812 const clippingAncestors = [...elementClippingAncestors, rootBoundary];
4813 const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
4814 let top = firstRect.top;
4815 let right = firstRect.right;
4816 let bottom = firstRect.bottom;
4817 let left = firstRect.left;
4818 for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
4819 const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
4820 top = max(rect.top, top);
4821 right = min(rect.right, right);
4822 bottom = min(rect.bottom, bottom);
4823 left = max(rect.left, left);
4824 }
4825 return {
4826 width: right - left,
4827 height: bottom - top,
4828 x: left,
4829 y: top
4830 };
4831 }
4832 function getDimensions(element) {
4833 const {
4834 width,
4835 height
4836 } = getCssDimensions(element);
4837 return {
4838 width,
4839 height
4840 };
4841 }
4842 function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
4843 const isOffsetParentAnElement = isHTMLElement(offsetParent);
4844 const documentElement = getDocumentElement(offsetParent);
4845 const isFixed = strategy === "fixed";
4846 const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
4847 let scroll = {
4848 scrollLeft: 0,
4849 scrollTop: 0
4850 };
4851 const offsets = createCoords(0);
4852 function setLeftRTLScrollbarOffset() {
4853 offsets.x = getWindowScrollBarX(documentElement);
4854 }
4855 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
4856 if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
4857 scroll = getNodeScroll(offsetParent);
4858 }
4859 if (isOffsetParentAnElement) {
4860 const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
4861 offsets.x = offsetRect.x + offsetParent.clientLeft;
4862 offsets.y = offsetRect.y + offsetParent.clientTop;
4863 } else if (documentElement) {
4864 setLeftRTLScrollbarOffset();
4865 }
4866 }
4867 if (isFixed && !isOffsetParentAnElement && documentElement) {
4868 setLeftRTLScrollbarOffset();
4869 }
4870 const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
4871 const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
4872 const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
4873 return {
4874 x: x2,
4875 y: y2,
4876 width: rect.width,
4877 height: rect.height
4878 };
4879 }
4880 function isStaticPositioned(element) {
4881 return getComputedStyle2(element).position === "static";
4882 }
4883 function getTrueOffsetParent(element, polyfill) {
4884 if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
4885 return null;
4886 }
4887 if (polyfill) {
4888 return polyfill(element);
4889 }
4890 let rawOffsetParent = element.offsetParent;
4891 if (getDocumentElement(element) === rawOffsetParent) {
4892 rawOffsetParent = rawOffsetParent.ownerDocument.body;
4893 }
4894 return rawOffsetParent;
4895 }
4896 function getOffsetParent(element, polyfill) {
4897 const win = getWindow(element);
4898 if (isTopLayer(element)) {
4899 return win;
4900 }
4901 if (!isHTMLElement(element)) {
4902 let svgOffsetParent = getParentNode(element);
4903 while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
4904 if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
4905 return svgOffsetParent;
4906 }
4907 svgOffsetParent = getParentNode(svgOffsetParent);
4908 }
4909 return win;
4910 }
4911 let offsetParent = getTrueOffsetParent(element, polyfill);
4912 while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
4913 offsetParent = getTrueOffsetParent(offsetParent, polyfill);
4914 }
4915 if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
4916 return win;
4917 }
4918 return offsetParent || getContainingBlock(element) || win;
4919 }
4920 var getElementRects = async function(data) {
4921 const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
4922 const getDimensionsFn = this.getDimensions;
4923 const floatingDimensions = await getDimensionsFn(data.floating);
4924 return {
4925 reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
4926 floating: {
4927 x: 0,
4928 y: 0,
4929 width: floatingDimensions.width,
4930 height: floatingDimensions.height
4931 }
4932 };
4933 };
4934 function isRTL(element) {
4935 return getComputedStyle2(element).direction === "rtl";
4936 }
4937 var platform2 = {
4938 convertOffsetParentRelativeRectToViewportRelativeRect,
4939 getDocumentElement,
4940 getClippingRect,
4941 getOffsetParent,
4942 getElementRects,
4943 getClientRects,
4944 getDimensions,
4945 getScale,
4946 isElement,
4947 isRTL
4948 };
4949 function rectsAreEqual(a2, b2) {
4950 return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
4951 }
4952 function observeMove(element, onMove) {
4953 let io = null;
4954 let timeoutId;
4955 const root = getDocumentElement(element);
4956 function cleanup() {
4957 var _io;
4958 clearTimeout(timeoutId);
4959 (_io = io) == null || _io.disconnect();
4960 io = null;
4961 }
4962 function refresh(skip, threshold) {
4963 if (skip === void 0) {
4964 skip = false;
4965 }
4966 if (threshold === void 0) {
4967 threshold = 1;
4968 }
4969 cleanup();
4970 const elementRectForRootMargin = element.getBoundingClientRect();
4971 const {
4972 left,
4973 top,
4974 width,
4975 height
4976 } = elementRectForRootMargin;
4977 if (!skip) {
4978 onMove();
4979 }
4980 if (!width || !height) {
4981 return;
4982 }
4983 const insetTop = floor(top);
4984 const insetRight = floor(root.clientWidth - (left + width));
4985 const insetBottom = floor(root.clientHeight - (top + height));
4986 const insetLeft = floor(left);
4987 const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
4988 const options = {
4989 rootMargin,
4990 threshold: max(0, min(1, threshold)) || 1
4991 };
4992 let isFirstUpdate = true;
4993 function handleObserve(entries) {
4994 const ratio = entries[0].intersectionRatio;
4995 if (ratio !== threshold) {
4996 if (!isFirstUpdate) {
4997 return refresh();
4998 }
4999 if (!ratio) {
5000 timeoutId = setTimeout(() => {
5001 refresh(false, 1e-7);
5002 }, 1e3);
5003 } else {
5004 refresh(false, ratio);
5005 }
5006 }
5007 if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
5008 refresh();
5009 }
5010 isFirstUpdate = false;
5011 }
5012 try {
5013 io = new IntersectionObserver(handleObserve, {
5014 ...options,
5015 // Handle <iframe>s
5016 root: root.ownerDocument
5017 });
5018 } catch (_e) {
5019 io = new IntersectionObserver(handleObserve, options);
5020 }
5021 io.observe(element);
5022 }
5023 refresh(true);
5024 return cleanup;
5025 }
5026 function autoUpdate(reference, floating, update2, options) {
5027 if (options === void 0) {
5028 options = {};
5029 }
5030 const {
5031 ancestorScroll = true,
5032 ancestorResize = true,
5033 elementResize = typeof ResizeObserver === "function",
5034 layoutShift = typeof IntersectionObserver === "function",
5035 animationFrame = false
5036 } = options;
5037 const referenceEl = unwrapElement(reference);
5038 const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
5039 ancestors.forEach((ancestor) => {
5040 ancestorScroll && ancestor.addEventListener("scroll", update2, {
5041 passive: true
5042 });
5043 ancestorResize && ancestor.addEventListener("resize", update2);
5044 });
5045 const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
5046 let reobserveFrame = -1;
5047 let resizeObserver = null;
5048 if (elementResize) {
5049 resizeObserver = new ResizeObserver((_ref) => {
5050 let [firstEntry] = _ref;
5051 if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
5052 resizeObserver.unobserve(floating);
5053 cancelAnimationFrame(reobserveFrame);
5054 reobserveFrame = requestAnimationFrame(() => {
5055 var _resizeObserver;
5056 (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
5057 });
5058 }
5059 update2();
5060 });
5061 if (referenceEl && !animationFrame) {
5062 resizeObserver.observe(referenceEl);
5063 }
5064 if (floating) {
5065 resizeObserver.observe(floating);
5066 }
5067 }
5068 let frameId;
5069 let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
5070 if (animationFrame) {
5071 frameLoop();
5072 }
5073 function frameLoop() {
5074 const nextRefRect = getBoundingClientRect(reference);
5075 if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
5076 update2();
5077 }
5078 prevRefRect = nextRefRect;
5079 frameId = requestAnimationFrame(frameLoop);
5080 }
5081 update2();
5082 return () => {
5083 var _resizeObserver2;
5084 ancestors.forEach((ancestor) => {
5085 ancestorScroll && ancestor.removeEventListener("scroll", update2);
5086 ancestorResize && ancestor.removeEventListener("resize", update2);
5087 });
5088 cleanupIo == null || cleanupIo();
5089 (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
5090 resizeObserver = null;
5091 if (animationFrame) {
5092 cancelAnimationFrame(frameId);
5093 }
5094 };
5095 }
5096 var offset2 = offset;
5097 var shift2 = shift;
5098 var flip2 = flip;
5099 var size2 = size;
5100 var hide2 = hide;
5101 var limitShift2 = limitShift;
5102 var computePosition2 = (reference, floating, options) => {
5103 const cache = /* @__PURE__ */ new Map();
5104 const mergedOptions = {
5105 platform: platform2,
5106 ...options
5107 };
5108 const platformWithCache = {
5109 ...mergedOptions.platform,
5110 _c: cache
5111 };
5112 return computePosition(reference, floating, {
5113 ...mergedOptions,
5114 platform: platformWithCache
5115 });
5116 };
5117
5118 // node_modules/@base-ui/react/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
5119 var React21 = __toESM(require_react(), 1);
5120 var import_react2 = __toESM(require_react(), 1);
5121 var ReactDOM3 = __toESM(require_react_dom(), 1);
5122 var isClient = typeof document !== "undefined";
5123 var noop2 = function noop3() {
5124 };
5125 var index = isClient ? import_react2.useLayoutEffect : noop2;
5126 function deepEqual(a2, b2) {
5127 if (a2 === b2) {
5128 return true;
5129 }
5130 if (typeof a2 !== typeof b2) {
5131 return false;
5132 }
5133 if (typeof a2 === "function" && a2.toString() === b2.toString()) {
5134 return true;
5135 }
5136 let length;
5137 let i2;
5138 let keys;
5139 if (a2 && b2 && typeof a2 === "object") {
5140 if (Array.isArray(a2)) {
5141 length = a2.length;
5142 if (length !== b2.length) return false;
5143 for (i2 = length; i2-- !== 0; ) {
5144 if (!deepEqual(a2[i2], b2[i2])) {
5145 return false;
5146 }
5147 }
5148 return true;
5149 }
5150 keys = Object.keys(a2);
5151 length = keys.length;
5152 if (length !== Object.keys(b2).length) {
5153 return false;
5154 }
5155 for (i2 = length; i2-- !== 0; ) {
5156 if (!{}.hasOwnProperty.call(b2, keys[i2])) {
5157 return false;
5158 }
5159 }
5160 for (i2 = length; i2-- !== 0; ) {
5161 const key = keys[i2];
5162 if (key === "_owner" && a2.$$typeof) {
5163 continue;
5164 }
5165 if (!deepEqual(a2[key], b2[key])) {
5166 return false;
5167 }
5168 }
5169 return true;
5170 }
5171 return a2 !== a2 && b2 !== b2;
5172 }
5173 function getDPR(element) {
5174 if (typeof window === "undefined") {
5175 return 1;
5176 }
5177 const win = element.ownerDocument.defaultView || window;
5178 return win.devicePixelRatio || 1;
5179 }
5180 function roundByDPR(element, value) {
5181 const dpr = getDPR(element);
5182 return Math.round(value * dpr) / dpr;
5183 }
5184 function useLatestRef(value) {
5185 const ref = React21.useRef(value);
5186 index(() => {
5187 ref.current = value;
5188 });
5189 return ref;
5190 }
5191 function useFloating(options) {
5192 if (options === void 0) {
5193 options = {};
5194 }
5195 const {
5196 placement = "bottom",
5197 strategy = "absolute",
5198 middleware = [],
5199 platform: platform3,
5200 elements: {
5201 reference: externalReference,
5202 floating: externalFloating
5203 } = {},
5204 transform = true,
5205 whileElementsMounted,
5206 open
5207 } = options;
5208 const [data, setData] = React21.useState({
5209 x: 0,
5210 y: 0,
5211 strategy,
5212 placement,
5213 middlewareData: {},
5214 isPositioned: false
5215 });
5216 const [latestMiddleware, setLatestMiddleware] = React21.useState(middleware);
5217 if (!deepEqual(latestMiddleware, middleware)) {
5218 setLatestMiddleware(middleware);
5219 }
5220 const [_reference, _setReference] = React21.useState(null);
5221 const [_floating, _setFloating] = React21.useState(null);
5222 const setReference = React21.useCallback((node) => {
5223 if (node !== referenceRef.current) {
5224 referenceRef.current = node;
5225 _setReference(node);
5226 }
5227 }, []);
5228 const setFloating = React21.useCallback((node) => {
5229 if (node !== floatingRef.current) {
5230 floatingRef.current = node;
5231 _setFloating(node);
5232 }
5233 }, []);
5234 const referenceEl = externalReference || _reference;
5235 const floatingEl = externalFloating || _floating;
5236 const referenceRef = React21.useRef(null);
5237 const floatingRef = React21.useRef(null);
5238 const dataRef = React21.useRef(data);
5239 const hasWhileElementsMounted = whileElementsMounted != null;
5240 const whileElementsMountedRef = useLatestRef(whileElementsMounted);
5241 const platformRef = useLatestRef(platform3);
5242 const openRef = useLatestRef(open);
5243 const update2 = React21.useCallback(() => {
5244 if (!referenceRef.current || !floatingRef.current) {
5245 return;
5246 }
5247 const config = {
5248 placement,
5249 strategy,
5250 middleware: latestMiddleware
5251 };
5252 if (platformRef.current) {
5253 config.platform = platformRef.current;
5254 }
5255 computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
5256 const fullData = {
5257 ...data2,
5258 // The floating element's position may be recomputed while it's closed
5259 // but still mounted (such as when transitioning out). To ensure
5260 // `isPositioned` will be `false` initially on the next open, avoid
5261 // setting it to `true` when `open === false` (must be specified).
5262 isPositioned: openRef.current !== false
5263 };
5264 if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
5265 dataRef.current = fullData;
5266 ReactDOM3.flushSync(() => {
5267 setData(fullData);
5268 });
5269 }
5270 });
5271 }, [latestMiddleware, placement, strategy, platformRef, openRef]);
5272 index(() => {
5273 if (open === false && dataRef.current.isPositioned) {
5274 dataRef.current.isPositioned = false;
5275 setData((data2) => ({
5276 ...data2,
5277 isPositioned: false
5278 }));
5279 }
5280 }, [open]);
5281 const isMountedRef = React21.useRef(false);
5282 index(() => {
5283 isMountedRef.current = true;
5284 return () => {
5285 isMountedRef.current = false;
5286 };
5287 }, []);
5288 index(() => {
5289 if (referenceEl) referenceRef.current = referenceEl;
5290 if (floatingEl) floatingRef.current = floatingEl;
5291 if (referenceEl && floatingEl) {
5292 if (whileElementsMountedRef.current) {
5293 return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
5294 }
5295 update2();
5296 }
5297 }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
5298 const refs = React21.useMemo(() => ({
5299 reference: referenceRef,
5300 floating: floatingRef,
5301 setReference,
5302 setFloating
5303 }), [setReference, setFloating]);
5304 const elements = React21.useMemo(() => ({
5305 reference: referenceEl,
5306 floating: floatingEl
5307 }), [referenceEl, floatingEl]);
5308 const floatingStyles = React21.useMemo(() => {
5309 const initialStyles = {
5310 position: strategy,
5311 left: 0,
5312 top: 0
5313 };
5314 if (!elements.floating) {
5315 return initialStyles;
5316 }
5317 const x2 = roundByDPR(elements.floating, data.x);
5318 const y2 = roundByDPR(elements.floating, data.y);
5319 if (transform) {
5320 return {
5321 ...initialStyles,
5322 transform: "translate(" + x2 + "px, " + y2 + "px)",
5323 ...getDPR(elements.floating) >= 1.5 && {
5324 willChange: "transform"
5325 }
5326 };
5327 }
5328 return {
5329 position: strategy,
5330 left: x2,
5331 top: y2
5332 };
5333 }, [strategy, transform, elements.floating, data.x, data.y]);
5334 return React21.useMemo(() => ({
5335 ...data,
5336 update: update2,
5337 refs,
5338 elements,
5339 floatingStyles
5340 }), [data, update2, refs, elements, floatingStyles]);
5341 }
5342 var offset3 = (options, deps) => {
5343 const result = offset2(options);
5344 return {
5345 name: result.name,
5346 fn: result.fn,
5347 options: [options, deps]
5348 };
5349 };
5350 var shift3 = (options, deps) => {
5351 const result = shift2(options);
5352 return {
5353 name: result.name,
5354 fn: result.fn,
5355 options: [options, deps]
5356 };
5357 };
5358 var limitShift3 = (options, deps) => {
5359 const result = limitShift2(options);
5360 return {
5361 fn: result.fn,
5362 options: [options, deps]
5363 };
5364 };
5365 var flip3 = (options, deps) => {
5366 const result = flip2(options);
5367 return {
5368 name: result.name,
5369 fn: result.fn,
5370 options: [options, deps]
5371 };
5372 };
5373 var size3 = (options, deps) => {
5374 const result = size2(options);
5375 return {
5376 name: result.name,
5377 fn: result.fn,
5378 options: [options, deps]
5379 };
5380 };
5381 var hide3 = (options, deps) => {
5382 const result = hide2(options);
5383 return {
5384 name: result.name,
5385 fn: result.fn,
5386 options: [options, deps]
5387 };
5388 };
5389
5390 // node_modules/@base-ui/utils/esm/store/createSelector.js
5391 var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
5392 if (other.length > 0) {
5393 throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
5394 }
5395 let selector2;
5396 if (a2 && b2 && c2 && d2 && e2 && f2) {
5397 selector2 = (state, a1, a22, a3) => {
5398 const va = a2(state, a1, a22, a3);
5399 const vb = b2(state, a1, a22, a3);
5400 const vc = c2(state, a1, a22, a3);
5401 const vd = d2(state, a1, a22, a3);
5402 const ve = e2(state, a1, a22, a3);
5403 return f2(va, vb, vc, vd, ve, a1, a22, a3);
5404 };
5405 } else if (a2 && b2 && c2 && d2 && e2) {
5406 selector2 = (state, a1, a22, a3) => {
5407 const va = a2(state, a1, a22, a3);
5408 const vb = b2(state, a1, a22, a3);
5409 const vc = c2(state, a1, a22, a3);
5410 const vd = d2(state, a1, a22, a3);
5411 return e2(va, vb, vc, vd, a1, a22, a3);
5412 };
5413 } else if (a2 && b2 && c2 && d2) {
5414 selector2 = (state, a1, a22, a3) => {
5415 const va = a2(state, a1, a22, a3);
5416 const vb = b2(state, a1, a22, a3);
5417 const vc = c2(state, a1, a22, a3);
5418 return d2(va, vb, vc, a1, a22, a3);
5419 };
5420 } else if (a2 && b2 && c2) {
5421 selector2 = (state, a1, a22, a3) => {
5422 const va = a2(state, a1, a22, a3);
5423 const vb = b2(state, a1, a22, a3);
5424 return c2(va, vb, a1, a22, a3);
5425 };
5426 } else if (a2 && b2) {
5427 selector2 = (state, a1, a22, a3) => {
5428 const va = a2(state, a1, a22, a3);
5429 return b2(va, a1, a22, a3);
5430 };
5431 } else if (a2) {
5432 selector2 = a2;
5433 } else {
5434 throw (
5435 /* minify-error-disabled */
5436 new Error("Missing arguments")
5437 );
5438 }
5439 return selector2;
5440 };
5441
5442 // node_modules/@base-ui/utils/esm/store/useStore.js
5443 var React23 = __toESM(require_react(), 1);
5444 var import_shim = __toESM(require_shim(), 1);
5445 var import_with_selector = __toESM(require_with_selector(), 1);
5446
5447 // node_modules/@base-ui/utils/esm/fastHooks.js
5448 var React22 = __toESM(require_react(), 1);
5449 var hooks = [];
5450 var currentInstance = void 0;
5451 function getInstance() {
5452 return currentInstance;
5453 }
5454 function register(hook) {
5455 hooks.push(hook);
5456 }
5457 function fastComponent(fn) {
5458 const FastComponent = (props, forwardedRef) => {
5459 const instance = useRefWithInit(createInstance).current;
5460 let result;
5461 try {
5462 currentInstance = instance;
5463 for (const hook of hooks) {
5464 hook.before(instance);
5465 }
5466 result = fn(props, forwardedRef);
5467 for (const hook of hooks) {
5468 hook.after(instance);
5469 }
5470 instance.didInitialize = true;
5471 } finally {
5472 currentInstance = void 0;
5473 }
5474 return result;
5475 };
5476 FastComponent.displayName = fn.displayName || fn.name;
5477 return FastComponent;
5478 }
5479 function fastComponentRef(fn) {
5480 return /* @__PURE__ */ React22.forwardRef(fastComponent(fn));
5481 }
5482 function createInstance() {
5483 return {
5484 didInitialize: false
5485 };
5486 }
5487
5488 // node_modules/@base-ui/utils/esm/store/useStore.js
5489 var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
5490 var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
5491 function useStore(store, selector2, a1, a2, a3) {
5492 return useStoreImplementation(store, selector2, a1, a2, a3);
5493 }
5494 function useStoreR19(store, selector2, a1, a2, a3) {
5495 const getSelection = React23.useCallback(() => selector2(store.getSnapshot(), a1, a2, a3), [store, selector2, a1, a2, a3]);
5496 return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
5497 }
5498 register({
5499 before(instance) {
5500 instance.syncIndex = 0;
5501 if (!instance.didInitialize) {
5502 instance.syncTick = 1;
5503 instance.syncHooks = [];
5504 instance.didChangeStore = true;
5505 instance.getSnapshot = () => {
5506 let didChange2 = false;
5507 for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
5508 const hook = instance.syncHooks[i2];
5509 const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
5510 if (hook.didChange || !Object.is(hook.value, value)) {
5511 didChange2 = true;
5512 hook.value = value;
5513 hook.didChange = false;
5514 }
5515 }
5516 if (didChange2) {
5517 instance.syncTick += 1;
5518 }
5519 return instance.syncTick;
5520 };
5521 }
5522 },
5523 after(instance) {
5524 if (instance.syncHooks.length > 0) {
5525 if (instance.didChangeStore) {
5526 instance.didChangeStore = false;
5527 instance.subscribe = (onStoreChange) => {
5528 const stores = /* @__PURE__ */ new Set();
5529 for (const hook of instance.syncHooks) {
5530 stores.add(hook.store);
5531 }
5532 const unsubscribes = [];
5533 for (const store of stores) {
5534 unsubscribes.push(store.subscribe(onStoreChange));
5535 }
5536 return () => {
5537 for (const unsubscribe of unsubscribes) {
5538 unsubscribe();
5539 }
5540 };
5541 };
5542 }
5543 (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
5544 }
5545 }
5546 });
5547 function useStoreFast(store, selector2, a1, a2, a3) {
5548 const instance = getInstance();
5549 if (!instance) {
5550 return useStoreR19(store, selector2, a1, a2, a3);
5551 }
5552 const index2 = instance.syncIndex;
5553 instance.syncIndex += 1;
5554 let hook;
5555 if (!instance.didInitialize) {
5556 hook = {
5557 store,
5558 selector: selector2,
5559 a1,
5560 a2,
5561 a3,
5562 value: selector2(store.getSnapshot(), a1, a2, a3),
5563 didChange: false
5564 };
5565 instance.syncHooks.push(hook);
5566 } else {
5567 hook = instance.syncHooks[index2];
5568 if (hook.store !== store || hook.selector !== selector2 || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
5569 if (hook.store !== store) {
5570 instance.didChangeStore = true;
5571 }
5572 hook.store = store;
5573 hook.selector = selector2;
5574 hook.a1 = a1;
5575 hook.a2 = a2;
5576 hook.a3 = a3;
5577 hook.didChange = true;
5578 }
5579 }
5580 return hook.value;
5581 }
5582 function useStoreLegacy(store, selector2, a1, a2, a3) {
5583 return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector2(state, a1, a2, a3));
5584 }
5585
5586 // node_modules/@base-ui/utils/esm/store/Store.js
5587 var Store = class {
5588 /**
5589 * The current state of the store.
5590 * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
5591 * 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).
5592 * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
5593 *
5594 * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
5595 */
5596 // Internal state to handle recursive `setState()` calls
5597 constructor(state) {
5598 this.state = state;
5599 this.listeners = /* @__PURE__ */ new Set();
5600 this.updateTick = 0;
5601 }
5602 /**
5603 * Registers a listener that will be called whenever the store's state changes.
5604 *
5605 * @param fn The listener function to be called on state changes.
5606 * @returns A function to unsubscribe the listener.
5607 */
5608 subscribe = (fn) => {
5609 this.listeners.add(fn);
5610 return () => {
5611 this.listeners.delete(fn);
5612 };
5613 };
5614 /**
5615 * Returns the current state of the store.
5616 */
5617 getSnapshot = () => {
5618 return this.state;
5619 };
5620 /**
5621 * Updates the entire store's state and notifies all registered listeners.
5622 *
5623 * @param newState The new state to set for the store.
5624 */
5625 setState(newState) {
5626 if (this.state === newState) {
5627 return;
5628 }
5629 this.state = newState;
5630 this.updateTick += 1;
5631 const currentTick = this.updateTick;
5632 for (const listener of this.listeners) {
5633 if (currentTick !== this.updateTick) {
5634 return;
5635 }
5636 listener(newState);
5637 }
5638 }
5639 /**
5640 * Merges the provided changes into the current state and notifies listeners if there are changes.
5641 *
5642 * @param changes An object containing the changes to apply to the current state.
5643 */
5644 update(changes) {
5645 for (const key in changes) {
5646 if (!Object.is(this.state[key], changes[key])) {
5647 this.setState({
5648 ...this.state,
5649 ...changes
5650 });
5651 return;
5652 }
5653 }
5654 }
5655 /**
5656 * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
5657 *
5658 * @param key The key in the store's state to update.
5659 * @param value The new value to set for the specified key.
5660 */
5661 set(key, value) {
5662 if (!Object.is(this.state[key], value)) {
5663 this.setState({
5664 ...this.state,
5665 [key]: value
5666 });
5667 }
5668 }
5669 /**
5670 * Gives the state a new reference and updates all registered listeners.
5671 */
5672 notifyAll() {
5673 const newState = {
5674 ...this.state
5675 };
5676 this.setState(newState);
5677 }
5678 use(selector2, a1, a2, a3) {
5679 return useStore(this, selector2, a1, a2, a3);
5680 }
5681 };
5682
5683 // node_modules/@base-ui/utils/esm/store/ReactStore.js
5684 var React24 = __toESM(require_react(), 1);
5685 var ReactStore = class extends Store {
5686 /**
5687 * Creates a new ReactStore instance.
5688 *
5689 * @param state Initial state of the store.
5690 * @param context Non-reactive context values.
5691 * @param selectors Optional selectors for use with `useState`.
5692 */
5693 constructor(state, context = {}, selectors3) {
5694 super(state);
5695 this.context = context;
5696 this.selectors = selectors3;
5697 }
5698 /**
5699 * Non-reactive values such as refs, callbacks, etc.
5700 */
5701 /**
5702 * Synchronizes a single external value into the store.
5703 *
5704 * Note that the while the value in `state` is updated immediately, the value returned
5705 * by `useState` is updated before the next render (similarly to React's `useState`).
5706 */
5707 useSyncedValue(key, value) {
5708 React24.useDebugValue(key);
5709 useIsoLayoutEffect(() => {
5710 if (this.state[key] !== value) {
5711 this.set(key, value);
5712 }
5713 }, [key, value]);
5714 }
5715 /**
5716 * Synchronizes a single external value into the store and
5717 * cleans it up (sets to `undefined`) on unmount.
5718 *
5719 * Note that the while the value in `state` is updated immediately, the value returned
5720 * by `useState` is updated before the next render (similarly to React's `useState`).
5721 */
5722 useSyncedValueWithCleanup(key, value) {
5723 const store = this;
5724 useIsoLayoutEffect(() => {
5725 if (store.state[key] !== value) {
5726 store.set(key, value);
5727 }
5728 return () => {
5729 store.set(key, void 0);
5730 };
5731 }, [store, key, value]);
5732 }
5733 /**
5734 * Synchronizes multiple external values into the store.
5735 *
5736 * Note that the while the values in `state` are updated immediately, the values returned
5737 * by `useState` are updated before the next render (similarly to React's `useState`).
5738 */
5739 useSyncedValues(statePart) {
5740 const store = this;
5741 if (true) {
5742 React24.useDebugValue(statePart, (p2) => Object.keys(p2));
5743 const keys = React24.useRef(Object.keys(statePart)).current;
5744 const nextKeys = Object.keys(statePart);
5745 if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
5746 console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
5747 }
5748 }
5749 const dependencies = Object.values(statePart);
5750 useIsoLayoutEffect(() => {
5751 store.update(statePart);
5752 }, [store, ...dependencies]);
5753 }
5754 /**
5755 * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
5756 * is non-undefined, the store's state at `key` is updated to match `controlled`.
5757 */
5758 useControlledProp(key, controlled) {
5759 React24.useDebugValue(key);
5760 const isControlled = controlled !== void 0;
5761 useIsoLayoutEffect(() => {
5762 if (isControlled && !Object.is(this.state[key], controlled)) {
5763 super.setState({
5764 ...this.state,
5765 [key]: controlled
5766 });
5767 }
5768 }, [key, controlled, isControlled]);
5769 if (true) {
5770 const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
5771 if (!cache.has(key)) {
5772 cache.set(key, isControlled);
5773 }
5774 const previouslyControlled = cache.get(key);
5775 if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
5776 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).`);
5777 }
5778 }
5779 }
5780 /** Gets the current value from the store using a selector with the provided key.
5781 *
5782 * @param key Key of the selector to use.
5783 */
5784 select(key, a1, a2, a3) {
5785 const selector2 = this.selectors[key];
5786 return selector2(this.state, a1, a2, a3);
5787 }
5788 /**
5789 * Returns a value from the store's state using a selector function.
5790 * Used to subscribe to specific parts of the state.
5791 * This methods causes a rerender whenever the selected state changes.
5792 *
5793 * @param key Key of the selector to use.
5794 */
5795 useState(key, a1, a2, a3) {
5796 React24.useDebugValue(key);
5797 return useStore(this, this.selectors[key], a1, a2, a3);
5798 }
5799 /**
5800 * Wraps a function with `useStableCallback` to ensure it has a stable reference
5801 * and assigns it to the context.
5802 *
5803 * @param key Key of the event callback. Must be a function in the context.
5804 * @param fn Function to assign.
5805 */
5806 useContextCallback(key, fn) {
5807 React24.useDebugValue(key);
5808 const stableFunction = useStableCallback(fn ?? NOOP);
5809 this.context[key] = stableFunction;
5810 }
5811 /**
5812 * Returns a stable setter function for a specific key in the store's state.
5813 * It's commonly used to pass as a ref callback to React elements.
5814 *
5815 * @param key Key of the state to set.
5816 */
5817 useStateSetter(key) {
5818 const ref = React24.useRef(void 0);
5819 if (ref.current === void 0) {
5820 ref.current = (value) => {
5821 this.set(key, value);
5822 };
5823 }
5824 return ref.current;
5825 }
5826 /**
5827 * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
5828 *
5829 * @param key Key of the selector to observe.
5830 * @param listener Listener function called when the selector result changes.
5831 */
5832 observe(selector2, listener) {
5833 let selectFn;
5834 if (typeof selector2 === "function") {
5835 selectFn = selector2;
5836 } else {
5837 selectFn = this.selectors[selector2];
5838 }
5839 let prevValue = selectFn(this.state);
5840 listener(prevValue, prevValue, this);
5841 return this.subscribe((nextState) => {
5842 const nextValue = selectFn(nextState);
5843 if (!Object.is(prevValue, nextValue)) {
5844 const oldValue = prevValue;
5845 prevValue = nextValue;
5846 listener(nextValue, oldValue, this);
5847 }
5848 });
5849 }
5850 };
5851
5852 // node_modules/@base-ui/react/esm/floating-ui-react/components/FloatingRootStore.js
5853 var selectors = {
5854 open: createSelector((state) => state.open),
5855 transitionStatus: createSelector((state) => state.transitionStatus),
5856 domReferenceElement: createSelector((state) => state.domReferenceElement),
5857 referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
5858 floatingElement: createSelector((state) => state.floatingElement),
5859 floatingId: createSelector((state) => state.floatingId)
5860 };
5861 var FloatingRootStore = class extends ReactStore {
5862 constructor(options) {
5863 const {
5864 syncOnly,
5865 nested,
5866 onOpenChange,
5867 triggerElements,
5868 ...initialState
5869 } = options;
5870 super({
5871 ...initialState,
5872 positionReference: initialState.referenceElement,
5873 domReferenceElement: initialState.referenceElement
5874 }, {
5875 onOpenChange,
5876 dataRef: {
5877 current: {}
5878 },
5879 events: createEventEmitter(),
5880 nested,
5881 triggerElements
5882 }, selectors);
5883 this.syncOnly = syncOnly;
5884 }
5885 /**
5886 * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
5887 */
5888 syncOpenEvent = (newOpen, event) => {
5889 if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
5890 // click events to upgrade a hover-open.
5891 event != null && isClickLikeEvent(event)) {
5892 this.context.dataRef.current.openEvent = newOpen ? event : void 0;
5893 }
5894 };
5895 /**
5896 * Runs the root-owned side effects for an open state change.
5897 */
5898 dispatchOpenChange = (newOpen, eventDetails) => {
5899 this.syncOpenEvent(newOpen, eventDetails.event);
5900 const details = {
5901 open: newOpen,
5902 reason: eventDetails.reason,
5903 nativeEvent: eventDetails.event,
5904 nested: this.context.nested,
5905 triggerElement: eventDetails.trigger
5906 };
5907 this.context.events.emit("openchange", details);
5908 };
5909 /**
5910 * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
5911 *
5912 * @param newOpen The new open state.
5913 * @param eventDetails Details about the event that triggered the open state change.
5914 */
5915 setOpen = (newOpen, eventDetails) => {
5916 if (this.syncOnly) {
5917 this.context.onOpenChange?.(newOpen, eventDetails);
5918 return;
5919 }
5920 this.dispatchOpenChange(newOpen, eventDetails);
5921 this.context.onOpenChange?.(newOpen, eventDetails);
5922 };
5923 };
5924
5925 // node_modules/@base-ui/react/esm/utils/popups/popupStoreUtils.js
5926 var React25 = __toESM(require_react(), 1);
5927 function useTriggerRegistration(id, store) {
5928 const registeredElementIdRef = React25.useRef(null);
5929 const registeredElementRef = React25.useRef(null);
5930 return React25.useCallback((element) => {
5931 if (id === void 0) {
5932 return;
5933 }
5934 if (registeredElementIdRef.current !== null) {
5935 const registeredId = registeredElementIdRef.current;
5936 const registeredElement = registeredElementRef.current;
5937 const currentElement = store.context.triggerElements.getById(registeredId);
5938 if (registeredElement && currentElement === registeredElement) {
5939 store.context.triggerElements.delete(registeredId);
5940 }
5941 registeredElementIdRef.current = null;
5942 registeredElementRef.current = null;
5943 }
5944 if (element !== null) {
5945 registeredElementIdRef.current = id;
5946 registeredElementRef.current = element;
5947 store.context.triggerElements.add(id, element);
5948 }
5949 }, [store, id]);
5950 }
5951 function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
5952 const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
5953 const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
5954 const registerTrigger = useStableCallback((element) => {
5955 baseRegisterTrigger(element);
5956 if (!element || !store.select("open")) {
5957 return;
5958 }
5959 const activeTriggerId = store.select("activeTriggerId");
5960 if (activeTriggerId === triggerId) {
5961 store.update({
5962 activeTriggerElement: element,
5963 ...stateUpdates
5964 });
5965 return;
5966 }
5967 if (activeTriggerId == null) {
5968 store.update({
5969 activeTriggerId: triggerId,
5970 activeTriggerElement: element,
5971 ...stateUpdates
5972 });
5973 }
5974 });
5975 useIsoLayoutEffect(() => {
5976 if (isMountedByThisTrigger) {
5977 store.update({
5978 activeTriggerElement: triggerElementRef.current,
5979 ...stateUpdates
5980 });
5981 }
5982 }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
5983 return {
5984 registerTrigger,
5985 isMountedByThisTrigger
5986 };
5987 }
5988 function useImplicitActiveTrigger(store) {
5989 const open = store.useState("open");
5990 useIsoLayoutEffect(() => {
5991 if (open && !store.select("activeTriggerId") && store.context.triggerElements.size === 1) {
5992 const iteratorResult = store.context.triggerElements.entries().next();
5993 if (!iteratorResult.done) {
5994 const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
5995 store.update({
5996 activeTriggerId: implicitTriggerId,
5997 activeTriggerElement: implicitTriggerElement
5998 });
5999 }
6000 }
6001 }, [open, store]);
6002 }
6003 function useOpenStateTransitions(open, store, onUnmount) {
6004 const {
6005 mounted,
6006 setMounted,
6007 transitionStatus
6008 } = useTransitionStatus(open);
6009 store.useSyncedValues({
6010 mounted,
6011 transitionStatus
6012 });
6013 const forceUnmount = useStableCallback(() => {
6014 setMounted(false);
6015 store.update({
6016 activeTriggerId: null,
6017 activeTriggerElement: null,
6018 mounted: false
6019 });
6020 onUnmount?.();
6021 store.context.onOpenChangeComplete?.(false);
6022 });
6023 const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
6024 useOpenChangeComplete({
6025 enabled: !preventUnmountingOnClose,
6026 open,
6027 ref: store.context.popupRef,
6028 onComplete() {
6029 if (!open) {
6030 forceUnmount();
6031 }
6032 }
6033 });
6034 return {
6035 forceUnmount,
6036 transitionStatus
6037 };
6038 }
6039
6040 // node_modules/@base-ui/react/esm/utils/popups/popupTriggerMap.js
6041 var PopupTriggerMap = class {
6042 constructor() {
6043 this.elementsSet = /* @__PURE__ */ new Set();
6044 this.idMap = /* @__PURE__ */ new Map();
6045 }
6046 /**
6047 * Adds a trigger element with the given ID.
6048 *
6049 * Note: The provided element is assumed to not be registered under multiple IDs.
6050 */
6051 add(id, element) {
6052 const existingElement = this.idMap.get(id);
6053 if (existingElement === element) {
6054 return;
6055 }
6056 if (existingElement !== void 0) {
6057 this.elementsSet.delete(existingElement);
6058 }
6059 this.elementsSet.add(element);
6060 this.idMap.set(id, element);
6061 if (true) {
6062 if (this.elementsSet.size !== this.idMap.size) {
6063 throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
6064 }
6065 }
6066 }
6067 /**
6068 * Removes the trigger element with the given ID.
6069 */
6070 delete(id) {
6071 const element = this.idMap.get(id);
6072 if (element) {
6073 this.elementsSet.delete(element);
6074 this.idMap.delete(id);
6075 }
6076 }
6077 /**
6078 * Whether the given element is registered as a trigger.
6079 */
6080 hasElement(element) {
6081 return this.elementsSet.has(element);
6082 }
6083 /**
6084 * Whether there is a registered trigger element matching the given predicate.
6085 */
6086 hasMatchingElement(predicate) {
6087 for (const element of this.elementsSet) {
6088 if (predicate(element)) {
6089 return true;
6090 }
6091 }
6092 return false;
6093 }
6094 /**
6095 * Returns the trigger element associated with the given ID, or undefined if no such element exists.
6096 */
6097 getById(id) {
6098 return this.idMap.get(id);
6099 }
6100 /**
6101 * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
6102 */
6103 entries() {
6104 return this.idMap.entries();
6105 }
6106 /**
6107 * Returns an iterable of all registered trigger elements.
6108 */
6109 elements() {
6110 return this.elementsSet.values();
6111 }
6112 /**
6113 * Returns the number of registered trigger elements.
6114 */
6115 get size() {
6116 return this.idMap.size;
6117 }
6118 };
6119
6120 // node_modules/@base-ui/react/esm/floating-ui-react/utils/getEmptyRootContext.js
6121 function getEmptyRootContext() {
6122 return new FloatingRootStore({
6123 open: false,
6124 transitionStatus: void 0,
6125 floatingElement: null,
6126 referenceElement: null,
6127 triggerElements: new PopupTriggerMap(),
6128 floatingId: "",
6129 syncOnly: false,
6130 nested: false,
6131 onOpenChange: void 0
6132 });
6133 }
6134
6135 // node_modules/@base-ui/react/esm/utils/popups/store.js
6136 function createInitialPopupStoreState() {
6137 return {
6138 open: false,
6139 openProp: void 0,
6140 mounted: false,
6141 transitionStatus: void 0,
6142 floatingRootContext: getEmptyRootContext(),
6143 preventUnmountingOnClose: false,
6144 payload: void 0,
6145 activeTriggerId: null,
6146 activeTriggerElement: null,
6147 triggerIdProp: void 0,
6148 popupElement: null,
6149 positionerElement: null,
6150 activeTriggerProps: EMPTY_OBJECT,
6151 inactiveTriggerProps: EMPTY_OBJECT,
6152 popupProps: EMPTY_OBJECT
6153 };
6154 }
6155 var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
6156 var popupStoreSelectors = {
6157 open: createSelector((state) => state.openProp ?? state.open),
6158 mounted: createSelector((state) => state.mounted),
6159 transitionStatus: createSelector((state) => state.transitionStatus),
6160 floatingRootContext: createSelector((state) => state.floatingRootContext),
6161 preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
6162 payload: createSelector((state) => state.payload),
6163 activeTriggerId: activeTriggerIdSelector,
6164 activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
6165 /**
6166 * Whether the trigger with the given ID was used to open the popup.
6167 */
6168 isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
6169 /**
6170 * Whether the popup is open and was activated by a trigger with the given ID.
6171 */
6172 isOpenedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.open),
6173 /**
6174 * Whether the popup is mounted and was activated by a trigger with the given ID.
6175 */
6176 isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
6177 triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
6178 popupProps: createSelector((state) => state.popupProps),
6179 popupElement: createSelector((state) => state.popupElement),
6180 positionerElement: createSelector((state) => state.positionerElement)
6181 };
6182
6183 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloatingRootContext.js
6184 function useFloatingRootContext(options) {
6185 const {
6186 open = false,
6187 onOpenChange,
6188 elements = {}
6189 } = options;
6190 const floatingId = useId();
6191 const nested = useFloatingParentNodeId() != null;
6192 if (true) {
6193 const optionDomReference = elements.reference;
6194 if (optionDomReference && !isElement(optionDomReference)) {
6195 console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
6196 }
6197 }
6198 const store = useRefWithInit(() => new FloatingRootStore({
6199 open,
6200 transitionStatus: void 0,
6201 onOpenChange,
6202 referenceElement: elements.reference ?? null,
6203 floatingElement: elements.floating ?? null,
6204 triggerElements: new PopupTriggerMap(),
6205 floatingId,
6206 syncOnly: false,
6207 nested
6208 })).current;
6209 useIsoLayoutEffect(() => {
6210 const valuesToSync = {
6211 open,
6212 floatingId
6213 };
6214 if (elements.reference !== void 0) {
6215 valuesToSync.referenceElement = elements.reference;
6216 valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
6217 }
6218 if (elements.floating !== void 0) {
6219 valuesToSync.floatingElement = elements.floating;
6220 }
6221 store.update(valuesToSync);
6222 }, [open, floatingId, elements.reference, elements.floating, store]);
6223 store.context.onOpenChange = onOpenChange;
6224 store.context.nested = nested;
6225 return store;
6226 }
6227
6228 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFloating.js
6229 function useFloating2(options = {}) {
6230 const {
6231 nodeId,
6232 externalTree
6233 } = options;
6234 const internalRootStore = useFloatingRootContext(options);
6235 const rootContext = options.rootContext || internalRootStore;
6236 const rootContextElements = {
6237 reference: rootContext.useState("referenceElement"),
6238 floating: rootContext.useState("floatingElement"),
6239 domReference: rootContext.useState("domReferenceElement")
6240 };
6241 const [positionReference, setPositionReferenceRaw] = React26.useState(null);
6242 const domReferenceRef = React26.useRef(null);
6243 const tree = useFloatingTree(externalTree);
6244 useIsoLayoutEffect(() => {
6245 if (rootContextElements.domReference) {
6246 domReferenceRef.current = rootContextElements.domReference;
6247 }
6248 }, [rootContextElements.domReference]);
6249 const position = useFloating({
6250 ...options,
6251 elements: {
6252 ...rootContextElements,
6253 ...positionReference && {
6254 reference: positionReference
6255 }
6256 }
6257 });
6258 const setPositionReference = React26.useCallback((node) => {
6259 const computedPositionReference = isElement(node) ? {
6260 getBoundingClientRect: () => node.getBoundingClientRect(),
6261 getClientRects: () => node.getClientRects(),
6262 contextElement: node
6263 } : node;
6264 setPositionReferenceRaw(computedPositionReference);
6265 position.refs.setReference(computedPositionReference);
6266 }, [position.refs]);
6267 const [localDomReference, setLocalDomReference] = React26.useState(void 0);
6268 const [localFloatingElement, setLocalFloatingElement] = React26.useState(null);
6269 rootContext.useSyncedValue("referenceElement", localDomReference ?? null);
6270 const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
6271 rootContext.useSyncedValue("domReferenceElement", localDomReference === void 0 ? rootContextElements.domReference : localDomReferenceElement);
6272 rootContext.useSyncedValue("floatingElement", localFloatingElement);
6273 const setReference = React26.useCallback((node) => {
6274 if (isElement(node) || node === null) {
6275 domReferenceRef.current = node;
6276 setLocalDomReference(node);
6277 }
6278 if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
6279 // `null` to support `positionReference` + an unstable `reference`
6280 // callback ref.
6281 node !== null && !isElement(node)) {
6282 position.refs.setReference(node);
6283 }
6284 }, [position.refs, setLocalDomReference]);
6285 const setFloating = React26.useCallback((node) => {
6286 setLocalFloatingElement(node);
6287 position.refs.setFloating(node);
6288 }, [position.refs]);
6289 const refs = React26.useMemo(() => ({
6290 ...position.refs,
6291 setReference,
6292 setFloating,
6293 setPositionReference,
6294 domReference: domReferenceRef
6295 }), [position.refs, setReference, setFloating, setPositionReference]);
6296 const elements = React26.useMemo(() => ({
6297 ...position.elements,
6298 domReference: rootContextElements.domReference
6299 }), [position.elements, rootContextElements.domReference]);
6300 const open = rootContext.useState("open");
6301 const floatingId = rootContext.useState("floatingId");
6302 const context = React26.useMemo(() => ({
6303 ...position,
6304 dataRef: rootContext.context.dataRef,
6305 open,
6306 onOpenChange: rootContext.setOpen,
6307 events: rootContext.context.events,
6308 floatingId,
6309 refs,
6310 elements,
6311 nodeId,
6312 rootStore: rootContext
6313 }), [position, refs, elements, nodeId, rootContext, open, floatingId]);
6314 useIsoLayoutEffect(() => {
6315 rootContext.context.dataRef.current.floatingContext = context;
6316 const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
6317 if (node) {
6318 node.context = context;
6319 }
6320 });
6321 return React26.useMemo(() => ({
6322 ...position,
6323 context,
6324 refs,
6325 elements,
6326 rootStore: rootContext
6327 }), [position, refs, elements, context, rootContext]);
6328 }
6329
6330 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useSyncedFloatingRootContext.js
6331 function useSyncedFloatingRootContext(options) {
6332 const {
6333 popupStore,
6334 treatPopupAsFloatingElement = false,
6335 onOpenChange
6336 } = options;
6337 const floatingId = useId();
6338 const nested = useFloatingParentNodeId() != null;
6339 const open = popupStore.useState("open");
6340 const referenceElement = popupStore.useState("activeTriggerElement");
6341 const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
6342 const triggerElements = popupStore.context.triggerElements;
6343 const store = useRefWithInit(() => new FloatingRootStore({
6344 open,
6345 transitionStatus: void 0,
6346 referenceElement,
6347 floatingElement,
6348 triggerElements,
6349 onOpenChange,
6350 floatingId,
6351 syncOnly: true,
6352 nested
6353 })).current;
6354 useIsoLayoutEffect(() => {
6355 const valuesToSync = {
6356 open,
6357 floatingId,
6358 referenceElement,
6359 floatingElement
6360 };
6361 if (isElement(referenceElement)) {
6362 valuesToSync.domReferenceElement = referenceElement;
6363 }
6364 if (store.state.positionReference === store.state.referenceElement) {
6365 valuesToSync.positionReference = referenceElement;
6366 }
6367 store.update(valuesToSync);
6368 }, [open, floatingId, referenceElement, floatingElement, store]);
6369 store.context.onOpenChange = onOpenChange;
6370 store.context.nested = nested;
6371 return store;
6372 }
6373
6374 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useFocus.js
6375 var React27 = __toESM(require_react(), 1);
6376 var isMacSafari = isMac && isSafari;
6377 function useFocus(context, props = {}) {
6378 const store = "rootStore" in context ? context.rootStore : context;
6379 const {
6380 events,
6381 dataRef
6382 } = store.context;
6383 const {
6384 enabled = true,
6385 delay
6386 } = props;
6387 const blockFocusRef = React27.useRef(false);
6388 const blockedReferenceRef = React27.useRef(null);
6389 const timeout = useTimeout();
6390 const keyboardModalityRef = React27.useRef(true);
6391 React27.useEffect(() => {
6392 const domReference = store.select("domReferenceElement");
6393 if (!enabled) {
6394 return void 0;
6395 }
6396 const win = getWindow(domReference);
6397 function onBlur() {
6398 const currentDomReference = store.select("domReferenceElement");
6399 if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
6400 blockFocusRef.current = true;
6401 }
6402 }
6403 function onKeyDown() {
6404 keyboardModalityRef.current = true;
6405 }
6406 function onPointerDown() {
6407 keyboardModalityRef.current = false;
6408 }
6409 return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
6410 }, [store, enabled]);
6411 React27.useEffect(() => {
6412 if (!enabled) {
6413 return void 0;
6414 }
6415 function onOpenChangeLocal(details) {
6416 if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
6417 const referenceElement = store.select("domReferenceElement");
6418 if (isElement(referenceElement)) {
6419 blockedReferenceRef.current = referenceElement;
6420 blockFocusRef.current = true;
6421 }
6422 }
6423 }
6424 events.on("openchange", onOpenChangeLocal);
6425 return () => {
6426 events.off("openchange", onOpenChangeLocal);
6427 };
6428 }, [events, enabled, store]);
6429 const reference = React27.useMemo(() => ({
6430 onMouseLeave() {
6431 blockFocusRef.current = false;
6432 blockedReferenceRef.current = null;
6433 },
6434 onFocus(event) {
6435 const focusTarget = event.currentTarget;
6436 if (blockFocusRef.current) {
6437 if (blockedReferenceRef.current === focusTarget) {
6438 return;
6439 }
6440 blockFocusRef.current = false;
6441 blockedReferenceRef.current = null;
6442 }
6443 const target = getTarget(event.nativeEvent);
6444 if (isElement(target)) {
6445 if (isMacSafari && !event.relatedTarget) {
6446 if (!keyboardModalityRef.current && !isTypeableElement(target)) {
6447 return;
6448 }
6449 } else if (!matchesFocusVisible(target)) {
6450 return;
6451 }
6452 }
6453 const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
6454 const {
6455 nativeEvent,
6456 currentTarget
6457 } = event;
6458 const delayValue = typeof delay === "function" ? delay() : delay;
6459 if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
6460 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6461 return;
6462 }
6463 timeout.start(delayValue, () => {
6464 if (blockFocusRef.current) {
6465 return;
6466 }
6467 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
6468 });
6469 },
6470 onBlur(event) {
6471 blockFocusRef.current = false;
6472 blockedReferenceRef.current = null;
6473 const relatedTarget = event.relatedTarget;
6474 const nativeEvent = event.nativeEvent;
6475 const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
6476 timeout.start(0, () => {
6477 const domReference = store.select("domReferenceElement");
6478 const activeEl = activeElement(ownerDocument(domReference));
6479 if (!relatedTarget && activeEl === domReference) {
6480 return;
6481 }
6482 if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
6483 return;
6484 }
6485 const nextFocusedElement = relatedTarget ?? activeEl;
6486 if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
6487 return;
6488 }
6489 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
6490 });
6491 }
6492 }), [dataRef, store, timeout, delay]);
6493 return React27.useMemo(() => enabled ? {
6494 reference,
6495 trigger: reference
6496 } : {}, [enabled, reference]);
6497 }
6498
6499 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6500 var React28 = __toESM(require_react(), 1);
6501
6502 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverInteractionSharedState.js
6503 var HoverInteraction = class _HoverInteraction {
6504 constructor() {
6505 this.pointerType = void 0;
6506 this.interactedInside = false;
6507 this.handler = void 0;
6508 this.blockMouseMove = true;
6509 this.performedPointerEventsMutation = false;
6510 this.pointerEventsScopeElement = null;
6511 this.pointerEventsReferenceElement = null;
6512 this.pointerEventsFloatingElement = null;
6513 this.restTimeoutPending = false;
6514 this.openChangeTimeout = new Timeout();
6515 this.restTimeout = new Timeout();
6516 this.handleCloseOptions = void 0;
6517 }
6518 static create() {
6519 return new _HoverInteraction();
6520 }
6521 dispose = () => {
6522 this.openChangeTimeout.clear();
6523 this.restTimeout.clear();
6524 };
6525 disposeEffect = () => {
6526 return this.dispose;
6527 };
6528 };
6529 var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
6530 function clearSafePolygonPointerEventsMutation(instance) {
6531 if (!instance.performedPointerEventsMutation) {
6532 return;
6533 }
6534 const scopeElement = instance.pointerEventsScopeElement;
6535 if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
6536 instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
6537 instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
6538 instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
6539 pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
6540 }
6541 instance.performedPointerEventsMutation = false;
6542 instance.pointerEventsScopeElement = null;
6543 instance.pointerEventsReferenceElement = null;
6544 instance.pointerEventsFloatingElement = null;
6545 }
6546 function applySafePolygonPointerEventsMutation(instance, options) {
6547 const {
6548 scopeElement,
6549 referenceElement,
6550 floatingElement
6551 } = options;
6552 const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
6553 if (existingOwner && existingOwner !== instance) {
6554 clearSafePolygonPointerEventsMutation(existingOwner);
6555 }
6556 clearSafePolygonPointerEventsMutation(instance);
6557 instance.performedPointerEventsMutation = true;
6558 instance.pointerEventsScopeElement = scopeElement;
6559 instance.pointerEventsReferenceElement = referenceElement;
6560 instance.pointerEventsFloatingElement = floatingElement;
6561 pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
6562 scopeElement.style.pointerEvents = "none";
6563 referenceElement.style.pointerEvents = "auto";
6564 floatingElement.style.pointerEvents = "auto";
6565 }
6566 function useHoverInteractionSharedState(store) {
6567 const instance = useRefWithInit(HoverInteraction.create).current;
6568 const data = store.context.dataRef.current;
6569 if (!data.hoverInteractionState) {
6570 data.hoverInteractionState = instance;
6571 }
6572 useOnMount(data.hoverInteractionState.disposeEffect);
6573 return data.hoverInteractionState;
6574 }
6575
6576 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverFloatingInteraction.js
6577 function useHoverFloatingInteraction(context, parameters = {}) {
6578 const store = "rootStore" in context ? context.rootStore : context;
6579 const open = store.useState("open");
6580 const floatingElement = store.useState("floatingElement");
6581 const domReferenceElement = store.useState("domReferenceElement");
6582 const {
6583 dataRef
6584 } = store.context;
6585 const {
6586 enabled = true,
6587 closeDelay: closeDelayProp = 0,
6588 nodeId: nodeIdProp
6589 } = parameters;
6590 const instance = useHoverInteractionSharedState(store);
6591 const tree = useFloatingTree();
6592 const parentId = useFloatingParentNodeId();
6593 const isClickLikeOpenEvent2 = useStableCallback(() => {
6594 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6595 });
6596 const isHoverOpen = useStableCallback(() => {
6597 const type = dataRef.current.openEvent?.type;
6598 return type?.includes("mouse") && type !== "mousedown";
6599 });
6600 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6601 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6602 });
6603 const closeWithDelay = React28.useCallback((event) => {
6604 const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
6605 const close = () => {
6606 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6607 tree?.events.emit("floating.closed", event);
6608 };
6609 if (closeDelay) {
6610 instance.openChangeTimeout.start(closeDelay, close);
6611 } else {
6612 instance.openChangeTimeout.clear();
6613 close();
6614 }
6615 }, [closeDelayProp, store, instance, tree]);
6616 const clearPointerEvents = useStableCallback(() => {
6617 clearSafePolygonPointerEventsMutation(instance);
6618 });
6619 const handleInteractInside = useStableCallback((event) => {
6620 const target = getTarget(event);
6621 if (!isInteractiveElement(target)) {
6622 instance.interactedInside = false;
6623 return;
6624 }
6625 instance.interactedInside = target?.closest("[aria-haspopup]") != null;
6626 });
6627 useIsoLayoutEffect(() => {
6628 if (!open) {
6629 instance.pointerType = void 0;
6630 instance.restTimeoutPending = false;
6631 instance.interactedInside = false;
6632 clearPointerEvents();
6633 }
6634 }, [open, instance, clearPointerEvents]);
6635 React28.useEffect(() => {
6636 return clearPointerEvents;
6637 }, [clearPointerEvents]);
6638 useIsoLayoutEffect(() => {
6639 if (!enabled) {
6640 return void 0;
6641 }
6642 if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
6643 const ref = domReferenceElement;
6644 const floatingEl = floatingElement;
6645 const doc = ownerDocument(floatingElement);
6646 const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
6647 if (parentFloating) {
6648 parentFloating.style.pointerEvents = "";
6649 }
6650 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? instance.pointerEventsScopeElement ?? parentFloating ?? ref.closest("[data-rootownerid]") ?? doc.body;
6651 applySafePolygonPointerEventsMutation(instance, {
6652 scopeElement,
6653 referenceElement: ref,
6654 floatingElement: floatingEl
6655 });
6656 return () => {
6657 clearPointerEvents();
6658 };
6659 }
6660 return void 0;
6661 }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
6662 const childClosedTimeout = useTimeout();
6663 React28.useEffect(() => {
6664 if (!enabled) {
6665 return void 0;
6666 }
6667 function onFloatingMouseEnter() {
6668 instance.openChangeTimeout.clear();
6669 childClosedTimeout.clear();
6670 tree?.events.off("floating.closed", onNodeClosed);
6671 clearPointerEvents();
6672 }
6673 function onFloatingMouseLeave(event) {
6674 if (tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6675 tree.events.on("floating.closed", onNodeClosed);
6676 return;
6677 }
6678 if (isRelatedTargetInsideEnabledTrigger(event.relatedTarget)) {
6679 return;
6680 }
6681 const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
6682 const relatedTarget = event.relatedTarget;
6683 const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
6684 if (isMovingIntoDescendantFloating) {
6685 return;
6686 }
6687 if (instance.handler) {
6688 instance.handler(event);
6689 return;
6690 }
6691 clearPointerEvents();
6692 if (!isClickLikeOpenEvent2()) {
6693 closeWithDelay(event);
6694 }
6695 }
6696 function onNodeClosed(event) {
6697 if (!tree || !parentId || getNodeChildren(tree.nodesRef.current, parentId).length > 0) {
6698 return;
6699 }
6700 childClosedTimeout.start(0, () => {
6701 tree.events.off("floating.closed", onNodeClosed);
6702 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6703 tree.events.emit("floating.closed", event);
6704 });
6705 }
6706 const floating = floatingElement;
6707 return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
6708 tree?.events.off("floating.closed", onNodeClosed);
6709 });
6710 }, [enabled, floatingElement, store, dataRef, nodeIdProp, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, closeWithDelay, clearPointerEvents, handleInteractInside, instance, tree, parentId, childClosedTimeout]);
6711 }
6712
6713 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useHoverReferenceInteraction.js
6714 var React29 = __toESM(require_react(), 1);
6715 var ReactDOM4 = __toESM(require_react_dom(), 1);
6716 var EMPTY_REF = {
6717 current: null
6718 };
6719 function useHoverReferenceInteraction(context, props = {}) {
6720 const store = "rootStore" in context ? context.rootStore : context;
6721 const {
6722 dataRef,
6723 events
6724 } = store.context;
6725 const {
6726 enabled = true,
6727 delay = 0,
6728 handleClose = null,
6729 mouseOnly = false,
6730 restMs = 0,
6731 move = true,
6732 triggerElementRef = EMPTY_REF,
6733 externalTree,
6734 isActiveTrigger = true,
6735 getHandleCloseContext,
6736 isClosing
6737 } = props;
6738 const tree = useFloatingTree(externalTree);
6739 const instance = useHoverInteractionSharedState(store);
6740 const isHoverCloseActiveRef = React29.useRef(false);
6741 const handleCloseRef = useValueAsRef(handleClose);
6742 const delayRef = useValueAsRef(delay);
6743 const restMsRef = useValueAsRef(restMs);
6744 const enabledRef = useValueAsRef(enabled);
6745 const isClosingRef = useValueAsRef(isClosing);
6746 if (isActiveTrigger) {
6747 instance.handleCloseOptions = handleCloseRef.current?.__options;
6748 }
6749 const isClickLikeOpenEvent2 = useStableCallback(() => {
6750 return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
6751 });
6752 const isRelatedTargetInsideEnabledTrigger = useStableCallback((target) => {
6753 return isTargetInsideEnabledTrigger(target, store.context.triggerElements);
6754 });
6755 const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
6756 const allTriggers = store.context.triggerElements;
6757 if (allTriggers.hasElement(currentTarget)) {
6758 return !currentDomReference || !contains(currentDomReference, currentTarget);
6759 }
6760 if (!isElement(target)) {
6761 return false;
6762 }
6763 const targetElement = target;
6764 return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
6765 });
6766 const closeWithDelay = useStableCallback((event, runElseBranch = true) => {
6767 const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
6768 if (closeDelay) {
6769 instance.openChangeTimeout.start(closeDelay, () => {
6770 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6771 tree?.events.emit("floating.closed", event);
6772 });
6773 } else if (runElseBranch) {
6774 instance.openChangeTimeout.clear();
6775 store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
6776 tree?.events.emit("floating.closed", event);
6777 }
6778 });
6779 const cleanupMouseMoveHandler = useStableCallback(() => {
6780 if (!instance.handler) {
6781 return;
6782 }
6783 const doc = ownerDocument(store.select("domReferenceElement"));
6784 doc.removeEventListener("mousemove", instance.handler);
6785 instance.handler = void 0;
6786 });
6787 const clearPointerEvents = useStableCallback(() => {
6788 clearSafePolygonPointerEventsMutation(instance);
6789 });
6790 React29.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
6791 React29.useEffect(() => {
6792 if (!enabled) {
6793 return void 0;
6794 }
6795 function onOpenChangeLocal(details) {
6796 if (!details.open) {
6797 isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
6798 cleanupMouseMoveHandler();
6799 instance.openChangeTimeout.clear();
6800 instance.restTimeout.clear();
6801 instance.blockMouseMove = true;
6802 instance.restTimeoutPending = false;
6803 } else {
6804 isHoverCloseActiveRef.current = false;
6805 }
6806 }
6807 events.on("openchange", onOpenChangeLocal);
6808 return () => {
6809 events.off("openchange", onOpenChangeLocal);
6810 };
6811 }, [enabled, events, instance, cleanupMouseMoveHandler]);
6812 React29.useEffect(() => {
6813 if (!enabled) {
6814 return void 0;
6815 }
6816 const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
6817 if (!isElement(trigger)) {
6818 return void 0;
6819 }
6820 function onMouseEnter(event) {
6821 instance.openChangeTimeout.clear();
6822 instance.blockMouseMove = false;
6823 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6824 return;
6825 }
6826 const restMsValue = getRestMs(restMsRef.current);
6827 const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
6828 const eventTarget = getTarget(event);
6829 const currentTarget = event.currentTarget ?? null;
6830 const currentDomReference = store.select("domReferenceElement");
6831 let triggerNode = currentTarget;
6832 if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
6833 for (const triggerElement of store.context.triggerElements.elements()) {
6834 if (contains(triggerElement, eventTarget)) {
6835 triggerNode = triggerElement;
6836 break;
6837 }
6838 }
6839 }
6840 if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
6841 triggerNode = currentDomReference;
6842 }
6843 const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
6844 const isOpen = store.select("open");
6845 const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
6846 const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
6847 const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
6848 const isRestOnlyDelay = restMsValue > 0 && !openDelay;
6849 const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
6850 const shouldOpen = !isOpen || isOverInactive;
6851 if (shouldOpenImmediately) {
6852 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6853 return;
6854 }
6855 if (isRestOnlyDelay) {
6856 return;
6857 }
6858 if (openDelay) {
6859 instance.openChangeTimeout.start(openDelay, () => {
6860 if (shouldOpen) {
6861 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6862 }
6863 });
6864 } else if (shouldOpen) {
6865 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
6866 }
6867 }
6868 function onMouseLeave(event) {
6869 if (isClickLikeOpenEvent2()) {
6870 clearPointerEvents();
6871 return;
6872 }
6873 cleanupMouseMoveHandler();
6874 const domReferenceElement = store.select("domReferenceElement");
6875 const doc = ownerDocument(domReferenceElement);
6876 instance.restTimeout.clear();
6877 instance.restTimeoutPending = false;
6878 const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
6879 const ignoreRelatedTargetTrigger = isRelatedTargetInsideEnabledTrigger(event.relatedTarget);
6880 if (ignoreRelatedTargetTrigger) {
6881 return;
6882 }
6883 if (handleCloseRef.current && handleCloseContextBase) {
6884 if (!store.select("open")) {
6885 instance.openChangeTimeout.clear();
6886 }
6887 const currentTrigger = triggerElementRef.current;
6888 instance.handler = handleCloseRef.current({
6889 ...handleCloseContextBase,
6890 tree,
6891 x: event.clientX,
6892 y: event.clientY,
6893 onClose() {
6894 clearPointerEvents();
6895 cleanupMouseMoveHandler();
6896 if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
6897 closeWithDelay(event, true);
6898 }
6899 }
6900 });
6901 doc.addEventListener("mousemove", instance.handler);
6902 instance.handler(event);
6903 return;
6904 }
6905 const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
6906 if (shouldClose) {
6907 closeWithDelay(event);
6908 }
6909 }
6910 if (move) {
6911 return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
6912 once: true
6913 }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6914 }
6915 return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
6916 }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, closeWithDelay, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, isRelatedTargetInsideEnabledTrigger, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef]);
6917 return React29.useMemo(() => {
6918 if (!enabled) {
6919 return void 0;
6920 }
6921 function setPointerRef(event) {
6922 instance.pointerType = event.pointerType;
6923 }
6924 return {
6925 onPointerDown: setPointerRef,
6926 onPointerEnter: setPointerRef,
6927 onMouseMove(event) {
6928 const {
6929 nativeEvent
6930 } = event;
6931 const trigger = event.currentTarget;
6932 const currentDomReference = store.select("domReferenceElement");
6933 const currentOpen = store.select("open");
6934 const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
6935 if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
6936 return;
6937 }
6938 if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
6939 const floatingElement = store.select("floatingElement");
6940 if (floatingElement) {
6941 const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
6942 applySafePolygonPointerEventsMutation(instance, {
6943 scopeElement,
6944 referenceElement: trigger,
6945 floatingElement
6946 });
6947 }
6948 }
6949 const restMsValue = getRestMs(restMsRef.current);
6950 if (currentOpen && !isOverInactive || restMsValue === 0) {
6951 return;
6952 }
6953 if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
6954 return;
6955 }
6956 instance.restTimeout.clear();
6957 function handleMouseMove() {
6958 instance.restTimeoutPending = false;
6959 if (isClickLikeOpenEvent2()) {
6960 return;
6961 }
6962 const latestOpen = store.select("open");
6963 if (!instance.blockMouseMove && (!latestOpen || isOverInactive)) {
6964 store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
6965 }
6966 }
6967 if (instance.pointerType === "touch") {
6968 ReactDOM4.flushSync(() => {
6969 handleMouseMove();
6970 });
6971 } else if (isOverInactive && currentOpen) {
6972 handleMouseMove();
6973 } else {
6974 instance.restTimeoutPending = true;
6975 instance.restTimeout.start(restMsValue, handleMouseMove);
6976 }
6977 }
6978 };
6979 }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef]);
6980 }
6981
6982 // node_modules/@base-ui/react/esm/floating-ui-react/hooks/useInteractions.js
6983 var React30 = __toESM(require_react(), 1);
6984 function useInteractions(propsList = []) {
6985 const referenceDeps = propsList.map((key) => key?.reference);
6986 const floatingDeps = propsList.map((key) => key?.floating);
6987 const itemDeps = propsList.map((key) => key?.item);
6988 const triggerDeps = propsList.map((key) => key?.trigger);
6989 const getReferenceProps = React30.useCallback(
6990 (userProps) => mergeProps2(userProps, propsList, "reference"),
6991 // eslint-disable-next-line react-hooks/exhaustive-deps
6992 referenceDeps
6993 );
6994 const getFloatingProps = React30.useCallback(
6995 (userProps) => mergeProps2(userProps, propsList, "floating"),
6996 // eslint-disable-next-line react-hooks/exhaustive-deps
6997 floatingDeps
6998 );
6999 const getItemProps = React30.useCallback(
7000 (userProps) => mergeProps2(userProps, propsList, "item"),
7001 // eslint-disable-next-line react-hooks/exhaustive-deps
7002 itemDeps
7003 );
7004 const getTriggerProps = React30.useCallback(
7005 (userProps) => mergeProps2(userProps, propsList, "trigger"),
7006 // eslint-disable-next-line react-hooks/exhaustive-deps
7007 triggerDeps
7008 );
7009 return React30.useMemo(() => ({
7010 getReferenceProps,
7011 getFloatingProps,
7012 getItemProps,
7013 getTriggerProps
7014 }), [getReferenceProps, getFloatingProps, getItemProps, getTriggerProps]);
7015 }
7016 function mergeProps2(userProps, propsList, elementKey) {
7017 const eventHandlers = /* @__PURE__ */ new Map();
7018 const isItem2 = elementKey === "item";
7019 const outputProps = {};
7020 if (elementKey === "floating") {
7021 outputProps.tabIndex = -1;
7022 outputProps[FOCUSABLE_ATTRIBUTE] = "";
7023 }
7024 for (const key in userProps) {
7025 if (isItem2 && userProps) {
7026 if (key === ACTIVE_KEY || key === SELECTED_KEY) {
7027 continue;
7028 }
7029 }
7030 outputProps[key] = userProps[key];
7031 }
7032 for (let i2 = 0; i2 < propsList.length; i2 += 1) {
7033 let props;
7034 const propsOrGetProps = propsList[i2]?.[elementKey];
7035 if (typeof propsOrGetProps === "function") {
7036 props = userProps ? propsOrGetProps(userProps) : null;
7037 } else {
7038 props = propsOrGetProps;
7039 }
7040 if (!props) {
7041 continue;
7042 }
7043 mutablyMergeProps(outputProps, props, isItem2, eventHandlers);
7044 }
7045 mutablyMergeProps(outputProps, userProps, isItem2, eventHandlers);
7046 return outputProps;
7047 }
7048 function mutablyMergeProps(outputProps, props, isItem2, eventHandlers) {
7049 for (const key in props) {
7050 const value = props[key];
7051 if (isItem2 && (key === ACTIVE_KEY || key === SELECTED_KEY)) {
7052 continue;
7053 }
7054 if (!key.startsWith("on")) {
7055 outputProps[key] = value;
7056 } else {
7057 if (!eventHandlers.has(key)) {
7058 eventHandlers.set(key, []);
7059 }
7060 if (typeof value === "function") {
7061 eventHandlers.get(key)?.push(value);
7062 outputProps[key] = (...args) => {
7063 return eventHandlers.get(key)?.map((fn) => fn(...args)).find((val) => val !== void 0);
7064 };
7065 }
7066 }
7067 }
7068 }
7069
7070 // node_modules/@base-ui/react/esm/floating-ui-react/safePolygon.js
7071 var CURSOR_SPEED_THRESHOLD = 0.1;
7072 var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
7073 var POLYGON_BUFFER = 0.5;
7074 function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
7075 return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
7076 }
7077 function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
7078 let isInsideValue = false;
7079 if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
7080 isInsideValue = !isInsideValue;
7081 }
7082 if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
7083 isInsideValue = !isInsideValue;
7084 }
7085 if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
7086 isInsideValue = !isInsideValue;
7087 }
7088 if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
7089 isInsideValue = !isInsideValue;
7090 }
7091 return isInsideValue;
7092 }
7093 function isInsideRect(pointX, pointY, rect) {
7094 return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
7095 }
7096 function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
7097 const minX = Math.min(x1, x2);
7098 const maxX = Math.max(x1, x2);
7099 const minY = Math.min(y1, y2);
7100 const maxY = Math.max(y1, y2);
7101 return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
7102 }
7103 function safePolygon(options = {}) {
7104 const {
7105 blockPointerEvents = false
7106 } = options;
7107 const timeout = new Timeout();
7108 const fn = ({
7109 x: x2,
7110 y: y2,
7111 placement,
7112 elements,
7113 onClose,
7114 nodeId,
7115 tree
7116 }) => {
7117 const side = placement?.split("-")[0];
7118 let hasLanded = false;
7119 let lastX = null;
7120 let lastY = null;
7121 let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
7122 function isCursorMovingSlowly(nextX, nextY) {
7123 const currentTime = performance.now();
7124 const elapsedTime = currentTime - lastCursorTime;
7125 if (lastX === null || lastY === null || elapsedTime === 0) {
7126 lastX = nextX;
7127 lastY = nextY;
7128 lastCursorTime = currentTime;
7129 return false;
7130 }
7131 const deltaX = nextX - lastX;
7132 const deltaY = nextY - lastY;
7133 const distanceSquared = deltaX * deltaX + deltaY * deltaY;
7134 const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
7135 lastX = nextX;
7136 lastY = nextY;
7137 lastCursorTime = currentTime;
7138 return distanceSquared < thresholdSquared;
7139 }
7140 function close() {
7141 timeout.clear();
7142 onClose();
7143 }
7144 return function onMouseMove(event) {
7145 timeout.clear();
7146 const domReference = elements.domReference;
7147 const floating = elements.floating;
7148 if (!domReference || !floating || side == null || x2 == null || y2 == null) {
7149 return void 0;
7150 }
7151 const {
7152 clientX,
7153 clientY
7154 } = event;
7155 const target = getTarget(event);
7156 const isLeave = event.type === "mouseleave";
7157 const isOverFloatingEl = contains(floating, target);
7158 const isOverReferenceEl = contains(domReference, target);
7159 if (isOverFloatingEl) {
7160 hasLanded = true;
7161 if (!isLeave) {
7162 return void 0;
7163 }
7164 }
7165 if (isOverReferenceEl) {
7166 hasLanded = false;
7167 if (!isLeave) {
7168 hasLanded = true;
7169 return void 0;
7170 }
7171 }
7172 if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
7173 return void 0;
7174 }
7175 function hasOpenChildNode() {
7176 return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
7177 }
7178 function closeIfNoOpenChild() {
7179 if (!hasOpenChildNode()) {
7180 close();
7181 }
7182 }
7183 if (hasOpenChildNode()) {
7184 return void 0;
7185 }
7186 const refRect = domReference.getBoundingClientRect();
7187 const rect = floating.getBoundingClientRect();
7188 const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
7189 const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
7190 const isFloatingWider = rect.width > refRect.width;
7191 const isFloatingTaller = rect.height > refRect.height;
7192 const left = (isFloatingWider ? refRect : rect).left;
7193 const right = (isFloatingWider ? refRect : rect).right;
7194 const top = (isFloatingTaller ? refRect : rect).top;
7195 const bottom = (isFloatingTaller ? refRect : rect).bottom;
7196 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) {
7197 closeIfNoOpenChild();
7198 return void 0;
7199 }
7200 let isInsideTroughRect = false;
7201 switch (side) {
7202 case "top":
7203 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
7204 break;
7205 case "bottom":
7206 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
7207 break;
7208 case "left":
7209 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
7210 break;
7211 case "right":
7212 isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
7213 break;
7214 default:
7215 }
7216 if (isInsideTroughRect) {
7217 return void 0;
7218 }
7219 if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
7220 closeIfNoOpenChild();
7221 return void 0;
7222 }
7223 if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
7224 closeIfNoOpenChild();
7225 return void 0;
7226 }
7227 let isInsidePolygon = false;
7228 switch (side) {
7229 case "top": {
7230 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7231 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7232 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7233 const cursorPointY = y2 + POLYGON_BUFFER + 1;
7234 const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
7235 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
7236 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7237 break;
7238 }
7239 case "bottom": {
7240 const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7241 const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7242 const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
7243 const cursorPointY = y2 - POLYGON_BUFFER;
7244 const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
7245 const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
7246 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
7247 break;
7248 }
7249 case "left": {
7250 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7251 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7252 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7253 const cursorPointX = x2 + POLYGON_BUFFER + 1;
7254 const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
7255 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
7256 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
7257 break;
7258 }
7259 case "right": {
7260 const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
7261 const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7262 const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
7263 const cursorPointX = x2 - POLYGON_BUFFER;
7264 const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
7265 const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
7266 isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
7267 break;
7268 }
7269 default:
7270 }
7271 if (!isInsidePolygon) {
7272 closeIfNoOpenChild();
7273 } else if (!hasLanded) {
7274 timeout.start(40, closeIfNoOpenChild);
7275 }
7276 return void 0;
7277 };
7278 };
7279 fn.__options = {
7280 ...options,
7281 blockPointerEvents
7282 };
7283 return fn;
7284 }
7285
7286 // node_modules/@base-ui/react/esm/utils/popupStateMapping.js
7287 var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
7288 CommonPopupDataAttributes2["open"] = "data-open";
7289 CommonPopupDataAttributes2["closed"] = "data-closed";
7290 CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
7291 CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
7292 CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
7293 CommonPopupDataAttributes2["side"] = "data-side";
7294 CommonPopupDataAttributes2["align"] = "data-align";
7295 return CommonPopupDataAttributes2;
7296 })({});
7297 var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
7298 CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
7299 CommonTriggerDataAttributes2["pressed"] = "data-pressed";
7300 return CommonTriggerDataAttributes2;
7301 })({});
7302 var TRIGGER_HOOK = {
7303 [CommonTriggerDataAttributes.popupOpen]: ""
7304 };
7305 var PRESSABLE_TRIGGER_HOOK = {
7306 [CommonTriggerDataAttributes.popupOpen]: "",
7307 [CommonTriggerDataAttributes.pressed]: ""
7308 };
7309 var POPUP_OPEN_HOOK = {
7310 [CommonPopupDataAttributes.open]: ""
7311 };
7312 var POPUP_CLOSED_HOOK = {
7313 [CommonPopupDataAttributes.closed]: ""
7314 };
7315 var ANCHOR_HIDDEN_HOOK = {
7316 [CommonPopupDataAttributes.anchorHidden]: ""
7317 };
7318 var triggerOpenStateMapping = {
7319 open(value) {
7320 if (value) {
7321 return TRIGGER_HOOK;
7322 }
7323 return null;
7324 }
7325 };
7326 var popupStateMapping = {
7327 open(value) {
7328 if (value) {
7329 return POPUP_OPEN_HOOK;
7330 }
7331 return POPUP_CLOSED_HOOK;
7332 },
7333 anchorHidden(value) {
7334 if (value) {
7335 return ANCHOR_HIDDEN_HOOK;
7336 }
7337 return null;
7338 }
7339 };
7340
7341 // node_modules/@base-ui/utils/esm/inertValue.js
7342 function inertValue(value) {
7343 if (isReactVersionAtLeast(19)) {
7344 return value;
7345 }
7346 return value ? "true" : void 0;
7347 }
7348
7349 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7350 var React31 = __toESM(require_react(), 1);
7351
7352 // node_modules/@base-ui/react/esm/floating-ui-react/middleware/arrow.js
7353 var baseArrow = (options) => ({
7354 name: "arrow",
7355 options,
7356 async fn(state) {
7357 const {
7358 x: x2,
7359 y: y2,
7360 placement,
7361 rects,
7362 platform: platform3,
7363 elements,
7364 middlewareData
7365 } = state;
7366 const {
7367 element,
7368 padding = 0,
7369 offsetParent = "real"
7370 } = evaluate(options, state) || {};
7371 if (element == null) {
7372 return {};
7373 }
7374 const paddingObject = getPaddingObject(padding);
7375 const coords = {
7376 x: x2,
7377 y: y2
7378 };
7379 const axis = getAlignmentAxis(placement);
7380 const length = getAxisLength(axis);
7381 const arrowDimensions = await platform3.getDimensions(element);
7382 const isYAxis = axis === "y";
7383 const minProp = isYAxis ? "top" : "left";
7384 const maxProp = isYAxis ? "bottom" : "right";
7385 const clientProp = isYAxis ? "clientHeight" : "clientWidth";
7386 const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
7387 const startDiff = coords[axis] - rects.reference[axis];
7388 const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements.floating;
7389 let clientSize = elements.floating[clientProp] || rects.floating[length];
7390 if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
7391 clientSize = elements.floating[clientProp] || rects.floating[length];
7392 }
7393 const centerToReference = endDiff / 2 - startDiff / 2;
7394 const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
7395 const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
7396 const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
7397 const min2 = minPadding;
7398 const max2 = clientSize - arrowDimensions[length] - maxPadding;
7399 const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
7400 const offset4 = clamp(min2, center, max2);
7401 const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
7402 const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
7403 return {
7404 [axis]: coords[axis] + alignmentOffset,
7405 data: {
7406 [axis]: offset4,
7407 centerOffset: center - offset4 - alignmentOffset,
7408 ...shouldAddOffset && {
7409 alignmentOffset
7410 }
7411 },
7412 reset: shouldAddOffset
7413 };
7414 }
7415 });
7416 var arrow4 = (options, deps) => ({
7417 ...baseArrow(options),
7418 options: [options, deps]
7419 });
7420
7421 // node_modules/@base-ui/react/esm/utils/hideMiddleware.js
7422 var hide4 = {
7423 name: "hide",
7424 async fn(state) {
7425 const {
7426 width,
7427 height,
7428 x: x2,
7429 y: y2
7430 } = state.rects.reference;
7431 const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
7432 const nativeHideResult = await hide3().fn(state);
7433 return {
7434 data: {
7435 referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
7436 }
7437 };
7438 }
7439 };
7440
7441 // node_modules/@base-ui/react/esm/utils/adaptiveOriginMiddleware.js
7442 var DEFAULT_SIDES = {
7443 sideX: "left",
7444 sideY: "top"
7445 };
7446 var adaptiveOrigin = {
7447 name: "adaptiveOrigin",
7448 async fn(state) {
7449 const {
7450 x: rawX,
7451 y: rawY,
7452 rects: {
7453 floating: floatRect
7454 },
7455 elements: {
7456 floating
7457 },
7458 platform: platform3,
7459 strategy,
7460 placement
7461 } = state;
7462 const win = getWindow(floating);
7463 const styles = win.getComputedStyle(floating);
7464 const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
7465 if (!hasTransition) {
7466 return {
7467 x: rawX,
7468 y: rawY,
7469 data: DEFAULT_SIDES
7470 };
7471 }
7472 const offsetParent = await platform3.getOffsetParent?.(floating);
7473 let offsetDimensions = {
7474 width: 0,
7475 height: 0
7476 };
7477 if (strategy === "fixed" && win?.visualViewport) {
7478 offsetDimensions = {
7479 width: win.visualViewport.width,
7480 height: win.visualViewport.height
7481 };
7482 } else if (offsetParent === win) {
7483 const doc = ownerDocument(floating);
7484 offsetDimensions = {
7485 width: doc.documentElement.clientWidth,
7486 height: doc.documentElement.clientHeight
7487 };
7488 } else if (await platform3.isElement?.(offsetParent)) {
7489 offsetDimensions = await platform3.getDimensions(offsetParent);
7490 }
7491 const currentSide = getSide(placement);
7492 let x2 = rawX;
7493 let y2 = rawY;
7494 if (currentSide === "left") {
7495 x2 = offsetDimensions.width - (rawX + floatRect.width);
7496 }
7497 if (currentSide === "top") {
7498 y2 = offsetDimensions.height - (rawY + floatRect.height);
7499 }
7500 const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
7501 const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
7502 return {
7503 x: x2,
7504 y: y2,
7505 data: {
7506 sideX,
7507 sideY
7508 }
7509 };
7510 }
7511 };
7512
7513 // node_modules/@base-ui/react/esm/utils/useAnchorPositioning.js
7514 function getLogicalSide(sideParam, renderedSide, isRtl) {
7515 const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
7516 const logicalRight = isRtl ? "inline-start" : "inline-end";
7517 const logicalLeft = isRtl ? "inline-end" : "inline-start";
7518 return {
7519 top: "top",
7520 right: isLogicalSideParam ? logicalRight : "right",
7521 bottom: "bottom",
7522 left: isLogicalSideParam ? logicalLeft : "left"
7523 }[renderedSide];
7524 }
7525 function getOffsetData(state, sideParam, isRtl) {
7526 const {
7527 rects,
7528 placement
7529 } = state;
7530 const data = {
7531 side: getLogicalSide(sideParam, getSide(placement), isRtl),
7532 align: getAlignment(placement) || "center",
7533 anchor: {
7534 width: rects.reference.width,
7535 height: rects.reference.height
7536 },
7537 positioner: {
7538 width: rects.floating.width,
7539 height: rects.floating.height
7540 }
7541 };
7542 return data;
7543 }
7544 function useAnchorPositioning(params) {
7545 const {
7546 // Public parameters
7547 anchor,
7548 positionMethod = "absolute",
7549 side: sideParam = "bottom",
7550 sideOffset = 0,
7551 align = "center",
7552 alignOffset = 0,
7553 collisionBoundary,
7554 collisionPadding: collisionPaddingParam = 5,
7555 sticky = false,
7556 arrowPadding = 5,
7557 disableAnchorTracking = false,
7558 // Private parameters
7559 keepMounted = false,
7560 floatingRootContext,
7561 mounted,
7562 collisionAvoidance,
7563 shiftCrossAxis = false,
7564 nodeId,
7565 adaptiveOrigin: adaptiveOrigin2,
7566 lazyFlip = false,
7567 externalTree
7568 } = params;
7569 const [mountSide, setMountSide] = React31.useState(null);
7570 if (!mounted && mountSide !== null) {
7571 setMountSide(null);
7572 }
7573 const collisionAvoidanceSide = collisionAvoidance.side || "flip";
7574 const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
7575 const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
7576 const anchorFn = typeof anchor === "function" ? anchor : void 0;
7577 const anchorFnCallback = useStableCallback(anchorFn);
7578 const anchorDep = anchorFn ? anchorFnCallback : anchor;
7579 const anchorValueRef = useValueAsRef(anchor);
7580 const mountedRef = useValueAsRef(mounted);
7581 const direction = useDirection();
7582 const isRtl = direction === "rtl";
7583 const side = mountSide || {
7584 top: "top",
7585 right: "right",
7586 bottom: "bottom",
7587 left: "left",
7588 "inline-end": isRtl ? "left" : "right",
7589 "inline-start": isRtl ? "right" : "left"
7590 }[sideParam];
7591 const placement = align === "center" ? side : `${side}-${align}`;
7592 let collisionPadding = collisionPaddingParam;
7593 const bias = 1;
7594 const biasTop = sideParam === "bottom" ? bias : 0;
7595 const biasBottom = sideParam === "top" ? bias : 0;
7596 const biasLeft = sideParam === "right" ? bias : 0;
7597 const biasRight = sideParam === "left" ? bias : 0;
7598 if (typeof collisionPadding === "number") {
7599 collisionPadding = {
7600 top: collisionPadding + biasTop,
7601 right: collisionPadding + biasRight,
7602 bottom: collisionPadding + biasBottom,
7603 left: collisionPadding + biasLeft
7604 };
7605 } else if (collisionPadding) {
7606 collisionPadding = {
7607 top: (collisionPadding.top || 0) + biasTop,
7608 right: (collisionPadding.right || 0) + biasRight,
7609 bottom: (collisionPadding.bottom || 0) + biasBottom,
7610 left: (collisionPadding.left || 0) + biasLeft
7611 };
7612 }
7613 const commonCollisionProps = {
7614 boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
7615 padding: collisionPadding
7616 };
7617 const arrowRef = React31.useRef(null);
7618 const sideOffsetRef = useValueAsRef(sideOffset);
7619 const alignOffsetRef = useValueAsRef(alignOffset);
7620 const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
7621 const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
7622 const middleware = [offset3((state) => {
7623 const data = getOffsetData(state, sideParam, isRtl);
7624 const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
7625 const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
7626 return {
7627 mainAxis: sideAxis,
7628 crossAxis: alignAxis,
7629 alignmentAxis: alignAxis
7630 };
7631 }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam])];
7632 const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
7633 const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
7634 const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
7635 ...commonCollisionProps,
7636 // Ensure the popup flips if it's been limited by its --available-height and it resizes.
7637 // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
7638 padding: {
7639 top: collisionPadding.top + bias,
7640 right: collisionPadding.right + bias,
7641 bottom: collisionPadding.bottom + bias,
7642 left: collisionPadding.left + bias
7643 },
7644 mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
7645 crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
7646 fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
7647 });
7648 const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
7649 const html = ownerDocument(data.elements.floating).documentElement;
7650 return {
7651 ...commonCollisionProps,
7652 // Use the Layout Viewport to avoid shifting around when pinch-zooming
7653 // for context menus.
7654 rootBoundary: shiftCrossAxis ? {
7655 x: 0,
7656 y: 0,
7657 width: html.clientWidth,
7658 height: html.clientHeight
7659 } : void 0,
7660 mainAxis: collisionAvoidanceAlign !== "none",
7661 crossAxis: crossAxisShiftEnabled,
7662 limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
7663 if (!arrowRef.current) {
7664 return {};
7665 }
7666 const {
7667 width,
7668 height
7669 } = arrowRef.current.getBoundingClientRect();
7670 const sideAxis = getSideAxis(getSide(limitData.placement));
7671 const arrowSize = sideAxis === "y" ? width : height;
7672 const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
7673 return {
7674 offset: arrowSize / 2 + offsetAmount / 2
7675 };
7676 })
7677 };
7678 }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
7679 if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
7680 middleware.push(shiftMiddleware, flipMiddleware);
7681 } else {
7682 middleware.push(flipMiddleware, shiftMiddleware);
7683 }
7684 middleware.push(size3({
7685 ...commonCollisionProps,
7686 apply({
7687 elements: {
7688 floating
7689 },
7690 availableWidth,
7691 availableHeight,
7692 rects
7693 }) {
7694 if (!mountedRef.current) {
7695 return;
7696 }
7697 const floatingStyle = floating.style;
7698 floatingStyle.setProperty("--available-width", `${availableWidth}px`);
7699 floatingStyle.setProperty("--available-height", `${availableHeight}px`);
7700 const dpr = getWindow(floating).devicePixelRatio || 1;
7701 const {
7702 x: x3,
7703 y: y3,
7704 width,
7705 height
7706 } = rects.reference;
7707 const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
7708 const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
7709 floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
7710 floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
7711 }
7712 }), arrow4(() => ({
7713 // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
7714 // we'll create a fake element.
7715 element: arrowRef.current || ownerDocument(arrowRef.current).createElement("div"),
7716 padding: arrowPadding,
7717 offsetParent: "floating"
7718 }), [arrowPadding]), {
7719 name: "transformOrigin",
7720 fn(state) {
7721 const {
7722 elements: elements2,
7723 middlewareData: middlewareData2,
7724 placement: renderedPlacement2,
7725 rects,
7726 y: y3
7727 } = state;
7728 const currentRenderedSide = getSide(renderedPlacement2);
7729 const currentRenderedAxis = getSideAxis(currentRenderedSide);
7730 const arrowEl = arrowRef.current;
7731 const arrowX = middlewareData2.arrow?.x || 0;
7732 const arrowY = middlewareData2.arrow?.y || 0;
7733 const arrowWidth = arrowEl?.clientWidth || 0;
7734 const arrowHeight = arrowEl?.clientHeight || 0;
7735 const transformX = arrowX + arrowWidth / 2;
7736 const transformY = arrowY + arrowHeight / 2;
7737 const shiftY = Math.abs(middlewareData2.shift?.y || 0);
7738 const halfAnchorHeight = rects.reference.height / 2;
7739 const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
7740 const isOverlappingAnchor = shiftY > sideOffsetValue;
7741 const adjacentTransformOrigin = {
7742 top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
7743 bottom: `${transformX}px ${-sideOffsetValue}px`,
7744 left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
7745 right: `${-sideOffsetValue}px ${transformY}px`
7746 }[currentRenderedSide];
7747 const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
7748 elements2.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
7749 return {};
7750 }
7751 }, hide4, adaptiveOrigin2);
7752 useIsoLayoutEffect(() => {
7753 if (!mounted && floatingRootContext) {
7754 floatingRootContext.update({
7755 referenceElement: null,
7756 floatingElement: null,
7757 domReferenceElement: null,
7758 positionReference: null
7759 });
7760 }
7761 }, [mounted, floatingRootContext]);
7762 const autoUpdateOptions = React31.useMemo(() => ({
7763 elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
7764 layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
7765 }), [disableAnchorTracking]);
7766 const {
7767 refs,
7768 elements,
7769 x: x2,
7770 y: y2,
7771 middlewareData,
7772 update: update2,
7773 placement: renderedPlacement,
7774 context,
7775 isPositioned,
7776 floatingStyles: originalFloatingStyles
7777 } = useFloating2({
7778 rootContext: floatingRootContext,
7779 open: keepMounted ? mounted : void 0,
7780 placement,
7781 middleware,
7782 strategy: positionMethod,
7783 whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
7784 nodeId,
7785 externalTree
7786 });
7787 const {
7788 sideX,
7789 sideY
7790 } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
7791 const resolvedPosition = isPositioned ? positionMethod : "fixed";
7792 const floatingStyles = React31.useMemo(() => {
7793 const base = adaptiveOrigin2 ? {
7794 position: resolvedPosition,
7795 [sideX]: x2,
7796 [sideY]: y2
7797 } : {
7798 position: resolvedPosition,
7799 ...originalFloatingStyles
7800 };
7801 if (!isPositioned) {
7802 base.opacity = 0;
7803 }
7804 return base;
7805 }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
7806 const registeredPositionReferenceRef = React31.useRef(null);
7807 useIsoLayoutEffect(() => {
7808 if (!mounted) {
7809 return;
7810 }
7811 const anchorValue = anchorValueRef.current;
7812 const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
7813 const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
7814 const finalAnchor = unwrappedElement || null;
7815 if (finalAnchor !== registeredPositionReferenceRef.current) {
7816 refs.setPositionReference(finalAnchor);
7817 registeredPositionReferenceRef.current = finalAnchor;
7818 }
7819 }, [mounted, refs, anchorDep, anchorValueRef]);
7820 React31.useEffect(() => {
7821 if (!mounted) {
7822 return;
7823 }
7824 const anchorValue = anchorValueRef.current;
7825 if (typeof anchorValue === "function") {
7826 return;
7827 }
7828 if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
7829 refs.setPositionReference(anchorValue.current);
7830 registeredPositionReferenceRef.current = anchorValue.current;
7831 }
7832 }, [mounted, refs, anchorDep, anchorValueRef]);
7833 React31.useEffect(() => {
7834 if (keepMounted && mounted && elements.domReference && elements.floating) {
7835 return autoUpdate(elements.domReference, elements.floating, update2, autoUpdateOptions);
7836 }
7837 return void 0;
7838 }, [keepMounted, mounted, elements, update2, autoUpdateOptions]);
7839 const renderedSide = getSide(renderedPlacement);
7840 const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
7841 const renderedAlign = getAlignment(renderedPlacement) || "center";
7842 const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
7843 useIsoLayoutEffect(() => {
7844 if (lazyFlip && mounted && isPositioned) {
7845 setMountSide(renderedSide);
7846 }
7847 }, [lazyFlip, mounted, isPositioned, renderedSide]);
7848 const arrowStyles = React31.useMemo(() => ({
7849 position: "absolute",
7850 top: middlewareData.arrow?.y,
7851 left: middlewareData.arrow?.x
7852 }), [middlewareData.arrow]);
7853 const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
7854 return React31.useMemo(() => ({
7855 positionerStyles: floatingStyles,
7856 arrowStyles,
7857 arrowRef,
7858 arrowUncentered,
7859 side: logicalRenderedSide,
7860 align: renderedAlign,
7861 physicalSide: renderedSide,
7862 anchorHidden,
7863 refs,
7864 context,
7865 isPositioned,
7866 update: update2
7867 }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
7868 }
7869 function isRef(param) {
7870 return param != null && "current" in param;
7871 }
7872
7873 // node_modules/@base-ui/react/esm/utils/getDisabledMountTransitionStyles.js
7874 function getDisabledMountTransitionStyles(transitionStatus) {
7875 return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
7876 }
7877
7878 // node_modules/@base-ui/react/esm/utils/usePositioner.js
7879 function usePositioner(componentProps, state, {
7880 styles,
7881 transitionStatus,
7882 props,
7883 refs,
7884 hidden,
7885 inert = false
7886 }) {
7887 const style = {
7888 ...styles
7889 };
7890 if (inert) {
7891 style.pointerEvents = "none";
7892 }
7893 return useRenderElement("div", componentProps, {
7894 state,
7895 ref: refs,
7896 props: [{
7897 role: "presentation",
7898 hidden,
7899 style
7900 }, getDisabledMountTransitionStyles(transitionStatus), props],
7901 stateAttributesMapping: popupStateMapping
7902 });
7903 }
7904
7905 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
7906 var React34 = __toESM(require_react(), 1);
7907 var ReactDOM5 = __toESM(require_react_dom(), 1);
7908
7909 // node_modules/@base-ui/utils/esm/usePreviousValue.js
7910 var React32 = __toESM(require_react(), 1);
7911 function usePreviousValue(value) {
7912 const [state, setState] = React32.useState({
7913 current: value,
7914 previous: null
7915 });
7916 if (value !== state.current) {
7917 setState({
7918 current: value,
7919 previous: state.current
7920 });
7921 }
7922 return state.previous;
7923 }
7924
7925 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7926 var React33 = __toESM(require_react(), 1);
7927
7928 // node_modules/@base-ui/react/esm/utils/getCssDimensions.js
7929 function getCssDimensions2(element) {
7930 const css = getComputedStyle2(element);
7931 let width = parseFloat(css.width) || 0;
7932 let height = parseFloat(css.height) || 0;
7933 const hasOffset = isHTMLElement(element);
7934 const offsetWidth = hasOffset ? element.offsetWidth : width;
7935 const offsetHeight = hasOffset ? element.offsetHeight : height;
7936 const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7937 if (shouldFallback) {
7938 width = offsetWidth;
7939 height = offsetHeight;
7940 }
7941 return {
7942 width,
7943 height
7944 };
7945 }
7946
7947 // node_modules/@base-ui/react/esm/utils/usePopupAutoResize.js
7948 var DEFAULT_ENABLED = () => true;
7949 function usePopupAutoResize(parameters) {
7950 const {
7951 popupElement,
7952 positionerElement,
7953 content,
7954 mounted,
7955 enabled = DEFAULT_ENABLED,
7956 onMeasureLayout: onMeasureLayoutParam,
7957 onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
7958 side,
7959 direction
7960 } = parameters;
7961 const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
7962 const animationFrame = useAnimationFrame();
7963 const committedDimensionsRef = React33.useRef(null);
7964 const liveDimensionsRef = React33.useRef(null);
7965 const isInitialRenderRef = React33.useRef(true);
7966 const restoreAnchoringStylesRef = React33.useRef(NOOP);
7967 const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
7968 const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
7969 const anchoringStyles = React33.useMemo(() => {
7970 let isOriginSide = side === "top";
7971 let isPhysicalLeft = side === "left";
7972 if (direction === "rtl") {
7973 isOriginSide = isOriginSide || side === "inline-end";
7974 isPhysicalLeft = isPhysicalLeft || side === "inline-end";
7975 } else {
7976 isOriginSide = isOriginSide || side === "inline-start";
7977 isPhysicalLeft = isPhysicalLeft || side === "inline-start";
7978 }
7979 return isOriginSide ? {
7980 position: "absolute",
7981 [side === "top" ? "bottom" : "top"]: "0",
7982 [isPhysicalLeft ? "right" : "left"]: "0"
7983 } : EMPTY_OBJECT;
7984 }, [side, direction]);
7985 useIsoLayoutEffect(() => {
7986 if (!mounted || !enabled() || typeof ResizeObserver !== "function") {
7987 restoreAnchoringStylesRef.current = NOOP;
7988 isInitialRenderRef.current = true;
7989 committedDimensionsRef.current = null;
7990 liveDimensionsRef.current = null;
7991 return void 0;
7992 }
7993 if (!popupElement || !positionerElement) {
7994 return void 0;
7995 }
7996 restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
7997 const observer = new ResizeObserver((entries) => {
7998 const entry = entries[0];
7999 if (entry) {
8000 liveDimensionsRef.current = {
8001 width: Math.ceil(entry.borderBoxSize[0].inlineSize),
8002 height: Math.ceil(entry.borderBoxSize[0].blockSize)
8003 };
8004 }
8005 });
8006 observer.observe(popupElement);
8007 setPopupCssSize(popupElement, "auto");
8008 const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
8009 const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
8010 const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
8011 const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
8012 "--available-width": "max-content",
8013 "--available-height": "max-content"
8014 });
8015 function restoreMeasurementOverrides() {
8016 restorePopupPosition();
8017 restorePopupTransform();
8018 restorePositionerAvailableSize();
8019 }
8020 function restoreMeasurementOverridesIncludingScale() {
8021 restoreMeasurementOverrides();
8022 restorePopupScale();
8023 }
8024 onMeasureLayout?.();
8025 if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
8026 setPositionerCssSize(positionerElement, "max-content");
8027 const dimensions = getCssDimensions2(popupElement);
8028 committedDimensionsRef.current = dimensions;
8029 setPositionerCssSize(positionerElement, dimensions);
8030 restoreMeasurementOverridesIncludingScale();
8031 onMeasureLayoutComplete?.(null, dimensions);
8032 isInitialRenderRef.current = false;
8033 return () => {
8034 observer.disconnect();
8035 restoreAnchoringStylesRef.current();
8036 restoreAnchoringStylesRef.current = NOOP;
8037 };
8038 }
8039 setPopupCssSize(popupElement, "auto");
8040 setPositionerCssSize(positionerElement, "max-content");
8041 const previousDimensions = committedDimensionsRef.current ?? liveDimensionsRef.current;
8042 const newDimensions = getCssDimensions2(popupElement);
8043 committedDimensionsRef.current = newDimensions;
8044 if (!previousDimensions) {
8045 setPositionerCssSize(positionerElement, newDimensions);
8046 restoreMeasurementOverridesIncludingScale();
8047 onMeasureLayoutComplete?.(null, newDimensions);
8048 return () => {
8049 observer.disconnect();
8050 animationFrame.cancel();
8051 restoreAnchoringStylesRef.current();
8052 restoreAnchoringStylesRef.current = NOOP;
8053 };
8054 }
8055 setPopupCssSize(popupElement, previousDimensions);
8056 restoreMeasurementOverridesIncludingScale();
8057 onMeasureLayoutComplete?.(previousDimensions, newDimensions);
8058 setPositionerCssSize(positionerElement, newDimensions);
8059 const abortController = new AbortController();
8060 animationFrame.request(() => {
8061 setPopupCssSize(popupElement, newDimensions);
8062 runOnceAnimationsFinish(() => {
8063 popupElement.style.setProperty("--popup-width", "auto");
8064 popupElement.style.setProperty("--popup-height", "auto");
8065 }, abortController.signal);
8066 });
8067 return () => {
8068 observer.disconnect();
8069 abortController.abort();
8070 animationFrame.cancel();
8071 restoreAnchoringStylesRef.current();
8072 restoreAnchoringStylesRef.current = NOOP;
8073 };
8074 }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, enabled, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
8075 }
8076 function overrideElementStyle(element, property, value) {
8077 const originalValue = element.style.getPropertyValue(property);
8078 element.style.setProperty(property, value);
8079 return () => {
8080 element.style.setProperty(property, originalValue);
8081 };
8082 }
8083 function applyElementStyles(element, styles) {
8084 const restorers = [];
8085 for (const [key, value] of Object.entries(styles)) {
8086 restorers.push(overrideElementStyle(element, key, value));
8087 }
8088 return restorers.length ? () => {
8089 restorers.forEach((restore) => restore());
8090 } : NOOP;
8091 }
8092 function setPopupCssSize(popupElement, size4) {
8093 const width = size4 === "auto" ? "auto" : `${size4.width}px`;
8094 const height = size4 === "auto" ? "auto" : `${size4.height}px`;
8095 popupElement.style.setProperty("--popup-width", width);
8096 popupElement.style.setProperty("--popup-height", height);
8097 }
8098 function setPositionerCssSize(positionerElement, size4) {
8099 const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
8100 const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
8101 positionerElement.style.setProperty("--positioner-width", width);
8102 positionerElement.style.setProperty("--positioner-height", height);
8103 }
8104
8105 // node_modules/@base-ui/react/esm/utils/usePopupViewport.js
8106 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
8107 function usePopupViewport(parameters) {
8108 const {
8109 store,
8110 side,
8111 cssVars,
8112 children
8113 } = parameters;
8114 const direction = useDirection();
8115 const activeTrigger = store.useState("activeTriggerElement");
8116 const activeTriggerId = store.useState("activeTriggerId");
8117 const open = store.useState("open");
8118 const payload = store.useState("payload");
8119 const mounted = store.useState("mounted");
8120 const popupElement = store.useState("popupElement");
8121 const positionerElement = store.useState("positionerElement");
8122 const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
8123 const currentContentKey = usePopupContentKey(activeTriggerId, payload);
8124 const capturedNodeRef = React34.useRef(null);
8125 const [previousContentNode, setPreviousContentNode] = React34.useState(null);
8126 const [newTriggerOffset, setNewTriggerOffset] = React34.useState(null);
8127 const currentContainerRef = React34.useRef(null);
8128 const previousContainerRef = React34.useRef(null);
8129 const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
8130 const cleanupFrame = useAnimationFrame();
8131 const [previousContentDimensions, setPreviousContentDimensions] = React34.useState(null);
8132 const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React34.useState(false);
8133 useIsoLayoutEffect(() => {
8134 store.set("hasViewport", true);
8135 return () => {
8136 store.set("hasViewport", false);
8137 };
8138 }, [store]);
8139 const handleMeasureLayout = useStableCallback(() => {
8140 currentContainerRef.current?.style.setProperty("animation", "none");
8141 currentContainerRef.current?.style.setProperty("transition", "none");
8142 previousContainerRef.current?.style.setProperty("display", "none");
8143 });
8144 const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
8145 currentContainerRef.current?.style.removeProperty("animation");
8146 currentContainerRef.current?.style.removeProperty("transition");
8147 previousContainerRef.current?.style.removeProperty("display");
8148 if (previousDimensions) {
8149 setPreviousContentDimensions(previousDimensions);
8150 }
8151 });
8152 const lastHandledTriggerRef = React34.useRef(null);
8153 useIsoLayoutEffect(() => {
8154 if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
8155 setPreviousContentNode(capturedNodeRef.current);
8156 setShowStartingStyleAttribute(true);
8157 const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
8158 setNewTriggerOffset(offset4);
8159 cleanupFrame.request(() => {
8160 ReactDOM5.flushSync(() => {
8161 setShowStartingStyleAttribute(false);
8162 });
8163 onAnimationsFinished(() => {
8164 setPreviousContentNode(null);
8165 setPreviousContentDimensions(null);
8166 capturedNodeRef.current = null;
8167 });
8168 });
8169 lastHandledTriggerRef.current = activeTrigger;
8170 }
8171 }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
8172 useIsoLayoutEffect(() => {
8173 const source = currentContainerRef.current;
8174 if (!source) {
8175 return;
8176 }
8177 const wrapper = ownerDocument(source).createElement("div");
8178 for (const child of Array.from(source.childNodes)) {
8179 wrapper.appendChild(child.cloneNode(true));
8180 }
8181 capturedNodeRef.current = wrapper;
8182 });
8183 const isTransitioning = previousContentNode != null;
8184 let childrenToRender;
8185 if (!isTransitioning) {
8186 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8187 "data-current": true,
8188 ref: currentContainerRef,
8189 children
8190 }, currentContentKey);
8191 } else {
8192 childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React34.Fragment, {
8193 children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8194 "data-previous": true,
8195 inert: inertValue(true),
8196 ref: previousContainerRef,
8197 style: {
8198 ...previousContentDimensions ? {
8199 [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
8200 [cssVars.popupHeight]: `${previousContentDimensions.height}px`
8201 } : null,
8202 position: "absolute"
8203 },
8204 "data-ending-style": showStartingStyleAttribute ? void 0 : ""
8205 }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
8206 "data-current": true,
8207 ref: currentContainerRef,
8208 "data-starting-style": showStartingStyleAttribute ? "" : void 0,
8209 children
8210 }, currentContentKey)]
8211 });
8212 }
8213 useIsoLayoutEffect(() => {
8214 const container = previousContainerRef.current;
8215 if (!container || !previousContentNode) {
8216 return;
8217 }
8218 container.replaceChildren(...Array.from(previousContentNode.childNodes));
8219 }, [previousContentNode]);
8220 usePopupAutoResize({
8221 popupElement,
8222 positionerElement,
8223 mounted,
8224 content: payload,
8225 onMeasureLayout: handleMeasureLayout,
8226 onMeasureLayoutComplete: handleMeasureLayoutComplete,
8227 side,
8228 direction
8229 });
8230 const state = {
8231 activationDirection: getActivationDirection(newTriggerOffset),
8232 transitioning: isTransitioning
8233 };
8234 return {
8235 children: childrenToRender,
8236 state
8237 };
8238 }
8239 function getActivationDirection(offset4) {
8240 if (!offset4) {
8241 return void 0;
8242 }
8243 return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
8244 }
8245 function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
8246 if (value > tolerance) {
8247 return positiveLabel;
8248 }
8249 if (value < -tolerance) {
8250 return negativeLabel;
8251 }
8252 return "";
8253 }
8254 function calculateRelativePosition(from, to) {
8255 const fromRect = from.getBoundingClientRect();
8256 const toRect = to.getBoundingClientRect();
8257 const fromCenter = {
8258 x: fromRect.left + fromRect.width / 2,
8259 y: fromRect.top + fromRect.height / 2
8260 };
8261 const toCenter = {
8262 x: toRect.left + toRect.width / 2,
8263 y: toRect.top + toRect.height / 2
8264 };
8265 return {
8266 horizontal: toCenter.x - fromCenter.x,
8267 vertical: toCenter.y - fromCenter.y
8268 };
8269 }
8270 function usePopupContentKey(activeTriggerId, payload) {
8271 const [contentKey, setContentKey] = React34.useState(0);
8272 const previousActiveTriggerIdRef = React34.useRef(activeTriggerId);
8273 const previousPayloadRef = React34.useRef(payload);
8274 const pendingPayloadUpdateRef = React34.useRef(false);
8275 useIsoLayoutEffect(() => {
8276 const previousActiveTriggerId = previousActiveTriggerIdRef.current;
8277 const previousPayload = previousPayloadRef.current;
8278 const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
8279 const payloadChanged = payload !== previousPayload;
8280 if (triggerIdChanged) {
8281 setContentKey((value) => value + 1);
8282 pendingPayloadUpdateRef.current = !payloadChanged;
8283 } else if (pendingPayloadUpdateRef.current && payloadChanged) {
8284 setContentKey((value) => value + 1);
8285 pendingPayloadUpdateRef.current = false;
8286 }
8287 previousActiveTriggerIdRef.current = activeTriggerId;
8288 previousPayloadRef.current = payload;
8289 }, [activeTriggerId, payload]);
8290 return `${activeTriggerId ?? "current"}-${contentKey}`;
8291 }
8292
8293 // node_modules/@base-ui/react/esm/utils/FloatingPortalLite.js
8294 var React35 = __toESM(require_react(), 1);
8295 var ReactDOM6 = __toESM(require_react_dom(), 1);
8296 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
8297 var FloatingPortalLite = /* @__PURE__ */ React35.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
8298 const {
8299 children,
8300 container,
8301 className,
8302 render: render4,
8303 style,
8304 ...elementProps
8305 } = componentProps;
8306 const {
8307 portalNode,
8308 portalSubtree
8309 } = useFloatingPortalNode({
8310 container,
8311 ref: forwardedRef,
8312 componentProps,
8313 elementProps
8314 });
8315 if (!portalSubtree && !portalNode) {
8316 return null;
8317 }
8318 return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React35.Fragment, {
8319 children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM6.createPortal(children, portalNode)]
8320 });
8321 });
8322 if (true) FloatingPortalLite.displayName = "FloatingPortalLite";
8323
8324 // node_modules/@base-ui/react/esm/tooltip/index.parts.js
8325 var index_parts_exports = {};
8326 __export(index_parts_exports, {
8327 Arrow: () => TooltipArrow,
8328 Handle: () => TooltipHandle,
8329 Popup: () => TooltipPopup,
8330 Portal: () => TooltipPortal,
8331 Positioner: () => TooltipPositioner,
8332 Provider: () => TooltipProvider,
8333 Root: () => TooltipRoot,
8334 Trigger: () => TooltipTrigger,
8335 Viewport: () => TooltipViewport,
8336 createHandle: () => createTooltipHandle
8337 });
8338
8339 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8340 var React38 = __toESM(require_react(), 1);
8341
8342 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRootContext.js
8343 var React36 = __toESM(require_react(), 1);
8344 var TooltipRootContext = /* @__PURE__ */ React36.createContext(void 0);
8345 if (true) TooltipRootContext.displayName = "TooltipRootContext";
8346 function useTooltipRootContext(optional) {
8347 const context = React36.useContext(TooltipRootContext);
8348 if (context === void 0 && !optional) {
8349 throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
8350 }
8351 return context;
8352 }
8353
8354 // node_modules/@base-ui/react/esm/tooltip/store/TooltipStore.js
8355 var React37 = __toESM(require_react(), 1);
8356 var ReactDOM7 = __toESM(require_react_dom(), 1);
8357 var selectors2 = {
8358 ...popupStoreSelectors,
8359 disabled: createSelector((state) => state.disabled),
8360 instantType: createSelector((state) => state.instantType),
8361 isInstantPhase: createSelector((state) => state.isInstantPhase),
8362 trackCursorAxis: createSelector((state) => state.trackCursorAxis),
8363 disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
8364 lastOpenChangeReason: createSelector((state) => state.openChangeReason),
8365 closeOnClick: createSelector((state) => state.closeOnClick),
8366 closeDelay: createSelector((state) => state.closeDelay),
8367 hasViewport: createSelector((state) => state.hasViewport)
8368 };
8369 var TooltipStore = class _TooltipStore extends ReactStore {
8370 constructor(initialState) {
8371 super({
8372 ...createInitialState(),
8373 ...initialState
8374 }, {
8375 popupRef: /* @__PURE__ */ React37.createRef(),
8376 onOpenChange: void 0,
8377 onOpenChangeComplete: void 0,
8378 triggerElements: new PopupTriggerMap()
8379 }, selectors2);
8380 }
8381 setOpen = (nextOpen, eventDetails) => {
8382 const reason = eventDetails.reason;
8383 const isHover = reason === reason_parts_exports.triggerHover;
8384 const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
8385 const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
8386 eventDetails.preventUnmountOnClose = () => {
8387 this.set("preventUnmountingOnClose", true);
8388 };
8389 this.context.onOpenChange?.(nextOpen, eventDetails);
8390 if (eventDetails.isCanceled) {
8391 return;
8392 }
8393 this.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
8394 const changeState = () => {
8395 const updatedState = {
8396 open: nextOpen,
8397 openChangeReason: reason
8398 };
8399 if (isFocusOpen) {
8400 updatedState.instantType = "focus";
8401 } else if (isDismissClose) {
8402 updatedState.instantType = "dismiss";
8403 } else if (reason === reason_parts_exports.triggerHover) {
8404 updatedState.instantType = void 0;
8405 }
8406 const newTriggerId = eventDetails.trigger?.id ?? null;
8407 if (newTriggerId || nextOpen) {
8408 updatedState.activeTriggerId = newTriggerId;
8409 updatedState.activeTriggerElement = eventDetails.trigger ?? null;
8410 }
8411 this.update(updatedState);
8412 };
8413 if (isHover) {
8414 ReactDOM7.flushSync(changeState);
8415 } else {
8416 changeState();
8417 }
8418 };
8419 static useStore(externalStore, initialState) {
8420 const internalStore = useRefWithInit(() => {
8421 return new _TooltipStore(initialState);
8422 }).current;
8423 const store = externalStore ?? internalStore;
8424 const floatingRootContext = useSyncedFloatingRootContext({
8425 popupStore: store,
8426 onOpenChange: store.setOpen
8427 });
8428 store.state.floatingRootContext = floatingRootContext;
8429 return store;
8430 }
8431 };
8432 function createInitialState() {
8433 return {
8434 ...createInitialPopupStoreState(),
8435 disabled: false,
8436 instantType: void 0,
8437 isInstantPhase: false,
8438 trackCursorAxis: "none",
8439 disableHoverablePopup: false,
8440 openChangeReason: null,
8441 closeOnClick: true,
8442 closeDelay: 0,
8443 hasViewport: false
8444 };
8445 }
8446
8447 // node_modules/@base-ui/react/esm/tooltip/root/TooltipRoot.js
8448 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
8449 var TooltipRoot = fastComponent(function TooltipRoot2(props) {
8450 const {
8451 disabled: disabled2 = false,
8452 defaultOpen = false,
8453 open: openProp,
8454 disableHoverablePopup = false,
8455 trackCursorAxis = "none",
8456 actionsRef,
8457 onOpenChange,
8458 onOpenChangeComplete,
8459 handle,
8460 triggerId: triggerIdProp,
8461 defaultTriggerId: defaultTriggerIdProp = null,
8462 children
8463 } = props;
8464 const store = TooltipStore.useStore(handle?.store, {
8465 open: defaultOpen,
8466 openProp,
8467 activeTriggerId: defaultTriggerIdProp,
8468 triggerIdProp
8469 });
8470 useOnFirstRender(() => {
8471 if (openProp === void 0 && store.state.open === false && defaultOpen === true) {
8472 store.update({
8473 open: true,
8474 activeTriggerId: defaultTriggerIdProp
8475 });
8476 }
8477 });
8478 store.useControlledProp("openProp", openProp);
8479 store.useControlledProp("triggerIdProp", triggerIdProp);
8480 store.useContextCallback("onOpenChange", onOpenChange);
8481 store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
8482 const openState = store.useState("open");
8483 const open = !disabled2 && openState;
8484 const activeTriggerId = store.useState("activeTriggerId");
8485 const payload = store.useState("payload");
8486 store.useSyncedValues({
8487 trackCursorAxis,
8488 disableHoverablePopup
8489 });
8490 useIsoLayoutEffect(() => {
8491 if (openState && disabled2) {
8492 store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
8493 }
8494 }, [openState, disabled2, store]);
8495 store.useSyncedValue("disabled", disabled2);
8496 useImplicitActiveTrigger(store);
8497 const {
8498 forceUnmount,
8499 transitionStatus
8500 } = useOpenStateTransitions(open, store);
8501 const floatingRootContext = store.select("floatingRootContext");
8502 const isInstantPhase = store.useState("isInstantPhase");
8503 const instantType = store.useState("instantType");
8504 const lastOpenChangeReason = store.useState("lastOpenChangeReason");
8505 const previousInstantTypeRef = React38.useRef(null);
8506 useIsoLayoutEffect(() => {
8507 if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
8508 if (instantType !== "delay") {
8509 previousInstantTypeRef.current = instantType;
8510 }
8511 store.set("instantType", "delay");
8512 } else if (previousInstantTypeRef.current !== null) {
8513 store.set("instantType", previousInstantTypeRef.current);
8514 previousInstantTypeRef.current = null;
8515 }
8516 }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
8517 useIsoLayoutEffect(() => {
8518 if (open) {
8519 if (activeTriggerId == null) {
8520 store.set("payload", void 0);
8521 }
8522 }
8523 }, [store, activeTriggerId, open]);
8524 const handleImperativeClose = React38.useCallback(() => {
8525 store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
8526 }, [store]);
8527 React38.useImperativeHandle(actionsRef, () => ({
8528 unmount: forceUnmount,
8529 close: handleImperativeClose
8530 }), [forceUnmount, handleImperativeClose]);
8531 const dismiss = useDismiss(floatingRootContext, {
8532 enabled: !disabled2,
8533 referencePress: () => store.select("closeOnClick")
8534 });
8535 const clientPoint = useClientPoint(floatingRootContext, {
8536 enabled: !disabled2 && trackCursorAxis !== "none",
8537 axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
8538 });
8539 const {
8540 getReferenceProps,
8541 getFloatingProps,
8542 getTriggerProps
8543 } = useInteractions([dismiss, clientPoint]);
8544 const activeTriggerProps = React38.useMemo(() => getReferenceProps(), [getReferenceProps]);
8545 const inactiveTriggerProps = React38.useMemo(() => getTriggerProps(), [getTriggerProps]);
8546 const popupProps = React38.useMemo(() => getFloatingProps(), [getFloatingProps]);
8547 store.useSyncedValues({
8548 activeTriggerProps,
8549 inactiveTriggerProps,
8550 popupProps
8551 });
8552 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipRootContext.Provider, {
8553 value: store,
8554 children: typeof children === "function" ? children({
8555 payload
8556 }) : children
8557 });
8558 });
8559 if (true) TooltipRoot.displayName = "TooltipRoot";
8560
8561 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8562 var React40 = __toESM(require_react(), 1);
8563
8564 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProviderContext.js
8565 var React39 = __toESM(require_react(), 1);
8566 var TooltipProviderContext = /* @__PURE__ */ React39.createContext(void 0);
8567 if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
8568 function useTooltipProviderContext() {
8569 return React39.useContext(TooltipProviderContext);
8570 }
8571
8572 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTriggerDataAttributes.js
8573 var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
8574 TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
8575 TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
8576 return TooltipTriggerDataAttributes2;
8577 })({});
8578
8579 // node_modules/@base-ui/react/esm/tooltip/utils/constants.js
8580 var OPEN_DELAY = 600;
8581
8582 // node_modules/@base-ui/react/esm/tooltip/trigger/TooltipTrigger.js
8583 var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
8584 const {
8585 className,
8586 render: render4,
8587 handle,
8588 payload,
8589 disabled: disabledProp,
8590 delay,
8591 closeOnClick = true,
8592 closeDelay,
8593 id: idProp,
8594 style,
8595 ...elementProps
8596 } = componentProps;
8597 const rootContext = useTooltipRootContext(true);
8598 const store = handle?.store ?? rootContext;
8599 if (!store) {
8600 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));
8601 }
8602 const thisTriggerId = useBaseUiId(idProp);
8603 const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
8604 const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
8605 const floatingRootContext = store.useState("floatingRootContext");
8606 const triggerElementRef = React40.useRef(null);
8607 const delayWithDefault = delay ?? OPEN_DELAY;
8608 const closeDelayWithDefault = closeDelay ?? 0;
8609 const {
8610 registerTrigger,
8611 isMountedByThisTrigger
8612 } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
8613 payload,
8614 closeOnClick,
8615 closeDelay: closeDelayWithDefault
8616 });
8617 const providerContext = useTooltipProviderContext();
8618 const {
8619 delayRef,
8620 isInstantPhase,
8621 hasProvider
8622 } = useDelayGroup(floatingRootContext, {
8623 open: isOpenedByThisTrigger
8624 });
8625 store.useSyncedValue("isInstantPhase", isInstantPhase);
8626 const rootDisabled = store.useState("disabled");
8627 const disabled2 = disabledProp ?? rootDisabled;
8628 const trackCursorAxis = store.useState("trackCursorAxis");
8629 const disableHoverablePopup = store.useState("disableHoverablePopup");
8630 const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
8631 enabled: !disabled2,
8632 mouseOnly: true,
8633 move: false,
8634 handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
8635 restMs() {
8636 const providerDelay = providerContext?.delay;
8637 const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
8638 let computedRestMs = delayWithDefault;
8639 if (hasProvider) {
8640 if (groupOpenValue !== 0) {
8641 computedRestMs = delay ?? providerDelay ?? delayWithDefault;
8642 } else {
8643 computedRestMs = 0;
8644 }
8645 }
8646 return computedRestMs;
8647 },
8648 delay() {
8649 const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
8650 let computedCloseDelay = closeDelayWithDefault;
8651 if (closeDelay == null && hasProvider) {
8652 computedCloseDelay = closeValue;
8653 }
8654 return {
8655 close: computedCloseDelay
8656 };
8657 },
8658 triggerElementRef,
8659 isActiveTrigger: isTriggerActive,
8660 isClosing: () => store.select("transitionStatus") === "ending"
8661 });
8662 const focusProps = useFocus(floatingRootContext, {
8663 enabled: !disabled2
8664 }).reference;
8665 const state = {
8666 open: isOpenedByThisTrigger
8667 };
8668 const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
8669 const element = useRenderElement("button", componentProps, {
8670 state,
8671 ref: [forwardedRef, registerTrigger, triggerElementRef],
8672 props: [hoverProps, focusProps, rootTriggerProps, {
8673 onPointerDown() {
8674 store.set("closeOnClick", closeOnClick);
8675 },
8676 id: thisTriggerId,
8677 [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0
8678 }, elementProps],
8679 stateAttributesMapping: triggerOpenStateMapping
8680 });
8681 return element;
8682 });
8683 if (true) TooltipTrigger.displayName = "TooltipTrigger";
8684
8685 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8686 var React42 = __toESM(require_react(), 1);
8687
8688 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortalContext.js
8689 var React41 = __toESM(require_react(), 1);
8690 var TooltipPortalContext = /* @__PURE__ */ React41.createContext(void 0);
8691 if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
8692 function useTooltipPortalContext() {
8693 const value = React41.useContext(TooltipPortalContext);
8694 if (value === void 0) {
8695 throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
8696 }
8697 return value;
8698 }
8699
8700 // node_modules/@base-ui/react/esm/tooltip/portal/TooltipPortal.js
8701 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
8702 var TooltipPortal = /* @__PURE__ */ React42.forwardRef(function TooltipPortal2(props, forwardedRef) {
8703 const {
8704 keepMounted = false,
8705 ...portalProps
8706 } = props;
8707 const store = useTooltipRootContext();
8708 const mounted = store.useState("mounted");
8709 const shouldRender = mounted || keepMounted;
8710 if (!shouldRender) {
8711 return null;
8712 }
8713 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
8714 value: keepMounted,
8715 children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
8716 ref: forwardedRef,
8717 ...portalProps
8718 })
8719 });
8720 });
8721 if (true) TooltipPortal.displayName = "TooltipPortal";
8722
8723 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8724 var React44 = __toESM(require_react(), 1);
8725
8726 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositionerContext.js
8727 var React43 = __toESM(require_react(), 1);
8728 var TooltipPositionerContext = /* @__PURE__ */ React43.createContext(void 0);
8729 if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
8730 function useTooltipPositionerContext() {
8731 const context = React43.useContext(TooltipPositionerContext);
8732 if (context === void 0) {
8733 throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
8734 }
8735 return context;
8736 }
8737
8738 // node_modules/@base-ui/react/esm/tooltip/positioner/TooltipPositioner.js
8739 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
8740 var TooltipPositioner = /* @__PURE__ */ React44.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
8741 const {
8742 render: render4,
8743 className,
8744 anchor,
8745 positionMethod = "absolute",
8746 side = "top",
8747 align = "center",
8748 sideOffset = 0,
8749 alignOffset = 0,
8750 collisionBoundary = "clipping-ancestors",
8751 collisionPadding = 5,
8752 arrowPadding = 5,
8753 sticky = false,
8754 disableAnchorTracking = false,
8755 collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
8756 style,
8757 ...elementProps
8758 } = componentProps;
8759 const store = useTooltipRootContext();
8760 const keepMounted = useTooltipPortalContext();
8761 const open = store.useState("open");
8762 const mounted = store.useState("mounted");
8763 const trackCursorAxis = store.useState("trackCursorAxis");
8764 const disableHoverablePopup = store.useState("disableHoverablePopup");
8765 const floatingRootContext = store.useState("floatingRootContext");
8766 const instantType = store.useState("instantType");
8767 const transitionStatus = store.useState("transitionStatus");
8768 const hasViewport = store.useState("hasViewport");
8769 const positioning = useAnchorPositioning({
8770 anchor,
8771 positionMethod,
8772 floatingRootContext,
8773 mounted,
8774 side,
8775 sideOffset,
8776 align,
8777 alignOffset,
8778 collisionBoundary,
8779 collisionPadding,
8780 sticky,
8781 arrowPadding,
8782 disableAnchorTracking,
8783 keepMounted,
8784 collisionAvoidance,
8785 adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
8786 });
8787 const state = React44.useMemo(() => ({
8788 open,
8789 side: positioning.side,
8790 align: positioning.align,
8791 anchorHidden: positioning.anchorHidden,
8792 instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
8793 }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
8794 const element = usePositioner(componentProps, state, {
8795 styles: positioning.positionerStyles,
8796 transitionStatus,
8797 props: elementProps,
8798 refs: [forwardedRef, store.useStateSetter("positionerElement")],
8799 hidden: !mounted,
8800 inert: !open || trackCursorAxis === "both" || disableHoverablePopup
8801 });
8802 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
8803 value: positioning,
8804 children: element
8805 });
8806 });
8807 if (true) TooltipPositioner.displayName = "TooltipPositioner";
8808
8809 // node_modules/@base-ui/react/esm/tooltip/popup/TooltipPopup.js
8810 var React45 = __toESM(require_react(), 1);
8811 var stateAttributesMapping = {
8812 ...popupStateMapping,
8813 ...transitionStatusMapping
8814 };
8815 var TooltipPopup = /* @__PURE__ */ React45.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
8816 const {
8817 className,
8818 render: render4,
8819 style,
8820 ...elementProps
8821 } = componentProps;
8822 const store = useTooltipRootContext();
8823 const {
8824 side,
8825 align
8826 } = useTooltipPositionerContext();
8827 const open = store.useState("open");
8828 const instantType = store.useState("instantType");
8829 const transitionStatus = store.useState("transitionStatus");
8830 const popupProps = store.useState("popupProps");
8831 const floatingContext = store.useState("floatingRootContext");
8832 useOpenChangeComplete({
8833 open,
8834 ref: store.context.popupRef,
8835 onComplete() {
8836 if (open) {
8837 store.context.onOpenChangeComplete?.(true);
8838 }
8839 }
8840 });
8841 const disabled2 = store.useState("disabled");
8842 const closeDelay = store.useState("closeDelay");
8843 useHoverFloatingInteraction(floatingContext, {
8844 enabled: !disabled2,
8845 closeDelay
8846 });
8847 const state = {
8848 open,
8849 side,
8850 align,
8851 instant: instantType,
8852 transitionStatus
8853 };
8854 const element = useRenderElement("div", componentProps, {
8855 state,
8856 ref: [forwardedRef, store.context.popupRef, store.useStateSetter("popupElement")],
8857 props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
8858 stateAttributesMapping
8859 });
8860 return element;
8861 });
8862 if (true) TooltipPopup.displayName = "TooltipPopup";
8863
8864 // node_modules/@base-ui/react/esm/tooltip/arrow/TooltipArrow.js
8865 var React46 = __toESM(require_react(), 1);
8866 var TooltipArrow = /* @__PURE__ */ React46.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
8867 const {
8868 className,
8869 render: render4,
8870 style,
8871 ...elementProps
8872 } = componentProps;
8873 const store = useTooltipRootContext();
8874 const open = store.useState("open");
8875 const instantType = store.useState("instantType");
8876 const {
8877 arrowRef,
8878 side,
8879 align,
8880 arrowUncentered,
8881 arrowStyles
8882 } = useTooltipPositionerContext();
8883 const state = {
8884 open,
8885 side,
8886 align,
8887 uncentered: arrowUncentered,
8888 instant: instantType
8889 };
8890 const element = useRenderElement("div", componentProps, {
8891 state,
8892 ref: [forwardedRef, arrowRef],
8893 props: [{
8894 style: arrowStyles,
8895 "aria-hidden": true
8896 }, elementProps],
8897 stateAttributesMapping: popupStateMapping
8898 });
8899 return element;
8900 });
8901 if (true) TooltipArrow.displayName = "TooltipArrow";
8902
8903 // node_modules/@base-ui/react/esm/tooltip/provider/TooltipProvider.js
8904 var React47 = __toESM(require_react(), 1);
8905 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
8906 var TooltipProvider = function TooltipProvider2(props) {
8907 const {
8908 delay,
8909 closeDelay,
8910 timeout = 400
8911 } = props;
8912 const contextValue = React47.useMemo(() => ({
8913 delay,
8914 closeDelay
8915 }), [delay, closeDelay]);
8916 const delayValue = React47.useMemo(() => ({
8917 open: delay,
8918 close: closeDelay
8919 }), [delay, closeDelay]);
8920 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
8921 value: contextValue,
8922 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
8923 delay: delayValue,
8924 timeoutMs: timeout,
8925 children: props.children
8926 })
8927 });
8928 };
8929 if (true) TooltipProvider.displayName = "TooltipProvider";
8930
8931 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8932 var React48 = __toESM(require_react(), 1);
8933
8934 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewportCssVars.js
8935 var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
8936 TooltipViewportCssVars2["popupWidth"] = "--popup-width";
8937 TooltipViewportCssVars2["popupHeight"] = "--popup-height";
8938 return TooltipViewportCssVars2;
8939 })({});
8940
8941 // node_modules/@base-ui/react/esm/tooltip/viewport/TooltipViewport.js
8942 var stateAttributesMapping2 = {
8943 activationDirection: (value) => value ? {
8944 "data-activation-direction": value
8945 } : null
8946 };
8947 var TooltipViewport = /* @__PURE__ */ React48.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
8948 const {
8949 render: render4,
8950 className,
8951 style,
8952 children,
8953 ...elementProps
8954 } = componentProps;
8955 const store = useTooltipRootContext();
8956 const positioner = useTooltipPositionerContext();
8957 const instantType = store.useState("instantType");
8958 const {
8959 children: childrenToRender,
8960 state: viewportState
8961 } = usePopupViewport({
8962 store,
8963 side: positioner.side,
8964 cssVars: TooltipViewportCssVars,
8965 children
8966 });
8967 const state = {
8968 activationDirection: viewportState.activationDirection,
8969 transitioning: viewportState.transitioning,
8970 instant: instantType
8971 };
8972 return useRenderElement("div", componentProps, {
8973 state,
8974 ref: forwardedRef,
8975 props: [elementProps, {
8976 children: childrenToRender
8977 }],
8978 stateAttributesMapping: stateAttributesMapping2
8979 });
8980 });
8981 if (true) TooltipViewport.displayName = "TooltipViewport";
8982
8983 // node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
8984 var TooltipHandle = class {
8985 /**
8986 * Internal store holding the tooltip state.
8987 * @internal
8988 */
8989 constructor() {
8990 this.store = new TooltipStore();
8991 }
8992 /**
8993 * Opens the tooltip and associates it with the trigger with the given ID.
8994 * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
8995 *
8996 * This method should only be called in an event handler or an effect (not during rendering).
8997 *
8998 * @param triggerId ID of the trigger to associate with the tooltip.
8999 */
9000 open(triggerId) {
9001 const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
9002 if (triggerId && !triggerElement) {
9003 throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
9004 }
9005 this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
9006 }
9007 /**
9008 * Closes the tooltip.
9009 */
9010 close() {
9011 this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
9012 }
9013 /**
9014 * Indicates whether the tooltip is currently open.
9015 */
9016 get isOpen() {
9017 return this.store.state.open;
9018 }
9019 };
9020 function createTooltipHandle() {
9021 return new TooltipHandle();
9022 }
9023
9024 // node_modules/@base-ui/react/esm/use-render/useRender.js
9025 function useRender(params) {
9026 return useRenderElement(params.defaultTagName ?? "div", params, params);
9027 }
9028
9029 // packages/ui/build-module/text/text.mjs
9030 var import_element9 = __toESM(require_element(), 1);
9031 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
9032 function getRuntime() {
9033 const globalScope = globalThis;
9034 if (globalScope.__wpStyleRuntime) {
9035 return globalScope.__wpStyleRuntime;
9036 }
9037 globalScope.__wpStyleRuntime = {
9038 documents: /* @__PURE__ */ new Map(),
9039 styles: /* @__PURE__ */ new Map(),
9040 injectedStyles: /* @__PURE__ */ new WeakMap()
9041 };
9042 if (typeof document !== "undefined") {
9043 registerDocument(document);
9044 }
9045 return globalScope.__wpStyleRuntime;
9046 }
9047 function documentContainsStyleHash(targetDocument, hash) {
9048 if (!targetDocument.head) {
9049 return false;
9050 }
9051 for (const style of targetDocument.head.querySelectorAll(
9052 `style[${STYLE_HASH_ATTRIBUTE}]`
9053 )) {
9054 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
9055 return true;
9056 }
9057 }
9058 return false;
9059 }
9060 function injectStyle(targetDocument, hash, css) {
9061 if (!targetDocument.head) {
9062 return;
9063 }
9064 const runtime = getRuntime();
9065 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9066 if (!injectedStyles) {
9067 injectedStyles = /* @__PURE__ */ new Set();
9068 runtime.injectedStyles.set(targetDocument, injectedStyles);
9069 }
9070 if (injectedStyles.has(hash)) {
9071 return;
9072 }
9073 if (documentContainsStyleHash(targetDocument, hash)) {
9074 injectedStyles.add(hash);
9075 return;
9076 }
9077 const style = targetDocument.createElement("style");
9078 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
9079 style.appendChild(targetDocument.createTextNode(css));
9080 targetDocument.head.appendChild(style);
9081 injectedStyles.add(hash);
9082 }
9083 function registerDocument(targetDocument) {
9084 const runtime = getRuntime();
9085 runtime.documents.set(
9086 targetDocument,
9087 (runtime.documents.get(targetDocument) ?? 0) + 1
9088 );
9089 for (const [hash, css] of runtime.styles) {
9090 injectStyle(targetDocument, hash, css);
9091 }
9092 return () => {
9093 const count = runtime.documents.get(targetDocument);
9094 if (count === void 0) {
9095 return;
9096 }
9097 if (count <= 1) {
9098 runtime.documents.delete(targetDocument);
9099 return;
9100 }
9101 runtime.documents.set(targetDocument, count - 1);
9102 };
9103 }
9104 function registerStyle(hash, css) {
9105 const runtime = getRuntime();
9106 runtime.styles.set(hash, css);
9107 for (const targetDocument of runtime.documents.keys()) {
9108 injectStyle(targetDocument, hash, css);
9109 }
9110 }
9111 if (typeof process === "undefined" || true) {
9112 registerStyle("0c8601dd83", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}');
9113 }
9114 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" };
9115 if (typeof process === "undefined" || true) {
9116 registerStyle("1fb29d3a3c", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}");
9117 }
9118 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" };
9119 var Text = (0, import_element9.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
9120 const element = useRender({
9121 render: render4,
9122 defaultTagName: "span",
9123 ref,
9124 props: mergeProps(props, {
9125 className: clsx_default(
9126 style_default.text,
9127 global_css_defense_default.heading,
9128 global_css_defense_default.p,
9129 style_default[variant],
9130 className
9131 )
9132 })
9133 });
9134 return element;
9135 });
9136
9137 // packages/icons/build-module/library/arrow-down.mjs
9138 var import_primitives = __toESM(require_primitives(), 1);
9139 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
9140 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" }) });
9141
9142 // packages/icons/build-module/library/arrow-left.mjs
9143 var import_primitives2 = __toESM(require_primitives(), 1);
9144 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
9145 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" }) });
9146
9147 // packages/icons/build-module/library/arrow-right.mjs
9148 var import_primitives3 = __toESM(require_primitives(), 1);
9149 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
9150 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" }) });
9151
9152 // packages/icons/build-module/library/arrow-up.mjs
9153 var import_primitives4 = __toESM(require_primitives(), 1);
9154 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
9155 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" }) });
9156
9157 // packages/icons/build-module/library/block-table.mjs
9158 var import_primitives5 = __toESM(require_primitives(), 1);
9159 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
9160 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" }) });
9161
9162 // packages/icons/build-module/library/category.mjs
9163 var import_primitives6 = __toESM(require_primitives(), 1);
9164 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
9165 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" }) });
9166
9167 // packages/icons/build-module/library/check.mjs
9168 var import_primitives7 = __toESM(require_primitives(), 1);
9169 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
9170 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" }) });
9171
9172 // packages/icons/build-module/library/close-small.mjs
9173 var import_primitives8 = __toESM(require_primitives(), 1);
9174 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
9175 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" }) });
9176
9177 // packages/icons/build-module/library/cog.mjs
9178 var import_primitives9 = __toESM(require_primitives(), 1);
9179 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
9180 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" }) });
9181
9182 // packages/icons/build-module/library/envelope.mjs
9183 var import_primitives10 = __toESM(require_primitives(), 1);
9184 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
9185 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" }) });
9186
9187 // packages/icons/build-module/library/error.mjs
9188 var import_primitives11 = __toESM(require_primitives(), 1);
9189 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
9190 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" }) });
9191
9192 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
9193 var import_primitives12 = __toESM(require_primitives(), 1);
9194 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
9195 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" }) });
9196
9197 // packages/icons/build-module/library/format-list-bullets.mjs
9198 var import_primitives13 = __toESM(require_primitives(), 1);
9199 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
9200 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" }) });
9201
9202 // packages/icons/build-module/library/funnel.mjs
9203 var import_primitives14 = __toESM(require_primitives(), 1);
9204 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
9205 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" }) });
9206
9207 // packages/icons/build-module/library/link.mjs
9208 var import_primitives15 = __toESM(require_primitives(), 1);
9209 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
9210 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" }) });
9211
9212 // packages/icons/build-module/library/mobile.mjs
9213 var import_primitives16 = __toESM(require_primitives(), 1);
9214 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
9215 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" }) });
9216
9217 // packages/icons/build-module/library/more-vertical.mjs
9218 var import_primitives17 = __toESM(require_primitives(), 1);
9219 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
9220 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" }) });
9221
9222 // packages/icons/build-module/library/next.mjs
9223 var import_primitives18 = __toESM(require_primitives(), 1);
9224 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
9225 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" }) });
9226
9227 // packages/icons/build-module/library/previous.mjs
9228 var import_primitives19 = __toESM(require_primitives(), 1);
9229 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
9230 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" }) });
9231
9232 // packages/icons/build-module/library/scheduled.mjs
9233 var import_primitives20 = __toESM(require_primitives(), 1);
9234 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
9235 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" }) });
9236
9237 // packages/icons/build-module/library/search.mjs
9238 var import_primitives21 = __toESM(require_primitives(), 1);
9239 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
9240 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" }) });
9241
9242 // packages/icons/build-module/library/seen.mjs
9243 var import_primitives22 = __toESM(require_primitives(), 1);
9244 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
9245 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" }) });
9246
9247 // packages/icons/build-module/library/unseen.mjs
9248 var import_primitives23 = __toESM(require_primitives(), 1);
9249 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
9250 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" }) });
9251
9252 // packages/ui/build-module/utils/render-slot-with-children.mjs
9253 var import_element10 = __toESM(require_element(), 1);
9254 function renderSlotWithChildren(slot, defaultSlot, children) {
9255 return (0, import_element10.cloneElement)(slot ?? defaultSlot, { children });
9256 }
9257
9258 // packages/ui/build-module/lock-unlock.mjs
9259 var import_private_apis2 = __toESM(require_private_apis(), 1);
9260 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
9261 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
9262 "@wordpress/ui"
9263 );
9264
9265 // packages/ui/build-module/stack/stack.mjs
9266 var import_element11 = __toESM(require_element(), 1);
9267 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
9268 function getRuntime2() {
9269 const globalScope = globalThis;
9270 if (globalScope.__wpStyleRuntime) {
9271 return globalScope.__wpStyleRuntime;
9272 }
9273 globalScope.__wpStyleRuntime = {
9274 documents: /* @__PURE__ */ new Map(),
9275 styles: /* @__PURE__ */ new Map(),
9276 injectedStyles: /* @__PURE__ */ new WeakMap()
9277 };
9278 if (typeof document !== "undefined") {
9279 registerDocument2(document);
9280 }
9281 return globalScope.__wpStyleRuntime;
9282 }
9283 function documentContainsStyleHash2(targetDocument, hash) {
9284 if (!targetDocument.head) {
9285 return false;
9286 }
9287 for (const style of targetDocument.head.querySelectorAll(
9288 `style[${STYLE_HASH_ATTRIBUTE2}]`
9289 )) {
9290 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
9291 return true;
9292 }
9293 }
9294 return false;
9295 }
9296 function injectStyle2(targetDocument, hash, css) {
9297 if (!targetDocument.head) {
9298 return;
9299 }
9300 const runtime = getRuntime2();
9301 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9302 if (!injectedStyles) {
9303 injectedStyles = /* @__PURE__ */ new Set();
9304 runtime.injectedStyles.set(targetDocument, injectedStyles);
9305 }
9306 if (injectedStyles.has(hash)) {
9307 return;
9308 }
9309 if (documentContainsStyleHash2(targetDocument, hash)) {
9310 injectedStyles.add(hash);
9311 return;
9312 }
9313 const style = targetDocument.createElement("style");
9314 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
9315 style.appendChild(targetDocument.createTextNode(css));
9316 targetDocument.head.appendChild(style);
9317 injectedStyles.add(hash);
9318 }
9319 function registerDocument2(targetDocument) {
9320 const runtime = getRuntime2();
9321 runtime.documents.set(
9322 targetDocument,
9323 (runtime.documents.get(targetDocument) ?? 0) + 1
9324 );
9325 for (const [hash, css] of runtime.styles) {
9326 injectStyle2(targetDocument, hash, css);
9327 }
9328 return () => {
9329 const count = runtime.documents.get(targetDocument);
9330 if (count === void 0) {
9331 return;
9332 }
9333 if (count <= 1) {
9334 runtime.documents.delete(targetDocument);
9335 return;
9336 }
9337 runtime.documents.set(targetDocument, count - 1);
9338 };
9339 }
9340 function registerStyle2(hash, css) {
9341 const runtime = getRuntime2();
9342 runtime.styles.set(hash, css);
9343 for (const targetDocument of runtime.documents.keys()) {
9344 injectStyle2(targetDocument, hash, css);
9345 }
9346 }
9347 if (typeof process === "undefined" || true) {
9348 registerStyle2("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
9349 }
9350 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
9351 var gapTokens = {
9352 xs: "var(--wpds-dimension-gap-xs, 4px)",
9353 sm: "var(--wpds-dimension-gap-sm, 8px)",
9354 md: "var(--wpds-dimension-gap-md, 12px)",
9355 lg: "var(--wpds-dimension-gap-lg, 16px)",
9356 xl: "var(--wpds-dimension-gap-xl, 24px)",
9357 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
9358 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
9359 };
9360 var Stack = (0, import_element11.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
9361 const style = {
9362 gap: gap && gapTokens[gap],
9363 alignItems: align,
9364 justifyContent: justify,
9365 flexDirection: direction,
9366 flexWrap: wrap
9367 };
9368 const element = useRender({
9369 render: render4,
9370 ref,
9371 props: mergeProps(props, { style, className: style_default2.stack })
9372 });
9373 return element;
9374 });
9375
9376 // packages/ui/build-module/tooltip/index.mjs
9377 var tooltip_exports = {};
9378 __export(tooltip_exports, {
9379 Popup: () => Popup,
9380 Portal: () => Portal,
9381 Positioner: () => Positioner,
9382 Provider: () => Provider,
9383 Root: () => Root,
9384 Trigger: () => Trigger
9385 });
9386
9387 // packages/ui/build-module/tooltip/popup.mjs
9388 var import_element14 = __toESM(require_element(), 1);
9389 var import_theme = __toESM(require_theme(), 1);
9390
9391 // packages/ui/build-module/tooltip/portal.mjs
9392 var import_element12 = __toESM(require_element(), 1);
9393
9394 // packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
9395 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
9396 function getRuntime3() {
9397 const globalScope = globalThis;
9398 if (globalScope.__wpStyleRuntime) {
9399 return globalScope.__wpStyleRuntime;
9400 }
9401 globalScope.__wpStyleRuntime = {
9402 documents: /* @__PURE__ */ new Map(),
9403 styles: /* @__PURE__ */ new Map(),
9404 injectedStyles: /* @__PURE__ */ new WeakMap()
9405 };
9406 if (typeof document !== "undefined") {
9407 registerDocument3(document);
9408 }
9409 return globalScope.__wpStyleRuntime;
9410 }
9411 function documentContainsStyleHash3(targetDocument, hash) {
9412 if (!targetDocument.head) {
9413 return false;
9414 }
9415 for (const style of targetDocument.head.querySelectorAll(
9416 `style[${STYLE_HASH_ATTRIBUTE3}]`
9417 )) {
9418 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
9419 return true;
9420 }
9421 }
9422 return false;
9423 }
9424 function injectStyle3(targetDocument, hash, css) {
9425 if (!targetDocument.head) {
9426 return;
9427 }
9428 const runtime = getRuntime3();
9429 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9430 if (!injectedStyles) {
9431 injectedStyles = /* @__PURE__ */ new Set();
9432 runtime.injectedStyles.set(targetDocument, injectedStyles);
9433 }
9434 if (injectedStyles.has(hash)) {
9435 return;
9436 }
9437 if (documentContainsStyleHash3(targetDocument, hash)) {
9438 injectedStyles.add(hash);
9439 return;
9440 }
9441 const style = targetDocument.createElement("style");
9442 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
9443 style.appendChild(targetDocument.createTextNode(css));
9444 targetDocument.head.appendChild(style);
9445 injectedStyles.add(hash);
9446 }
9447 function registerDocument3(targetDocument) {
9448 const runtime = getRuntime3();
9449 runtime.documents.set(
9450 targetDocument,
9451 (runtime.documents.get(targetDocument) ?? 0) + 1
9452 );
9453 for (const [hash, css] of runtime.styles) {
9454 injectStyle3(targetDocument, hash, css);
9455 }
9456 return () => {
9457 const count = runtime.documents.get(targetDocument);
9458 if (count === void 0) {
9459 return;
9460 }
9461 if (count <= 1) {
9462 runtime.documents.delete(targetDocument);
9463 return;
9464 }
9465 runtime.documents.set(targetDocument, count - 1);
9466 };
9467 }
9468 function registerStyle3(hash, css) {
9469 const runtime = getRuntime3();
9470 runtime.styles.set(hash, css);
9471 for (const targetDocument of runtime.documents.keys()) {
9472 injectStyle3(targetDocument, hash, css);
9473 }
9474 }
9475 if (typeof process === "undefined" || true) {
9476 registerStyle3("45eb1fe20f", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}");
9477 }
9478 var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
9479 var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
9480 function resolveOwnerDocument() {
9481 return typeof document === "undefined" ? null : document;
9482 }
9483 function isInWordPressEnvironment() {
9484 let topWp;
9485 try {
9486 topWp = window.top?.wp;
9487 } catch {
9488 }
9489 const wp = topWp ?? window.wp;
9490 return typeof wp?.components === "object" && wp.components !== null;
9491 }
9492 var cachedSlot = null;
9493 function createSlot(ownerDocument2) {
9494 const element = ownerDocument2.createElement("div");
9495 element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
9496 if (wp_compat_overlay_slot_default.slot) {
9497 element.classList.add(wp_compat_overlay_slot_default.slot);
9498 }
9499 ownerDocument2.body.appendChild(element);
9500 return element;
9501 }
9502 function getWpCompatOverlaySlot() {
9503 if (typeof window === "undefined") {
9504 return void 0;
9505 }
9506 if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
9507 return void 0;
9508 }
9509 const ownerDocument2 = resolveOwnerDocument();
9510 if (!ownerDocument2 || !ownerDocument2.body) {
9511 return void 0;
9512 }
9513 if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
9514 return cachedSlot;
9515 }
9516 const existing = ownerDocument2.querySelector(
9517 `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
9518 );
9519 if (existing instanceof HTMLDivElement) {
9520 cachedSlot = existing;
9521 return existing;
9522 }
9523 if (cachedSlot?.isConnected) {
9524 cachedSlot.remove();
9525 }
9526 cachedSlot = createSlot(ownerDocument2);
9527 return cachedSlot;
9528 }
9529
9530 // packages/ui/build-module/tooltip/portal.mjs
9531 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
9532 var Portal = (0, import_element12.forwardRef)(
9533 function TooltipPortal3({ container, ...restProps }, ref) {
9534 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
9535 index_parts_exports.Portal,
9536 {
9537 container: container ?? getWpCompatOverlaySlot(),
9538 ...restProps,
9539 ref
9540 }
9541 );
9542 }
9543 );
9544
9545 // packages/ui/build-module/tooltip/positioner.mjs
9546 var import_element13 = __toESM(require_element(), 1);
9547 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
9548 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
9549 function getRuntime4() {
9550 const globalScope = globalThis;
9551 if (globalScope.__wpStyleRuntime) {
9552 return globalScope.__wpStyleRuntime;
9553 }
9554 globalScope.__wpStyleRuntime = {
9555 documents: /* @__PURE__ */ new Map(),
9556 styles: /* @__PURE__ */ new Map(),
9557 injectedStyles: /* @__PURE__ */ new WeakMap()
9558 };
9559 if (typeof document !== "undefined") {
9560 registerDocument4(document);
9561 }
9562 return globalScope.__wpStyleRuntime;
9563 }
9564 function documentContainsStyleHash4(targetDocument, hash) {
9565 if (!targetDocument.head) {
9566 return false;
9567 }
9568 for (const style of targetDocument.head.querySelectorAll(
9569 `style[${STYLE_HASH_ATTRIBUTE4}]`
9570 )) {
9571 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
9572 return true;
9573 }
9574 }
9575 return false;
9576 }
9577 function injectStyle4(targetDocument, hash, css) {
9578 if (!targetDocument.head) {
9579 return;
9580 }
9581 const runtime = getRuntime4();
9582 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9583 if (!injectedStyles) {
9584 injectedStyles = /* @__PURE__ */ new Set();
9585 runtime.injectedStyles.set(targetDocument, injectedStyles);
9586 }
9587 if (injectedStyles.has(hash)) {
9588 return;
9589 }
9590 if (documentContainsStyleHash4(targetDocument, hash)) {
9591 injectedStyles.add(hash);
9592 return;
9593 }
9594 const style = targetDocument.createElement("style");
9595 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
9596 style.appendChild(targetDocument.createTextNode(css));
9597 targetDocument.head.appendChild(style);
9598 injectedStyles.add(hash);
9599 }
9600 function registerDocument4(targetDocument) {
9601 const runtime = getRuntime4();
9602 runtime.documents.set(
9603 targetDocument,
9604 (runtime.documents.get(targetDocument) ?? 0) + 1
9605 );
9606 for (const [hash, css] of runtime.styles) {
9607 injectStyle4(targetDocument, hash, css);
9608 }
9609 return () => {
9610 const count = runtime.documents.get(targetDocument);
9611 if (count === void 0) {
9612 return;
9613 }
9614 if (count <= 1) {
9615 runtime.documents.delete(targetDocument);
9616 return;
9617 }
9618 runtime.documents.set(targetDocument, count - 1);
9619 };
9620 }
9621 function registerStyle4(hash, css) {
9622 const runtime = getRuntime4();
9623 runtime.styles.set(hash, css);
9624 for (const targetDocument of runtime.documents.keys()) {
9625 injectStyle4(targetDocument, hash, css);
9626 }
9627 }
9628 if (typeof process === "undefined" || true) {
9629 registerStyle4("e3ae230cea", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}");
9630 }
9631 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
9632 if (typeof process === "undefined" || true) {
9633 registerStyle4("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9634 }
9635 var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9636 var Positioner = (0, import_element13.forwardRef)(
9637 function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
9638 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
9639 index_parts_exports.Positioner,
9640 {
9641 ref,
9642 align,
9643 side,
9644 sideOffset,
9645 ...props,
9646 className: clsx_default(
9647 resets_default["box-sizing"],
9648 style_default3.positioner,
9649 className
9650 )
9651 }
9652 );
9653 }
9654 );
9655
9656 // packages/ui/build-module/tooltip/popup.mjs
9657 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
9658 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
9659 function getRuntime5() {
9660 const globalScope = globalThis;
9661 if (globalScope.__wpStyleRuntime) {
9662 return globalScope.__wpStyleRuntime;
9663 }
9664 globalScope.__wpStyleRuntime = {
9665 documents: /* @__PURE__ */ new Map(),
9666 styles: /* @__PURE__ */ new Map(),
9667 injectedStyles: /* @__PURE__ */ new WeakMap()
9668 };
9669 if (typeof document !== "undefined") {
9670 registerDocument5(document);
9671 }
9672 return globalScope.__wpStyleRuntime;
9673 }
9674 function documentContainsStyleHash5(targetDocument, hash) {
9675 if (!targetDocument.head) {
9676 return false;
9677 }
9678 for (const style of targetDocument.head.querySelectorAll(
9679 `style[${STYLE_HASH_ATTRIBUTE5}]`
9680 )) {
9681 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
9682 return true;
9683 }
9684 }
9685 return false;
9686 }
9687 function injectStyle5(targetDocument, hash, css) {
9688 if (!targetDocument.head) {
9689 return;
9690 }
9691 const runtime = getRuntime5();
9692 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9693 if (!injectedStyles) {
9694 injectedStyles = /* @__PURE__ */ new Set();
9695 runtime.injectedStyles.set(targetDocument, injectedStyles);
9696 }
9697 if (injectedStyles.has(hash)) {
9698 return;
9699 }
9700 if (documentContainsStyleHash5(targetDocument, hash)) {
9701 injectedStyles.add(hash);
9702 return;
9703 }
9704 const style = targetDocument.createElement("style");
9705 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
9706 style.appendChild(targetDocument.createTextNode(css));
9707 targetDocument.head.appendChild(style);
9708 injectedStyles.add(hash);
9709 }
9710 function registerDocument5(targetDocument) {
9711 const runtime = getRuntime5();
9712 runtime.documents.set(
9713 targetDocument,
9714 (runtime.documents.get(targetDocument) ?? 0) + 1
9715 );
9716 for (const [hash, css] of runtime.styles) {
9717 injectStyle5(targetDocument, hash, css);
9718 }
9719 return () => {
9720 const count = runtime.documents.get(targetDocument);
9721 if (count === void 0) {
9722 return;
9723 }
9724 if (count <= 1) {
9725 runtime.documents.delete(targetDocument);
9726 return;
9727 }
9728 runtime.documents.set(targetDocument, count - 1);
9729 };
9730 }
9731 function registerStyle5(hash, css) {
9732 const runtime = getRuntime5();
9733 runtime.styles.set(hash, css);
9734 for (const targetDocument of runtime.documents.keys()) {
9735 injectStyle5(targetDocument, hash, css);
9736 }
9737 }
9738 if (typeof process === "undefined" || true) {
9739 registerStyle5("8293efbb49", '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}');
9740 }
9741 var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
9742 var ThemeProvider = unlock2(import_theme.privateApis).ThemeProvider;
9743 var Popup = (0, import_element14.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
9744 const popupContent = (
9745 /* This should ideally use whatever dark color makes sense,
9746 * and not be hardcoded to #1e1e1e. The solutions would be to:
9747 * - review the design of the tooltip, in case we want to stop
9748 * hardcoding it to a dark background
9749 * - create new semantic tokens as needed (aliasing either the
9750 * "inverted bg" or "perma-dark bg" private tokens) and have
9751 * Tooltip.Popup use them;
9752 * - remove the hardcoded `bg` setting from the `ThemeProvider`
9753 * below
9754 */
9755 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ThemeProvider, { color: { bg: "#1e1e1e" }, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
9756 index_parts_exports.Popup,
9757 {
9758 ref,
9759 className: clsx_default(style_default4.popup, className),
9760 ...props,
9761 children
9762 }
9763 ) })
9764 );
9765 const positionedPopup = renderSlotWithChildren(
9766 positioner,
9767 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Positioner, {}),
9768 popupContent
9769 );
9770 return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Portal, {}), positionedPopup);
9771 });
9772
9773 // packages/ui/build-module/tooltip/trigger.mjs
9774 var import_element15 = __toESM(require_element(), 1);
9775 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
9776 var Trigger = (0, import_element15.forwardRef)(
9777 function TooltipTrigger3(props, ref) {
9778 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(index_parts_exports.Trigger, { ref, ...props });
9779 }
9780 );
9781
9782 // packages/ui/build-module/tooltip/root.mjs
9783 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
9784 function Root(props) {
9785 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(index_parts_exports.Root, { ...props });
9786 }
9787
9788 // packages/ui/build-module/tooltip/provider.mjs
9789 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
9790 function Provider({ ...props }) {
9791 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(index_parts_exports.Provider, { ...props });
9792 }
9793
9794 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
9795 var import_element16 = __toESM(require_element(), 1);
9796 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
9797 function getRuntime6() {
9798 const globalScope = globalThis;
9799 if (globalScope.__wpStyleRuntime) {
9800 return globalScope.__wpStyleRuntime;
9801 }
9802 globalScope.__wpStyleRuntime = {
9803 documents: /* @__PURE__ */ new Map(),
9804 styles: /* @__PURE__ */ new Map(),
9805 injectedStyles: /* @__PURE__ */ new WeakMap()
9806 };
9807 if (typeof document !== "undefined") {
9808 registerDocument6(document);
9809 }
9810 return globalScope.__wpStyleRuntime;
9811 }
9812 function documentContainsStyleHash6(targetDocument, hash) {
9813 if (!targetDocument.head) {
9814 return false;
9815 }
9816 for (const style of targetDocument.head.querySelectorAll(
9817 `style[${STYLE_HASH_ATTRIBUTE6}]`
9818 )) {
9819 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
9820 return true;
9821 }
9822 }
9823 return false;
9824 }
9825 function injectStyle6(targetDocument, hash, css) {
9826 if (!targetDocument.head) {
9827 return;
9828 }
9829 const runtime = getRuntime6();
9830 let injectedStyles = runtime.injectedStyles.get(targetDocument);
9831 if (!injectedStyles) {
9832 injectedStyles = /* @__PURE__ */ new Set();
9833 runtime.injectedStyles.set(targetDocument, injectedStyles);
9834 }
9835 if (injectedStyles.has(hash)) {
9836 return;
9837 }
9838 if (documentContainsStyleHash6(targetDocument, hash)) {
9839 injectedStyles.add(hash);
9840 return;
9841 }
9842 const style = targetDocument.createElement("style");
9843 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
9844 style.appendChild(targetDocument.createTextNode(css));
9845 targetDocument.head.appendChild(style);
9846 injectedStyles.add(hash);
9847 }
9848 function registerDocument6(targetDocument) {
9849 const runtime = getRuntime6();
9850 runtime.documents.set(
9851 targetDocument,
9852 (runtime.documents.get(targetDocument) ?? 0) + 1
9853 );
9854 for (const [hash, css] of runtime.styles) {
9855 injectStyle6(targetDocument, hash, css);
9856 }
9857 return () => {
9858 const count = runtime.documents.get(targetDocument);
9859 if (count === void 0) {
9860 return;
9861 }
9862 if (count <= 1) {
9863 runtime.documents.delete(targetDocument);
9864 return;
9865 }
9866 runtime.documents.set(targetDocument, count - 1);
9867 };
9868 }
9869 function registerStyle6(hash, css) {
9870 const runtime = getRuntime6();
9871 runtime.styles.set(hash, css);
9872 for (const targetDocument of runtime.documents.keys()) {
9873 injectStyle6(targetDocument, hash, css);
9874 }
9875 }
9876 if (typeof process === "undefined" || true) {
9877 registerStyle6("c46e8cb841", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}");
9878 }
9879 var style_default5 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
9880 var VisuallyHidden = (0, import_element16.forwardRef)(
9881 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
9882 const element = useRender({
9883 render: render4,
9884 ref,
9885 props: mergeProps(
9886 { className: style_default5["visually-hidden"] },
9887 restProps,
9888 {
9889 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
9890 "data-visually-hidden": ""
9891 }
9892 )
9893 });
9894 return element;
9895 }
9896 );
9897
9898 // packages/dataviews/build-module/components/dataviews-context/index.mjs
9899 var import_element17 = __toESM(require_element(), 1);
9900
9901 // packages/dataviews/build-module/constants.mjs
9902 var import_i18n = __toESM(require_i18n(), 1);
9903 var OPERATOR_IS_ANY = "isAny";
9904 var OPERATOR_IS_NONE = "isNone";
9905 var OPERATOR_IS_ALL = "isAll";
9906 var OPERATOR_IS_NOT_ALL = "isNotAll";
9907 var OPERATOR_BETWEEN = "between";
9908 var OPERATOR_IN_THE_PAST = "inThePast";
9909 var OPERATOR_OVER = "over";
9910 var OPERATOR_IS = "is";
9911 var OPERATOR_IS_NOT = "isNot";
9912 var OPERATOR_LESS_THAN = "lessThan";
9913 var OPERATOR_GREATER_THAN = "greaterThan";
9914 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
9915 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
9916 var OPERATOR_BEFORE = "before";
9917 var OPERATOR_AFTER = "after";
9918 var OPERATOR_BEFORE_INC = "beforeInc";
9919 var OPERATOR_AFTER_INC = "afterInc";
9920 var OPERATOR_CONTAINS = "contains";
9921 var OPERATOR_NOT_CONTAINS = "notContains";
9922 var OPERATOR_STARTS_WITH = "startsWith";
9923 var OPERATOR_ON = "on";
9924 var OPERATOR_NOT_ON = "notOn";
9925 var SORTING_DIRECTIONS = ["asc", "desc"];
9926 var sortArrows = { asc: "\u2191", desc: "\u2193" };
9927 var sortValues = { asc: "ascending", desc: "descending" };
9928 var sortLabels = {
9929 asc: (0, import_i18n.__)("Sort ascending"),
9930 desc: (0, import_i18n.__)("Sort descending")
9931 };
9932 var sortIcons = {
9933 asc: arrow_up_default,
9934 desc: arrow_down_default
9935 };
9936 var LAYOUT_TABLE = "table";
9937 var LAYOUT_GRID = "grid";
9938 var LAYOUT_LIST = "list";
9939 var LAYOUT_ACTIVITY = "activity";
9940 var LAYOUT_PICKER_GRID = "pickerGrid";
9941 var LAYOUT_PICKER_TABLE = "pickerTable";
9942
9943 // packages/dataviews/build-module/components/dataviews-context/index.mjs
9944 var DataViewsContext = (0, import_element17.createContext)({
9945 view: { type: LAYOUT_TABLE },
9946 onChangeView: () => {
9947 },
9948 fields: [],
9949 data: [],
9950 paginationInfo: {
9951 totalItems: 0,
9952 totalPages: 0
9953 },
9954 selection: [],
9955 onChangeSelection: () => {
9956 },
9957 setOpenedFilter: () => {
9958 },
9959 openedFilter: null,
9960 getItemId: (item) => item.id,
9961 isItemClickable: () => true,
9962 renderItemLink: void 0,
9963 containerWidth: 0,
9964 containerRef: (0, import_element17.createRef)(),
9965 resizeObserverRef: () => {
9966 },
9967 defaultLayouts: { list: {}, grid: {}, table: {} },
9968 filters: [],
9969 isShowingFilter: false,
9970 setIsShowingFilter: () => {
9971 },
9972 hasInitiallyLoaded: false,
9973 config: {
9974 perPageSizes: []
9975 },
9976 intersectionObserver: null
9977 });
9978 DataViewsContext.displayName = "DataViewsContext";
9979 var dataviews_context_default = DataViewsContext;
9980
9981 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
9982 var import_i18n21 = __toESM(require_i18n(), 1);
9983
9984 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
9985 var import_i18n9 = __toESM(require_i18n(), 1);
9986 var import_components6 = __toESM(require_components(), 1);
9987 var import_element25 = __toESM(require_element(), 1);
9988 var import_keycodes = __toESM(require_keycodes(), 1);
9989
9990 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
9991 var import_components = __toESM(require_components(), 1);
9992 var import_i18n2 = __toESM(require_i18n(), 1);
9993 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
9994 function DataViewsSelectionCheckbox({
9995 selection,
9996 onChangeSelection,
9997 item,
9998 getItemId,
9999 titleField,
10000 disabled: disabled2,
10001 ...extraProps
10002 }) {
10003 const id = getItemId(item);
10004 const isInSelectionArray = selection.includes(id);
10005 const checked = !disabled2 && isInSelectionArray;
10006 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
10007 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
10008 import_components.CheckboxControl,
10009 {
10010 className: "dataviews-selection-checkbox",
10011 "aria-label": selectionLabel,
10012 "aria-disabled": disabled2,
10013 checked,
10014 onChange: () => {
10015 if (disabled2) {
10016 return;
10017 }
10018 onChangeSelection(
10019 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
10020 );
10021 },
10022 ...extraProps
10023 }
10024 );
10025 }
10026
10027 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10028 var import_components2 = __toESM(require_components(), 1);
10029 var import_i18n3 = __toESM(require_i18n(), 1);
10030 var import_element18 = __toESM(require_element(), 1);
10031 var import_data4 = __toESM(require_data(), 1);
10032 var import_compose = __toESM(require_compose(), 1);
10033
10034 // packages/dataviews/build-module/lock-unlock.mjs
10035 var import_private_apis3 = __toESM(require_private_apis(), 1);
10036 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
10037 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
10038 "@wordpress/dataviews"
10039 );
10040
10041 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
10042 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
10043 var { Menu, kebabCase } = unlock3(import_components2.privateApis);
10044 function ButtonTrigger({
10045 action,
10046 onClick,
10047 items,
10048 variant
10049 }) {
10050 const label = typeof action.label === "string" ? action.label : action.label(items);
10051 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10052 import_components2.Button,
10053 {
10054 disabled: !!action.disabled,
10055 accessibleWhenDisabled: true,
10056 size: "compact",
10057 variant,
10058 onClick,
10059 children: label
10060 }
10061 );
10062 }
10063 function MenuItemTrigger({
10064 action,
10065 onClick,
10066 items
10067 }) {
10068 const label = typeof action.label === "string" ? action.label : action.label(items);
10069 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.ItemLabel, { children: label }) });
10070 }
10071 function ActionModal({
10072 action,
10073 items,
10074 closeModal
10075 }) {
10076 const label = typeof action.label === "string" ? action.label : action.label(items);
10077 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
10078 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10079 import_components2.Modal,
10080 {
10081 title: modalHeader || label,
10082 __experimentalHideHeader: !!action.hideModalHeader,
10083 onRequestClose: closeModal,
10084 focusOnMount: action.modalFocusOnMount ?? true,
10085 size: action.modalSize || "medium",
10086 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
10087 action.id
10088 )}`,
10089 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(action.RenderModal, { items, closeModal })
10090 }
10091 );
10092 }
10093 function ActionsMenuGroup({
10094 actions,
10095 item,
10096 registry,
10097 setActiveModalAction
10098 }) {
10099 const { primaryActions, regularActions } = (0, import_element18.useMemo)(() => {
10100 return actions.reduce(
10101 (acc, action) => {
10102 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
10103 return acc;
10104 },
10105 {
10106 primaryActions: [],
10107 regularActions: []
10108 }
10109 );
10110 }, [actions]);
10111 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10112 MenuItemTrigger,
10113 {
10114 action,
10115 onClick: () => {
10116 if ("RenderModal" in action) {
10117 setActiveModalAction(action);
10118 return;
10119 }
10120 action.callback([item], { registry });
10121 },
10122 items: [item]
10123 },
10124 action.id
10125 ));
10126 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu.Group, { children: [
10127 renderActionGroup(primaryActions),
10128 renderActionGroup(regularActions)
10129 ] });
10130 }
10131 function ItemActions({
10132 item,
10133 actions,
10134 isCompact
10135 }) {
10136 const registry = (0, import_data4.useRegistry)();
10137 const { primaryActions, eligibleActions } = (0, import_element18.useMemo)(() => {
10138 const _eligibleActions = actions.filter(
10139 (action) => !action.isEligible || action.isEligible(item)
10140 );
10141 const _primaryActions = _eligibleActions.filter(
10142 (action) => action.isPrimary
10143 );
10144 return {
10145 primaryActions: _primaryActions,
10146 eligibleActions: _eligibleActions
10147 };
10148 }, [actions, item]);
10149 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10150 if (isCompact) {
10151 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10152 CompactItemActions,
10153 {
10154 item,
10155 actions: eligibleActions,
10156 isSmall: true,
10157 registry
10158 }
10159 );
10160 }
10161 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
10162 Stack,
10163 {
10164 direction: "row",
10165 justify: "flex-end",
10166 className: "dataviews-item-actions",
10167 style: {
10168 flexShrink: 0,
10169 width: "auto"
10170 },
10171 children: [
10172 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10173 PrimaryActions,
10174 {
10175 item,
10176 actions: primaryActions,
10177 registry
10178 }
10179 ),
10180 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
10181 // there if there are any actions at all.
10182 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10183 CompactItemActions,
10184 {
10185 item,
10186 actions: eligibleActions,
10187 registry
10188 }
10189 )
10190 ]
10191 }
10192 );
10193 }
10194 function CompactItemActions({
10195 item,
10196 actions,
10197 isSmall,
10198 registry
10199 }) {
10200 const [activeModalAction, setActiveModalAction] = (0, import_element18.useState)(
10201 null
10202 );
10203 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10204 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu, { placement: "bottom-end", children: [
10205 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10206 Menu.TriggerButton,
10207 {
10208 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10209 import_components2.Button,
10210 {
10211 size: isSmall ? "small" : "compact",
10212 icon: more_vertical_default,
10213 label: (0, import_i18n3.__)("Actions"),
10214 accessibleWhenDisabled: true,
10215 disabled: !actions.length,
10216 className: "dataviews-all-actions-button"
10217 }
10218 )
10219 }
10220 ),
10221 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10222 ActionsMenuGroup,
10223 {
10224 actions,
10225 item,
10226 registry,
10227 setActiveModalAction
10228 }
10229 ) })
10230 ] }),
10231 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10232 ActionModal,
10233 {
10234 action: activeModalAction,
10235 items: [item],
10236 closeModal: () => setActiveModalAction(null)
10237 }
10238 )
10239 ] });
10240 }
10241 function PrimaryActions({
10242 item,
10243 actions,
10244 registry,
10245 buttonVariant
10246 }) {
10247 const [activeModalAction, setActiveModalAction] = (0, import_element18.useState)(null);
10248 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
10249 if (isMobileViewport) {
10250 return null;
10251 }
10252 if (!Array.isArray(actions) || actions.length === 0) {
10253 return null;
10254 }
10255 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
10256 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10257 ButtonTrigger,
10258 {
10259 action,
10260 onClick: () => {
10261 if ("RenderModal" in action) {
10262 setActiveModalAction(action);
10263 return;
10264 }
10265 action.callback([item], { registry });
10266 },
10267 items: [item],
10268 variant: buttonVariant
10269 },
10270 action.id
10271 )),
10272 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
10273 ActionModal,
10274 {
10275 action: activeModalAction,
10276 items: [item],
10277 closeModal: () => setActiveModalAction(null)
10278 }
10279 )
10280 ] });
10281 }
10282
10283 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10284 var import_components3 = __toESM(require_components(), 1);
10285 var import_i18n5 = __toESM(require_i18n(), 1);
10286 var import_element19 = __toESM(require_element(), 1);
10287 var import_data5 = __toESM(require_data(), 1);
10288 var import_compose2 = __toESM(require_compose(), 1);
10289
10290 // packages/dataviews/build-module/utils/get-footer-message.mjs
10291 var import_i18n4 = __toESM(require_i18n(), 1);
10292 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
10293 if (selectionCount > 0) {
10294 return (0, import_i18n4.sprintf)(
10295 /* translators: %d: number of items. */
10296 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
10297 selectionCount
10298 );
10299 }
10300 if (onlyTotalCount || totalItems <= itemsCount) {
10301 return (0, import_i18n4.sprintf)(
10302 /* translators: %d: number of items. */
10303 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
10304 totalItems
10305 );
10306 }
10307 return (0, import_i18n4.sprintf)(
10308 /* translators: %1$d: number of items. %2$d: total number of items. */
10309 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
10310 itemsCount,
10311 totalItems
10312 );
10313 }
10314
10315 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
10316 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
10317 function ActionWithModal({
10318 action,
10319 items,
10320 ActionTriggerComponent
10321 }) {
10322 const [isModalOpen, setIsModalOpen] = (0, import_element19.useState)(false);
10323 const actionTriggerProps = {
10324 action,
10325 onClick: () => {
10326 setIsModalOpen(true);
10327 },
10328 items
10329 };
10330 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
10331 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
10332 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10333 ActionModal,
10334 {
10335 action,
10336 items,
10337 closeModal: () => setIsModalOpen(false)
10338 }
10339 )
10340 ] });
10341 }
10342 function useHasAPossibleBulkAction(actions, item) {
10343 return (0, import_element19.useMemo)(() => {
10344 return actions.some((action) => {
10345 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10346 });
10347 }, [actions, item]);
10348 }
10349 function useSomeItemHasAPossibleBulkAction(actions, data) {
10350 return (0, import_element19.useMemo)(() => {
10351 return data.some((item) => {
10352 return actions.some((action) => {
10353 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
10354 });
10355 });
10356 }, [actions, data]);
10357 }
10358 function BulkSelectionCheckbox({
10359 selection,
10360 onChangeSelection,
10361 data,
10362 actions,
10363 getItemId,
10364 disableSelectAll = false
10365 }) {
10366 const selectableItems = (0, import_element19.useMemo)(() => {
10367 return data.filter((item) => {
10368 return actions.some(
10369 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
10370 );
10371 });
10372 }, [data, actions]);
10373 const selectedItems = data.filter(
10374 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10375 );
10376 const hasSelection = selection.length > 0;
10377 const areAllSelected = selectedItems.length === selectableItems.length;
10378 if (disableSelectAll) {
10379 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10380 import_components3.CheckboxControl,
10381 {
10382 className: "dataviews-view-table-selection-checkbox",
10383 checked: hasSelection,
10384 disabled: !hasSelection,
10385 onChange: () => {
10386 onChangeSelection([]);
10387 },
10388 "aria-label": (0, import_i18n5.__)("Deselect all")
10389 }
10390 );
10391 }
10392 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10393 import_components3.CheckboxControl,
10394 {
10395 className: "dataviews-view-table-selection-checkbox",
10396 checked: areAllSelected,
10397 indeterminate: !areAllSelected && !!selectedItems.length,
10398 onChange: () => {
10399 if (areAllSelected) {
10400 onChangeSelection([]);
10401 } else {
10402 onChangeSelection(
10403 selectableItems.map((item) => getItemId(item))
10404 );
10405 }
10406 },
10407 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
10408 }
10409 );
10410 }
10411 function ActionTrigger({
10412 action,
10413 onClick,
10414 isBusy,
10415 items
10416 }) {
10417 const label = typeof action.label === "string" ? action.label : action.label(items);
10418 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10419 if (isMobile) {
10420 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10421 import_components3.Button,
10422 {
10423 disabled: isBusy,
10424 accessibleWhenDisabled: true,
10425 label,
10426 icon: action.icon,
10427 size: "compact",
10428 onClick,
10429 isBusy
10430 }
10431 );
10432 }
10433 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10434 import_components3.Button,
10435 {
10436 disabled: isBusy,
10437 accessibleWhenDisabled: true,
10438 size: "compact",
10439 onClick,
10440 isBusy,
10441 children: label
10442 }
10443 );
10444 }
10445 var EMPTY_ARRAY2 = [];
10446 function ActionButton({
10447 action,
10448 selectedItems,
10449 actionInProgress,
10450 setActionInProgress
10451 }) {
10452 const registry = (0, import_data5.useRegistry)();
10453 const selectedEligibleItems = (0, import_element19.useMemo)(() => {
10454 return selectedItems.filter((item) => {
10455 return !action.isEligible || action.isEligible(item);
10456 });
10457 }, [action, selectedItems]);
10458 if ("RenderModal" in action) {
10459 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10460 ActionWithModal,
10461 {
10462 action,
10463 items: selectedEligibleItems,
10464 ActionTriggerComponent: ActionTrigger
10465 },
10466 action.id
10467 );
10468 }
10469 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10470 ActionTrigger,
10471 {
10472 action,
10473 onClick: async () => {
10474 setActionInProgress(action.id);
10475 await action.callback(selectedItems, {
10476 registry
10477 });
10478 setActionInProgress(null);
10479 },
10480 items: selectedEligibleItems,
10481 isBusy: actionInProgress === action.id
10482 },
10483 action.id
10484 );
10485 }
10486 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
10487 const message2 = getFooterMessage(
10488 selection.length,
10489 data.length,
10490 paginationInfo.totalItems,
10491 isInfiniteScroll
10492 );
10493 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10494 Stack,
10495 {
10496 direction: "row",
10497 className: "dataviews-bulk-actions-footer__container",
10498 gap: "md",
10499 align: "center",
10500 children: [
10501 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10502 BulkSelectionCheckbox,
10503 {
10504 selection,
10505 onChangeSelection,
10506 data,
10507 actions,
10508 getItemId,
10509 disableSelectAll: isInfiniteScroll
10510 }
10511 ),
10512 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
10513 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
10514 Stack,
10515 {
10516 direction: "row",
10517 className: "dataviews-bulk-actions-footer__action-buttons",
10518 gap: "xs",
10519 children: [
10520 actionsToShow.map((action) => {
10521 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10522 ActionButton,
10523 {
10524 action,
10525 selectedItems,
10526 actionInProgress,
10527 setActionInProgress
10528 },
10529 action.id
10530 );
10531 }),
10532 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10533 import_components3.Button,
10534 {
10535 icon: close_small_default,
10536 showTooltip: true,
10537 tooltipPosition: "top",
10538 size: "compact",
10539 label: (0, import_i18n5.__)("Cancel"),
10540 disabled: !!actionInProgress,
10541 accessibleWhenDisabled: false,
10542 onClick: () => {
10543 onChangeSelection(EMPTY_ARRAY2);
10544 }
10545 }
10546 )
10547 ]
10548 }
10549 )
10550 ]
10551 }
10552 );
10553 }
10554 function FooterContent({
10555 selection,
10556 actions,
10557 onChangeSelection,
10558 data,
10559 getItemId,
10560 isInfiniteScroll,
10561 paginationInfo
10562 }) {
10563 const [actionInProgress, setActionInProgress] = (0, import_element19.useState)(
10564 null
10565 );
10566 const footerContentRef = (0, import_element19.useRef)(void 0);
10567 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
10568 const bulkActions = (0, import_element19.useMemo)(
10569 () => actions.filter((action) => action.supportsBulk),
10570 [actions]
10571 );
10572 const selectableItems = (0, import_element19.useMemo)(() => {
10573 return data.filter((item) => {
10574 return bulkActions.some(
10575 (action) => !action.isEligible || action.isEligible(item)
10576 );
10577 });
10578 }, [data, bulkActions]);
10579 const selectedItems = (0, import_element19.useMemo)(() => {
10580 return data.filter(
10581 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
10582 );
10583 }, [selection, data, getItemId, selectableItems]);
10584 const actionsToShow = (0, import_element19.useMemo)(
10585 () => actions.filter((action) => {
10586 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
10587 (item) => !action.isEligible || action.isEligible(item)
10588 );
10589 }),
10590 [actions, selectedItems, isMobile]
10591 );
10592 if (!actionInProgress) {
10593 if (footerContentRef.current) {
10594 footerContentRef.current = void 0;
10595 }
10596 return renderFooterContent(
10597 data,
10598 actions,
10599 getItemId,
10600 isInfiniteScroll,
10601 selection,
10602 actionsToShow,
10603 selectedItems,
10604 actionInProgress,
10605 setActionInProgress,
10606 onChangeSelection,
10607 paginationInfo
10608 );
10609 } else if (!footerContentRef.current) {
10610 footerContentRef.current = renderFooterContent(
10611 data,
10612 actions,
10613 getItemId,
10614 isInfiniteScroll,
10615 selection,
10616 actionsToShow,
10617 selectedItems,
10618 actionInProgress,
10619 setActionInProgress,
10620 onChangeSelection,
10621 paginationInfo
10622 );
10623 }
10624 return footerContentRef.current;
10625 }
10626 function BulkActionsFooter() {
10627 const {
10628 data,
10629 selection,
10630 actions = EMPTY_ARRAY2,
10631 onChangeSelection,
10632 getItemId,
10633 paginationInfo,
10634 view
10635 } = (0, import_element19.useContext)(dataviews_context_default);
10636 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10637 FooterContent,
10638 {
10639 selection,
10640 onChangeSelection,
10641 data,
10642 actions,
10643 getItemId,
10644 isInfiniteScroll: !!view.infiniteScrollEnabled,
10645 paginationInfo
10646 }
10647 );
10648 }
10649
10650 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10651 var import_i18n6 = __toESM(require_i18n(), 1);
10652 var import_components4 = __toESM(require_components(), 1);
10653 var import_element20 = __toESM(require_element(), 1);
10654
10655 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
10656 function getHideableFields(view, fields) {
10657 const togglableFields = [
10658 view?.titleField,
10659 view?.mediaField,
10660 view?.descriptionField
10661 ].filter(Boolean);
10662 return fields.filter(
10663 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
10664 );
10665 }
10666
10667 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
10668 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
10669 var { Menu: Menu2 } = unlock3(import_components4.privateApis);
10670 function WithMenuSeparators({ children }) {
10671 return import_element20.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_element20.Fragment, { children: [
10672 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Separator, {}),
10673 child
10674 ] }, i2));
10675 }
10676 var _HeaderMenu = (0, import_element20.forwardRef)(function HeaderMenu({
10677 fieldId,
10678 view,
10679 fields,
10680 onChangeView,
10681 onHide,
10682 setOpenedFilter,
10683 canMove = true,
10684 canInsertLeft = true,
10685 canInsertRight = true
10686 }, ref) {
10687 const visibleFieldIds = view.fields ?? [];
10688 const index2 = visibleFieldIds?.indexOf(fieldId);
10689 const isSorted = view.sort?.field === fieldId;
10690 let isHidable = false;
10691 let isSortable = false;
10692 let canAddFilter = false;
10693 let operators = [];
10694 const field = fields.find((f2) => f2.id === fieldId);
10695 const { setIsShowingFilter } = (0, import_element20.useContext)(dataviews_context_default);
10696 if (!field) {
10697 return null;
10698 }
10699 isHidable = field.enableHiding !== false;
10700 isSortable = field.enableSorting !== false;
10701 const header = field.header;
10702 operators = !!field.filterBy && field.filterBy?.operators || [];
10703 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
10704 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
10705 return header;
10706 }
10707 const hiddenFields = getHideableFields(view, fields).filter(
10708 (f2) => !visibleFieldIds.includes(f2.id)
10709 );
10710 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
10711 const isRtl = (0, import_i18n6.isRTL)();
10712 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10713 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10714 Menu2.TriggerButton,
10715 {
10716 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10717 import_components4.Button,
10718 {
10719 size: "compact",
10720 className: "dataviews-view-table-header-button",
10721 ref,
10722 variant: "tertiary"
10723 }
10724 ),
10725 children: [
10726 header,
10727 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
10728 ]
10729 }
10730 ),
10731 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(WithMenuSeparators, { children: [
10732 isSortable && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
10733 (direction) => {
10734 const isChecked = view.sort && isSorted && view.sort.direction === direction;
10735 const value = `${fieldId}-${direction}`;
10736 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10737 Menu2.RadioItem,
10738 {
10739 name: "view-table-sorting",
10740 value,
10741 checked: isChecked,
10742 onChange: () => {
10743 onChangeView({
10744 ...view,
10745 sort: {
10746 field: fieldId,
10747 direction
10748 },
10749 showLevels: false
10750 });
10751 },
10752 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
10753 },
10754 value
10755 );
10756 }
10757 ) }),
10758 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10759 Menu2.Item,
10760 {
10761 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: funnel_default }),
10762 onClick: () => {
10763 setOpenedFilter(fieldId);
10764 setIsShowingFilter(true);
10765 onChangeView({
10766 ...view,
10767 page: 1,
10768 filters: [
10769 ...view.filters || [],
10770 {
10771 field: fieldId,
10772 value: void 0,
10773 operator: operators[0]
10774 }
10775 ]
10776 });
10777 },
10778 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
10779 }
10780 ) }),
10781 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2.Group, { children: [
10782 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10783 Menu2.Item,
10784 {
10785 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_left_default }),
10786 disabled: isRtl ? index2 >= visibleFieldIds.length - 1 : index2 < 1,
10787 onClick: () => {
10788 const targetIndex = isRtl ? index2 + 1 : index2 - 1;
10789 const newFields = [
10790 ...visibleFieldIds
10791 ];
10792 newFields.splice(index2, 1);
10793 newFields.splice(
10794 targetIndex,
10795 0,
10796 fieldId
10797 );
10798 onChangeView({
10799 ...view,
10800 fields: newFields
10801 });
10802 },
10803 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
10804 }
10805 ),
10806 canMove && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10807 Menu2.Item,
10808 {
10809 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: arrow_right_default }),
10810 disabled: isRtl ? index2 < 1 : index2 >= visibleFieldIds.length - 1,
10811 onClick: () => {
10812 const targetIndex = isRtl ? index2 - 1 : index2 + 1;
10813 const newFields = [
10814 ...visibleFieldIds
10815 ];
10816 newFields.splice(index2, 1);
10817 newFields.splice(
10818 targetIndex,
10819 0,
10820 fieldId
10821 );
10822 onChangeView({
10823 ...view,
10824 fields: newFields
10825 });
10826 },
10827 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
10828 }
10829 ),
10830 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10831 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
10832 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
10833 const insertIndex = isRtl ? index2 + 1 : index2;
10834 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10835 Menu2.Item,
10836 {
10837 onClick: () => {
10838 onChangeView({
10839 ...view,
10840 fields: [
10841 ...visibleFieldIds.slice(
10842 0,
10843 insertIndex
10844 ),
10845 hiddenField.id,
10846 ...visibleFieldIds.slice(
10847 insertIndex
10848 )
10849 ]
10850 });
10851 },
10852 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
10853 },
10854 hiddenField.id
10855 );
10856 }) })
10857 ] }),
10858 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Menu2, { children: [
10859 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
10860 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
10861 const insertIndex = isRtl ? index2 : index2 + 1;
10862 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10863 Menu2.Item,
10864 {
10865 onClick: () => {
10866 onChangeView({
10867 ...view,
10868 fields: [
10869 ...visibleFieldIds.slice(
10870 0,
10871 insertIndex
10872 ),
10873 hiddenField.id,
10874 ...visibleFieldIds.slice(
10875 insertIndex
10876 )
10877 ]
10878 });
10879 },
10880 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
10881 },
10882 hiddenField.id
10883 );
10884 }) })
10885 ] }),
10886 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10887 Menu2.Item,
10888 {
10889 prefix: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components4.Icon, { icon: unseen_default }),
10890 onClick: () => {
10891 onHide(field);
10892 onChangeView({
10893 ...view,
10894 fields: visibleFieldIds.filter(
10895 (id) => id !== fieldId
10896 )
10897 });
10898 },
10899 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
10900 }
10901 )
10902 ] })
10903 ] }) })
10904 ] });
10905 });
10906 var ColumnHeaderMenu = _HeaderMenu;
10907 var column_header_menu_default = ColumnHeaderMenu;
10908
10909 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
10910 var import_element21 = __toESM(require_element(), 1);
10911 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
10912 function getClickableItemProps({
10913 item,
10914 isItemClickable,
10915 onClickItem,
10916 className
10917 }) {
10918 if (!isItemClickable(item) || !onClickItem) {
10919 return { className };
10920 }
10921 return {
10922 className: className ? `${className} ${className}--clickable` : void 0,
10923 role: "button",
10924 tabIndex: 0,
10925 onClick: (event) => {
10926 event.stopPropagation();
10927 onClickItem(item);
10928 },
10929 onKeyDown: (event) => {
10930 if (event.key === "Enter" || event.key === "" || event.key === " ") {
10931 event.stopPropagation();
10932 onClickItem(item);
10933 }
10934 }
10935 };
10936 }
10937 function ItemClickWrapper({
10938 item,
10939 isItemClickable,
10940 onClickItem,
10941 renderItemLink,
10942 className,
10943 children,
10944 ...extraProps
10945 }) {
10946 if (!isItemClickable(item)) {
10947 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className, ...extraProps, children });
10948 }
10949 if (renderItemLink) {
10950 const renderedElement = renderItemLink({
10951 item,
10952 className: `${className} ${className}--clickable`,
10953 ...extraProps,
10954 children
10955 });
10956 return (0, import_element21.cloneElement)(renderedElement, {
10957 onClick: (event) => {
10958 event.stopPropagation();
10959 if (renderedElement.props.onClick) {
10960 renderedElement.props.onClick(event);
10961 }
10962 },
10963 onKeyDown: (event) => {
10964 if (event.key === "Enter" || event.key === "" || event.key === " ") {
10965 event.stopPropagation();
10966 if (renderedElement.props.onKeyDown) {
10967 renderedElement.props.onKeyDown(event);
10968 }
10969 }
10970 }
10971 });
10972 }
10973 const clickProps = getClickableItemProps({
10974 item,
10975 isItemClickable,
10976 onClickItem,
10977 className
10978 });
10979 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...clickProps, ...extraProps, children });
10980 }
10981
10982 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
10983 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
10984 function ColumnPrimary({
10985 item,
10986 level,
10987 titleField,
10988 mediaField,
10989 descriptionField,
10990 onClickItem,
10991 renderItemLink,
10992 isItemClickable
10993 }) {
10994 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
10995 mediaField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
10996 ItemClickWrapper,
10997 {
10998 item,
10999 isItemClickable,
11000 onClickItem,
11001 renderItemLink,
11002 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
11003 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
11004 children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11005 mediaField.render,
11006 {
11007 item,
11008 field: mediaField,
11009 config: { sizes: "32px" }
11010 }
11011 )
11012 }
11013 ),
11014 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11015 Stack,
11016 {
11017 direction: "column",
11018 align: "flex-start",
11019 className: "dataviews-view-table__primary-column-content",
11020 children: [
11021 titleField && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
11022 ItemClickWrapper,
11023 {
11024 item,
11025 isItemClickable,
11026 onClickItem,
11027 renderItemLink,
11028 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
11029 children: [
11030 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { className: "dataviews-view-table__level", children: [
11031 Array(level).fill("\u2014").join(" "),
11032 "\xA0"
11033 ] }),
11034 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(titleField.render, { item, field: titleField })
11035 ]
11036 }
11037 ),
11038 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
11039 descriptionField.render,
11040 {
11041 item,
11042 field: descriptionField
11043 }
11044 )
11045 ]
11046 }
11047 )
11048 ] });
11049 }
11050 var column_primary_default = ColumnPrimary;
11051
11052 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
11053 var import_element22 = __toESM(require_element(), 1);
11054 var import_i18n7 = __toESM(require_i18n(), 1);
11055 var isScrolledToEnd = (element) => {
11056 if ((0, import_i18n7.isRTL)()) {
11057 const scrollLeft = Math.abs(element.scrollLeft);
11058 return scrollLeft <= 1;
11059 }
11060 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
11061 };
11062 function useScrollState({
11063 scrollContainerRef,
11064 enabledHorizontal = false
11065 }) {
11066 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element22.useState)(false);
11067 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element22.useState)(false);
11068 const handleScroll = (0, import_element22.useCallback)(() => {
11069 const scrollContainer = scrollContainerRef.current;
11070 if (!scrollContainer) {
11071 return;
11072 }
11073 if (enabledHorizontal) {
11074 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
11075 }
11076 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
11077 }, [scrollContainerRef, enabledHorizontal]);
11078 (0, import_element22.useEffect)(() => {
11079 if (typeof window === "undefined" || !scrollContainerRef.current) {
11080 return () => {
11081 };
11082 }
11083 const scrollContainer = scrollContainerRef.current;
11084 handleScroll();
11085 scrollContainer.addEventListener("scroll", handleScroll);
11086 window.addEventListener("resize", handleScroll);
11087 return () => {
11088 scrollContainer.removeEventListener("scroll", handleScroll);
11089 window.removeEventListener("resize", handleScroll);
11090 };
11091 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
11092 return { isHorizontalScrollEnd, isVerticallyScrolled };
11093 }
11094
11095 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
11096 function getDataByGroup(data, groupByField) {
11097 return data.reduce((groups, item) => {
11098 const groupName = groupByField.getValue({ item });
11099 if (!groups.has(groupName)) {
11100 groups.set(groupName, []);
11101 }
11102 groups.get(groupName)?.push(item);
11103 return groups;
11104 }, /* @__PURE__ */ new Map());
11105 }
11106
11107 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
11108 var import_components5 = __toESM(require_components(), 1);
11109 var import_i18n8 = __toESM(require_i18n(), 1);
11110 var import_element23 = __toESM(require_element(), 1);
11111 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
11112 function FieldItem({
11113 field,
11114 isVisible: isVisible2,
11115 onToggleVisibility
11116 }) {
11117 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: [
11118 /* @__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 }) }),
11119 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
11120 ] }) });
11121 }
11122 function isDefined(item) {
11123 return !!item;
11124 }
11125 function PropertiesSection({
11126 showLabel = true
11127 }) {
11128 const { view, fields, onChangeView } = (0, import_element23.useContext)(dataviews_context_default);
11129 const regularFields = getHideableFields(view, fields);
11130 if (!regularFields?.length) {
11131 return null;
11132 }
11133 const titleField = fields.find((f2) => f2.id === view.titleField);
11134 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
11135 const descriptionField = fields.find(
11136 (f2) => f2.id === view.descriptionField
11137 );
11138 const lockedFields = [
11139 {
11140 field: titleField,
11141 isVisibleFlag: "showTitle"
11142 },
11143 {
11144 field: previewField2,
11145 isVisibleFlag: "showMedia"
11146 },
11147 {
11148 field: descriptionField,
11149 isVisibleFlag: "showDescription"
11150 }
11151 ].filter(({ field }) => isDefined(field));
11152 const visibleFieldIds = view.fields ?? [];
11153 const visibleRegularFieldsCount = regularFields.filter(
11154 (f2) => visibleFieldIds.includes(f2.id)
11155 ).length;
11156 const visibleLockedFields = lockedFields.filter(
11157 ({ isVisibleFlag }) => (
11158 // @ts-expect-error
11159 view[isVisibleFlag] ?? true
11160 )
11161 );
11162 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
11163 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
11164 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
11165 showLabel && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
11166 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11167 Stack,
11168 {
11169 direction: "column",
11170 className: "dataviews-view-config__properties",
11171 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
11172 lockedFields.map(({ field, isVisibleFlag }) => {
11173 const isVisible2 = view[isVisibleFlag] ?? true;
11174 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
11175 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11176 FieldItem,
11177 {
11178 field: fieldToRender,
11179 isVisible: isVisible2,
11180 onToggleVisibility: () => {
11181 onChangeView({
11182 ...view,
11183 [isVisibleFlag]: !isVisible2
11184 });
11185 }
11186 },
11187 field.id
11188 );
11189 }),
11190 regularFields.map((field) => {
11191 const isVisible2 = visibleFieldIds.includes(field.id);
11192 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
11193 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
11194 FieldItem,
11195 {
11196 field: fieldToRender,
11197 isVisible: isVisible2,
11198 onToggleVisibility: () => {
11199 onChangeView({
11200 ...view,
11201 fields: isVisible2 ? visibleFieldIds.filter(
11202 (fieldId) => fieldId !== field.id
11203 ) : [...visibleFieldIds, field.id]
11204 });
11205 }
11206 },
11207 field.id
11208 );
11209 })
11210 ] })
11211 }
11212 )
11213 ] });
11214 }
11215
11216 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
11217 var import_element24 = __toESM(require_element(), 1);
11218 function useDelayedLoading(isLoading, options = { delay: 400 }) {
11219 const [showLoader, setShowLoader] = (0, import_element24.useState)(false);
11220 (0, import_element24.useEffect)(() => {
11221 if (!isLoading) {
11222 return;
11223 }
11224 const timeout = setTimeout(() => {
11225 setShowLoader(true);
11226 }, options.delay);
11227 return () => {
11228 clearTimeout(timeout);
11229 setShowLoader(false);
11230 };
11231 }, [isLoading, options.delay]);
11232 return showLoader;
11233 }
11234
11235 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
11236 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
11237 function getEffectiveAlign(explicitAlign, fieldType) {
11238 if (explicitAlign) {
11239 return explicitAlign;
11240 }
11241 if (fieldType === "integer" || fieldType === "number") {
11242 return "end";
11243 }
11244 return void 0;
11245 }
11246 function TableColumnField({
11247 item,
11248 fields,
11249 column,
11250 align
11251 }) {
11252 const field = fields.find((f2) => f2.id === column);
11253 if (!field) {
11254 return null;
11255 }
11256 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
11257 "dataviews-view-table__cell-align-end": align === "end",
11258 "dataviews-view-table__cell-align-center": align === "center"
11259 });
11260 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(field.render, { item, field }) });
11261 }
11262 function TableRow({
11263 hasBulkActions,
11264 item,
11265 level,
11266 actions,
11267 fields,
11268 id,
11269 view,
11270 titleField,
11271 mediaField,
11272 descriptionField,
11273 selection,
11274 getItemId,
11275 isItemClickable,
11276 onClickItem,
11277 renderItemLink,
11278 onChangeSelection,
11279 isActionsColumnSticky,
11280 posinset
11281 }) {
11282 const { paginationInfo } = (0, import_element25.useContext)(dataviews_context_default);
11283 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
11284 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
11285 const {
11286 showTitle = true,
11287 showMedia = true,
11288 showDescription = true,
11289 infiniteScrollEnabled
11290 } = view;
11291 const isTouchDeviceRef = (0, import_element25.useRef)(false);
11292 const columns = view.fields ?? [];
11293 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11294 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11295 "tr",
11296 {
11297 className: clsx_default("dataviews-view-table__row", {
11298 "is-selected": hasPossibleBulkAction && isSelected2,
11299 "has-bulk-actions": hasPossibleBulkAction
11300 }),
11301 onTouchStart: () => {
11302 isTouchDeviceRef.current = true;
11303 },
11304 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
11305 "aria-posinset": posinset,
11306 role: infiniteScrollEnabled ? "article" : void 0,
11307 onMouseDown: (event) => {
11308 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11309 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
11310 event?.preventDefault();
11311 }
11312 },
11313 onClick: (event) => {
11314 if (!hasPossibleBulkAction) {
11315 return;
11316 }
11317 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
11318 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
11319 onChangeSelection(
11320 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
11321 );
11322 }
11323 },
11324 children: [
11325 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)(
11326 DataViewsSelectionCheckbox,
11327 {
11328 item,
11329 selection,
11330 onChangeSelection,
11331 getItemId,
11332 titleField,
11333 disabled: !hasPossibleBulkAction
11334 }
11335 ) }) }),
11336 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11337 column_primary_default,
11338 {
11339 item,
11340 level,
11341 titleField: showTitle ? titleField : void 0,
11342 mediaField: showMedia ? mediaField : void 0,
11343 descriptionField: showDescription ? descriptionField : void 0,
11344 isItemClickable,
11345 onClickItem,
11346 renderItemLink
11347 }
11348 ) }),
11349 columns.map((column) => {
11350 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11351 const field = fields.find((f2) => f2.id === column);
11352 const effectiveAlign = getEffectiveAlign(align, field?.type);
11353 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11354 "td",
11355 {
11356 style: {
11357 width,
11358 maxWidth,
11359 minWidth
11360 },
11361 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11362 TableColumnField,
11363 {
11364 fields,
11365 item,
11366 column,
11367 align: effectiveAlign
11368 }
11369 )
11370 },
11371 column
11372 );
11373 }),
11374 !!actions?.length && // Disable reason: we are not making the element interactive,
11375 // but preventing any click events from bubbling up to the
11376 // table row. This allows us to add a click handler to the row
11377 // itself (to toggle row selection) without erroneously
11378 // intercepting click events from ItemActions.
11379 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11380 "td",
11381 {
11382 className: clsx_default("dataviews-view-table__actions-column", {
11383 "dataviews-view-table__actions-column--sticky": true,
11384 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
11385 }),
11386 onClick: (e2) => e2.stopPropagation(),
11387 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ItemActions, { item, actions })
11388 }
11389 )
11390 ]
11391 }
11392 );
11393 }
11394 function ViewTable({
11395 actions,
11396 data,
11397 fields,
11398 getItemId,
11399 getItemLevel,
11400 isLoading = false,
11401 onChangeView,
11402 onChangeSelection,
11403 selection,
11404 setOpenedFilter,
11405 onClickItem,
11406 isItemClickable,
11407 renderItemLink,
11408 view,
11409 className,
11410 empty
11411 }) {
11412 const { containerRef } = (0, import_element25.useContext)(dataviews_context_default);
11413 const isDelayedLoading = useDelayedLoading(isLoading);
11414 const headerMenuRefs = (0, import_element25.useRef)(/* @__PURE__ */ new Map());
11415 const headerMenuToFocusRef = (0, import_element25.useRef)(void 0);
11416 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element25.useState)();
11417 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element25.useState)(null);
11418 (0, import_element25.useEffect)(() => {
11419 if (headerMenuToFocusRef.current) {
11420 headerMenuToFocusRef.current.focus();
11421 headerMenuToFocusRef.current = void 0;
11422 }
11423 });
11424 const tableNoticeId = (0, import_element25.useId)();
11425 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
11426 scrollContainerRef: containerRef,
11427 enabledHorizontal: !!actions?.length
11428 });
11429 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
11430 if (nextHeaderMenuToFocus) {
11431 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
11432 setNextHeaderMenuToFocus(void 0);
11433 return;
11434 }
11435 const onHide = (field) => {
11436 const hidden = headerMenuRefs.current.get(field.id);
11437 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
11438 setNextHeaderMenuToFocus(fallback?.node);
11439 };
11440 const handleHeaderContextMenu = (event) => {
11441 event.preventDefault();
11442 event.stopPropagation();
11443 const virtualAnchor = {
11444 getBoundingClientRect: () => ({
11445 x: event.clientX,
11446 y: event.clientY,
11447 top: event.clientY,
11448 left: event.clientX,
11449 right: event.clientX,
11450 bottom: event.clientY,
11451 width: 0,
11452 height: 0,
11453 toJSON: () => ({})
11454 })
11455 };
11456 window.requestAnimationFrame(() => {
11457 setContextMenuAnchor(virtualAnchor);
11458 });
11459 };
11460 const hasData = !!data?.length;
11461 const titleField = fields.find((field) => field.id === view.titleField);
11462 const mediaField = fields.find((field) => field.id === view.mediaField);
11463 const descriptionField = fields.find(
11464 (field) => field.id === view.descriptionField
11465 );
11466 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
11467 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
11468 const { showTitle = true, showMedia = true, showDescription = true } = view;
11469 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
11470 const columns = view.fields ?? [];
11471 const headerMenuRef = (column, index2) => (node) => {
11472 if (node) {
11473 headerMenuRefs.current.set(column, {
11474 node,
11475 fallback: columns[index2 > 0 ? index2 - 1 : 1]
11476 });
11477 } else {
11478 headerMenuRefs.current.delete(column);
11479 }
11480 };
11481 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
11482 const isRtl = (0, import_i18n9.isRTL)();
11483 if (!hasData) {
11484 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11485 "div",
11486 {
11487 className: clsx_default("dataviews-no-results", {
11488 "is-refreshing": isDelayedLoading
11489 }),
11490 id: tableNoticeId,
11491 children: empty
11492 }
11493 );
11494 }
11495 return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
11496 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
11497 "table",
11498 {
11499 className: clsx_default("dataviews-view-table", className, {
11500 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
11501 view.layout.density
11502 ),
11503 "has-bulk-actions": hasBulkActions,
11504 "is-refreshing": !isInfiniteScroll && isDelayedLoading
11505 }),
11506 "aria-busy": isLoading,
11507 "aria-describedby": tableNoticeId,
11508 role: isInfiniteScroll ? "feed" : void 0,
11509 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
11510 children: [
11511 /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("colgroup", { children: [
11512 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
11513 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
11514 columns.map((column, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11515 "col",
11516 {
11517 className: clsx_default(
11518 `dataviews-view-table__col-${column}`,
11519 {
11520 "dataviews-view-table__col-expand": !hasPrimaryColumn && index2 === columns.length - 1
11521 }
11522 )
11523 },
11524 `col-${column}`
11525 )),
11526 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("col", { className: "dataviews-view-table__col-actions" })
11527 ] }),
11528 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11529 import_components6.Popover,
11530 {
11531 anchor: contextMenuAnchor,
11532 onClose: () => setContextMenuAnchor(null),
11533 placement: "bottom-start",
11534 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(PropertiesSection, { showLabel: false })
11535 }
11536 ),
11537 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11538 "thead",
11539 {
11540 className: clsx_default({
11541 "dataviews-view-table__thead--stuck": isVerticallyScrolled
11542 }),
11543 onContextMenu: handleHeaderContextMenu,
11544 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tr", { className: "dataviews-view-table__row", children: [
11545 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11546 "th",
11547 {
11548 className: "dataviews-view-table__checkbox-column",
11549 scope: "col",
11550 onContextMenu: handleHeaderContextMenu,
11551 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11552 BulkSelectionCheckbox,
11553 {
11554 selection,
11555 onChangeSelection,
11556 data,
11557 actions,
11558 getItemId
11559 }
11560 )
11561 }
11562 ),
11563 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11564 column_header_menu_default,
11565 {
11566 ref: headerMenuRef(
11567 titleField.id,
11568 0
11569 ),
11570 fieldId: titleField.id,
11571 view,
11572 fields,
11573 onChangeView,
11574 onHide,
11575 setOpenedFilter,
11576 canMove: false,
11577 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
11578 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
11579 }
11580 ) }),
11581 columns.map((column, index2) => {
11582 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
11583 const field = fields.find(
11584 (f2) => f2.id === column
11585 );
11586 const effectiveAlign = getEffectiveAlign(
11587 align,
11588 field?.type
11589 );
11590 const canInsertOrMove = view.layout?.enableMoving ?? true;
11591 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11592 "th",
11593 {
11594 style: {
11595 width,
11596 maxWidth,
11597 minWidth,
11598 textAlign: effectiveAlign
11599 },
11600 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
11601 scope: "col",
11602 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11603 column_header_menu_default,
11604 {
11605 ref: headerMenuRef(column, index2),
11606 fieldId: column,
11607 view,
11608 fields,
11609 onChangeView,
11610 onHide,
11611 setOpenedFilter,
11612 canMove: canInsertOrMove,
11613 canInsertLeft: canInsertOrMove,
11614 canInsertRight: canInsertOrMove
11615 }
11616 )
11617 },
11618 column
11619 );
11620 }),
11621 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11622 "th",
11623 {
11624 className: clsx_default(
11625 "dataviews-view-table__actions-column",
11626 {
11627 "dataviews-view-table__actions-column--sticky": true,
11628 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
11629 }
11630 ),
11631 children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
11632 }
11633 )
11634 ] })
11635 }
11636 ),
11637 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
11638 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("tbody", { children: [
11639 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11640 "td",
11641 {
11642 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
11643 className: "dataviews-view-table__group-header-cell",
11644 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
11645 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
11646 (0, import_i18n9.__)("%1$s: %2$s"),
11647 groupField.label,
11648 groupName
11649 )
11650 }
11651 ) }),
11652 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11653 TableRow,
11654 {
11655 item,
11656 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11657 hasBulkActions,
11658 actions,
11659 fields,
11660 id: getItemId(item) || index2.toString(),
11661 view,
11662 titleField,
11663 mediaField,
11664 descriptionField,
11665 selection,
11666 getItemId,
11667 onChangeSelection,
11668 onClickItem,
11669 renderItemLink,
11670 isItemClickable,
11671 isActionsColumnSticky: !isHorizontalScrollEnd
11672 },
11673 getItemId(item)
11674 ))
11675 ] }, `group-${groupName}`)
11676 ) : /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("tbody", { children: hasData && data.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
11677 TableRow,
11678 {
11679 item,
11680 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
11681 hasBulkActions,
11682 actions,
11683 fields,
11684 id: getItemId(item) || index2.toString(),
11685 view,
11686 titleField,
11687 mediaField,
11688 descriptionField,
11689 selection,
11690 getItemId,
11691 onChangeSelection,
11692 onClickItem,
11693 renderItemLink,
11694 isItemClickable,
11695 isActionsColumnSticky: !isHorizontalScrollEnd,
11696 posinset: isInfiniteScroll ? index2 + 1 : void 0
11697 },
11698 getItemId(item)
11699 )) })
11700 ]
11701 }
11702 ),
11703 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, {}) }) })
11704 ] });
11705 }
11706 var table_default = ViewTable;
11707
11708 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
11709 var import_components9 = __toESM(require_components(), 1);
11710 var import_i18n12 = __toESM(require_i18n(), 1);
11711
11712 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11713 var import_components8 = __toESM(require_components(), 1);
11714 var import_i18n11 = __toESM(require_i18n(), 1);
11715 var import_compose3 = __toESM(require_compose(), 1);
11716 var import_keycodes2 = __toESM(require_keycodes(), 1);
11717 var import_element29 = __toESM(require_element(), 1);
11718
11719 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
11720 var import_components7 = __toESM(require_components(), 1);
11721 var import_i18n10 = __toESM(require_i18n(), 1);
11722 var import_element26 = __toESM(require_element(), 1);
11723 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
11724 var imageSizes = [
11725 {
11726 value: 120,
11727 breakpoint: 1
11728 },
11729 {
11730 value: 170,
11731 breakpoint: 1
11732 },
11733 {
11734 value: 230,
11735 breakpoint: 1
11736 },
11737 {
11738 value: 290,
11739 breakpoint: 1112
11740 // at minimum image width, 4 images display at this container size
11741 },
11742 {
11743 value: 350,
11744 breakpoint: 1636
11745 // at minimum image width, 6 images display at this container size
11746 },
11747 {
11748 value: 430,
11749 breakpoint: 588
11750 // at minimum image width, 2 images display at this container size
11751 }
11752 ];
11753 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
11754 function useGridColumns() {
11755 const context = (0, import_element26.useContext)(dataviews_context_default);
11756 const view = context.view;
11757 return (0, import_element26.useMemo)(() => {
11758 const containerWidth = context.containerWidth;
11759 const gap = 32;
11760 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
11761 const columns = Math.floor(
11762 (containerWidth + gap) / (previewSize + gap)
11763 );
11764 return Math.max(1, columns);
11765 }, [context.containerWidth, view.layout?.previewSize]);
11766 }
11767
11768 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
11769 var import_element27 = __toESM(require_element(), 1);
11770 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
11771 var GridItems = (0, import_element27.forwardRef)(({ className, previewSize, ...props }, ref) => {
11772 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11773 "div",
11774 {
11775 ref,
11776 className: clsx_default("dataviews-view-grid-items", className),
11777 style: {
11778 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
11779 },
11780 ...props
11781 }
11782 );
11783 });
11784
11785 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
11786 var import_element28 = __toESM(require_element(), 1);
11787 function useIntersectionObserver(elementRef, posinset) {
11788 const { intersectionObserver } = (0, import_element28.useContext)(dataviews_context_default);
11789 (0, import_element28.useEffect)(() => {
11790 const element = elementRef.current;
11791 if (!element || posinset === void 0 || !intersectionObserver) {
11792 return;
11793 }
11794 intersectionObserver.observe(element);
11795 return () => {
11796 intersectionObserver.unobserve(element);
11797 };
11798 }, [elementRef, intersectionObserver, posinset]);
11799 }
11800 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
11801 const hasData = !!data?.length;
11802 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
11803 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
11804 }
11805
11806 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
11807 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
11808 var { Badge: WCBadge } = unlock3(import_components8.privateApis);
11809 function chunk(array, size4) {
11810 const chunks = [];
11811 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size4) {
11812 chunks.push(array.slice(i2, i2 + size4));
11813 }
11814 return chunks;
11815 }
11816 var GridItem = (0, import_element29.forwardRef)(
11817 function GridItem2({
11818 view,
11819 selection,
11820 onChangeSelection,
11821 onClickItem,
11822 isItemClickable,
11823 renderItemLink,
11824 getItemId,
11825 item,
11826 actions,
11827 mediaField,
11828 titleField,
11829 descriptionField,
11830 regularFields,
11831 badgeFields,
11832 hasBulkActions,
11833 config,
11834 posinset,
11835 setsize,
11836 ...props
11837 }, forwardedRef) {
11838 const {
11839 showTitle = true,
11840 showMedia = true,
11841 showDescription = true
11842 } = view;
11843 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
11844 const id = getItemId(item);
11845 const elementRef = (0, import_element29.useRef)(null);
11846 const setRefs = (0, import_element29.useCallback)(
11847 (node) => {
11848 elementRef.current = node;
11849 if (typeof forwardedRef === "function") {
11850 forwardedRef(node);
11851 } else if (forwardedRef) {
11852 forwardedRef.current = node;
11853 }
11854 },
11855 [forwardedRef]
11856 );
11857 useIntersectionObserver(elementRef, posinset);
11858 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
11859 const isSelected2 = selection.includes(id);
11860 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
11861 const rendersMediaField = showMedia && mediaField?.render;
11862 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11863 mediaField.render,
11864 {
11865 item,
11866 field: mediaField,
11867 config
11868 }
11869 ) : mediaPlaceholder;
11870 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(titleField.render, { item, field: titleField }) : null;
11871 let mediaA11yProps;
11872 let titleA11yProps;
11873 if (isItemClickable(item) && onClickItem) {
11874 if (renderedTitleField) {
11875 mediaA11yProps = {
11876 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
11877 };
11878 titleA11yProps = {
11879 id: `dataviews-view-grid__title-field-${instanceId}`
11880 };
11881 } else {
11882 mediaA11yProps = {
11883 "aria-label": (0, import_i18n11.__)("Navigate to item")
11884 };
11885 }
11886 }
11887 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
11888 Stack,
11889 {
11890 direction: "column",
11891 ...props,
11892 ref: setRefs,
11893 "aria-setsize": setsize,
11894 "aria-posinset": posinset,
11895 className: clsx_default(
11896 props.className,
11897 "dataviews-view-grid__row__gridcell",
11898 "dataviews-view-grid__card",
11899 {
11900 "is-selected": hasBulkAction && isSelected2
11901 }
11902 ),
11903 onClickCapture: (event) => {
11904 props.onClickCapture?.(event);
11905 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
11906 event.stopPropagation();
11907 event.preventDefault();
11908 if (!hasBulkAction) {
11909 return;
11910 }
11911 onChangeSelection(
11912 isSelected2 ? selection.filter(
11913 (itemId) => id !== itemId
11914 ) : [...selection, id]
11915 );
11916 }
11917 },
11918 children: [
11919 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11920 ItemClickWrapper,
11921 {
11922 item,
11923 isItemClickable,
11924 onClickItem,
11925 renderItemLink,
11926 className: clsx_default("dataviews-view-grid__media", {
11927 "dataviews-view-grid__media--placeholder": !rendersMediaField
11928 }),
11929 ...mediaA11yProps,
11930 children: renderedMediaField
11931 }
11932 ),
11933 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11934 DataViewsSelectionCheckbox,
11935 {
11936 item,
11937 selection,
11938 onChangeSelection,
11939 getItemId,
11940 titleField,
11941 disabled: !hasBulkAction
11942 }
11943 ),
11944 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11945 ItemActions,
11946 {
11947 item,
11948 actions,
11949 isCompact: true
11950 }
11951 ) }),
11952 showTitle && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-grid__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11953 ItemClickWrapper,
11954 {
11955 item,
11956 isItemClickable,
11957 onClickItem,
11958 renderItemLink,
11959 className: "dataviews-view-grid__title-field dataviews-title-field",
11960 ...titleA11yProps,
11961 title: titleField?.getValueFormatted({
11962 item,
11963 field: titleField
11964 }) || void 0,
11965 children: renderedTitleField
11966 }
11967 ) }),
11968 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Stack, { direction: "column", gap: "xs", children: [
11969 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11970 descriptionField.render,
11971 {
11972 item,
11973 field: descriptionField
11974 }
11975 ),
11976 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11977 Stack,
11978 {
11979 direction: "row",
11980 className: "dataviews-view-grid__badge-fields",
11981 gap: "sm",
11982 wrap: "wrap",
11983 align: "top",
11984 justify: "flex-start",
11985 children: badgeFields.map((field) => {
11986 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11987 WCBadge,
11988 {
11989 className: "dataviews-view-grid__field-value",
11990 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
11991 field.render,
11992 {
11993 item,
11994 field
11995 }
11996 )
11997 },
11998 field.id
11999 );
12000 })
12001 }
12002 ),
12003 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12004 Stack,
12005 {
12006 direction: "column",
12007 className: "dataviews-view-grid__fields",
12008 gap: "xs",
12009 children: regularFields.map((field) => {
12010 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12011 import_components8.Flex,
12012 {
12013 className: "dataviews-view-grid__field",
12014 gap: 1,
12015 justify: "flex-start",
12016 expanded: true,
12017 style: { height: "auto" },
12018 direction: "row",
12019 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
12020 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(tooltip_exports.Root, { children: [
12021 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12022 tooltip_exports.Trigger,
12023 {
12024 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header })
12025 }
12026 ),
12027 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(tooltip_exports.Popup, { children: field.label })
12028 ] }),
12029 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12030 import_components8.FlexItem,
12031 {
12032 className: "dataviews-view-grid__field-value",
12033 style: { maxHeight: "none" },
12034 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12035 field.render,
12036 {
12037 item,
12038 field
12039 }
12040 )
12041 }
12042 )
12043 ] })
12044 },
12045 field.id
12046 );
12047 })
12048 }
12049 )
12050 ] })
12051 ]
12052 }
12053 );
12054 }
12055 );
12056 function CompositeGrid({
12057 data,
12058 isInfiniteScroll,
12059 className,
12060 inert,
12061 isLoading,
12062 view,
12063 fields,
12064 selection,
12065 onChangeSelection,
12066 onClickItem,
12067 isItemClickable,
12068 renderItemLink,
12069 getItemId,
12070 actions
12071 }) {
12072 const { paginationInfo, resizeObserverRef } = (0, import_element29.useContext)(dataviews_context_default);
12073 const gridColumns = useGridColumns();
12074 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
12075 const titleField = fields.find(
12076 (field) => field.id === view?.titleField
12077 );
12078 const mediaField = fields.find(
12079 (field) => field.id === view?.mediaField
12080 );
12081 const descriptionField = fields.find(
12082 (field) => field.id === view?.descriptionField
12083 );
12084 const otherFields = view.fields ?? [];
12085 const { regularFields, badgeFields } = otherFields.reduce(
12086 (accumulator, fieldId) => {
12087 const field = fields.find((f2) => f2.id === fieldId);
12088 if (!field) {
12089 return accumulator;
12090 }
12091 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
12092 accumulator[key].push(field);
12093 return accumulator;
12094 },
12095 { regularFields: [], badgeFields: [] }
12096 );
12097 const size4 = "900px";
12098 const totalRows = Math.ceil(data.length / gridColumns);
12099 const placeholdersNeeded = usePlaceholdersNeeded(
12100 data,
12101 isInfiniteScroll,
12102 gridColumns
12103 );
12104 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, {
12105 // Render infinite scroll layout (no rows, feed semantics)
12106 children: [
12107 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
12108 import_components8.Composite,
12109 {
12110 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12111 GridItems,
12112 {
12113 className: clsx_default(
12114 "dataviews-view-grid-infinite-scroll",
12115 className,
12116 {
12117 [`has-${view.layout?.density}-density`]: view.layout?.density && [
12118 "compact",
12119 "comfortable"
12120 ].includes(view.layout.density)
12121 }
12122 ),
12123 previewSize: view.layout?.previewSize,
12124 "aria-busy": isLoading,
12125 ref: resizeObserverRef
12126 }
12127 ),
12128 role: "feed",
12129 focusWrap: true,
12130 inert,
12131 children: [
12132 Array.from({ length: placeholdersNeeded }).map(
12133 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12134 import_components8.Composite.Item,
12135 {
12136 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12137 Stack,
12138 {
12139 ...props,
12140 direction: "column",
12141 role: "article",
12142 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
12143 }
12144 ),
12145 "aria-hidden": true,
12146 tabIndex: -1
12147 },
12148 `placeholder-${index2}`
12149 )
12150 ),
12151 data.map((item) => {
12152 const itemId = getItemId(item);
12153 const stablePosition = item.position;
12154 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12155 import_components8.Composite.Item,
12156 {
12157 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12158 GridItem,
12159 {
12160 ...props,
12161 id: itemId,
12162 role: "article",
12163 view,
12164 selection,
12165 onChangeSelection,
12166 onClickItem,
12167 isItemClickable,
12168 renderItemLink,
12169 getItemId,
12170 item,
12171 actions,
12172 mediaField,
12173 titleField,
12174 descriptionField,
12175 regularFields,
12176 badgeFields,
12177 hasBulkActions,
12178 posinset: stablePosition,
12179 setsize: paginationInfo.totalItems,
12180 config: {
12181 sizes: size4
12182 }
12183 }
12184 )
12185 },
12186 itemId
12187 );
12188 })
12189 ]
12190 }
12191 ),
12192 // Render standard grid layout (with rows, grid semantics)
12193 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12194 import_components8.Composite,
12195 {
12196 role: "grid",
12197 className: clsx_default("dataviews-view-grid", className, {
12198 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12199 view.layout.density
12200 )
12201 }),
12202 focusWrap: true,
12203 "aria-busy": isLoading,
12204 "aria-rowcount": totalRows,
12205 ref: resizeObserverRef,
12206 inert,
12207 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12208 import_components8.Composite.Row,
12209 {
12210 render: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12211 "div",
12212 {
12213 role: "row",
12214 "aria-rowindex": i2 + 1,
12215 "aria-label": (0, import_i18n11.sprintf)(
12216 /* translators: %d: The row number in the grid */
12217 (0, import_i18n11.__)("Row %d"),
12218 i2 + 1
12219 ),
12220 className: "dataviews-view-grid__row",
12221 style: {
12222 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
12223 }
12224 }
12225 ),
12226 children: row.map((item) => {
12227 const itemId = getItemId(item);
12228 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12229 import_components8.Composite.Item,
12230 {
12231 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
12232 GridItem,
12233 {
12234 ...props,
12235 id: itemId,
12236 role: "gridcell",
12237 view,
12238 selection,
12239 onChangeSelection,
12240 onClickItem,
12241 isItemClickable,
12242 renderItemLink,
12243 getItemId,
12244 item,
12245 actions,
12246 mediaField,
12247 titleField,
12248 descriptionField,
12249 regularFields,
12250 badgeFields,
12251 hasBulkActions,
12252 config: {
12253 sizes: size4
12254 }
12255 }
12256 )
12257 },
12258 itemId
12259 );
12260 })
12261 },
12262 i2
12263 ))
12264 }
12265 )
12266 ]
12267 });
12268 }
12269
12270 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
12271 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
12272 function ViewGrid({
12273 actions,
12274 data,
12275 fields,
12276 getItemId,
12277 isLoading,
12278 onChangeSelection,
12279 onClickItem,
12280 isItemClickable,
12281 renderItemLink,
12282 selection,
12283 view,
12284 className,
12285 empty
12286 }) {
12287 const isDelayedLoading = useDelayedLoading(!!isLoading);
12288 const hasData = !!data?.length;
12289 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
12290 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
12291 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12292 if (!hasData) {
12293 return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12294 "div",
12295 {
12296 className: clsx_default("dataviews-no-results", {
12297 "is-refreshing": isDelayedLoading
12298 }),
12299 children: empty
12300 }
12301 );
12302 }
12303 const gridProps = {
12304 className: clsx_default(className, {
12305 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12306 }),
12307 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12308 isLoading,
12309 view,
12310 fields,
12311 selection,
12312 onChangeSelection,
12313 onClickItem,
12314 isItemClickable,
12315 renderItemLink,
12316 getItemId,
12317 actions
12318 };
12319 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_jsx_runtime51.Fragment, {
12320 // Render multiple groups.
12321 children: [
12322 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
12323 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
12324 Stack,
12325 {
12326 direction: "column",
12327 gap: "sm",
12328 children: [
12329 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
12330 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12331 (0, import_i18n12.__)("%1$s: %2$s"),
12332 groupField.label,
12333 groupName
12334 ) }),
12335 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12336 CompositeGrid,
12337 {
12338 ...gridProps,
12339 data: groupItems,
12340 isInfiniteScroll: false
12341 }
12342 )
12343 ]
12344 },
12345 groupName
12346 )
12347 ) }),
12348 // Render a single grid with all data.
12349 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
12350 CompositeGrid,
12351 {
12352 ...gridProps,
12353 data,
12354 isInfiniteScroll: !!isInfiniteScroll
12355 }
12356 ),
12357 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components9.Spinner, {}) })
12358 ]
12359 });
12360 }
12361 var grid_default = ViewGrid;
12362
12363 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
12364 var import_compose4 = __toESM(require_compose(), 1);
12365 var import_components10 = __toESM(require_components(), 1);
12366 var import_element30 = __toESM(require_element(), 1);
12367 var import_i18n13 = __toESM(require_i18n(), 1);
12368 var import_data6 = __toESM(require_data(), 1);
12369 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
12370 var { Menu: Menu3 } = unlock3(import_components10.privateApis);
12371 function generateItemWrapperCompositeId(idPrefix) {
12372 return `${idPrefix}-item-wrapper`;
12373 }
12374 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
12375 return `${idPrefix}-primary-action-${primaryActionId}`;
12376 }
12377 function generateDropdownTriggerCompositeId(idPrefix) {
12378 return `${idPrefix}-dropdown`;
12379 }
12380 function PrimaryActionGridCell({
12381 idPrefix,
12382 primaryAction,
12383 item
12384 }) {
12385 const registry = (0, import_data6.useRegistry)();
12386 const [isModalOpen, setIsModalOpen] = (0, import_element30.useState)(false);
12387 const compositeItemId = generatePrimaryActionCompositeId(
12388 idPrefix,
12389 primaryAction.id
12390 );
12391 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
12392 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12393 import_components10.Composite.Item,
12394 {
12395 id: compositeItemId,
12396 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12397 import_components10.Button,
12398 {
12399 disabled: !!primaryAction.disabled,
12400 accessibleWhenDisabled: true,
12401 text: label,
12402 size: "small",
12403 onClick: () => setIsModalOpen(true)
12404 }
12405 ),
12406 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12407 ActionModal,
12408 {
12409 action: primaryAction,
12410 items: [item],
12411 closeModal: () => setIsModalOpen(false)
12412 }
12413 )
12414 }
12415 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12416 import_components10.Composite.Item,
12417 {
12418 id: compositeItemId,
12419 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12420 import_components10.Button,
12421 {
12422 disabled: !!primaryAction.disabled,
12423 accessibleWhenDisabled: true,
12424 size: "small",
12425 onClick: () => {
12426 primaryAction.callback([item], { registry });
12427 },
12428 children: label
12429 }
12430 )
12431 }
12432 ) }, primaryAction.id);
12433 }
12434 function ListItem({
12435 view,
12436 actions,
12437 idPrefix,
12438 isSelected: isSelected2,
12439 item,
12440 titleField,
12441 mediaField,
12442 descriptionField,
12443 onSelect,
12444 otherFields,
12445 onDropdownTriggerKeyDown,
12446 posinset
12447 }) {
12448 const {
12449 showTitle = true,
12450 showMedia = true,
12451 showDescription = true,
12452 infiniteScrollEnabled
12453 } = view;
12454 const itemRef = (0, import_element30.useRef)(null);
12455 const labelId = `${idPrefix}-label`;
12456 const descriptionId = `${idPrefix}-description`;
12457 const registry = (0, import_data6.useRegistry)();
12458 const [isHovered, setIsHovered] = (0, import_element30.useState)(false);
12459 const [activeModalAction, setActiveModalAction] = (0, import_element30.useState)(
12460 null
12461 );
12462 const handleHover = ({ type }) => {
12463 const isHover = type === "mouseenter";
12464 setIsHovered(isHover);
12465 };
12466 const { paginationInfo } = (0, import_element30.useContext)(dataviews_context_default);
12467 (0, import_element30.useEffect)(() => {
12468 if (isSelected2) {
12469 itemRef.current?.scrollIntoView({
12470 behavior: "auto",
12471 block: "nearest",
12472 inline: "nearest"
12473 });
12474 }
12475 }, [isSelected2]);
12476 const { primaryAction, eligibleActions } = (0, import_element30.useMemo)(() => {
12477 const _eligibleActions = actions.filter(
12478 (action) => !action.isEligible || action.isEligible(item)
12479 );
12480 const _primaryActions = _eligibleActions.filter(
12481 (action) => action.isPrimary
12482 );
12483 return {
12484 primaryAction: _primaryActions[0],
12485 eligibleActions: _eligibleActions
12486 };
12487 }, [actions, item]);
12488 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
12489 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)(
12490 mediaField.render,
12491 {
12492 item,
12493 field: mediaField,
12494 config: { sizes: "52px" }
12495 }
12496 ) }) : null;
12497 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(titleField.render, { item, field: titleField }) : null;
12498 const renderDescription = showDescription && descriptionField?.render;
12499 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
12500 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12501 Stack,
12502 {
12503 direction: "row",
12504 gap: "md",
12505 className: "dataviews-view-list__item-actions",
12506 children: [
12507 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12508 PrimaryActionGridCell,
12509 {
12510 idPrefix,
12511 primaryAction,
12512 item
12513 }
12514 ),
12515 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { role: "gridcell", children: [
12516 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Menu3, { placement: "bottom-end", children: [
12517 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12518 Menu3.TriggerButton,
12519 {
12520 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12521 import_components10.Composite.Item,
12522 {
12523 id: generateDropdownTriggerCompositeId(
12524 idPrefix
12525 ),
12526 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12527 import_components10.Button,
12528 {
12529 size: "small",
12530 icon: more_vertical_default,
12531 label: (0, import_i18n13.__)("Actions"),
12532 accessibleWhenDisabled: true,
12533 disabled: !actions.length,
12534 onKeyDown: onDropdownTriggerKeyDown
12535 }
12536 )
12537 }
12538 )
12539 }
12540 ),
12541 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12542 ActionsMenuGroup,
12543 {
12544 actions: eligibleActions,
12545 item,
12546 registry,
12547 setActiveModalAction
12548 }
12549 ) })
12550 ] }),
12551 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12552 ActionModal,
12553 {
12554 action: activeModalAction,
12555 items: [item],
12556 closeModal: () => setActiveModalAction(null)
12557 }
12558 )
12559 ] })
12560 ]
12561 }
12562 );
12563 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12564 import_components10.Composite.Row,
12565 {
12566 ref: itemRef,
12567 render: (
12568 /* aria-posinset breaks Composite.Row if passed to it directly. */
12569 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12570 "div",
12571 {
12572 "aria-posinset": posinset,
12573 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
12574 }
12575 )
12576 ),
12577 role: infiniteScrollEnabled ? "article" : "row",
12578 className: clsx_default({
12579 "is-selected": isSelected2,
12580 "is-hovered": isHovered
12581 }),
12582 onMouseEnter: handleHover,
12583 onMouseLeave: handleHover,
12584 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12585 Stack,
12586 {
12587 direction: "row",
12588 className: "dataviews-view-list__item-wrapper",
12589 children: [
12590 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12591 import_components10.Composite.Item,
12592 {
12593 id: generateItemWrapperCompositeId(idPrefix),
12594 "aria-pressed": isSelected2,
12595 "aria-labelledby": labelId,
12596 "aria-describedby": descriptionId,
12597 className: "dataviews-view-list__item",
12598 onClick: () => onSelect(item)
12599 }
12600 ) }),
12601 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12602 Stack,
12603 {
12604 direction: "row",
12605 gap: "md",
12606 justify: "start",
12607 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
12608 style: { flex: 1, minWidth: 0 },
12609 children: [
12610 renderedMediaField,
12611 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12612 Stack,
12613 {
12614 direction: "column",
12615 gap: "xs",
12616 className: "dataviews-view-list__field-wrapper",
12617 children: [
12618 /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(Stack, { direction: "row", align: "center", children: [
12619 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12620 "div",
12621 {
12622 className: "dataviews-title-field dataviews-view-list__title-field",
12623 id: labelId,
12624 children: renderedTitleField
12625 }
12626 ),
12627 usedActions
12628 ] }),
12629 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12630 descriptionField.render,
12631 {
12632 item,
12633 field: descriptionField
12634 }
12635 ) }),
12636 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12637 "div",
12638 {
12639 className: "dataviews-view-list__fields",
12640 id: descriptionId,
12641 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12642 "div",
12643 {
12644 className: "dataviews-view-list__field",
12645 children: [
12646 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12647 VisuallyHidden,
12648 {
12649 className: "dataviews-view-list__field-label",
12650 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", {}),
12651 children: field.label
12652 }
12653 ),
12654 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12655 field.render,
12656 {
12657 item,
12658 field
12659 }
12660 ) })
12661 ]
12662 },
12663 field.id
12664 ))
12665 }
12666 )
12667 ]
12668 }
12669 )
12670 ]
12671 }
12672 )
12673 ]
12674 }
12675 )
12676 }
12677 );
12678 }
12679 function isDefined2(item) {
12680 return !!item;
12681 }
12682 function ViewList(props) {
12683 const {
12684 actions,
12685 data,
12686 fields,
12687 getItemId,
12688 isLoading,
12689 onChangeSelection,
12690 selection,
12691 view,
12692 className,
12693 empty
12694 } = props;
12695 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
12696 const isDelayedLoading = useDelayedLoading(!!isLoading);
12697 const selectedItem = data?.findLast(
12698 (item) => selection.includes(getItemId(item))
12699 );
12700 const titleField = fields.find((field) => field.id === view.titleField);
12701 const mediaField = fields.find((field) => field.id === view.mediaField);
12702 const descriptionField = fields.find(
12703 (field) => field.id === view.descriptionField
12704 );
12705 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
12706 const onSelect = (item) => onChangeSelection([getItemId(item)]);
12707 const generateCompositeItemIdPrefix = (0, import_element30.useCallback)(
12708 (item) => `${baseId}-${getItemId(item)}`,
12709 [baseId, getItemId]
12710 );
12711 const isActiveCompositeItem = (0, import_element30.useCallback)(
12712 (item, idToCheck) => {
12713 return idToCheck.startsWith(
12714 generateCompositeItemIdPrefix(item)
12715 );
12716 },
12717 [generateCompositeItemIdPrefix]
12718 );
12719 const [activeCompositeId, setActiveCompositeId] = (0, import_element30.useState)(void 0);
12720 const compositeRef = (0, import_element30.useRef)(null);
12721 (0, import_element30.useEffect)(() => {
12722 if (selectedItem) {
12723 setActiveCompositeId(
12724 generateItemWrapperCompositeId(
12725 generateCompositeItemIdPrefix(selectedItem)
12726 )
12727 );
12728 }
12729 }, [selectedItem, generateCompositeItemIdPrefix]);
12730 const activeItemIndex = data.findIndex(
12731 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
12732 );
12733 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
12734 const isActiveIdInList = activeItemIndex !== -1;
12735 const selectCompositeItem = (0, import_element30.useCallback)(
12736 (targetIndex, generateCompositeId) => {
12737 const clampedIndex = Math.min(
12738 data.length - 1,
12739 Math.max(0, targetIndex)
12740 );
12741 if (!data[clampedIndex]) {
12742 return;
12743 }
12744 const itemIdPrefix = generateCompositeItemIdPrefix(
12745 data[clampedIndex]
12746 );
12747 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
12748 setActiveCompositeId(targetCompositeItemId);
12749 if (compositeRef.current?.contains(
12750 compositeRef.current.ownerDocument.activeElement
12751 )) {
12752 document.getElementById(targetCompositeItemId)?.focus();
12753 }
12754 },
12755 [data, generateCompositeItemIdPrefix]
12756 );
12757 (0, import_element30.useEffect)(() => {
12758 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
12759 if (!isActiveIdInList && wasActiveIdInList) {
12760 selectCompositeItem(
12761 previousActiveItemIndex,
12762 generateItemWrapperCompositeId
12763 );
12764 }
12765 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
12766 const onDropdownTriggerKeyDown = (0, import_element30.useCallback)(
12767 (event) => {
12768 if (event.key === "ArrowDown") {
12769 event.preventDefault();
12770 selectCompositeItem(
12771 activeItemIndex + 1,
12772 generateDropdownTriggerCompositeId
12773 );
12774 }
12775 if (event.key === "ArrowUp") {
12776 event.preventDefault();
12777 selectCompositeItem(
12778 activeItemIndex - 1,
12779 generateDropdownTriggerCompositeId
12780 );
12781 }
12782 },
12783 [selectCompositeItem, activeItemIndex]
12784 );
12785 const hasData = !!data?.length;
12786 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
12787 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
12788 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
12789 if (!hasData) {
12790 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12791 "div",
12792 {
12793 className: clsx_default("dataviews-no-results", {
12794 "is-refreshing": isDelayedLoading
12795 }),
12796 children: empty
12797 }
12798 );
12799 }
12800 if (hasData && groupField && dataByGroup) {
12801 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12802 import_components10.Composite,
12803 {
12804 ref: compositeRef,
12805 id: `${baseId}`,
12806 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
12807 className: "dataviews-view-list__group",
12808 role: "grid",
12809 activeId: activeCompositeId,
12810 setActiveId: setActiveCompositeId,
12811 children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12812 Stack,
12813 {
12814 direction: "column",
12815 gap: "lg",
12816 className: clsx_default("dataviews-view-list", className),
12817 children: Array.from(dataByGroup.entries()).map(
12818 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
12819 Stack,
12820 {
12821 direction: "column",
12822 gap: "sm",
12823 children: [
12824 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
12825 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
12826 (0, import_i18n13.__)("%1$s: %2$s"),
12827 groupField.label,
12828 groupName
12829 ) }),
12830 groupItems.map((item) => {
12831 const id = generateCompositeItemIdPrefix(item);
12832 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12833 ListItem,
12834 {
12835 view,
12836 idPrefix: id,
12837 actions,
12838 item,
12839 isSelected: item === selectedItem,
12840 onSelect,
12841 mediaField,
12842 titleField,
12843 descriptionField,
12844 otherFields,
12845 onDropdownTriggerKeyDown
12846 },
12847 id
12848 );
12849 })
12850 ]
12851 },
12852 groupName
12853 )
12854 )
12855 }
12856 )
12857 }
12858 );
12859 }
12860 return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
12861 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12862 import_components10.Composite,
12863 {
12864 ref: compositeRef,
12865 id: baseId,
12866 render: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", {}),
12867 className: clsx_default("dataviews-view-list", className, {
12868 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
12869 view.layout.density
12870 ),
12871 "is-refreshing": !isInfiniteScroll && isDelayedLoading
12872 }),
12873 role: view.infiniteScrollEnabled ? "feed" : "grid",
12874 activeId: activeCompositeId,
12875 setActiveId: setActiveCompositeId,
12876 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
12877 children: data.map((item, index2) => {
12878 const id = generateCompositeItemIdPrefix(item);
12879 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
12880 ListItem,
12881 {
12882 view,
12883 idPrefix: id,
12884 actions,
12885 item,
12886 isSelected: item === selectedItem,
12887 onSelect,
12888 mediaField,
12889 titleField,
12890 descriptionField,
12891 otherFields,
12892 onDropdownTriggerKeyDown,
12893 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
12894 },
12895 id
12896 );
12897 })
12898 }
12899 ),
12900 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components10.Spinner, {}) })
12901 ] });
12902 }
12903
12904 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
12905 var import_components11 = __toESM(require_components(), 1);
12906
12907 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
12908 var import_i18n14 = __toESM(require_i18n(), 1);
12909 var import_element31 = __toESM(require_element(), 1);
12910 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
12911 function ActivityGroup({
12912 groupName,
12913 groupData,
12914 groupField,
12915 showLabel = true,
12916 children
12917 }) {
12918 const groupHeader = showLabel ? (0, import_element31.createInterpolateElement)(
12919 // translators: %s: The label of the field e.g. "Status".
12920 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
12921 {
12922 groupName: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
12923 groupField.render,
12924 {
12925 item: groupData[0],
12926 field: groupField
12927 }
12928 )
12929 }
12930 ) : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(groupField.render, { item: groupData[0], field: groupField });
12931 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
12932 Stack,
12933 {
12934 direction: "column",
12935 className: "dataviews-view-activity__group",
12936 children: [
12937 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
12938 children
12939 ]
12940 },
12941 groupName
12942 );
12943 }
12944
12945 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
12946 var import_element32 = __toESM(require_element(), 1);
12947 var import_data7 = __toESM(require_data(), 1);
12948 var import_compose5 = __toESM(require_compose(), 1);
12949 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
12950 function ActivityItem(props) {
12951 const {
12952 view,
12953 actions,
12954 item,
12955 titleField,
12956 mediaField,
12957 descriptionField,
12958 otherFields,
12959 posinset,
12960 onClickItem,
12961 renderItemLink,
12962 isItemClickable
12963 } = props;
12964 const {
12965 showTitle = true,
12966 showMedia = true,
12967 showDescription = true,
12968 infiniteScrollEnabled
12969 } = view;
12970 const itemRef = (0, import_element32.useRef)(null);
12971 const registry = (0, import_data7.useRegistry)();
12972 const { paginationInfo } = (0, import_element32.useContext)(dataviews_context_default);
12973 const { primaryActions, eligibleActions } = (0, import_element32.useMemo)(() => {
12974 const _eligibleActions = actions.filter(
12975 (action) => !action.isEligible || action.isEligible(item)
12976 );
12977 const _primaryActions = _eligibleActions.filter(
12978 (action) => action.isPrimary
12979 );
12980 return {
12981 primaryActions: _primaryActions,
12982 eligibleActions: _eligibleActions
12983 };
12984 }, [actions, item]);
12985 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
12986 const density = view.layout?.density ?? "balanced";
12987 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12988 mediaField.render,
12989 {
12990 item,
12991 field: mediaField,
12992 config: {
12993 sizes: density === "comfortable" ? "32px" : "24px"
12994 }
12995 }
12996 ) : null;
12997 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
12998 "span",
12999 {
13000 className: "dataviews-view-activity__item-bullet",
13001 "aria-hidden": "true"
13002 }
13003 ) });
13004 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(titleField.render, { item, field: titleField }) : null;
13005 const verticalGap = (0, import_element32.useMemo)(() => {
13006 switch (density) {
13007 case "comfortable":
13008 return "md";
13009 default:
13010 return "sm";
13011 }
13012 }, [density]);
13013 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13014 "div",
13015 {
13016 ref: itemRef,
13017 role: infiniteScrollEnabled ? "article" : void 0,
13018 "aria-posinset": posinset,
13019 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
13020 className: clsx_default(
13021 "dataviews-view-activity__item",
13022 density === "compact" && "is-compact",
13023 density === "balanced" && "is-balanced",
13024 density === "comfortable" && "is-comfortable"
13025 ),
13026 children: /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
13027 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13028 Stack,
13029 {
13030 direction: "column",
13031 gap: "xs",
13032 align: "center",
13033 className: "dataviews-view-activity__item-type",
13034 children: renderedMediaField
13035 }
13036 ),
13037 /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13038 Stack,
13039 {
13040 direction: "column",
13041 gap: verticalGap,
13042 align: "flex-start",
13043 className: "dataviews-view-activity__item-content",
13044 children: [
13045 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13046 ItemClickWrapper,
13047 {
13048 item,
13049 isItemClickable,
13050 onClickItem,
13051 renderItemLink,
13052 className: "dataviews-view-activity__item-title",
13053 children: renderedTitleField
13054 }
13055 ),
13056 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13057 descriptionField.render,
13058 {
13059 item,
13060 field: descriptionField
13061 }
13062 ) }),
13063 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
13064 "div",
13065 {
13066 className: "dataviews-view-activity__item-field",
13067 children: [
13068 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13069 VisuallyHidden,
13070 {
13071 className: "dataviews-view-activity__item-field-label",
13072 render: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", {}),
13073 children: field.label
13074 }
13075 ),
13076 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13077 field.render,
13078 {
13079 item,
13080 field
13081 }
13082 ) })
13083 ]
13084 },
13085 field.id
13086 )) }),
13087 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13088 PrimaryActions,
13089 {
13090 item,
13091 actions: primaryActions,
13092 registry,
13093 buttonVariant: "secondary"
13094 }
13095 )
13096 ]
13097 }
13098 ),
13099 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
13100 // there if there are any actions at all.
13101 isMobileViewport && // At the same time, only show the menu if there are actions to show.
13102 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
13103 ItemActions,
13104 {
13105 item,
13106 actions: eligibleActions,
13107 isCompact: true
13108 }
13109 ) })
13110 ] })
13111 }
13112 );
13113 }
13114 var activity_item_default = ActivityItem;
13115
13116 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
13117 var import_react6 = __toESM(require_react(), 1);
13118 function isDefined3(item) {
13119 return !!item;
13120 }
13121 function ActivityItems(props) {
13122 const { data, fields, getItemId, view } = props;
13123 const titleField = fields.find((field) => field.id === view.titleField);
13124 const mediaField = fields.find((field) => field.id === view.mediaField);
13125 const descriptionField = fields.find(
13126 (field) => field.id === view.descriptionField
13127 );
13128 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
13129 return data.map((item, index2) => {
13130 return /* @__PURE__ */ (0, import_react6.createElement)(
13131 activity_item_default,
13132 {
13133 ...props,
13134 key: getItemId(item),
13135 item,
13136 mediaField,
13137 titleField,
13138 descriptionField,
13139 otherFields,
13140 posinset: view.infiniteScrollEnabled ? index2 + 1 : void 0
13141 }
13142 );
13143 });
13144 }
13145
13146 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
13147 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
13148 function ViewActivity(props) {
13149 const { empty, data, fields, isLoading, view, className } = props;
13150 const isDelayedLoading = useDelayedLoading(!!isLoading);
13151 const hasData = !!data?.length;
13152 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
13153 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
13154 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13155 if (!hasData) {
13156 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13157 "div",
13158 {
13159 className: clsx_default("dataviews-no-results", {
13160 "is-refreshing": isDelayedLoading
13161 }),
13162 children: empty
13163 }
13164 );
13165 }
13166 const isInert = !isInfiniteScroll && !!isLoading;
13167 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
13168 "is-refreshing": !isInfiniteScroll && isDelayedLoading
13169 });
13170 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
13171 if (hasData && groupField && dataByGroup) {
13172 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13173 Stack,
13174 {
13175 direction: "column",
13176 gap: "sm",
13177 className: wrapperClassName,
13178 inert: isInert ? "true" : void 0,
13179 children: groupedEntries.map(
13180 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13181 ActivityGroup,
13182 {
13183 groupName,
13184 groupData,
13185 groupField,
13186 showLabel: view.groupBy?.showLabel !== false,
13187 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13188 ActivityItems,
13189 {
13190 ...props,
13191 data: groupData
13192 }
13193 )
13194 },
13195 groupName
13196 )
13197 )
13198 }
13199 );
13200 }
13201 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
13202 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
13203 "div",
13204 {
13205 className: wrapperClassName,
13206 role: view.infiniteScrollEnabled ? "feed" : void 0,
13207 inert: isInert ? "true" : void 0,
13208 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ActivityItems, { ...props })
13209 }
13210 ),
13211 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components11.Spinner, {}) })
13212 ] });
13213 }
13214
13215 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13216 var import_components14 = __toESM(require_components(), 1);
13217 var import_i18n17 = __toESM(require_i18n(), 1);
13218 var import_compose6 = __toESM(require_compose(), 1);
13219 var import_element35 = __toESM(require_element(), 1);
13220
13221 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13222 var import_components13 = __toESM(require_components(), 1);
13223 var import_data8 = __toESM(require_data(), 1);
13224 var import_element34 = __toESM(require_element(), 1);
13225 var import_i18n16 = __toESM(require_i18n(), 1);
13226
13227 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
13228 var import_components12 = __toESM(require_components(), 1);
13229 var import_element33 = __toESM(require_element(), 1);
13230 var import_i18n15 = __toESM(require_i18n(), 1);
13231 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
13232 function DataViewsPagination() {
13233 const {
13234 view,
13235 onChangeView,
13236 paginationInfo: { totalItems = 0, totalPages }
13237 } = (0, import_element33.useContext)(dataviews_context_default);
13238 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
13239 return null;
13240 }
13241 const currentPage = view.page ?? 1;
13242 const pageSelectOptions = Array.from(Array(totalPages)).map(
13243 (_, i2) => {
13244 const page = i2 + 1;
13245 return {
13246 value: page.toString(),
13247 label: page.toString(),
13248 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
13249 // translators: 1: current page number. 2: total number of pages.
13250 (0, import_i18n15.__)("Page %1$d of %2$d"),
13251 currentPage,
13252 totalPages
13253 ) : page.toString()
13254 };
13255 }
13256 );
13257 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
13258 Stack,
13259 {
13260 direction: "row",
13261 className: "dataviews-pagination",
13262 justify: "end",
13263 align: "center",
13264 gap: "xl",
13265 children: [
13266 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13267 Stack,
13268 {
13269 direction: "row",
13270 justify: "flex-start",
13271 align: "center",
13272 gap: "xs",
13273 className: "dataviews-pagination__page-select",
13274 children: (0, import_element33.createInterpolateElement)(
13275 (0, import_i18n15.sprintf)(
13276 // translators: 1: Current page number, 2: Total number of pages.
13277 (0, import_i18n15._x)(
13278 "<div>Page</div>%1$s<div>of %2$d</div>",
13279 "paging"
13280 ),
13281 "<CurrentPage />",
13282 totalPages
13283 ),
13284 {
13285 div: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { "aria-hidden": true }),
13286 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
13287 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13288 import_components12.SelectControl,
13289 {
13290 "aria-label": (0, import_i18n15.__)("Current page"),
13291 value: currentPage.toString(),
13292 options: pageSelectOptions,
13293 onChange: (newValue) => {
13294 onChangeView({
13295 ...view,
13296 page: +newValue
13297 });
13298 },
13299 size: "small",
13300 variant: "minimal"
13301 }
13302 )
13303 }
13304 )
13305 }
13306 ),
13307 /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
13308 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13309 import_components12.Button,
13310 {
13311 onClick: () => onChangeView({
13312 ...view,
13313 page: currentPage - 1
13314 }),
13315 disabled: currentPage === 1,
13316 accessibleWhenDisabled: true,
13317 label: (0, import_i18n15.__)("Previous page"),
13318 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
13319 showTooltip: true,
13320 size: "compact",
13321 tooltipPosition: "top"
13322 }
13323 ),
13324 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
13325 import_components12.Button,
13326 {
13327 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
13328 disabled: currentPage >= totalPages,
13329 accessibleWhenDisabled: true,
13330 label: (0, import_i18n15.__)("Next page"),
13331 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
13332 showTooltip: true,
13333 size: "compact",
13334 tooltipPosition: "top"
13335 }
13336 )
13337 ] })
13338 ]
13339 }
13340 );
13341 }
13342 var dataviews_pagination_default = (0, import_element33.memo)(DataViewsPagination);
13343
13344 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
13345 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
13346 function useIsMultiselectPicker(actions) {
13347 return (0, import_element34.useMemo)(() => {
13348 return actions?.every((action) => action.supportsBulk);
13349 }, [actions]);
13350 }
13351
13352 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
13353 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
13354 var { Badge: WCBadge2 } = unlock3(import_components14.privateApis);
13355 function GridItem3({
13356 view,
13357 multiselect,
13358 selection,
13359 onChangeSelection,
13360 getItemId,
13361 item,
13362 mediaField,
13363 titleField,
13364 descriptionField,
13365 regularFields,
13366 badgeFields,
13367 config,
13368 posinset,
13369 setsize
13370 }) {
13371 const { showTitle = true, showMedia = true, showDescription = true } = view;
13372 const id = getItemId(item);
13373 const elementRef = (0, import_element35.useRef)(null);
13374 const isSelected2 = selection.includes(id);
13375 useIntersectionObserver(elementRef, posinset);
13376 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13377 mediaField.render,
13378 {
13379 item,
13380 field: mediaField,
13381 config
13382 }
13383 ) : null;
13384 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(titleField.render, { item, field: titleField }) : null;
13385 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13386 import_components14.Composite.Item,
13387 {
13388 ref: elementRef,
13389 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
13390 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Stack, { direction: "column", children, ...props }),
13391 role: "option",
13392 "aria-posinset": posinset,
13393 "aria-setsize": setsize,
13394 className: clsx_default("dataviews-view-picker-grid__card", {
13395 "is-selected": isSelected2
13396 }),
13397 "aria-selected": isSelected2,
13398 onClick: () => {
13399 if (isSelected2) {
13400 onChangeSelection(
13401 selection.filter((itemId) => id !== itemId)
13402 );
13403 } else {
13404 const newSelection = multiselect ? [...selection, id] : [id];
13405 onChangeSelection(newSelection);
13406 }
13407 },
13408 children: [
13409 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
13410 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13411 DataViewsSelectionCheckbox,
13412 {
13413 item,
13414 selection,
13415 onChangeSelection,
13416 getItemId,
13417 titleField,
13418 disabled: false,
13419 "aria-hidden": true,
13420 tabIndex: -1
13421 }
13422 ),
13423 showTitle && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13424 Stack,
13425 {
13426 direction: "row",
13427 justify: "space-between",
13428 className: "dataviews-view-picker-grid__title-actions",
13429 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
13430 }
13431 ),
13432 /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", gap: "xs", children: [
13433 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13434 descriptionField.render,
13435 {
13436 item,
13437 field: descriptionField
13438 }
13439 ),
13440 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13441 Stack,
13442 {
13443 direction: "row",
13444 className: "dataviews-view-picker-grid__badge-fields",
13445 gap: "sm",
13446 wrap: "wrap",
13447 align: "top",
13448 justify: "flex-start",
13449 children: badgeFields.map((field) => {
13450 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13451 WCBadge2,
13452 {
13453 className: "dataviews-view-picker-grid__field-value",
13454 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13455 field.render,
13456 {
13457 item,
13458 field
13459 }
13460 )
13461 },
13462 field.id
13463 );
13464 })
13465 }
13466 ),
13467 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13468 Stack,
13469 {
13470 direction: "column",
13471 className: "dataviews-view-picker-grid__fields",
13472 gap: "xs",
13473 children: regularFields.map((field) => {
13474 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13475 import_components14.Flex,
13476 {
13477 className: "dataviews-view-picker-grid__field",
13478 gap: 1,
13479 justify: "flex-start",
13480 expanded: true,
13481 style: { height: "auto" },
13482 direction: "row",
13483 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
13484 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
13485 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13486 import_components14.FlexItem,
13487 {
13488 className: "dataviews-view-picker-grid__field-value",
13489 style: { maxHeight: "none" },
13490 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13491 field.render,
13492 {
13493 item,
13494 field
13495 }
13496 )
13497 }
13498 )
13499 ] })
13500 },
13501 field.id
13502 );
13503 })
13504 }
13505 )
13506 ] })
13507 ]
13508 },
13509 id
13510 );
13511 }
13512 function GridGroup({
13513 groupName,
13514 groupField,
13515 showLabel = true,
13516 children
13517 }) {
13518 const headerId = (0, import_compose6.useInstanceId)(
13519 GridGroup,
13520 "dataviews-view-picker-grid-group__header"
13521 );
13522 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13523 Stack,
13524 {
13525 direction: "column",
13526 gap: "sm",
13527 role: "group",
13528 "aria-labelledby": headerId,
13529 children: [
13530 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13531 "h3",
13532 {
13533 className: "dataviews-view-picker-grid-group__header",
13534 id: headerId,
13535 children: showLabel ? (0, import_i18n17.sprintf)(
13536 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
13537 (0, import_i18n17.__)("%1$s: %2$s"),
13538 groupField.label,
13539 groupName
13540 ) : groupName
13541 }
13542 ),
13543 children
13544 ]
13545 },
13546 groupName
13547 );
13548 }
13549 function ViewPickerGrid({
13550 actions,
13551 data,
13552 fields,
13553 getItemId,
13554 isLoading,
13555 onChangeSelection,
13556 selection,
13557 view,
13558 className,
13559 empty
13560 }) {
13561 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element35.useContext)(dataviews_context_default);
13562 const titleField = fields.find(
13563 (field) => field.id === view?.titleField
13564 );
13565 const mediaField = fields.find(
13566 (field) => field.id === view?.mediaField
13567 );
13568 const descriptionField = fields.find(
13569 (field) => field.id === view?.descriptionField
13570 );
13571 const otherFields = view.fields ?? [];
13572 const { regularFields, badgeFields } = otherFields.reduce(
13573 (accumulator, fieldId) => {
13574 const field = fields.find((f2) => f2.id === fieldId);
13575 if (!field) {
13576 return accumulator;
13577 }
13578 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
13579 accumulator[key].push(field);
13580 return accumulator;
13581 },
13582 { regularFields: [], badgeFields: [] }
13583 );
13584 const hasData = !!data?.length;
13585 const usedPreviewSize = view.layout?.previewSize;
13586 const isMultiselect = useIsMultiselectPicker(actions);
13587 const size4 = "900px";
13588 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13589 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13590 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
13591 const currentPage = view?.page ?? 1;
13592 const perPage = view?.perPage ?? 0;
13593 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
13594 const gridColumns = useGridColumns();
13595 const placeholdersNeeded = usePlaceholdersNeeded(
13596 data,
13597 isInfiniteScroll,
13598 gridColumns
13599 );
13600 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, {
13601 // Render multiple groups.
13602 children: [
13603 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13604 import_components14.Composite,
13605 {
13606 virtualFocus: true,
13607 orientation: "horizontal",
13608 role: "listbox",
13609 "aria-multiselectable": isMultiselect,
13610 className: clsx_default(
13611 "dataviews-view-picker-grid",
13612 className,
13613 {
13614 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13615 view.layout.density
13616 )
13617 }
13618 ),
13619 "aria-label": itemListLabel,
13620 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13621 Stack,
13622 {
13623 direction: "column",
13624 gap: "lg",
13625 children,
13626 ...props
13627 }
13628 ),
13629 children: Array.from(dataByGroup.entries()).map(
13630 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13631 GridGroup,
13632 {
13633 groupName,
13634 groupField,
13635 showLabel: view.groupBy?.showLabel !== false,
13636 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13637 GridItems,
13638 {
13639 previewSize: usedPreviewSize,
13640 style: {
13641 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
13642 },
13643 "aria-busy": isLoading,
13644 ref: resizeObserverRef,
13645 children: groupItems.map((item) => {
13646 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
13647 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13648 GridItem3,
13649 {
13650 view,
13651 multiselect: isMultiselect,
13652 selection,
13653 onChangeSelection,
13654 getItemId,
13655 item,
13656 mediaField,
13657 titleField,
13658 descriptionField,
13659 regularFields,
13660 badgeFields,
13661 config: {
13662 sizes: size4
13663 },
13664 posinset: posInSet,
13665 setsize: setSize
13666 },
13667 getItemId(item)
13668 );
13669 })
13670 }
13671 )
13672 },
13673 groupName
13674 )
13675 )
13676 }
13677 ),
13678 // Render a single grid with all data.
13679 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
13680 import_components14.Composite,
13681 {
13682 render: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13683 GridItems,
13684 {
13685 className: clsx_default(
13686 "dataviews-view-picker-grid",
13687 className,
13688 {
13689 [`has-${view.layout?.density}-density`]: view.layout?.density && [
13690 "compact",
13691 "comfortable"
13692 ].includes(view.layout.density)
13693 }
13694 ),
13695 previewSize: usedPreviewSize,
13696 "aria-busy": isLoading,
13697 ref: resizeObserverRef
13698 }
13699 ),
13700 virtualFocus: true,
13701 orientation: "horizontal",
13702 role: "listbox",
13703 "aria-multiselectable": isMultiselect,
13704 "aria-label": itemListLabel,
13705 children: [
13706 Array.from({ length: placeholdersNeeded }).map(
13707 (_, index2) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13708 import_components14.Composite.Item,
13709 {
13710 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13711 Stack,
13712 {
13713 direction: "column",
13714 children,
13715 ...props
13716 }
13717 ),
13718 role: "option",
13719 "aria-hidden": true,
13720 tabIndex: -1,
13721 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
13722 },
13723 `placeholder-${index2}`
13724 )
13725 ),
13726 data.map((item) => {
13727 const posinset = item.position;
13728 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13729 GridItem3,
13730 {
13731 view,
13732 multiselect: isMultiselect,
13733 selection,
13734 onChangeSelection,
13735 getItemId,
13736 item,
13737 mediaField,
13738 titleField,
13739 descriptionField,
13740 regularFields,
13741 badgeFields,
13742 config: {
13743 sizes: size4
13744 },
13745 posinset,
13746 setsize: setSize
13747 },
13748 getItemId(item)
13749 );
13750 })
13751 ]
13752 }
13753 ),
13754 // Render empty state.
13755 !hasData && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13756 "div",
13757 {
13758 className: clsx_default({
13759 "dataviews-loading": isLoading,
13760 "dataviews-no-results": !isLoading
13761 }),
13762 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) }) : empty
13763 }
13764 ),
13765 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components14.Spinner, {}) })
13766 ]
13767 });
13768 }
13769 var picker_grid_default = ViewPickerGrid;
13770
13771 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
13772 var import_i18n18 = __toESM(require_i18n(), 1);
13773 var import_components15 = __toESM(require_components(), 1);
13774 var import_element36 = __toESM(require_element(), 1);
13775 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13776 function TableColumnField2({
13777 item,
13778 fields,
13779 column,
13780 align
13781 }) {
13782 const field = fields.find((f2) => f2.id === column);
13783 if (!field) {
13784 return null;
13785 }
13786 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
13787 "dataviews-view-table__cell-align-end": align === "end",
13788 "dataviews-view-table__cell-align-center": align === "center"
13789 });
13790 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(field.render, { item, field }) });
13791 }
13792 function TableRow2({
13793 item,
13794 fields,
13795 id,
13796 view,
13797 titleField,
13798 mediaField,
13799 descriptionField,
13800 selection,
13801 getItemId,
13802 onChangeSelection,
13803 multiselect,
13804 posinset
13805 }) {
13806 const { paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
13807 const isSelected2 = selection.includes(id);
13808 const [isHovered, setIsHovered] = (0, import_element36.useState)(false);
13809 const elementRef = (0, import_element36.useRef)(null);
13810 useIntersectionObserver(elementRef, posinset);
13811 const {
13812 showTitle = true,
13813 showMedia = true,
13814 showDescription = true,
13815 infiniteScrollEnabled
13816 } = view;
13817 const handleMouseEnter = () => {
13818 setIsHovered(true);
13819 };
13820 const handleMouseLeave = () => {
13821 setIsHovered(false);
13822 };
13823 const columns = view.fields ?? [];
13824 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13825 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13826 import_components15.Composite.Item,
13827 {
13828 ref: elementRef,
13829 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13830 "tr",
13831 {
13832 className: clsx_default("dataviews-view-table__row", {
13833 "is-selected": isSelected2,
13834 "is-hovered": isHovered
13835 }),
13836 onMouseEnter: handleMouseEnter,
13837 onMouseLeave: handleMouseLeave,
13838 children,
13839 ...props
13840 }
13841 ),
13842 "aria-selected": isSelected2,
13843 "aria-setsize": paginationInfo.totalItems || void 0,
13844 "aria-posinset": posinset,
13845 role: infiniteScrollEnabled ? "article" : "option",
13846 onMouseDown: (event) => {
13847 if (event.button !== 0) {
13848 return;
13849 }
13850 event.currentTarget.parentElement?.focus({
13851 preventScroll: true
13852 });
13853 },
13854 onClick: () => {
13855 if (isSelected2) {
13856 onChangeSelection(
13857 selection.filter((itemId) => id !== itemId)
13858 );
13859 } else {
13860 const newSelection = multiselect ? [...selection, id] : [id];
13861 onChangeSelection(newSelection);
13862 }
13863 },
13864 children: [
13865 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13866 "td",
13867 {
13868 className: "dataviews-view-table__checkbox-column",
13869 role: "presentation",
13870 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13871 DataViewsSelectionCheckbox,
13872 {
13873 item,
13874 selection,
13875 onChangeSelection,
13876 getItemId,
13877 titleField,
13878 disabled: false,
13879 "aria-hidden": true,
13880 tabIndex: -1
13881 }
13882 ) })
13883 }
13884 ),
13885 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13886 "td",
13887 {
13888 role: "presentation",
13889 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13890 column_primary_default,
13891 {
13892 item,
13893 titleField: showTitle ? titleField : void 0,
13894 mediaField: showMedia ? mediaField : void 0,
13895 descriptionField: showDescription ? descriptionField : void 0,
13896 isItemClickable: () => false
13897 }
13898 )
13899 }
13900 ),
13901 columns.map((column) => {
13902 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
13903 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13904 "td",
13905 {
13906 style: {
13907 width,
13908 maxWidth,
13909 minWidth
13910 },
13911 role: "presentation",
13912 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13913 TableColumnField2,
13914 {
13915 fields,
13916 item,
13917 column,
13918 align
13919 }
13920 )
13921 },
13922 column
13923 );
13924 })
13925 ]
13926 },
13927 id
13928 );
13929 }
13930 function ViewPickerTable({
13931 actions,
13932 data,
13933 fields,
13934 getItemId,
13935 isLoading = false,
13936 onChangeView,
13937 onChangeSelection,
13938 selection,
13939 setOpenedFilter,
13940 view,
13941 className,
13942 empty
13943 }) {
13944 const headerMenuRefs = (0, import_element36.useRef)(/* @__PURE__ */ new Map());
13945 const headerMenuToFocusRef = (0, import_element36.useRef)(void 0);
13946 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element36.useState)();
13947 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
13948 (0, import_element36.useEffect)(() => {
13949 if (headerMenuToFocusRef.current) {
13950 headerMenuToFocusRef.current.focus();
13951 headerMenuToFocusRef.current = void 0;
13952 }
13953 });
13954 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
13955 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
13956 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
13957 const tableNoticeId = (0, import_element36.useId)();
13958 if (nextHeaderMenuToFocus) {
13959 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
13960 setNextHeaderMenuToFocus(void 0);
13961 return;
13962 }
13963 const onHide = (field) => {
13964 const hidden = headerMenuRefs.current.get(field.id);
13965 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
13966 setNextHeaderMenuToFocus(fallback?.node);
13967 };
13968 const hasData = !!data?.length;
13969 const titleField = fields.find((field) => field.id === view.titleField);
13970 const mediaField = fields.find((field) => field.id === view.mediaField);
13971 const descriptionField = fields.find(
13972 (field) => field.id === view.descriptionField
13973 );
13974 const { showTitle = true, showMedia = true, showDescription = true } = view;
13975 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
13976 const columns = view.fields ?? [];
13977 const headerMenuRef = (column, index2) => (node) => {
13978 if (node) {
13979 headerMenuRefs.current.set(column, {
13980 node,
13981 fallback: columns[index2 > 0 ? index2 - 1 : 1]
13982 });
13983 } else {
13984 headerMenuRefs.current.delete(column);
13985 }
13986 };
13987 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
13988 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
13989 "table",
13990 {
13991 className: clsx_default(
13992 "dataviews-view-table",
13993 "dataviews-view-picker-table",
13994 className,
13995 {
13996 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
13997 view.layout.density
13998 )
13999 }
14000 ),
14001 "aria-busy": isLoading,
14002 "aria-describedby": tableNoticeId,
14003 role: isInfiniteScroll ? "feed" : "listbox",
14004 children: [
14005 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14006 "tr",
14007 {
14008 className: "dataviews-view-table__row",
14009 role: "presentation",
14010 children: [
14011 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14012 BulkSelectionCheckbox,
14013 {
14014 selection,
14015 onChangeSelection,
14016 data,
14017 actions,
14018 getItemId,
14019 disableSelectAll: isInfiniteScroll
14020 }
14021 ) }),
14022 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14023 column_header_menu_default,
14024 {
14025 ref: headerMenuRef(
14026 titleField.id,
14027 0
14028 ),
14029 fieldId: titleField.id,
14030 view,
14031 fields,
14032 onChangeView,
14033 onHide,
14034 setOpenedFilter,
14035 canMove: false
14036 }
14037 ) }),
14038 columns.map((column, index2) => {
14039 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
14040 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14041 "th",
14042 {
14043 style: {
14044 width,
14045 maxWidth,
14046 minWidth,
14047 textAlign: align
14048 },
14049 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
14050 scope: "col",
14051 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14052 column_header_menu_default,
14053 {
14054 ref: headerMenuRef(column, index2),
14055 fieldId: column,
14056 view,
14057 fields,
14058 onChangeView,
14059 onHide,
14060 setOpenedFilter,
14061 canMove: view.layout?.enableMoving ?? true
14062 }
14063 )
14064 },
14065 column
14066 );
14067 })
14068 ]
14069 }
14070 ) }),
14071 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
14072 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14073 import_components15.Composite,
14074 {
14075 virtualFocus: true,
14076 orientation: "vertical",
14077 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "group" }),
14078 children: [
14079 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14080 "tr",
14081 {
14082 className: "dataviews-view-table__group-header-row",
14083 role: "presentation",
14084 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14085 "td",
14086 {
14087 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
14088 className: "dataviews-view-table__group-header-cell",
14089 role: "presentation",
14090 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
14091 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
14092 (0, import_i18n18.__)("%1$s: %2$s"),
14093 groupField.label,
14094 groupName
14095 )
14096 }
14097 )
14098 }
14099 ),
14100 groupItems.map((item, index2) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14101 TableRow2,
14102 {
14103 item,
14104 fields,
14105 id: getItemId(item) || index2.toString(),
14106 view,
14107 titleField,
14108 mediaField,
14109 descriptionField,
14110 selection,
14111 getItemId,
14112 onChangeSelection,
14113 multiselect: isMultiselect
14114 },
14115 getItemId(item)
14116 ))
14117 ]
14118 },
14119 `group-${groupName}`
14120 )
14121 ) : /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14122 import_components15.Composite,
14123 {
14124 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("tbody", { role: "presentation" }),
14125 virtualFocus: true,
14126 orientation: "vertical",
14127 children: hasData && data.map((item, index2) => {
14128 const itemId = getItemId(item);
14129 const posinset = item.position;
14130 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
14131 TableRow2,
14132 {
14133 item,
14134 fields,
14135 id: itemId || index2.toString(),
14136 view,
14137 titleField,
14138 mediaField,
14139 descriptionField,
14140 selection,
14141 getItemId,
14142 onChangeSelection,
14143 multiselect: isMultiselect,
14144 posinset
14145 },
14146 itemId
14147 );
14148 })
14149 }
14150 )
14151 ]
14152 }
14153 ),
14154 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
14155 "div",
14156 {
14157 className: clsx_default({
14158 "dataviews-loading": isLoading,
14159 "dataviews-no-results": !hasData && !isLoading
14160 }),
14161 id: tableNoticeId,
14162 children: [
14163 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) }) : empty),
14164 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components15.Spinner, {}) })
14165 ]
14166 }
14167 )
14168 ] });
14169 }
14170 var picker_table_default = ViewPickerTable;
14171
14172 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
14173 var import_components16 = __toESM(require_components(), 1);
14174 var import_i18n19 = __toESM(require_i18n(), 1);
14175 var import_element37 = __toESM(require_element(), 1);
14176 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
14177 function DensityPicker() {
14178 const context = (0, import_element37.useContext)(dataviews_context_default);
14179 const view = context.view;
14180 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
14181 import_components16.__experimentalToggleGroupControl,
14182 {
14183 size: "__unstable-large",
14184 label: (0, import_i18n19.__)("Density"),
14185 value: view.layout?.density || "balanced",
14186 onChange: (value) => {
14187 context.onChangeView({
14188 ...view,
14189 layout: {
14190 ...view.layout,
14191 density: value
14192 }
14193 });
14194 },
14195 isBlock: true,
14196 children: [
14197 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14198 import_components16.__experimentalToggleGroupControlOption,
14199 {
14200 value: "comfortable",
14201 label: (0, import_i18n19._x)(
14202 "Comfortable",
14203 "Density option for DataView layout"
14204 )
14205 },
14206 "comfortable"
14207 ),
14208 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14209 import_components16.__experimentalToggleGroupControlOption,
14210 {
14211 value: "balanced",
14212 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout")
14213 },
14214 "balanced"
14215 ),
14216 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
14217 import_components16.__experimentalToggleGroupControlOption,
14218 {
14219 value: "compact",
14220 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout")
14221 },
14222 "compact"
14223 )
14224 ]
14225 }
14226 );
14227 }
14228
14229 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
14230 var import_components17 = __toESM(require_components(), 1);
14231 var import_i18n20 = __toESM(require_i18n(), 1);
14232 var import_element38 = __toESM(require_element(), 1);
14233 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
14234 var imageSizes2 = [
14235 {
14236 value: 120,
14237 breakpoint: 1
14238 },
14239 {
14240 value: 170,
14241 breakpoint: 1
14242 },
14243 {
14244 value: 230,
14245 breakpoint: 1
14246 },
14247 {
14248 value: 290,
14249 breakpoint: 1112
14250 // at minimum image width, 4 images display at this container size
14251 },
14252 {
14253 value: 350,
14254 breakpoint: 1636
14255 // at minimum image width, 6 images display at this container size
14256 },
14257 {
14258 value: 430,
14259 breakpoint: 588
14260 // at minimum image width, 2 images display at this container size
14261 }
14262 ];
14263 function PreviewSizePicker() {
14264 const context = (0, import_element38.useContext)(dataviews_context_default);
14265 const view = context.view;
14266 const breakValues = imageSizes2.filter((size4) => {
14267 return context.containerWidth >= size4.breakpoint;
14268 });
14269 const layoutPreviewSize = view.layout?.previewSize ?? 230;
14270 const previewSizeToUse = breakValues.map((size4, index2) => ({ ...size4, index: index2 })).filter((size4) => size4.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
14271 const marks = breakValues.map((size4, index2) => {
14272 return {
14273 value: index2
14274 };
14275 });
14276 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
14277 import_components17.RangeControl,
14278 {
14279 __next40pxDefaultSize: true,
14280 showTooltip: false,
14281 label: (0, import_i18n20.__)("Preview size"),
14282 value: previewSizeToUse,
14283 min: 0,
14284 max: breakValues.length - 1,
14285 withInputField: false,
14286 onChange: (value = 0) => {
14287 context.onChangeView({
14288 ...view,
14289 layout: {
14290 ...view.layout,
14291 previewSize: breakValues[value].value
14292 }
14293 });
14294 },
14295 step: 1,
14296 marks
14297 }
14298 );
14299 }
14300
14301 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
14302 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
14303 function GridConfigOptions() {
14304 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
14305 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(DensityPicker, {}),
14306 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(PreviewSizePicker, {})
14307 ] });
14308 }
14309
14310 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
14311 var VIEW_LAYOUTS = [
14312 {
14313 type: LAYOUT_TABLE,
14314 label: (0, import_i18n21.__)("Table"),
14315 component: table_default,
14316 icon: block_table_default,
14317 viewConfigOptions: DensityPicker
14318 },
14319 {
14320 type: LAYOUT_GRID,
14321 label: (0, import_i18n21.__)("Grid"),
14322 component: grid_default,
14323 icon: category_default,
14324 viewConfigOptions: GridConfigOptions
14325 },
14326 {
14327 type: LAYOUT_LIST,
14328 label: (0, import_i18n21.__)("List"),
14329 component: ViewList,
14330 icon: (0, import_i18n21.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
14331 viewConfigOptions: DensityPicker
14332 },
14333 {
14334 type: LAYOUT_ACTIVITY,
14335 label: (0, import_i18n21.__)("Activity"),
14336 component: ViewActivity,
14337 icon: scheduled_default,
14338 viewConfigOptions: DensityPicker
14339 },
14340 {
14341 type: LAYOUT_PICKER_GRID,
14342 label: (0, import_i18n21.__)("Grid"),
14343 component: picker_grid_default,
14344 icon: category_default,
14345 viewConfigOptions: GridConfigOptions,
14346 isPicker: true
14347 },
14348 {
14349 type: LAYOUT_PICKER_TABLE,
14350 label: (0, import_i18n21.__)("Table"),
14351 component: picker_table_default,
14352 icon: block_table_default,
14353 viewConfigOptions: DensityPicker,
14354 isPicker: true
14355 }
14356 ];
14357
14358 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
14359 var import_element46 = __toESM(require_element(), 1);
14360
14361 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14362 var import_components20 = __toESM(require_components(), 1);
14363 var import_i18n24 = __toESM(require_i18n(), 1);
14364 var import_element43 = __toESM(require_element(), 1);
14365
14366 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
14367 function noop4(..._) {
14368 }
14369 function applyState(argument, currentValue) {
14370 if (isUpdater(argument)) {
14371 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
14372 return argument(value);
14373 }
14374 return argument;
14375 }
14376 function isUpdater(argument) {
14377 return typeof argument === "function";
14378 }
14379 function isLazyValue(value) {
14380 return typeof value === "function";
14381 }
14382 function hasOwnProperty(object, prop) {
14383 if (typeof Object.hasOwn === "function") {
14384 return Object.hasOwn(object, prop);
14385 }
14386 return Object.prototype.hasOwnProperty.call(object, prop);
14387 }
14388 function chain(...fns) {
14389 return (...args) => {
14390 for (const fn of fns) {
14391 if (typeof fn === "function") {
14392 fn(...args);
14393 }
14394 }
14395 };
14396 }
14397 function normalizeString(str) {
14398 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
14399 }
14400 function omit2(object, keys) {
14401 const result = { ...object };
14402 for (const key of keys) {
14403 if (hasOwnProperty(result, key)) {
14404 delete result[key];
14405 }
14406 }
14407 return result;
14408 }
14409 function pick(object, paths) {
14410 const result = {};
14411 for (const key of paths) {
14412 if (hasOwnProperty(object, key)) {
14413 result[key] = object[key];
14414 }
14415 }
14416 return result;
14417 }
14418 function identity(value) {
14419 return value;
14420 }
14421 function invariant(condition, message2) {
14422 if (condition) return;
14423 if (typeof message2 !== "string") throw new Error("Invariant failed");
14424 throw new Error(message2);
14425 }
14426 function getKeys(obj) {
14427 return Object.keys(obj);
14428 }
14429 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
14430 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
14431 if (result == null) return false;
14432 return !result;
14433 }
14434 function disabledFromProps(props) {
14435 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
14436 }
14437 function removeUndefinedValues(obj) {
14438 const result = {};
14439 for (const key in obj) {
14440 if (obj[key] !== void 0) {
14441 result[key] = obj[key];
14442 }
14443 }
14444 return result;
14445 }
14446 function defaultValue(...values) {
14447 for (const value of values) {
14448 if (value !== void 0) return value;
14449 }
14450 return void 0;
14451 }
14452
14453 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
14454 var import_react7 = __toESM(require_react(), 1);
14455 function setRef(ref, value) {
14456 if (typeof ref === "function") {
14457 ref(value);
14458 } else if (ref) {
14459 ref.current = value;
14460 }
14461 }
14462 function isValidElementWithRef(element) {
14463 if (!element) return false;
14464 if (!(0, import_react7.isValidElement)(element)) return false;
14465 if ("ref" in element.props) return true;
14466 if ("ref" in element) return true;
14467 return false;
14468 }
14469 function getRefProperty(element) {
14470 if (!isValidElementWithRef(element)) return null;
14471 const props = { ...element.props };
14472 return props.ref || element.ref;
14473 }
14474 function mergeProps3(base, overrides) {
14475 const props = { ...base };
14476 for (const key in overrides) {
14477 if (!hasOwnProperty(overrides, key)) continue;
14478 if (key === "className") {
14479 const prop = "className";
14480 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
14481 continue;
14482 }
14483 if (key === "style") {
14484 const prop = "style";
14485 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
14486 continue;
14487 }
14488 const overrideValue = overrides[key];
14489 if (typeof overrideValue === "function" && key.startsWith("on")) {
14490 const baseValue = base[key];
14491 if (typeof baseValue === "function") {
14492 props[key] = (...args) => {
14493 overrideValue(...args);
14494 baseValue(...args);
14495 };
14496 continue;
14497 }
14498 }
14499 props[key] = overrideValue;
14500 }
14501 return props;
14502 }
14503
14504 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
14505 var canUseDOM = checkIsBrowser();
14506 function checkIsBrowser() {
14507 var _a;
14508 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
14509 }
14510 function getDocument(node) {
14511 if (!node) return document;
14512 if ("self" in node) return node.document;
14513 return node.ownerDocument || document;
14514 }
14515 function getActiveElement(node, activeDescendant = false) {
14516 var _a;
14517 const { activeElement: activeElement2 } = getDocument(node);
14518 if (!(activeElement2 == null ? void 0 : activeElement2.nodeName)) {
14519 return null;
14520 }
14521 if (isFrame(activeElement2) && ((_a = activeElement2.contentDocument) == null ? void 0 : _a.body)) {
14522 return getActiveElement(
14523 activeElement2.contentDocument.body,
14524 activeDescendant
14525 );
14526 }
14527 if (activeDescendant) {
14528 const id = activeElement2.getAttribute("aria-activedescendant");
14529 if (id) {
14530 const element = getDocument(activeElement2).getElementById(id);
14531 if (element) {
14532 return element;
14533 }
14534 }
14535 }
14536 return activeElement2;
14537 }
14538 function contains2(parent, child) {
14539 return parent === child || parent.contains(child);
14540 }
14541 function isFrame(element) {
14542 return element.tagName === "IFRAME";
14543 }
14544 function isButton(element) {
14545 const tagName = element.tagName.toLowerCase();
14546 if (tagName === "button") return true;
14547 if (tagName === "input" && element.type) {
14548 return buttonInputTypes.indexOf(element.type) !== -1;
14549 }
14550 return false;
14551 }
14552 var buttonInputTypes = [
14553 "button",
14554 "color",
14555 "file",
14556 "image",
14557 "reset",
14558 "submit"
14559 ];
14560 function isVisible(element) {
14561 if (typeof element.checkVisibility === "function") {
14562 return element.checkVisibility();
14563 }
14564 const htmlElement = element;
14565 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
14566 }
14567 function isTextField(element) {
14568 try {
14569 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
14570 const isTextArea = element.tagName === "TEXTAREA";
14571 return isTextInput || isTextArea || false;
14572 } catch (_error) {
14573 return false;
14574 }
14575 }
14576 function isTextbox(element) {
14577 return element.isContentEditable || isTextField(element);
14578 }
14579 function getTextboxValue(element) {
14580 if (isTextField(element)) {
14581 return element.value;
14582 }
14583 if (element.isContentEditable) {
14584 const range = getDocument(element).createRange();
14585 range.selectNodeContents(element);
14586 return range.toString();
14587 }
14588 return "";
14589 }
14590 function getTextboxSelection(element) {
14591 let start = 0;
14592 let end = 0;
14593 if (isTextField(element)) {
14594 start = element.selectionStart || 0;
14595 end = element.selectionEnd || 0;
14596 } else if (element.isContentEditable) {
14597 const selection = getDocument(element).getSelection();
14598 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains2(element, selection.anchorNode) && selection.focusNode && contains2(element, selection.focusNode)) {
14599 const range = selection.getRangeAt(0);
14600 const nextRange = range.cloneRange();
14601 nextRange.selectNodeContents(element);
14602 nextRange.setEnd(range.startContainer, range.startOffset);
14603 start = nextRange.toString().length;
14604 nextRange.setEnd(range.endContainer, range.endOffset);
14605 end = nextRange.toString().length;
14606 }
14607 }
14608 return { start, end };
14609 }
14610 function getPopupRole(element, fallback) {
14611 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
14612 const role = element == null ? void 0 : element.getAttribute("role");
14613 if (role && allowedPopupRoles.indexOf(role) !== -1) {
14614 return role;
14615 }
14616 return fallback;
14617 }
14618 function getScrollingElement(element) {
14619 if (!element) return null;
14620 const isScrollableOverflow = (overflow) => {
14621 if (overflow === "auto") return true;
14622 if (overflow === "scroll") return true;
14623 return false;
14624 };
14625 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
14626 const { overflowY } = getComputedStyle(element);
14627 if (isScrollableOverflow(overflowY)) return element;
14628 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
14629 const { overflowX } = getComputedStyle(element);
14630 if (isScrollableOverflow(overflowX)) return element;
14631 }
14632 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
14633 }
14634 function setSelectionRange(element, ...args) {
14635 if (/text|search|password|tel|url/i.test(element.type)) {
14636 element.setSelectionRange(...args);
14637 }
14638 }
14639 function sortBasedOnDOMPosition(items, getElement) {
14640 const pairs = items.map((item, index2) => [index2, item]);
14641 let isOrderDifferent = false;
14642 pairs.sort(([indexA, a2], [indexB, b2]) => {
14643 const elementA = getElement(a2);
14644 const elementB = getElement(b2);
14645 if (elementA === elementB) return 0;
14646 if (!elementA || !elementB) return 0;
14647 if (isElementPreceding(elementA, elementB)) {
14648 if (indexA > indexB) {
14649 isOrderDifferent = true;
14650 }
14651 return -1;
14652 }
14653 if (indexA < indexB) {
14654 isOrderDifferent = true;
14655 }
14656 return 1;
14657 });
14658 if (isOrderDifferent) {
14659 return pairs.map(([_, item]) => item);
14660 }
14661 return items;
14662 }
14663 function isElementPreceding(a2, b2) {
14664 return Boolean(
14665 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
14666 );
14667 }
14668
14669 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
14670 function isTouchDevice() {
14671 return canUseDOM && !!navigator.maxTouchPoints;
14672 }
14673 function isApple() {
14674 if (!canUseDOM) return false;
14675 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
14676 }
14677 function isSafari2() {
14678 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
14679 }
14680 function isFirefox2() {
14681 return canUseDOM && /firefox\//i.test(navigator.userAgent);
14682 }
14683
14684 // node_modules/@ariakit/core/esm/utils/events.js
14685 function isPortalEvent(event) {
14686 return Boolean(
14687 event.currentTarget && !contains2(event.currentTarget, event.target)
14688 );
14689 }
14690 function isSelfTarget(event) {
14691 return event.target === event.currentTarget;
14692 }
14693 function isOpeningInNewTab(event) {
14694 const element = event.currentTarget;
14695 if (!element) return false;
14696 const isAppleDevice = isApple();
14697 if (isAppleDevice && !event.metaKey) return false;
14698 if (!isAppleDevice && !event.ctrlKey) return false;
14699 const tagName = element.tagName.toLowerCase();
14700 if (tagName === "a") return true;
14701 if (tagName === "button" && element.type === "submit") return true;
14702 if (tagName === "input" && element.type === "submit") return true;
14703 return false;
14704 }
14705 function isDownloading(event) {
14706 const element = event.currentTarget;
14707 if (!element) return false;
14708 const tagName = element.tagName.toLowerCase();
14709 if (!event.altKey) return false;
14710 if (tagName === "a") return true;
14711 if (tagName === "button" && element.type === "submit") return true;
14712 if (tagName === "input" && element.type === "submit") return true;
14713 return false;
14714 }
14715 function fireBlurEvent(element, eventInit) {
14716 const event = new FocusEvent("blur", eventInit);
14717 const defaultAllowed = element.dispatchEvent(event);
14718 const bubbleInit = { ...eventInit, bubbles: true };
14719 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
14720 return defaultAllowed;
14721 }
14722 function fireKeyboardEvent(element, type, eventInit) {
14723 const event = new KeyboardEvent(type, eventInit);
14724 return element.dispatchEvent(event);
14725 }
14726 function fireClickEvent(element, eventInit) {
14727 const event = new MouseEvent("click", eventInit);
14728 return element.dispatchEvent(event);
14729 }
14730 function isFocusEventOutside(event, container) {
14731 const containerElement = container || event.currentTarget;
14732 const relatedTarget = event.relatedTarget;
14733 return !relatedTarget || !contains2(containerElement, relatedTarget);
14734 }
14735 function queueBeforeEvent(element, type, callback, timeout) {
14736 const createTimer = (callback2) => {
14737 if (timeout) {
14738 const timerId2 = setTimeout(callback2, timeout);
14739 return () => clearTimeout(timerId2);
14740 }
14741 const timerId = requestAnimationFrame(callback2);
14742 return () => cancelAnimationFrame(timerId);
14743 };
14744 const cancelTimer = createTimer(() => {
14745 element.removeEventListener(type, callSync, true);
14746 callback();
14747 });
14748 const callSync = () => {
14749 cancelTimer();
14750 callback();
14751 };
14752 element.addEventListener(type, callSync, { once: true, capture: true });
14753 return cancelTimer;
14754 }
14755 function addGlobalEventListener(type, listener, options, scope = window) {
14756 const children = [];
14757 try {
14758 scope.document.addEventListener(type, listener, options);
14759 for (const frame of Array.from(scope.frames)) {
14760 children.push(addGlobalEventListener(type, listener, options, frame));
14761 }
14762 } catch (e2) {
14763 }
14764 const removeEventListener = () => {
14765 try {
14766 scope.document.removeEventListener(type, listener, options);
14767 } catch (e2) {
14768 }
14769 for (const remove of children) {
14770 remove();
14771 }
14772 };
14773 return removeEventListener;
14774 }
14775
14776 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
14777 var React49 = __toESM(require_react(), 1);
14778 var import_react8 = __toESM(require_react(), 1);
14779 var _React = { ...React49 };
14780 var useReactId = _React.useId;
14781 var useReactDeferredValue = _React.useDeferredValue;
14782 var useReactInsertionEffect = _React.useInsertionEffect;
14783 var useSafeLayoutEffect = canUseDOM ? import_react8.useLayoutEffect : import_react8.useEffect;
14784 function useInitialValue(value) {
14785 const [initialValue] = (0, import_react8.useState)(value);
14786 return initialValue;
14787 }
14788 function useLiveRef(value) {
14789 const ref = (0, import_react8.useRef)(value);
14790 useSafeLayoutEffect(() => {
14791 ref.current = value;
14792 });
14793 return ref;
14794 }
14795 function useEvent(callback) {
14796 const ref = (0, import_react8.useRef)(() => {
14797 throw new Error("Cannot call an event handler while rendering.");
14798 });
14799 if (useReactInsertionEffect) {
14800 useReactInsertionEffect(() => {
14801 ref.current = callback;
14802 });
14803 } else {
14804 ref.current = callback;
14805 }
14806 return (0, import_react8.useCallback)((...args) => {
14807 var _a;
14808 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
14809 }, []);
14810 }
14811 function useTransactionState(callback) {
14812 const [state, setState] = (0, import_react8.useState)(null);
14813 useSafeLayoutEffect(() => {
14814 if (state == null) return;
14815 if (!callback) return;
14816 let prevState = null;
14817 callback((prev) => {
14818 prevState = prev;
14819 return state;
14820 });
14821 return () => {
14822 callback(prevState);
14823 };
14824 }, [state, callback]);
14825 return [state, setState];
14826 }
14827 function useMergeRefs(...refs) {
14828 return (0, import_react8.useMemo)(() => {
14829 if (!refs.some(Boolean)) return;
14830 return (value) => {
14831 for (const ref of refs) {
14832 setRef(ref, value);
14833 }
14834 };
14835 }, refs);
14836 }
14837 function useId4(defaultId) {
14838 if (useReactId) {
14839 const reactId = useReactId();
14840 if (defaultId) return defaultId;
14841 return reactId;
14842 }
14843 const [id, setId] = (0, import_react8.useState)(defaultId);
14844 useSafeLayoutEffect(() => {
14845 if (defaultId || id) return;
14846 const random = Math.random().toString(36).slice(2, 8);
14847 setId(`id-${random}`);
14848 }, [defaultId, id]);
14849 return defaultId || id;
14850 }
14851 function useTagName(refOrElement, type) {
14852 const stringOrUndefined = (type2) => {
14853 if (typeof type2 !== "string") return;
14854 return type2;
14855 };
14856 const [tagName, setTagName] = (0, import_react8.useState)(() => stringOrUndefined(type));
14857 useSafeLayoutEffect(() => {
14858 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
14859 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
14860 }, [refOrElement, type]);
14861 return tagName;
14862 }
14863 function useAttribute(refOrElement, attributeName, defaultValue2) {
14864 const initialValue = useInitialValue(defaultValue2);
14865 const [attribute, setAttribute] = (0, import_react8.useState)(initialValue);
14866 (0, import_react8.useEffect)(() => {
14867 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
14868 if (!element) return;
14869 const callback = () => {
14870 const value = element.getAttribute(attributeName);
14871 setAttribute(value == null ? initialValue : value);
14872 };
14873 const observer = new MutationObserver(callback);
14874 observer.observe(element, { attributeFilter: [attributeName] });
14875 callback();
14876 return () => observer.disconnect();
14877 }, [refOrElement, attributeName, initialValue]);
14878 return attribute;
14879 }
14880 function useUpdateEffect(effect, deps) {
14881 const mounted = (0, import_react8.useRef)(false);
14882 (0, import_react8.useEffect)(() => {
14883 if (mounted.current) {
14884 return effect();
14885 }
14886 mounted.current = true;
14887 }, deps);
14888 (0, import_react8.useEffect)(
14889 () => () => {
14890 mounted.current = false;
14891 },
14892 []
14893 );
14894 }
14895 function useUpdateLayoutEffect(effect, deps) {
14896 const mounted = (0, import_react8.useRef)(false);
14897 useSafeLayoutEffect(() => {
14898 if (mounted.current) {
14899 return effect();
14900 }
14901 mounted.current = true;
14902 }, deps);
14903 useSafeLayoutEffect(
14904 () => () => {
14905 mounted.current = false;
14906 },
14907 []
14908 );
14909 }
14910 function useForceUpdate() {
14911 return (0, import_react8.useReducer)(() => [], []);
14912 }
14913 function useBooleanEvent(booleanOrCallback) {
14914 return useEvent(
14915 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
14916 );
14917 }
14918 function useWrapElement(props, callback, deps = []) {
14919 const wrapElement = (0, import_react8.useCallback)(
14920 (element) => {
14921 if (props.wrapElement) {
14922 element = props.wrapElement(element);
14923 }
14924 return callback(element);
14925 },
14926 [...deps, props.wrapElement]
14927 );
14928 return { ...props, wrapElement };
14929 }
14930 function useMetadataProps(props, key, value) {
14931 const parent = props.onLoadedMetadataCapture;
14932 const onLoadedMetadataCapture = (0, import_react8.useMemo)(() => {
14933 return Object.assign(() => {
14934 }, { ...parent, [key]: value });
14935 }, [parent, key, value]);
14936 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
14937 }
14938 var hasInstalledGlobalEventListeners = false;
14939 function useIsMouseMoving() {
14940 (0, import_react8.useEffect)(() => {
14941 if (hasInstalledGlobalEventListeners) return;
14942 addGlobalEventListener("mousemove", setMouseMoving, true);
14943 addGlobalEventListener("mousedown", resetMouseMoving, true);
14944 addGlobalEventListener("mouseup", resetMouseMoving, true);
14945 addGlobalEventListener("keydown", resetMouseMoving, true);
14946 addGlobalEventListener("scroll", resetMouseMoving, true);
14947 hasInstalledGlobalEventListeners = true;
14948 }, []);
14949 const isMouseMoving = useEvent(() => mouseMoving);
14950 return isMouseMoving;
14951 }
14952 var mouseMoving = false;
14953 var previousScreenX = 0;
14954 var previousScreenY = 0;
14955 function hasMouseMovement(event) {
14956 const movementX = event.movementX || event.screenX - previousScreenX;
14957 const movementY = event.movementY || event.screenY - previousScreenY;
14958 previousScreenX = event.screenX;
14959 previousScreenY = event.screenY;
14960 return movementX || movementY || false;
14961 }
14962 function setMouseMoving(event) {
14963 if (!hasMouseMovement(event)) return;
14964 mouseMoving = true;
14965 }
14966 function resetMouseMoving() {
14967 mouseMoving = false;
14968 }
14969
14970 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
14971 var React50 = __toESM(require_react(), 1);
14972 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
14973 function forwardRef22(render4) {
14974 const Role = React50.forwardRef(
14975 // @ts-ignore Incompatible with React 19 types. Ignore for now.
14976 (props, ref) => render4({ ...props, ref })
14977 );
14978 Role.displayName = render4.displayName || render4.name;
14979 return Role;
14980 }
14981 function memo22(Component, propsAreEqual) {
14982 return React50.memo(Component, propsAreEqual);
14983 }
14984 function createElement3(Type, props) {
14985 const { wrapElement, render: render4, ...rest } = props;
14986 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
14987 let element;
14988 if (React50.isValidElement(render4)) {
14989 const renderProps = {
14990 // @ts-ignore Incompatible with React 19 types. Ignore for now.
14991 ...render4.props,
14992 ref: mergedRef
14993 };
14994 element = React50.cloneElement(render4, mergeProps3(rest, renderProps));
14995 } else if (render4) {
14996 element = render4(rest);
14997 } else {
14998 element = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Type, { ...rest });
14999 }
15000 if (wrapElement) {
15001 return wrapElement(element);
15002 }
15003 return element;
15004 }
15005 function createHook(useProps) {
15006 const useRole = (props = {}) => {
15007 return useProps(props);
15008 };
15009 useRole.displayName = useProps.name;
15010 return useRole;
15011 }
15012 function createStoreContext(providers = [], scopedProviders = []) {
15013 const context = React50.createContext(void 0);
15014 const scopedContext = React50.createContext(void 0);
15015 const useContext210 = () => React50.useContext(context);
15016 const useScopedContext = (onlyScoped = false) => {
15017 const scoped = React50.useContext(scopedContext);
15018 const store = useContext210();
15019 if (onlyScoped) return scoped;
15020 return scoped || store;
15021 };
15022 const useProviderContext = () => {
15023 const scoped = React50.useContext(scopedContext);
15024 const store = useContext210();
15025 if (scoped && scoped === store) return;
15026 return store;
15027 };
15028 const ContextProvider = (props) => {
15029 return providers.reduceRight(
15030 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Provider2, { ...props, children }),
15031 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(context.Provider, { ...props })
15032 );
15033 };
15034 const ScopedContextProvider = (props) => {
15035 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
15036 (children, Provider2) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Provider2, { ...props, children }),
15037 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(scopedContext.Provider, { ...props })
15038 ) });
15039 };
15040 return {
15041 context,
15042 scopedContext,
15043 useContext: useContext210,
15044 useScopedContext,
15045 useProviderContext,
15046 ContextProvider,
15047 ScopedContextProvider
15048 };
15049 }
15050
15051 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
15052 var ctx = createStoreContext();
15053 var useCollectionContext = ctx.useContext;
15054 var useCollectionScopedContext = ctx.useScopedContext;
15055 var useCollectionProviderContext = ctx.useProviderContext;
15056 var CollectionContextProvider = ctx.ContextProvider;
15057 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
15058
15059 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
15060 var import_react9 = __toESM(require_react(), 1);
15061 var ctx2 = createStoreContext(
15062 [CollectionContextProvider],
15063 [CollectionScopedContextProvider]
15064 );
15065 var useCompositeContext = ctx2.useContext;
15066 var useCompositeScopedContext = ctx2.useScopedContext;
15067 var useCompositeProviderContext = ctx2.useProviderContext;
15068 var CompositeContextProvider = ctx2.ContextProvider;
15069 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
15070 var CompositeItemContext = (0, import_react9.createContext)(
15071 void 0
15072 );
15073 var CompositeRowContext = (0, import_react9.createContext)(
15074 void 0
15075 );
15076
15077 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
15078 function findFirstEnabledItem(items, excludeId) {
15079 return items.find((item) => {
15080 if (excludeId) {
15081 return !item.disabled && item.id !== excludeId;
15082 }
15083 return !item.disabled;
15084 });
15085 }
15086 function getEnabledItem(store, id) {
15087 if (!id) return null;
15088 return store.item(id) || null;
15089 }
15090 function groupItemsByRows(items) {
15091 const rows = [];
15092 for (const item of items) {
15093 const row = rows.find((currentRow) => {
15094 var _a;
15095 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
15096 });
15097 if (row) {
15098 row.push(item);
15099 } else {
15100 rows.push([item]);
15101 }
15102 }
15103 return rows;
15104 }
15105 function selectTextField(element, collapseToEnd = false) {
15106 if (isTextField(element)) {
15107 element.setSelectionRange(
15108 collapseToEnd ? element.value.length : 0,
15109 element.value.length
15110 );
15111 } else if (element.isContentEditable) {
15112 const selection = getDocument(element).getSelection();
15113 selection == null ? void 0 : selection.selectAllChildren(element);
15114 if (collapseToEnd) {
15115 selection == null ? void 0 : selection.collapseToEnd();
15116 }
15117 }
15118 }
15119 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
15120 function focusSilently(element) {
15121 element[FOCUS_SILENTLY] = true;
15122 element.focus({ preventScroll: true });
15123 }
15124 function silentlyFocused(element) {
15125 const isSilentlyFocused = element[FOCUS_SILENTLY];
15126 delete element[FOCUS_SILENTLY];
15127 return isSilentlyFocused;
15128 }
15129 function isItem(store, element, exclude) {
15130 if (!element) return false;
15131 if (element === exclude) return false;
15132 const item = store.item(element.id);
15133 if (!item) return false;
15134 if (exclude && item.element === exclude) return false;
15135 return true;
15136 }
15137
15138 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
15139 var import_react10 = __toESM(require_react(), 1);
15140 var TagName = "div";
15141 var useCollectionItem = createHook(
15142 function useCollectionItem2({
15143 store,
15144 shouldRegisterItem = true,
15145 getItem = identity,
15146 // @ts-expect-error This prop may come from a collection renderer.
15147 element,
15148 ...props
15149 }) {
15150 const context = useCollectionContext();
15151 store = store || context;
15152 const id = useId4(props.id);
15153 const ref = (0, import_react10.useRef)(element);
15154 (0, import_react10.useEffect)(() => {
15155 const element2 = ref.current;
15156 if (!id) return;
15157 if (!element2) return;
15158 if (!shouldRegisterItem) return;
15159 const item = getItem({ id, element: element2 });
15160 return store == null ? void 0 : store.renderItem(item);
15161 }, [id, shouldRegisterItem, getItem, store]);
15162 props = {
15163 ...props,
15164 ref: useMergeRefs(ref, props.ref)
15165 };
15166 return removeUndefinedValues(props);
15167 }
15168 );
15169 var CollectionItem = forwardRef22(function CollectionItem2(props) {
15170 const htmlProps = useCollectionItem(props);
15171 return createElement3(TagName, htmlProps);
15172 });
15173
15174 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
15175 var import_react11 = __toESM(require_react(), 1);
15176 var FocusableContext = (0, import_react11.createContext)(true);
15177
15178 // node_modules/@ariakit/core/esm/utils/focus.js
15179 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'])";
15180 function isFocusable(element) {
15181 if (!element.matches(selector)) return false;
15182 if (!isVisible(element)) return false;
15183 if (element.closest("[inert]")) return false;
15184 return true;
15185 }
15186 function getClosestFocusable(element) {
15187 while (element && !isFocusable(element)) {
15188 element = element.closest(selector);
15189 }
15190 return element || null;
15191 }
15192 function hasFocus(element) {
15193 const activeElement2 = getActiveElement(element);
15194 if (!activeElement2) return false;
15195 if (activeElement2 === element) return true;
15196 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15197 if (!activeDescendant) return false;
15198 return activeDescendant === element.id;
15199 }
15200 function hasFocusWithin(element) {
15201 const activeElement2 = getActiveElement(element);
15202 if (!activeElement2) return false;
15203 if (contains2(element, activeElement2)) return true;
15204 const activeDescendant = activeElement2.getAttribute("aria-activedescendant");
15205 if (!activeDescendant) return false;
15206 if (!("id" in element)) return false;
15207 if (activeDescendant === element.id) return true;
15208 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
15209 }
15210 function focusIfNeeded(element) {
15211 if (!hasFocusWithin(element) && isFocusable(element)) {
15212 element.focus();
15213 }
15214 }
15215 function focusIntoView(element, options) {
15216 if (!("scrollIntoView" in element)) {
15217 element.focus();
15218 } else {
15219 element.focus({ preventScroll: true });
15220 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
15221 }
15222 }
15223
15224 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
15225 var import_react12 = __toESM(require_react(), 1);
15226 var TagName2 = "div";
15227 var isSafariBrowser = isSafari2();
15228 var alwaysFocusVisibleInputTypes = [
15229 "text",
15230 "search",
15231 "url",
15232 "tel",
15233 "email",
15234 "password",
15235 "number",
15236 "date",
15237 "month",
15238 "week",
15239 "time",
15240 "datetime",
15241 "datetime-local"
15242 ];
15243 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
15244 function markSafariFocusAncestor(element, value) {
15245 if (!element) return;
15246 element[safariFocusAncestorSymbol] = value;
15247 }
15248 function isAlwaysFocusVisible(element) {
15249 const { tagName, readOnly, type } = element;
15250 if (tagName === "TEXTAREA" && !readOnly) return true;
15251 if (tagName === "SELECT" && !readOnly) return true;
15252 if (tagName === "INPUT" && !readOnly) {
15253 return alwaysFocusVisibleInputTypes.includes(type);
15254 }
15255 if (element.isContentEditable) return true;
15256 const role = element.getAttribute("role");
15257 if (role === "combobox" && element.dataset.name) {
15258 return true;
15259 }
15260 return false;
15261 }
15262 function getLabels(element) {
15263 if ("labels" in element) {
15264 return element.labels;
15265 }
15266 return null;
15267 }
15268 function isNativeCheckboxOrRadio(element) {
15269 const tagName = element.tagName.toLowerCase();
15270 if (tagName === "input" && element.type) {
15271 return element.type === "radio" || element.type === "checkbox";
15272 }
15273 return false;
15274 }
15275 function isNativeTabbable(tagName) {
15276 if (!tagName) return true;
15277 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
15278 }
15279 function supportsDisabledAttribute(tagName) {
15280 if (!tagName) return true;
15281 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
15282 }
15283 function getTabIndex2(focusable2, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
15284 if (!focusable2) {
15285 return tabIndexProp;
15286 }
15287 if (trulyDisabled) {
15288 if (nativeTabbable && !supportsDisabled) {
15289 return -1;
15290 }
15291 return;
15292 }
15293 if (nativeTabbable) {
15294 return tabIndexProp;
15295 }
15296 return tabIndexProp || 0;
15297 }
15298 function useDisableEvent(onEvent, disabled2) {
15299 return useEvent((event) => {
15300 onEvent == null ? void 0 : onEvent(event);
15301 if (event.defaultPrevented) return;
15302 if (disabled2) {
15303 event.stopPropagation();
15304 event.preventDefault();
15305 }
15306 });
15307 }
15308 var hasInstalledGlobalEventListeners2 = false;
15309 var isKeyboardModality = true;
15310 function onGlobalMouseDown(event) {
15311 const target = event.target;
15312 if (target && "hasAttribute" in target) {
15313 if (!target.hasAttribute("data-focus-visible")) {
15314 isKeyboardModality = false;
15315 }
15316 }
15317 }
15318 function onGlobalKeyDown(event) {
15319 if (event.metaKey) return;
15320 if (event.ctrlKey) return;
15321 if (event.altKey) return;
15322 isKeyboardModality = true;
15323 }
15324 var useFocusable = createHook(
15325 function useFocusable2({
15326 focusable: focusable2 = true,
15327 accessibleWhenDisabled,
15328 autoFocus,
15329 onFocusVisible,
15330 ...props
15331 }) {
15332 const ref = (0, import_react12.useRef)(null);
15333 (0, import_react12.useEffect)(() => {
15334 if (!focusable2) return;
15335 if (hasInstalledGlobalEventListeners2) return;
15336 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
15337 addGlobalEventListener("keydown", onGlobalKeyDown, true);
15338 hasInstalledGlobalEventListeners2 = true;
15339 }, [focusable2]);
15340 if (isSafariBrowser) {
15341 (0, import_react12.useEffect)(() => {
15342 if (!focusable2) return;
15343 const element = ref.current;
15344 if (!element) return;
15345 if (!isNativeCheckboxOrRadio(element)) return;
15346 const labels = getLabels(element);
15347 if (!labels) return;
15348 const onMouseUp = () => queueMicrotask(() => element.focus());
15349 for (const label of labels) {
15350 label.addEventListener("mouseup", onMouseUp);
15351 }
15352 return () => {
15353 for (const label of labels) {
15354 label.removeEventListener("mouseup", onMouseUp);
15355 }
15356 };
15357 }, [focusable2]);
15358 }
15359 const disabled2 = focusable2 && disabledFromProps(props);
15360 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
15361 const [focusVisible, setFocusVisible] = (0, import_react12.useState)(false);
15362 (0, import_react12.useEffect)(() => {
15363 if (!focusable2) return;
15364 if (trulyDisabled && focusVisible) {
15365 setFocusVisible(false);
15366 }
15367 }, [focusable2, trulyDisabled, focusVisible]);
15368 (0, import_react12.useEffect)(() => {
15369 if (!focusable2) return;
15370 if (!focusVisible) return;
15371 const element = ref.current;
15372 if (!element) return;
15373 if (typeof IntersectionObserver === "undefined") return;
15374 const observer = new IntersectionObserver(() => {
15375 if (!isFocusable(element)) {
15376 setFocusVisible(false);
15377 }
15378 });
15379 observer.observe(element);
15380 return () => observer.disconnect();
15381 }, [focusable2, focusVisible]);
15382 const onKeyPressCapture = useDisableEvent(
15383 props.onKeyPressCapture,
15384 disabled2
15385 );
15386 const onMouseDownCapture = useDisableEvent(
15387 props.onMouseDownCapture,
15388 disabled2
15389 );
15390 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
15391 const onMouseDownProp = props.onMouseDown;
15392 const onMouseDown = useEvent((event) => {
15393 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
15394 if (event.defaultPrevented) return;
15395 if (!focusable2) return;
15396 const element = event.currentTarget;
15397 if (!isSafariBrowser) return;
15398 if (isPortalEvent(event)) return;
15399 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
15400 let receivedFocus = false;
15401 const onFocus = () => {
15402 receivedFocus = true;
15403 };
15404 const options = { capture: true, once: true };
15405 element.addEventListener("focusin", onFocus, options);
15406 const focusableContainer = getClosestFocusable(element.parentElement);
15407 markSafariFocusAncestor(focusableContainer, true);
15408 queueBeforeEvent(element, "mouseup", () => {
15409 element.removeEventListener("focusin", onFocus, true);
15410 markSafariFocusAncestor(focusableContainer, false);
15411 if (receivedFocus) return;
15412 focusIfNeeded(element);
15413 });
15414 });
15415 const handleFocusVisible = (event, currentTarget) => {
15416 if (currentTarget) {
15417 event.currentTarget = currentTarget;
15418 }
15419 if (!focusable2) return;
15420 const element = event.currentTarget;
15421 if (!element) return;
15422 if (!hasFocus(element)) return;
15423 onFocusVisible == null ? void 0 : onFocusVisible(event);
15424 if (event.defaultPrevented) return;
15425 element.dataset.focusVisible = "true";
15426 setFocusVisible(true);
15427 };
15428 const onKeyDownCaptureProp = props.onKeyDownCapture;
15429 const onKeyDownCapture = useEvent((event) => {
15430 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
15431 if (event.defaultPrevented) return;
15432 if (!focusable2) return;
15433 if (focusVisible) return;
15434 if (event.metaKey) return;
15435 if (event.altKey) return;
15436 if (event.ctrlKey) return;
15437 if (!isSelfTarget(event)) return;
15438 const element = event.currentTarget;
15439 const applyFocusVisible = () => handleFocusVisible(event, element);
15440 queueBeforeEvent(element, "focusout", applyFocusVisible);
15441 });
15442 const onFocusCaptureProp = props.onFocusCapture;
15443 const onFocusCapture = useEvent((event) => {
15444 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
15445 if (event.defaultPrevented) return;
15446 if (!focusable2) return;
15447 if (!isSelfTarget(event)) {
15448 setFocusVisible(false);
15449 return;
15450 }
15451 const element = event.currentTarget;
15452 const applyFocusVisible = () => handleFocusVisible(event, element);
15453 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
15454 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
15455 } else {
15456 setFocusVisible(false);
15457 }
15458 });
15459 const onBlurProp = props.onBlur;
15460 const onBlur = useEvent((event) => {
15461 onBlurProp == null ? void 0 : onBlurProp(event);
15462 if (!focusable2) return;
15463 if (!isFocusEventOutside(event)) return;
15464 event.currentTarget.removeAttribute("data-focus-visible");
15465 setFocusVisible(false);
15466 });
15467 const autoFocusOnShow = (0, import_react12.useContext)(FocusableContext);
15468 const autoFocusRef = useEvent((element) => {
15469 if (!focusable2) return;
15470 if (!autoFocus) return;
15471 if (!element) return;
15472 if (!autoFocusOnShow) return;
15473 queueMicrotask(() => {
15474 if (hasFocus(element)) return;
15475 if (!isFocusable(element)) return;
15476 element.focus();
15477 });
15478 });
15479 const tagName = useTagName(ref);
15480 const nativeTabbable = focusable2 && isNativeTabbable(tagName);
15481 const supportsDisabled = focusable2 && supportsDisabledAttribute(tagName);
15482 const styleProp = props.style;
15483 const style = (0, import_react12.useMemo)(() => {
15484 if (trulyDisabled) {
15485 return { pointerEvents: "none", ...styleProp };
15486 }
15487 return styleProp;
15488 }, [trulyDisabled, styleProp]);
15489 props = {
15490 "data-focus-visible": focusable2 && focusVisible || void 0,
15491 "data-autofocus": autoFocus || void 0,
15492 "aria-disabled": disabled2 || void 0,
15493 ...props,
15494 ref: useMergeRefs(ref, autoFocusRef, props.ref),
15495 style,
15496 tabIndex: getTabIndex2(
15497 focusable2,
15498 trulyDisabled,
15499 nativeTabbable,
15500 supportsDisabled,
15501 props.tabIndex
15502 ),
15503 disabled: supportsDisabled && trulyDisabled ? true : void 0,
15504 // TODO: Test Focusable contentEditable.
15505 contentEditable: disabled2 ? void 0 : props.contentEditable,
15506 onKeyPressCapture,
15507 onClickCapture,
15508 onMouseDownCapture,
15509 onMouseDown,
15510 onKeyDownCapture,
15511 onFocusCapture,
15512 onBlur
15513 };
15514 return removeUndefinedValues(props);
15515 }
15516 );
15517 var Focusable = forwardRef22(function Focusable2(props) {
15518 const htmlProps = useFocusable(props);
15519 return createElement3(TagName2, htmlProps);
15520 });
15521
15522 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
15523 var import_react13 = __toESM(require_react(), 1);
15524 var TagName3 = "button";
15525 function isNativeClick(event) {
15526 if (!event.isTrusted) return false;
15527 const element = event.currentTarget;
15528 if (event.key === "Enter") {
15529 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
15530 }
15531 if (event.key === " ") {
15532 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
15533 }
15534 return false;
15535 }
15536 var symbol = /* @__PURE__ */ Symbol("command");
15537 var useCommand = createHook(
15538 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
15539 const ref = (0, import_react13.useRef)(null);
15540 const [isNativeButton, setIsNativeButton] = (0, import_react13.useState)(false);
15541 (0, import_react13.useEffect)(() => {
15542 if (!ref.current) return;
15543 setIsNativeButton(isButton(ref.current));
15544 }, []);
15545 const [active, setActive] = (0, import_react13.useState)(false);
15546 const activeRef = (0, import_react13.useRef)(false);
15547 const disabled2 = disabledFromProps(props);
15548 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
15549 const onKeyDownProp = props.onKeyDown;
15550 const onKeyDown = useEvent((event) => {
15551 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
15552 const element = event.currentTarget;
15553 if (event.defaultPrevented) return;
15554 if (isDuplicate) return;
15555 if (disabled2) return;
15556 if (!isSelfTarget(event)) return;
15557 if (isTextField(element)) return;
15558 if (element.isContentEditable) return;
15559 const isEnter = clickOnEnter && event.key === "Enter";
15560 const isSpace = clickOnSpace && event.key === " ";
15561 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
15562 const shouldPreventSpace = event.key === " " && !clickOnSpace;
15563 if (shouldPreventEnter || shouldPreventSpace) {
15564 event.preventDefault();
15565 return;
15566 }
15567 if (isEnter || isSpace) {
15568 const nativeClick = isNativeClick(event);
15569 if (isEnter) {
15570 if (!nativeClick) {
15571 event.preventDefault();
15572 const { view, ...eventInit } = event;
15573 const click = () => fireClickEvent(element, eventInit);
15574 if (isFirefox2()) {
15575 queueBeforeEvent(element, "keyup", click);
15576 } else {
15577 queueMicrotask(click);
15578 }
15579 }
15580 } else if (isSpace) {
15581 activeRef.current = true;
15582 if (!nativeClick) {
15583 event.preventDefault();
15584 setActive(true);
15585 }
15586 }
15587 }
15588 });
15589 const onKeyUpProp = props.onKeyUp;
15590 const onKeyUp = useEvent((event) => {
15591 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
15592 if (event.defaultPrevented) return;
15593 if (isDuplicate) return;
15594 if (disabled2) return;
15595 if (event.metaKey) return;
15596 const isSpace = clickOnSpace && event.key === " ";
15597 if (activeRef.current && isSpace) {
15598 activeRef.current = false;
15599 if (!isNativeClick(event)) {
15600 event.preventDefault();
15601 setActive(false);
15602 const element = event.currentTarget;
15603 const { view, ...eventInit } = event;
15604 queueMicrotask(() => fireClickEvent(element, eventInit));
15605 }
15606 }
15607 });
15608 props = {
15609 "data-active": active || void 0,
15610 type: isNativeButton ? "button" : void 0,
15611 ...metadataProps,
15612 ...props,
15613 ref: useMergeRefs(ref, props.ref),
15614 onKeyDown,
15615 onKeyUp
15616 };
15617 props = useFocusable(props);
15618 return props;
15619 }
15620 );
15621 var Command = forwardRef22(function Command2(props) {
15622 const htmlProps = useCommand(props);
15623 return createElement3(TagName3, htmlProps);
15624 });
15625
15626 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
15627 function getInternal(store, key) {
15628 const internals = store.__unstableInternals;
15629 invariant(internals, "Invalid store");
15630 return internals[key];
15631 }
15632 function createStore(initialState, ...stores) {
15633 let state = initialState;
15634 let prevStateBatch = state;
15635 let lastUpdate = /* @__PURE__ */ Symbol();
15636 let destroy = noop4;
15637 const instances = /* @__PURE__ */ new Set();
15638 const updatedKeys = /* @__PURE__ */ new Set();
15639 const setups = /* @__PURE__ */ new Set();
15640 const listeners = /* @__PURE__ */ new Set();
15641 const batchListeners = /* @__PURE__ */ new Set();
15642 const disposables = /* @__PURE__ */ new WeakMap();
15643 const listenerKeys = /* @__PURE__ */ new WeakMap();
15644 const storeSetup = (callback) => {
15645 setups.add(callback);
15646 return () => setups.delete(callback);
15647 };
15648 const storeInit = () => {
15649 const initialized = instances.size;
15650 const instance = /* @__PURE__ */ Symbol();
15651 instances.add(instance);
15652 const maybeDestroy = () => {
15653 instances.delete(instance);
15654 if (instances.size) return;
15655 destroy();
15656 };
15657 if (initialized) return maybeDestroy;
15658 const desyncs = getKeys(state).map(
15659 (key) => chain(
15660 ...stores.map((store) => {
15661 var _a;
15662 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
15663 if (!storeState) return;
15664 if (!hasOwnProperty(storeState, key)) return;
15665 return sync(store, [key], (state2) => {
15666 setState(
15667 key,
15668 state2[key],
15669 // @ts-expect-error - Not public API. This is just to prevent
15670 // infinite loops.
15671 true
15672 );
15673 });
15674 })
15675 )
15676 );
15677 const teardowns = [];
15678 for (const setup2 of setups) {
15679 teardowns.push(setup2());
15680 }
15681 const cleanups = stores.map(init);
15682 destroy = chain(...desyncs, ...teardowns, ...cleanups);
15683 return maybeDestroy;
15684 };
15685 const sub = (keys, listener, set2 = listeners) => {
15686 set2.add(listener);
15687 listenerKeys.set(listener, keys);
15688 return () => {
15689 var _a;
15690 (_a = disposables.get(listener)) == null ? void 0 : _a();
15691 disposables.delete(listener);
15692 listenerKeys.delete(listener);
15693 set2.delete(listener);
15694 };
15695 };
15696 const storeSubscribe = (keys, listener) => sub(keys, listener);
15697 const storeSync = (keys, listener) => {
15698 disposables.set(listener, listener(state, state));
15699 return sub(keys, listener);
15700 };
15701 const storeBatch = (keys, listener) => {
15702 disposables.set(listener, listener(state, prevStateBatch));
15703 return sub(keys, listener, batchListeners);
15704 };
15705 const storePick = (keys) => createStore(pick(state, keys), finalStore);
15706 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
15707 const getState = () => state;
15708 const setState = (key, value, fromStores = false) => {
15709 var _a;
15710 if (!hasOwnProperty(state, key)) return;
15711 const nextValue = applyState(value, state[key]);
15712 if (nextValue === state[key]) return;
15713 if (!fromStores) {
15714 for (const store of stores) {
15715 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
15716 }
15717 }
15718 const prevState = state;
15719 state = { ...state, [key]: nextValue };
15720 const thisUpdate = /* @__PURE__ */ Symbol();
15721 lastUpdate = thisUpdate;
15722 updatedKeys.add(key);
15723 const run = (listener, prev, uKeys) => {
15724 var _a2;
15725 const keys = listenerKeys.get(listener);
15726 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
15727 if (!keys || keys.some(updated)) {
15728 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
15729 disposables.set(listener, listener(state, prev));
15730 }
15731 };
15732 for (const listener of listeners) {
15733 run(listener, prevState);
15734 }
15735 queueMicrotask(() => {
15736 if (lastUpdate !== thisUpdate) return;
15737 const snapshot = state;
15738 for (const listener of batchListeners) {
15739 run(listener, prevStateBatch, updatedKeys);
15740 }
15741 prevStateBatch = snapshot;
15742 updatedKeys.clear();
15743 });
15744 };
15745 const finalStore = {
15746 getState,
15747 setState,
15748 __unstableInternals: {
15749 setup: storeSetup,
15750 init: storeInit,
15751 subscribe: storeSubscribe,
15752 sync: storeSync,
15753 batch: storeBatch,
15754 pick: storePick,
15755 omit: storeOmit
15756 }
15757 };
15758 return finalStore;
15759 }
15760 function setup(store, ...args) {
15761 if (!store) return;
15762 return getInternal(store, "setup")(...args);
15763 }
15764 function init(store, ...args) {
15765 if (!store) return;
15766 return getInternal(store, "init")(...args);
15767 }
15768 function subscribe(store, ...args) {
15769 if (!store) return;
15770 return getInternal(store, "subscribe")(...args);
15771 }
15772 function sync(store, ...args) {
15773 if (!store) return;
15774 return getInternal(store, "sync")(...args);
15775 }
15776 function batch(store, ...args) {
15777 if (!store) return;
15778 return getInternal(store, "batch")(...args);
15779 }
15780 function omit22(store, ...args) {
15781 if (!store) return;
15782 return getInternal(store, "omit")(...args);
15783 }
15784 function pick2(store, ...args) {
15785 if (!store) return;
15786 return getInternal(store, "pick")(...args);
15787 }
15788 function mergeStore(...stores) {
15789 var _a;
15790 const initialState = {};
15791 for (const store2 of stores) {
15792 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
15793 if (nextState) {
15794 Object.assign(initialState, nextState);
15795 }
15796 }
15797 const store = createStore(initialState, ...stores);
15798 return Object.assign({}, ...stores, store);
15799 }
15800 function throwOnConflictingProps(props, store) {
15801 if (false) return;
15802 if (!store) return;
15803 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
15804 var _a;
15805 const stateKey = key.replace("default", "");
15806 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
15807 });
15808 if (!defaultKeys.length) return;
15809 const storeState = store.getState();
15810 const conflictingProps = defaultKeys.filter(
15811 (key) => hasOwnProperty(storeState, key)
15812 );
15813 if (!conflictingProps.length) return;
15814 throw new Error(
15815 `Passing a store prop in conjunction with a default state is not supported.
15816
15817 const store = useSelectStore();
15818 <SelectProvider store={store} defaultValue="Apple" />
15819 ^ ^
15820
15821 Instead, pass the default state to the topmost store:
15822
15823 const store = useSelectStore({ defaultValue: "Apple" });
15824 <SelectProvider store={store} />
15825
15826 See https://github.com/ariakit/ariakit/pull/2745 for more details.
15827
15828 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
15829 `
15830 );
15831 }
15832
15833 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
15834 var React51 = __toESM(require_react(), 1);
15835 var import_shim2 = __toESM(require_shim(), 1);
15836 var { useSyncExternalStore: useSyncExternalStore2 } = import_shim2.default;
15837 var noopSubscribe = () => () => {
15838 };
15839 function useStoreState(store, keyOrSelector = identity) {
15840 const storeSubscribe = React51.useCallback(
15841 (callback) => {
15842 if (!store) return noopSubscribe();
15843 return subscribe(store, null, callback);
15844 },
15845 [store]
15846 );
15847 const getSnapshot = () => {
15848 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
15849 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
15850 const state = store == null ? void 0 : store.getState();
15851 if (selector2) return selector2(state);
15852 if (!state) return;
15853 if (!key) return;
15854 if (!hasOwnProperty(state, key)) return;
15855 return state[key];
15856 };
15857 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
15858 }
15859 function useStoreStateObject(store, object) {
15860 const objRef = React51.useRef(
15861 {}
15862 );
15863 const storeSubscribe = React51.useCallback(
15864 (callback) => {
15865 if (!store) return noopSubscribe();
15866 return subscribe(store, null, callback);
15867 },
15868 [store]
15869 );
15870 const getSnapshot = () => {
15871 const state = store == null ? void 0 : store.getState();
15872 let updated = false;
15873 const obj = objRef.current;
15874 for (const prop in object) {
15875 const keyOrSelector = object[prop];
15876 if (typeof keyOrSelector === "function") {
15877 const value = keyOrSelector(state);
15878 if (value !== obj[prop]) {
15879 obj[prop] = value;
15880 updated = true;
15881 }
15882 }
15883 if (typeof keyOrSelector === "string") {
15884 if (!state) continue;
15885 if (!hasOwnProperty(state, keyOrSelector)) continue;
15886 const value = state[keyOrSelector];
15887 if (value !== obj[prop]) {
15888 obj[prop] = value;
15889 updated = true;
15890 }
15891 }
15892 }
15893 if (updated) {
15894 objRef.current = { ...obj };
15895 }
15896 return objRef.current;
15897 };
15898 return useSyncExternalStore2(storeSubscribe, getSnapshot, getSnapshot);
15899 }
15900 function useStoreProps(store, props, key, setKey) {
15901 const value = hasOwnProperty(props, key) ? props[key] : void 0;
15902 const setValue = setKey ? props[setKey] : void 0;
15903 const propsRef = useLiveRef({ value, setValue });
15904 useSafeLayoutEffect(() => {
15905 return sync(store, [key], (state, prev) => {
15906 const { value: value2, setValue: setValue2 } = propsRef.current;
15907 if (!setValue2) return;
15908 if (state[key] === prev[key]) return;
15909 if (state[key] === value2) return;
15910 setValue2(state[key]);
15911 });
15912 }, [store, key]);
15913 useSafeLayoutEffect(() => {
15914 if (value === void 0) return;
15915 store.setState(key, value);
15916 return batch(store, [key], () => {
15917 if (value === void 0) return;
15918 store.setState(key, value);
15919 });
15920 });
15921 }
15922 function useStore2(createStore2, props) {
15923 const [store, setStore] = React51.useState(() => createStore2(props));
15924 useSafeLayoutEffect(() => init(store), [store]);
15925 const useState210 = React51.useCallback(
15926 (keyOrSelector) => useStoreState(store, keyOrSelector),
15927 [store]
15928 );
15929 const memoizedStore = React51.useMemo(
15930 () => ({ ...store, useState: useState210 }),
15931 [store, useState210]
15932 );
15933 const updateStore = useEvent(() => {
15934 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
15935 });
15936 return [memoizedStore, updateStore];
15937 }
15938
15939 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
15940 var import_react14 = __toESM(require_react(), 1);
15941 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
15942 var TagName4 = "button";
15943 function isEditableElement(element) {
15944 if (isTextbox(element)) return true;
15945 return element.tagName === "INPUT" && !isButton(element);
15946 }
15947 function getNextPageOffset(scrollingElement, pageUp = false) {
15948 const height = scrollingElement.clientHeight;
15949 const { top } = scrollingElement.getBoundingClientRect();
15950 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
15951 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
15952 if (scrollingElement.tagName === "HTML") {
15953 return pageOffset + scrollingElement.scrollTop;
15954 }
15955 return pageOffset;
15956 }
15957 function getItemOffset(itemElement, pageUp = false) {
15958 const { top } = itemElement.getBoundingClientRect();
15959 if (pageUp) {
15960 return top + itemElement.clientHeight;
15961 }
15962 return top;
15963 }
15964 function findNextPageItemId(element, store, next, pageUp = false) {
15965 var _a;
15966 if (!store) return;
15967 if (!next) return;
15968 const { renderedItems } = store.getState();
15969 const scrollingElement = getScrollingElement(element);
15970 if (!scrollingElement) return;
15971 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
15972 let id;
15973 let prevDifference;
15974 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
15975 const previousId = id;
15976 id = next(i2);
15977 if (!id) break;
15978 if (id === previousId) continue;
15979 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
15980 if (!itemElement) continue;
15981 const itemOffset = getItemOffset(itemElement, pageUp);
15982 const difference = itemOffset - nextPageOffset;
15983 const absDifference = Math.abs(difference);
15984 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
15985 if (prevDifference !== void 0 && prevDifference < absDifference) {
15986 id = previousId;
15987 }
15988 break;
15989 }
15990 prevDifference = absDifference;
15991 }
15992 return id;
15993 }
15994 function targetIsAnotherItem(event, store) {
15995 if (isSelfTarget(event)) return false;
15996 return isItem(store, event.target);
15997 }
15998 var useCompositeItem = createHook(
15999 function useCompositeItem2({
16000 store,
16001 rowId: rowIdProp,
16002 preventScrollOnKeyDown = false,
16003 moveOnKeyPress = true,
16004 tabbable: tabbable2 = false,
16005 getItem: getItemProp,
16006 "aria-setsize": ariaSetSizeProp,
16007 "aria-posinset": ariaPosInSetProp,
16008 ...props
16009 }) {
16010 const context = useCompositeContext();
16011 store = store || context;
16012 const id = useId4(props.id);
16013 const ref = (0, import_react14.useRef)(null);
16014 const row = (0, import_react14.useContext)(CompositeRowContext);
16015 const disabled2 = disabledFromProps(props);
16016 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
16017 const {
16018 rowId,
16019 baseElement,
16020 isActiveItem,
16021 ariaSetSize,
16022 ariaPosInSet,
16023 isTabbable
16024 } = useStoreStateObject(store, {
16025 rowId(state) {
16026 if (rowIdProp) return rowIdProp;
16027 if (!state) return;
16028 if (!(row == null ? void 0 : row.baseElement)) return;
16029 if (row.baseElement !== state.baseElement) return;
16030 return row.id;
16031 },
16032 baseElement(state) {
16033 return (state == null ? void 0 : state.baseElement) || void 0;
16034 },
16035 isActiveItem(state) {
16036 return !!state && state.activeId === id;
16037 },
16038 ariaSetSize(state) {
16039 if (ariaSetSizeProp != null) return ariaSetSizeProp;
16040 if (!state) return;
16041 if (!(row == null ? void 0 : row.ariaSetSize)) return;
16042 if (row.baseElement !== state.baseElement) return;
16043 return row.ariaSetSize;
16044 },
16045 ariaPosInSet(state) {
16046 if (ariaPosInSetProp != null) return ariaPosInSetProp;
16047 if (!state) return;
16048 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
16049 if (row.baseElement !== state.baseElement) return;
16050 const itemsInRow = state.renderedItems.filter(
16051 (item) => item.rowId === rowId
16052 );
16053 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
16054 },
16055 isTabbable(state) {
16056 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
16057 if (state.virtualFocus) return false;
16058 if (tabbable2) return true;
16059 if (state.activeId === null) return false;
16060 const item = store == null ? void 0 : store.item(state.activeId);
16061 if (item == null ? void 0 : item.disabled) return true;
16062 if (!(item == null ? void 0 : item.element)) return true;
16063 return state.activeId === id;
16064 }
16065 });
16066 const getItem = (0, import_react14.useCallback)(
16067 (item) => {
16068 var _a;
16069 const nextItem = {
16070 ...item,
16071 id: id || item.id,
16072 rowId,
16073 disabled: !!trulyDisabled,
16074 children: (_a = item.element) == null ? void 0 : _a.textContent
16075 };
16076 if (getItemProp) {
16077 return getItemProp(nextItem);
16078 }
16079 return nextItem;
16080 },
16081 [id, rowId, trulyDisabled, getItemProp]
16082 );
16083 const onFocusProp = props.onFocus;
16084 const hasFocusedComposite = (0, import_react14.useRef)(false);
16085 const onFocus = useEvent((event) => {
16086 onFocusProp == null ? void 0 : onFocusProp(event);
16087 if (event.defaultPrevented) return;
16088 if (isPortalEvent(event)) return;
16089 if (!id) return;
16090 if (!store) return;
16091 if (targetIsAnotherItem(event, store)) return;
16092 const { virtualFocus, baseElement: baseElement2 } = store.getState();
16093 store.setActiveId(id);
16094 if (isTextbox(event.currentTarget)) {
16095 selectTextField(event.currentTarget);
16096 }
16097 if (!virtualFocus) return;
16098 if (!isSelfTarget(event)) return;
16099 if (isEditableElement(event.currentTarget)) return;
16100 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
16101 if (isSafari2() && event.currentTarget.hasAttribute("data-autofocus")) {
16102 event.currentTarget.scrollIntoView({
16103 block: "nearest",
16104 inline: "nearest"
16105 });
16106 }
16107 hasFocusedComposite.current = true;
16108 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
16109 if (fromComposite) {
16110 focusSilently(baseElement2);
16111 } else {
16112 baseElement2.focus();
16113 }
16114 });
16115 const onBlurCaptureProp = props.onBlurCapture;
16116 const onBlurCapture = useEvent((event) => {
16117 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16118 if (event.defaultPrevented) return;
16119 const state = store == null ? void 0 : store.getState();
16120 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
16121 hasFocusedComposite.current = false;
16122 event.preventDefault();
16123 event.stopPropagation();
16124 }
16125 });
16126 const onKeyDownProp = props.onKeyDown;
16127 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
16128 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16129 const onKeyDown = useEvent((event) => {
16130 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16131 if (event.defaultPrevented) return;
16132 if (!isSelfTarget(event)) return;
16133 if (!store) return;
16134 const { currentTarget } = event;
16135 const state = store.getState();
16136 const item = store.item(id);
16137 const isGrid2 = !!(item == null ? void 0 : item.rowId);
16138 const isVertical = state.orientation !== "horizontal";
16139 const isHorizontal = state.orientation !== "vertical";
16140 const canHomeEnd = () => {
16141 if (isGrid2) return true;
16142 if (isHorizontal) return true;
16143 if (!state.baseElement) return true;
16144 if (!isTextField(state.baseElement)) return true;
16145 return false;
16146 };
16147 const keyMap = {
16148 ArrowUp: (isGrid2 || isVertical) && store.up,
16149 ArrowRight: (isGrid2 || isHorizontal) && store.next,
16150 ArrowDown: (isGrid2 || isVertical) && store.down,
16151 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
16152 Home: () => {
16153 if (!canHomeEnd()) return;
16154 if (!isGrid2 || event.ctrlKey) {
16155 return store == null ? void 0 : store.first();
16156 }
16157 return store == null ? void 0 : store.previous(-1);
16158 },
16159 End: () => {
16160 if (!canHomeEnd()) return;
16161 if (!isGrid2 || event.ctrlKey) {
16162 return store == null ? void 0 : store.last();
16163 }
16164 return store == null ? void 0 : store.next(-1);
16165 },
16166 PageUp: () => {
16167 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
16168 },
16169 PageDown: () => {
16170 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
16171 }
16172 };
16173 const action = keyMap[event.key];
16174 if (action) {
16175 if (isTextbox(currentTarget)) {
16176 const selection = getTextboxSelection(currentTarget);
16177 const isLeft = isHorizontal && event.key === "ArrowLeft";
16178 const isRight = isHorizontal && event.key === "ArrowRight";
16179 const isUp = isVertical && event.key === "ArrowUp";
16180 const isDown = isVertical && event.key === "ArrowDown";
16181 if (isRight || isDown) {
16182 const { length: valueLength } = getTextboxValue(currentTarget);
16183 if (selection.end !== valueLength) return;
16184 } else if ((isLeft || isUp) && selection.start !== 0) return;
16185 }
16186 const nextId = action();
16187 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
16188 if (!moveOnKeyPressProp(event)) return;
16189 event.preventDefault();
16190 store.move(nextId);
16191 }
16192 }
16193 });
16194 const providerValue = (0, import_react14.useMemo)(
16195 () => ({ id, baseElement }),
16196 [id, baseElement]
16197 );
16198 props = useWrapElement(
16199 props,
16200 (element) => /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
16201 [providerValue]
16202 );
16203 props = {
16204 id,
16205 "data-active-item": isActiveItem || void 0,
16206 ...props,
16207 ref: useMergeRefs(ref, props.ref),
16208 tabIndex: isTabbable ? props.tabIndex : -1,
16209 onFocus,
16210 onBlurCapture,
16211 onKeyDown
16212 };
16213 props = useCommand(props);
16214 props = useCollectionItem({
16215 store,
16216 ...props,
16217 getItem,
16218 shouldRegisterItem: id ? props.shouldRegisterItem : false
16219 });
16220 return removeUndefinedValues({
16221 ...props,
16222 "aria-setsize": ariaSetSize,
16223 "aria-posinset": ariaPosInSet
16224 });
16225 }
16226 );
16227 var CompositeItem = memo22(
16228 forwardRef22(function CompositeItem2(props) {
16229 const htmlProps = useCompositeItem(props);
16230 return createElement3(TagName4, htmlProps);
16231 })
16232 );
16233
16234 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
16235 function toArray(arg) {
16236 if (Array.isArray(arg)) {
16237 return arg;
16238 }
16239 return typeof arg !== "undefined" ? [arg] : [];
16240 }
16241 function flatten2DArray(array) {
16242 const flattened = [];
16243 for (const row of array) {
16244 flattened.push(...row);
16245 }
16246 return flattened;
16247 }
16248 function reverseArray(array) {
16249 return array.slice().reverse();
16250 }
16251
16252 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
16253 var import_react15 = __toESM(require_react(), 1);
16254 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
16255 var TagName5 = "div";
16256 function isGrid(items) {
16257 return items.some((item) => !!item.rowId);
16258 }
16259 function isPrintableKey(event) {
16260 const target = event.target;
16261 if (target && !isTextField(target)) return false;
16262 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
16263 }
16264 function isModifierKey(event) {
16265 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
16266 }
16267 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
16268 return useEvent((event) => {
16269 var _a;
16270 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
16271 if (event.defaultPrevented) return;
16272 if (event.isPropagationStopped()) return;
16273 if (!isSelfTarget(event)) return;
16274 if (isModifierKey(event)) return;
16275 if (isPrintableKey(event)) return;
16276 const state = store.getState();
16277 const activeElement2 = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
16278 if (!activeElement2) return;
16279 const { view, ...eventInit } = event;
16280 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
16281 if (activeElement2 !== previousElement) {
16282 activeElement2.focus();
16283 }
16284 if (!fireKeyboardEvent(activeElement2, event.type, eventInit)) {
16285 event.preventDefault();
16286 }
16287 if (event.currentTarget.contains(activeElement2)) {
16288 event.stopPropagation();
16289 }
16290 });
16291 }
16292 function findFirstEnabledItemInTheLastRow(items) {
16293 return findFirstEnabledItem(
16294 flatten2DArray(reverseArray(groupItemsByRows(items)))
16295 );
16296 }
16297 function useScheduleFocus(store) {
16298 const [scheduled, setScheduled] = (0, import_react15.useState)(false);
16299 const schedule = (0, import_react15.useCallback)(() => setScheduled(true), []);
16300 const activeItem = store.useState(
16301 (state) => getEnabledItem(store, state.activeId)
16302 );
16303 (0, import_react15.useEffect)(() => {
16304 const activeElement2 = activeItem == null ? void 0 : activeItem.element;
16305 if (!scheduled) return;
16306 if (!activeElement2) return;
16307 setScheduled(false);
16308 activeElement2.focus({ preventScroll: true });
16309 }, [activeItem, scheduled]);
16310 return schedule;
16311 }
16312 var useComposite = createHook(
16313 function useComposite2({
16314 store,
16315 composite = true,
16316 focusOnMove = composite,
16317 moveOnKeyPress = true,
16318 ...props
16319 }) {
16320 const context = useCompositeProviderContext();
16321 store = store || context;
16322 invariant(
16323 store,
16324 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
16325 );
16326 const ref = (0, import_react15.useRef)(null);
16327 const previousElementRef = (0, import_react15.useRef)(null);
16328 const scheduleFocus = useScheduleFocus(store);
16329 const moves = store.useState("moves");
16330 const [, setBaseElement] = useTransactionState(
16331 composite ? store.setBaseElement : null
16332 );
16333 (0, import_react15.useEffect)(() => {
16334 var _a;
16335 if (!store) return;
16336 if (!moves) return;
16337 if (!composite) return;
16338 if (!focusOnMove) return;
16339 const { activeId: activeId2 } = store.getState();
16340 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16341 if (!itemElement) return;
16342 focusIntoView(itemElement);
16343 }, [store, moves, composite, focusOnMove]);
16344 useSafeLayoutEffect(() => {
16345 if (!store) return;
16346 if (!moves) return;
16347 if (!composite) return;
16348 const { baseElement, activeId: activeId2 } = store.getState();
16349 const isSelfAcive = activeId2 === null;
16350 if (!isSelfAcive) return;
16351 if (!baseElement) return;
16352 const previousElement = previousElementRef.current;
16353 previousElementRef.current = null;
16354 if (previousElement) {
16355 fireBlurEvent(previousElement, { relatedTarget: baseElement });
16356 }
16357 if (!hasFocus(baseElement)) {
16358 baseElement.focus();
16359 }
16360 }, [store, moves, composite]);
16361 const activeId = store.useState("activeId");
16362 const virtualFocus = store.useState("virtualFocus");
16363 useSafeLayoutEffect(() => {
16364 var _a;
16365 if (!store) return;
16366 if (!composite) return;
16367 if (!virtualFocus) return;
16368 const previousElement = previousElementRef.current;
16369 previousElementRef.current = null;
16370 if (!previousElement) return;
16371 const activeElement2 = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
16372 const relatedTarget = activeElement2 || getActiveElement(previousElement);
16373 if (relatedTarget === previousElement) return;
16374 fireBlurEvent(previousElement, { relatedTarget });
16375 }, [store, activeId, virtualFocus, composite]);
16376 const onKeyDownCapture = useKeyboardEventProxy(
16377 store,
16378 props.onKeyDownCapture,
16379 previousElementRef
16380 );
16381 const onKeyUpCapture = useKeyboardEventProxy(
16382 store,
16383 props.onKeyUpCapture,
16384 previousElementRef
16385 );
16386 const onFocusCaptureProp = props.onFocusCapture;
16387 const onFocusCapture = useEvent((event) => {
16388 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
16389 if (event.defaultPrevented) return;
16390 if (!store) return;
16391 const { virtualFocus: virtualFocus2 } = store.getState();
16392 if (!virtualFocus2) return;
16393 const previousActiveElement = event.relatedTarget;
16394 const isSilentlyFocused = silentlyFocused(event.currentTarget);
16395 if (isSelfTarget(event) && isSilentlyFocused) {
16396 event.stopPropagation();
16397 previousElementRef.current = previousActiveElement;
16398 }
16399 });
16400 const onFocusProp = props.onFocus;
16401 const onFocus = useEvent((event) => {
16402 onFocusProp == null ? void 0 : onFocusProp(event);
16403 if (event.defaultPrevented) return;
16404 if (!composite) return;
16405 if (!store) return;
16406 const { relatedTarget } = event;
16407 const { virtualFocus: virtualFocus2 } = store.getState();
16408 if (virtualFocus2) {
16409 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
16410 queueMicrotask(scheduleFocus);
16411 }
16412 } else if (isSelfTarget(event)) {
16413 store.setActiveId(null);
16414 }
16415 });
16416 const onBlurCaptureProp = props.onBlurCapture;
16417 const onBlurCapture = useEvent((event) => {
16418 var _a;
16419 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
16420 if (event.defaultPrevented) return;
16421 if (!store) return;
16422 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
16423 if (!virtualFocus2) return;
16424 const activeElement2 = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
16425 const nextActiveElement = event.relatedTarget;
16426 const nextActiveElementIsItem = isItem(store, nextActiveElement);
16427 const previousElement = previousElementRef.current;
16428 previousElementRef.current = null;
16429 if (isSelfTarget(event) && nextActiveElementIsItem) {
16430 if (nextActiveElement === activeElement2) {
16431 if (previousElement && previousElement !== nextActiveElement) {
16432 fireBlurEvent(previousElement, event);
16433 }
16434 } else if (activeElement2) {
16435 fireBlurEvent(activeElement2, event);
16436 } else if (previousElement) {
16437 fireBlurEvent(previousElement, event);
16438 }
16439 event.stopPropagation();
16440 } else {
16441 const targetIsItem = isItem(store, event.target);
16442 if (!targetIsItem && activeElement2) {
16443 fireBlurEvent(activeElement2, event);
16444 }
16445 }
16446 });
16447 const onKeyDownProp = props.onKeyDown;
16448 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
16449 const onKeyDown = useEvent((event) => {
16450 var _a;
16451 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
16452 if (event.nativeEvent.isComposing) return;
16453 if (event.defaultPrevented) return;
16454 if (!store) return;
16455 if (!isSelfTarget(event)) return;
16456 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
16457 const activeItem = getEnabledItem(store, activeId2);
16458 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
16459 const isVertical = orientation !== "horizontal";
16460 const isHorizontal = orientation !== "vertical";
16461 const grid = isGrid(renderedItems);
16462 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
16463 if (isHorizontalKey && isTextField(event.currentTarget)) return;
16464 const up = () => {
16465 if (grid) {
16466 const item = findFirstEnabledItemInTheLastRow(renderedItems);
16467 return item == null ? void 0 : item.id;
16468 }
16469 return store == null ? void 0 : store.last();
16470 };
16471 const keyMap = {
16472 ArrowUp: (grid || isVertical) && up,
16473 ArrowRight: (grid || isHorizontal) && store.first,
16474 ArrowDown: (grid || isVertical) && store.first,
16475 ArrowLeft: (grid || isHorizontal) && store.last,
16476 Home: store.first,
16477 End: store.last,
16478 PageUp: store.first,
16479 PageDown: store.last
16480 };
16481 const action = keyMap[event.key];
16482 if (action) {
16483 const id = action();
16484 if (id !== void 0) {
16485 if (!moveOnKeyPressProp(event)) return;
16486 event.preventDefault();
16487 store.move(id);
16488 }
16489 }
16490 });
16491 props = useWrapElement(
16492 props,
16493 (element) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CompositeContextProvider, { value: store, children: element }),
16494 [store]
16495 );
16496 const activeDescendant = store.useState((state) => {
16497 var _a;
16498 if (!store) return;
16499 if (!composite) return;
16500 if (!state.virtualFocus) return;
16501 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
16502 });
16503 props = {
16504 "aria-activedescendant": activeDescendant,
16505 ...props,
16506 ref: useMergeRefs(ref, setBaseElement, props.ref),
16507 onKeyDownCapture,
16508 onKeyUpCapture,
16509 onFocusCapture,
16510 onFocus,
16511 onBlurCapture,
16512 onKeyDown
16513 };
16514 const focusable2 = store.useState(
16515 (state) => composite && (state.virtualFocus || state.activeId === null)
16516 );
16517 props = useFocusable({ focusable: focusable2, ...props });
16518 return props;
16519 }
16520 );
16521 var Composite5 = forwardRef22(function Composite22(props) {
16522 const htmlProps = useComposite(props);
16523 return createElement3(TagName5, htmlProps);
16524 });
16525
16526 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
16527 var ctx3 = createStoreContext();
16528 var useDisclosureContext = ctx3.useContext;
16529 var useDisclosureScopedContext = ctx3.useScopedContext;
16530 var useDisclosureProviderContext = ctx3.useProviderContext;
16531 var DisclosureContextProvider = ctx3.ContextProvider;
16532 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
16533
16534 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
16535 var import_react16 = __toESM(require_react(), 1);
16536 var ctx4 = createStoreContext(
16537 [DisclosureContextProvider],
16538 [DisclosureScopedContextProvider]
16539 );
16540 var useDialogContext = ctx4.useContext;
16541 var useDialogScopedContext = ctx4.useScopedContext;
16542 var useDialogProviderContext = ctx4.useProviderContext;
16543 var DialogContextProvider = ctx4.ContextProvider;
16544 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
16545 var DialogHeadingContext = (0, import_react16.createContext)(void 0);
16546 var DialogDescriptionContext = (0, import_react16.createContext)(void 0);
16547
16548 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
16549 var import_react17 = __toESM(require_react(), 1);
16550 var import_react_dom4 = __toESM(require_react_dom(), 1);
16551 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
16552 var TagName6 = "div";
16553 function afterTimeout(timeoutMs, cb) {
16554 const timeoutId = setTimeout(cb, timeoutMs);
16555 return () => clearTimeout(timeoutId);
16556 }
16557 function afterPaint2(cb) {
16558 let raf = requestAnimationFrame(() => {
16559 raf = requestAnimationFrame(cb);
16560 });
16561 return () => cancelAnimationFrame(raf);
16562 }
16563 function parseCSSTime(...times) {
16564 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
16565 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
16566 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
16567 if (currentTime > longestTime) return currentTime;
16568 return longestTime;
16569 }, 0);
16570 }
16571 function isHidden(mounted, hidden, alwaysVisible) {
16572 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
16573 }
16574 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
16575 const context = useDisclosureProviderContext();
16576 store = store || context;
16577 invariant(
16578 store,
16579 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
16580 );
16581 const ref = (0, import_react17.useRef)(null);
16582 const id = useId4(props.id);
16583 const [transition, setTransition] = (0, import_react17.useState)(null);
16584 const open = store.useState("open");
16585 const mounted = store.useState("mounted");
16586 const animated = store.useState("animated");
16587 const contentElement = store.useState("contentElement");
16588 const otherElement = useStoreState(store.disclosure, "contentElement");
16589 useSafeLayoutEffect(() => {
16590 if (!ref.current) return;
16591 store == null ? void 0 : store.setContentElement(ref.current);
16592 }, [store]);
16593 useSafeLayoutEffect(() => {
16594 let previousAnimated;
16595 store == null ? void 0 : store.setState("animated", (animated2) => {
16596 previousAnimated = animated2;
16597 return true;
16598 });
16599 return () => {
16600 if (previousAnimated === void 0) return;
16601 store == null ? void 0 : store.setState("animated", previousAnimated);
16602 };
16603 }, [store]);
16604 useSafeLayoutEffect(() => {
16605 if (!animated) return;
16606 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
16607 setTransition(null);
16608 return;
16609 }
16610 return afterPaint2(() => {
16611 setTransition(open ? "enter" : mounted ? "leave" : null);
16612 });
16613 }, [animated, contentElement, open, mounted]);
16614 useSafeLayoutEffect(() => {
16615 if (!store) return;
16616 if (!animated) return;
16617 if (!transition) return;
16618 if (!contentElement) return;
16619 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
16620 const stopAnimationSync = () => (0, import_react_dom4.flushSync)(stopAnimation);
16621 if (transition === "leave" && open) return;
16622 if (transition === "enter" && !open) return;
16623 if (typeof animated === "number") {
16624 const timeout2 = animated;
16625 return afterTimeout(timeout2, stopAnimationSync);
16626 }
16627 const {
16628 transitionDuration,
16629 animationDuration,
16630 transitionDelay,
16631 animationDelay
16632 } = getComputedStyle(contentElement);
16633 const {
16634 transitionDuration: transitionDuration2 = "0",
16635 animationDuration: animationDuration2 = "0",
16636 transitionDelay: transitionDelay2 = "0",
16637 animationDelay: animationDelay2 = "0"
16638 } = otherElement ? getComputedStyle(otherElement) : {};
16639 const delay = parseCSSTime(
16640 transitionDelay,
16641 animationDelay,
16642 transitionDelay2,
16643 animationDelay2
16644 );
16645 const duration = parseCSSTime(
16646 transitionDuration,
16647 animationDuration,
16648 transitionDuration2,
16649 animationDuration2
16650 );
16651 const timeout = delay + duration;
16652 if (!timeout) {
16653 if (transition === "enter") {
16654 store.setState("animated", false);
16655 }
16656 stopAnimation();
16657 return;
16658 }
16659 const frameRate = 1e3 / 60;
16660 const maxTimeout = Math.max(timeout - frameRate, 0);
16661 return afterTimeout(maxTimeout, stopAnimationSync);
16662 }, [store, animated, contentElement, otherElement, open, transition]);
16663 props = useWrapElement(
16664 props,
16665 (element) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DialogScopedContextProvider, { value: store, children: element }),
16666 [store]
16667 );
16668 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
16669 const styleProp = props.style;
16670 const style = (0, import_react17.useMemo)(() => {
16671 if (hidden) {
16672 return { ...styleProp, display: "none" };
16673 }
16674 return styleProp;
16675 }, [hidden, styleProp]);
16676 props = {
16677 id,
16678 "data-open": open || void 0,
16679 "data-enter": transition === "enter" || void 0,
16680 "data-leave": transition === "leave" || void 0,
16681 hidden,
16682 ...props,
16683 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
16684 style
16685 };
16686 return removeUndefinedValues(props);
16687 });
16688 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
16689 const htmlProps = useDisclosureContent(props);
16690 return createElement3(TagName6, htmlProps);
16691 });
16692 var DisclosureContent = forwardRef22(function DisclosureContent2({
16693 unmountOnHide,
16694 ...props
16695 }) {
16696 const context = useDisclosureProviderContext();
16697 const store = props.store || context;
16698 const mounted = useStoreState(
16699 store,
16700 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
16701 );
16702 if (mounted === false) return null;
16703 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(DisclosureContentImpl, { ...props });
16704 });
16705
16706 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
16707 function createDisclosureStore(props = {}) {
16708 const store = mergeStore(
16709 props.store,
16710 omit22(props.disclosure, ["contentElement", "disclosureElement"])
16711 );
16712 throwOnConflictingProps(props, store);
16713 const syncState = store == null ? void 0 : store.getState();
16714 const open = defaultValue(
16715 props.open,
16716 syncState == null ? void 0 : syncState.open,
16717 props.defaultOpen,
16718 false
16719 );
16720 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
16721 const initialState = {
16722 open,
16723 animated,
16724 animating: !!animated && open,
16725 mounted: open,
16726 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
16727 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
16728 };
16729 const disclosure = createStore(initialState, store);
16730 setup(
16731 disclosure,
16732 () => sync(disclosure, ["animated", "animating"], (state) => {
16733 if (state.animated) return;
16734 disclosure.setState("animating", false);
16735 })
16736 );
16737 setup(
16738 disclosure,
16739 () => subscribe(disclosure, ["open"], () => {
16740 if (!disclosure.getState().animated) return;
16741 disclosure.setState("animating", true);
16742 })
16743 );
16744 setup(
16745 disclosure,
16746 () => sync(disclosure, ["open", "animating"], (state) => {
16747 disclosure.setState("mounted", state.open || state.animating);
16748 })
16749 );
16750 return {
16751 ...disclosure,
16752 disclosure: props.disclosure,
16753 setOpen: (value) => disclosure.setState("open", value),
16754 show: () => disclosure.setState("open", true),
16755 hide: () => disclosure.setState("open", false),
16756 toggle: () => disclosure.setState("open", (open2) => !open2),
16757 stopAnimation: () => disclosure.setState("animating", false),
16758 setContentElement: (value) => disclosure.setState("contentElement", value),
16759 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
16760 };
16761 }
16762
16763 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
16764 function useDisclosureStoreProps(store, update2, props) {
16765 useUpdateEffect(update2, [props.store, props.disclosure]);
16766 useStoreProps(store, props, "open", "setOpen");
16767 useStoreProps(store, props, "mounted", "setMounted");
16768 useStoreProps(store, props, "animated");
16769 return Object.assign(store, { disclosure: props.disclosure });
16770 }
16771
16772 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
16773 var ctx5 = createStoreContext(
16774 [DialogContextProvider],
16775 [DialogScopedContextProvider]
16776 );
16777 var usePopoverContext = ctx5.useContext;
16778 var usePopoverScopedContext = ctx5.useScopedContext;
16779 var usePopoverProviderContext = ctx5.useProviderContext;
16780 var PopoverContextProvider = ctx5.ContextProvider;
16781 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
16782
16783 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
16784 function getCommonParent(items) {
16785 var _a;
16786 const firstItem = items.find((item) => !!item.element);
16787 const lastItem = [...items].reverse().find((item) => !!item.element);
16788 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
16789 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
16790 const parent = parentElement;
16791 if (lastItem && parent.contains(lastItem.element)) {
16792 return parentElement;
16793 }
16794 parentElement = parentElement.parentElement;
16795 }
16796 return getDocument(parentElement).body;
16797 }
16798 function getPrivateStore(store) {
16799 return store == null ? void 0 : store.__unstablePrivateStore;
16800 }
16801 function createCollectionStore(props = {}) {
16802 var _a;
16803 throwOnConflictingProps(props, props.store);
16804 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
16805 const items = defaultValue(
16806 props.items,
16807 syncState == null ? void 0 : syncState.items,
16808 props.defaultItems,
16809 []
16810 );
16811 const itemsMap = new Map(items.map((item) => [item.id, item]));
16812 const initialState = {
16813 items,
16814 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
16815 };
16816 const syncPrivateStore = getPrivateStore(props.store);
16817 const privateStore = createStore(
16818 { items, renderedItems: initialState.renderedItems },
16819 syncPrivateStore
16820 );
16821 const collection = createStore(initialState, props.store);
16822 const sortItems = (renderedItems) => {
16823 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
16824 privateStore.setState("renderedItems", sortedItems);
16825 collection.setState("renderedItems", sortedItems);
16826 };
16827 setup(collection, () => init(privateStore));
16828 setup(privateStore, () => {
16829 return batch(privateStore, ["items"], (state) => {
16830 collection.setState("items", state.items);
16831 });
16832 });
16833 setup(privateStore, () => {
16834 return batch(privateStore, ["renderedItems"], (state) => {
16835 let firstRun = true;
16836 let raf = requestAnimationFrame(() => {
16837 const { renderedItems } = collection.getState();
16838 if (state.renderedItems === renderedItems) return;
16839 sortItems(state.renderedItems);
16840 });
16841 if (typeof IntersectionObserver !== "function") {
16842 return () => cancelAnimationFrame(raf);
16843 }
16844 const ioCallback = () => {
16845 if (firstRun) {
16846 firstRun = false;
16847 return;
16848 }
16849 cancelAnimationFrame(raf);
16850 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
16851 };
16852 const root = getCommonParent(state.renderedItems);
16853 const observer = new IntersectionObserver(ioCallback, { root });
16854 for (const item of state.renderedItems) {
16855 if (!item.element) continue;
16856 observer.observe(item.element);
16857 }
16858 return () => {
16859 cancelAnimationFrame(raf);
16860 observer.disconnect();
16861 };
16862 });
16863 });
16864 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
16865 let prevItem;
16866 setItems((items2) => {
16867 const index2 = items2.findIndex(({ id }) => id === item.id);
16868 const nextItems = items2.slice();
16869 if (index2 !== -1) {
16870 prevItem = items2[index2];
16871 const nextItem = { ...prevItem, ...item };
16872 nextItems[index2] = nextItem;
16873 itemsMap.set(item.id, nextItem);
16874 } else {
16875 nextItems.push(item);
16876 itemsMap.set(item.id, item);
16877 }
16878 return nextItems;
16879 });
16880 const unmergeItem = () => {
16881 setItems((items2) => {
16882 if (!prevItem) {
16883 if (canDeleteFromMap) {
16884 itemsMap.delete(item.id);
16885 }
16886 return items2.filter(({ id }) => id !== item.id);
16887 }
16888 const index2 = items2.findIndex(({ id }) => id === item.id);
16889 if (index2 === -1) return items2;
16890 const nextItems = items2.slice();
16891 nextItems[index2] = prevItem;
16892 itemsMap.set(item.id, prevItem);
16893 return nextItems;
16894 });
16895 };
16896 return unmergeItem;
16897 };
16898 const registerItem = (item) => mergeItem(
16899 item,
16900 (getItems) => privateStore.setState("items", getItems),
16901 true
16902 );
16903 return {
16904 ...collection,
16905 registerItem,
16906 renderItem: (item) => chain(
16907 registerItem(item),
16908 mergeItem(
16909 item,
16910 (getItems) => privateStore.setState("renderedItems", getItems)
16911 )
16912 ),
16913 item: (id) => {
16914 if (!id) return null;
16915 let item = itemsMap.get(id);
16916 if (!item) {
16917 const { items: items2 } = privateStore.getState();
16918 item = items2.find((item2) => item2.id === id);
16919 if (item) {
16920 itemsMap.set(id, item);
16921 }
16922 }
16923 return item || null;
16924 },
16925 // @ts-expect-error Internal
16926 __unstablePrivateStore: privateStore
16927 };
16928 }
16929
16930 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
16931 function useCollectionStoreProps(store, update2, props) {
16932 useUpdateEffect(update2, [props.store]);
16933 useStoreProps(store, props, "items", "setItems");
16934 return store;
16935 }
16936
16937 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
16938 var NULL_ITEM = { id: null };
16939 function findFirstEnabledItem2(items, excludeId) {
16940 return items.find((item) => {
16941 if (excludeId) {
16942 return !item.disabled && item.id !== excludeId;
16943 }
16944 return !item.disabled;
16945 });
16946 }
16947 function getEnabledItems(items, excludeId) {
16948 return items.filter((item) => {
16949 if (excludeId) {
16950 return !item.disabled && item.id !== excludeId;
16951 }
16952 return !item.disabled;
16953 });
16954 }
16955 function getItemsInRow(items, rowId) {
16956 return items.filter((item) => item.rowId === rowId);
16957 }
16958 function flipItems(items, activeId, shouldInsertNullItem = false) {
16959 const index2 = items.findIndex((item) => item.id === activeId);
16960 return [
16961 ...items.slice(index2 + 1),
16962 ...shouldInsertNullItem ? [NULL_ITEM] : [],
16963 ...items.slice(0, index2)
16964 ];
16965 }
16966 function groupItemsByRows2(items) {
16967 const rows = [];
16968 for (const item of items) {
16969 const row = rows.find((currentRow) => {
16970 var _a;
16971 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
16972 });
16973 if (row) {
16974 row.push(item);
16975 } else {
16976 rows.push([item]);
16977 }
16978 }
16979 return rows;
16980 }
16981 function getMaxRowLength(array) {
16982 let maxLength = 0;
16983 for (const { length } of array) {
16984 if (length > maxLength) {
16985 maxLength = length;
16986 }
16987 }
16988 return maxLength;
16989 }
16990 function createEmptyItem(rowId) {
16991 return {
16992 id: "__EMPTY_ITEM__",
16993 disabled: true,
16994 rowId
16995 };
16996 }
16997 function normalizeRows(rows, activeId, focusShift) {
16998 const maxLength = getMaxRowLength(rows);
16999 for (const row of rows) {
17000 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17001 const item = row[i2];
17002 if (!item || focusShift && item.disabled) {
17003 const isFirst = i2 === 0;
17004 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
17005 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
17006 }
17007 }
17008 }
17009 return rows;
17010 }
17011 function verticalizeItems(items) {
17012 const rows = groupItemsByRows2(items);
17013 const maxLength = getMaxRowLength(rows);
17014 const verticalized = [];
17015 for (let i2 = 0; i2 < maxLength; i2 += 1) {
17016 for (const row of rows) {
17017 const item = row[i2];
17018 if (item) {
17019 verticalized.push({
17020 ...item,
17021 // If there's no rowId, it means that it's not a grid composite, but
17022 // a single row instead. So, instead of verticalizing it, that is,
17023 // assigning a different rowId based on the column index, we keep it
17024 // undefined so they will be part of the same row. This is useful
17025 // when using up/down on one-dimensional composites.
17026 rowId: item.rowId ? `${i2}` : void 0
17027 });
17028 }
17029 }
17030 }
17031 return verticalized;
17032 }
17033 function createCompositeStore(props = {}) {
17034 var _a;
17035 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
17036 const collection = createCollectionStore(props);
17037 const activeId = defaultValue(
17038 props.activeId,
17039 syncState == null ? void 0 : syncState.activeId,
17040 props.defaultActiveId
17041 );
17042 const initialState = {
17043 ...collection.getState(),
17044 id: defaultValue(
17045 props.id,
17046 syncState == null ? void 0 : syncState.id,
17047 `id-${Math.random().toString(36).slice(2, 8)}`
17048 ),
17049 activeId,
17050 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
17051 includesBaseElement: defaultValue(
17052 props.includesBaseElement,
17053 syncState == null ? void 0 : syncState.includesBaseElement,
17054 activeId === null
17055 ),
17056 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
17057 orientation: defaultValue(
17058 props.orientation,
17059 syncState == null ? void 0 : syncState.orientation,
17060 "both"
17061 ),
17062 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
17063 virtualFocus: defaultValue(
17064 props.virtualFocus,
17065 syncState == null ? void 0 : syncState.virtualFocus,
17066 false
17067 ),
17068 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
17069 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
17070 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
17071 };
17072 const composite = createStore(initialState, collection, props.store);
17073 setup(
17074 composite,
17075 () => sync(composite, ["renderedItems", "activeId"], (state) => {
17076 composite.setState("activeId", (activeId2) => {
17077 var _a2;
17078 if (activeId2 !== void 0) return activeId2;
17079 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
17080 });
17081 })
17082 );
17083 const getNextId = (direction = "next", options = {}) => {
17084 var _a2, _b;
17085 const defaultState = composite.getState();
17086 const {
17087 skip = 0,
17088 activeId: activeId2 = defaultState.activeId,
17089 focusShift = defaultState.focusShift,
17090 focusLoop = defaultState.focusLoop,
17091 focusWrap = defaultState.focusWrap,
17092 includesBaseElement = defaultState.includesBaseElement,
17093 renderedItems = defaultState.renderedItems,
17094 rtl = defaultState.rtl
17095 } = options;
17096 const isVerticalDirection = direction === "up" || direction === "down";
17097 const isNextDirection = direction === "next" || direction === "down";
17098 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
17099 const canShift = focusShift && !skip;
17100 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
17101 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
17102 );
17103 items = canReverse ? reverseArray(items) : items;
17104 items = isVerticalDirection ? verticalizeItems(items) : items;
17105 if (activeId2 == null) {
17106 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
17107 }
17108 const activeItem = items.find((item) => item.id === activeId2);
17109 if (!activeItem) {
17110 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
17111 }
17112 const isGrid2 = items.some((item) => item.rowId);
17113 const activeIndex = items.indexOf(activeItem);
17114 const nextItems = items.slice(activeIndex + 1);
17115 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
17116 if (skip) {
17117 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
17118 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
17119 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
17120 return nextItem2 == null ? void 0 : nextItem2.id;
17121 }
17122 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
17123 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
17124 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
17125 if (canLoop) {
17126 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
17127 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
17128 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
17129 return nextItem2 == null ? void 0 : nextItem2.id;
17130 }
17131 if (canWrap) {
17132 const nextItem2 = findFirstEnabledItem2(
17133 // We can use nextItems, which contains all the next items, including
17134 // items from other rows, to wrap between rows. However, if there is a
17135 // null item (the composite container), we'll only use the next items in
17136 // the row. So moving next from the last item will focus on the
17137 // composite container. On grid composites, horizontal navigation never
17138 // focuses on the composite container, only vertical.
17139 hasNullItem ? nextItemsInRow : nextItems,
17140 activeId2
17141 );
17142 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
17143 return nextId;
17144 }
17145 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
17146 if (!nextItem && hasNullItem) {
17147 return null;
17148 }
17149 return nextItem == null ? void 0 : nextItem.id;
17150 };
17151 return {
17152 ...collection,
17153 ...composite,
17154 setBaseElement: (element) => composite.setState("baseElement", element),
17155 setActiveId: (id) => composite.setState("activeId", id),
17156 move: (id) => {
17157 if (id === void 0) return;
17158 composite.setState("activeId", id);
17159 composite.setState("moves", (moves) => moves + 1);
17160 },
17161 first: () => {
17162 var _a2;
17163 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
17164 },
17165 last: () => {
17166 var _a2;
17167 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
17168 },
17169 next: (options) => {
17170 if (options !== void 0 && typeof options === "number") {
17171 options = { skip: options };
17172 }
17173 return getNextId("next", options);
17174 },
17175 previous: (options) => {
17176 if (options !== void 0 && typeof options === "number") {
17177 options = { skip: options };
17178 }
17179 return getNextId("previous", options);
17180 },
17181 down: (options) => {
17182 if (options !== void 0 && typeof options === "number") {
17183 options = { skip: options };
17184 }
17185 return getNextId("down", options);
17186 },
17187 up: (options) => {
17188 if (options !== void 0 && typeof options === "number") {
17189 options = { skip: options };
17190 }
17191 return getNextId("up", options);
17192 }
17193 };
17194 }
17195
17196 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
17197 function useCompositeStoreOptions(props) {
17198 const id = useId4(props.id);
17199 return { id, ...props };
17200 }
17201 function useCompositeStoreProps(store, update2, props) {
17202 store = useCollectionStoreProps(store, update2, props);
17203 useStoreProps(store, props, "activeId", "setActiveId");
17204 useStoreProps(store, props, "includesBaseElement");
17205 useStoreProps(store, props, "virtualFocus");
17206 useStoreProps(store, props, "orientation");
17207 useStoreProps(store, props, "rtl");
17208 useStoreProps(store, props, "focusLoop");
17209 useStoreProps(store, props, "focusWrap");
17210 useStoreProps(store, props, "focusShift");
17211 return store;
17212 }
17213
17214 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
17215 var import_react18 = __toESM(require_react(), 1);
17216 var ComboboxListRoleContext = (0, import_react18.createContext)(
17217 void 0
17218 );
17219 var ctx6 = createStoreContext(
17220 [PopoverContextProvider, CompositeContextProvider],
17221 [PopoverScopedContextProvider, CompositeScopedContextProvider]
17222 );
17223 var useComboboxContext = ctx6.useContext;
17224 var useComboboxScopedContext = ctx6.useScopedContext;
17225 var useComboboxProviderContext = ctx6.useProviderContext;
17226 var ComboboxContextProvider = ctx6.ContextProvider;
17227 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
17228 var ComboboxItemValueContext = (0, import_react18.createContext)(
17229 void 0
17230 );
17231 var ComboboxItemCheckedContext = (0, import_react18.createContext)(false);
17232
17233 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
17234 function createDialogStore(props = {}) {
17235 return createDisclosureStore(props);
17236 }
17237
17238 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
17239 function useDialogStoreProps(store, update2, props) {
17240 return useDisclosureStoreProps(store, update2, props);
17241 }
17242
17243 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
17244 function createPopoverStore({
17245 popover: otherPopover,
17246 ...props
17247 } = {}) {
17248 const store = mergeStore(
17249 props.store,
17250 omit22(otherPopover, [
17251 "arrowElement",
17252 "anchorElement",
17253 "contentElement",
17254 "popoverElement",
17255 "disclosureElement"
17256 ])
17257 );
17258 throwOnConflictingProps(props, store);
17259 const syncState = store == null ? void 0 : store.getState();
17260 const dialog = createDialogStore({ ...props, store });
17261 const placement = defaultValue(
17262 props.placement,
17263 syncState == null ? void 0 : syncState.placement,
17264 "bottom"
17265 );
17266 const initialState = {
17267 ...dialog.getState(),
17268 placement,
17269 currentPlacement: placement,
17270 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
17271 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
17272 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
17273 rendered: /* @__PURE__ */ Symbol("rendered")
17274 };
17275 const popover = createStore(initialState, dialog, store);
17276 return {
17277 ...dialog,
17278 ...popover,
17279 setAnchorElement: (element) => popover.setState("anchorElement", element),
17280 setPopoverElement: (element) => popover.setState("popoverElement", element),
17281 setArrowElement: (element) => popover.setState("arrowElement", element),
17282 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
17283 };
17284 }
17285
17286 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
17287 function usePopoverStoreProps(store, update2, props) {
17288 useUpdateEffect(update2, [props.popover]);
17289 useStoreProps(store, props, "placement");
17290 return useDialogStoreProps(store, update2, props);
17291 }
17292
17293 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
17294 var TagName7 = "div";
17295 var usePopoverAnchor = createHook(
17296 function usePopoverAnchor2({ store, ...props }) {
17297 const context = usePopoverProviderContext();
17298 store = store || context;
17299 props = {
17300 ...props,
17301 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
17302 };
17303 return props;
17304 }
17305 );
17306 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
17307 const htmlProps = usePopoverAnchor(props);
17308 return createElement3(TagName7, htmlProps);
17309 });
17310
17311 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
17312 var import_react19 = __toESM(require_react(), 1);
17313 var TagName8 = "div";
17314 function getMouseDestination(event) {
17315 const relatedTarget = event.relatedTarget;
17316 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
17317 return relatedTarget;
17318 }
17319 return null;
17320 }
17321 function hoveringInside(event) {
17322 const nextElement = getMouseDestination(event);
17323 if (!nextElement) return false;
17324 return contains2(event.currentTarget, nextElement);
17325 }
17326 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
17327 function movingToAnotherItem(event) {
17328 let dest = getMouseDestination(event);
17329 if (!dest) return false;
17330 do {
17331 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
17332 dest = dest.parentElement;
17333 } while (dest);
17334 return false;
17335 }
17336 var useCompositeHover = createHook(
17337 function useCompositeHover2({
17338 store,
17339 focusOnHover = true,
17340 blurOnHoverEnd = !!focusOnHover,
17341 ...props
17342 }) {
17343 const context = useCompositeContext();
17344 store = store || context;
17345 invariant(
17346 store,
17347 "CompositeHover must be wrapped in a Composite component."
17348 );
17349 const isMouseMoving = useIsMouseMoving();
17350 const onMouseMoveProp = props.onMouseMove;
17351 const focusOnHoverProp = useBooleanEvent(focusOnHover);
17352 const onMouseMove = useEvent((event) => {
17353 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
17354 if (event.defaultPrevented) return;
17355 if (!isMouseMoving()) return;
17356 if (!focusOnHoverProp(event)) return;
17357 if (!hasFocusWithin(event.currentTarget)) {
17358 const baseElement = store == null ? void 0 : store.getState().baseElement;
17359 if (baseElement && !hasFocus(baseElement)) {
17360 baseElement.focus();
17361 }
17362 }
17363 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
17364 });
17365 const onMouseLeaveProp = props.onMouseLeave;
17366 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
17367 const onMouseLeave = useEvent((event) => {
17368 var _a;
17369 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
17370 if (event.defaultPrevented) return;
17371 if (!isMouseMoving()) return;
17372 if (hoveringInside(event)) return;
17373 if (movingToAnotherItem(event)) return;
17374 if (!focusOnHoverProp(event)) return;
17375 if (!blurOnHoverEndProp(event)) return;
17376 store == null ? void 0 : store.setActiveId(null);
17377 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
17378 });
17379 const ref = (0, import_react19.useCallback)((element) => {
17380 if (!element) return;
17381 element[symbol2] = true;
17382 }, []);
17383 props = {
17384 ...props,
17385 ref: useMergeRefs(ref, props.ref),
17386 onMouseMove,
17387 onMouseLeave
17388 };
17389 return removeUndefinedValues(props);
17390 }
17391 );
17392 var CompositeHover = memo22(
17393 forwardRef22(function CompositeHover2(props) {
17394 const htmlProps = useCompositeHover(props);
17395 return createElement3(TagName8, htmlProps);
17396 })
17397 );
17398
17399 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
17400 var import_react20 = __toESM(require_react(), 1);
17401 var TagName9 = "input";
17402 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
17403 if (!autoSelect) return false;
17404 const firstItem = items.find((item) => !item.disabled && item.value);
17405 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
17406 }
17407 function hasCompletionString(value, activeValue) {
17408 if (!activeValue) return false;
17409 if (value == null) return false;
17410 value = normalizeString(value);
17411 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
17412 }
17413 function isInputEvent(event) {
17414 return event.type === "input";
17415 }
17416 function isAriaAutoCompleteValue(value) {
17417 return value === "inline" || value === "list" || value === "both" || value === "none";
17418 }
17419 function getDefaultAutoSelectId(items) {
17420 const item = items.find((item2) => {
17421 var _a;
17422 if (item2.disabled) return false;
17423 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
17424 });
17425 return item == null ? void 0 : item.id;
17426 }
17427 var useCombobox = createHook(
17428 function useCombobox2({
17429 store,
17430 focusable: focusable2 = true,
17431 autoSelect: autoSelectProp = false,
17432 getAutoSelectId,
17433 setValueOnChange,
17434 showMinLength = 0,
17435 showOnChange,
17436 showOnMouseDown,
17437 showOnClick = showOnMouseDown,
17438 showOnKeyDown,
17439 showOnKeyPress = showOnKeyDown,
17440 blurActiveItemOnClick,
17441 setValueOnClick = true,
17442 moveOnKeyPress = true,
17443 autoComplete = "list",
17444 ...props
17445 }) {
17446 const context = useComboboxProviderContext();
17447 store = store || context;
17448 invariant(
17449 store,
17450 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
17451 );
17452 const ref = (0, import_react20.useRef)(null);
17453 const [valueUpdated, forceValueUpdate] = useForceUpdate();
17454 const canAutoSelectRef = (0, import_react20.useRef)(false);
17455 const composingRef = (0, import_react20.useRef)(false);
17456 const autoSelect = store.useState(
17457 (state) => state.virtualFocus && autoSelectProp
17458 );
17459 const inline4 = autoComplete === "inline" || autoComplete === "both";
17460 const [canInline, setCanInline] = (0, import_react20.useState)(inline4);
17461 useUpdateLayoutEffect(() => {
17462 if (!inline4) return;
17463 setCanInline(true);
17464 }, [inline4]);
17465 const storeValue = store.useState("value");
17466 const prevSelectedValueRef = (0, import_react20.useRef)(void 0);
17467 (0, import_react20.useEffect)(() => {
17468 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
17469 prevSelectedValueRef.current = prev.selectedValue;
17470 });
17471 }, []);
17472 const inlineActiveValue = store.useState((state) => {
17473 var _a;
17474 if (!inline4) return;
17475 if (!canInline) return;
17476 if (state.activeValue && Array.isArray(state.selectedValue)) {
17477 if (state.selectedValue.includes(state.activeValue)) return;
17478 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
17479 }
17480 return state.activeValue;
17481 });
17482 const items = store.useState("renderedItems");
17483 const open = store.useState("open");
17484 const contentElement = store.useState("contentElement");
17485 const value = (0, import_react20.useMemo)(() => {
17486 if (!inline4) return storeValue;
17487 if (!canInline) return storeValue;
17488 const firstItemAutoSelected = isFirstItemAutoSelected(
17489 items,
17490 inlineActiveValue,
17491 autoSelect
17492 );
17493 if (firstItemAutoSelected) {
17494 if (hasCompletionString(storeValue, inlineActiveValue)) {
17495 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
17496 return storeValue + slice;
17497 }
17498 return storeValue;
17499 }
17500 return inlineActiveValue || storeValue;
17501 }, [inline4, canInline, items, inlineActiveValue, autoSelect, storeValue]);
17502 (0, import_react20.useEffect)(() => {
17503 const element = ref.current;
17504 if (!element) return;
17505 const onCompositeItemMove = () => setCanInline(true);
17506 element.addEventListener("combobox-item-move", onCompositeItemMove);
17507 return () => {
17508 element.removeEventListener("combobox-item-move", onCompositeItemMove);
17509 };
17510 }, []);
17511 (0, import_react20.useEffect)(() => {
17512 if (!inline4) return;
17513 if (!canInline) return;
17514 if (!inlineActiveValue) return;
17515 const firstItemAutoSelected = isFirstItemAutoSelected(
17516 items,
17517 inlineActiveValue,
17518 autoSelect
17519 );
17520 if (!firstItemAutoSelected) return;
17521 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
17522 let cleanup = noop4;
17523 queueMicrotask(() => {
17524 const element = ref.current;
17525 if (!element) return;
17526 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
17527 const nextStart = storeValue.length;
17528 const nextEnd = inlineActiveValue.length;
17529 setSelectionRange(element, nextStart, nextEnd);
17530 cleanup = () => {
17531 if (!hasFocus(element)) return;
17532 const { start, end } = getTextboxSelection(element);
17533 if (start !== nextStart) return;
17534 if (end !== nextEnd) return;
17535 setSelectionRange(element, prevStart, prevEnd);
17536 };
17537 });
17538 return () => cleanup();
17539 }, [
17540 valueUpdated,
17541 inline4,
17542 canInline,
17543 inlineActiveValue,
17544 items,
17545 autoSelect,
17546 storeValue
17547 ]);
17548 const scrollingElementRef = (0, import_react20.useRef)(null);
17549 const getAutoSelectIdProp = useEvent(getAutoSelectId);
17550 const autoSelectIdRef = (0, import_react20.useRef)(null);
17551 (0, import_react20.useEffect)(() => {
17552 if (!open) return;
17553 if (!contentElement) return;
17554 const scrollingElement = getScrollingElement(contentElement);
17555 if (!scrollingElement) return;
17556 scrollingElementRef.current = scrollingElement;
17557 const onUserScroll = () => {
17558 canAutoSelectRef.current = false;
17559 };
17560 const onScroll = () => {
17561 if (!store) return;
17562 if (!canAutoSelectRef.current) return;
17563 const { activeId } = store.getState();
17564 if (activeId === null) return;
17565 if (activeId === autoSelectIdRef.current) return;
17566 canAutoSelectRef.current = false;
17567 };
17568 const options = { passive: true, capture: true };
17569 scrollingElement.addEventListener("wheel", onUserScroll, options);
17570 scrollingElement.addEventListener("touchmove", onUserScroll, options);
17571 scrollingElement.addEventListener("scroll", onScroll, options);
17572 return () => {
17573 scrollingElement.removeEventListener("wheel", onUserScroll, true);
17574 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
17575 scrollingElement.removeEventListener("scroll", onScroll, true);
17576 };
17577 }, [open, contentElement, store]);
17578 useSafeLayoutEffect(() => {
17579 if (!storeValue) return;
17580 if (composingRef.current) return;
17581 canAutoSelectRef.current = true;
17582 }, [storeValue]);
17583 useSafeLayoutEffect(() => {
17584 if (autoSelect !== "always" && open) return;
17585 canAutoSelectRef.current = open;
17586 }, [autoSelect, open]);
17587 const resetValueOnSelect = store.useState("resetValueOnSelect");
17588 useUpdateEffect(() => {
17589 var _a, _b;
17590 const canAutoSelect = canAutoSelectRef.current;
17591 if (!store) return;
17592 if (!open) return;
17593 if (!canAutoSelect && !resetValueOnSelect) return;
17594 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
17595 if (baseElement && !hasFocus(baseElement)) return;
17596 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
17597 const observer = new MutationObserver(forceValueUpdate);
17598 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
17599 return () => observer.disconnect();
17600 }
17601 if (autoSelect && canAutoSelect) {
17602 const userAutoSelectId = getAutoSelectIdProp(items);
17603 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
17604 autoSelectIdRef.current = autoSelectId;
17605 store.move(autoSelectId != null ? autoSelectId : null);
17606 } else {
17607 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
17608 if (element && "scrollIntoView" in element) {
17609 element.scrollIntoView({ block: "nearest", inline: "nearest" });
17610 }
17611 }
17612 return;
17613 }, [
17614 store,
17615 open,
17616 valueUpdated,
17617 storeValue,
17618 autoSelect,
17619 resetValueOnSelect,
17620 getAutoSelectIdProp,
17621 items
17622 ]);
17623 (0, import_react20.useEffect)(() => {
17624 if (!inline4) return;
17625 const combobox = ref.current;
17626 if (!combobox) return;
17627 const elements = [combobox, contentElement].filter(
17628 (value2) => !!value2
17629 );
17630 const onBlur2 = (event) => {
17631 if (elements.every((el) => isFocusEventOutside(event, el))) {
17632 store == null ? void 0 : store.setValue(value);
17633 }
17634 };
17635 for (const element of elements) {
17636 element.addEventListener("focusout", onBlur2);
17637 }
17638 return () => {
17639 for (const element of elements) {
17640 element.removeEventListener("focusout", onBlur2);
17641 }
17642 };
17643 }, [inline4, contentElement, store, value]);
17644 const canShow = (event) => {
17645 const currentTarget = event.currentTarget;
17646 return currentTarget.value.length >= showMinLength;
17647 };
17648 const onChangeProp = props.onChange;
17649 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
17650 const setValueOnChangeProp = useBooleanEvent(
17651 // If the combobox is combined with tags, the value will be set by the tag
17652 // input component.
17653 setValueOnChange != null ? setValueOnChange : !store.tag
17654 );
17655 const onChange = useEvent((event) => {
17656 onChangeProp == null ? void 0 : onChangeProp(event);
17657 if (event.defaultPrevented) return;
17658 if (!store) return;
17659 const currentTarget = event.currentTarget;
17660 const { value: value2, selectionStart, selectionEnd } = currentTarget;
17661 const nativeEvent = event.nativeEvent;
17662 canAutoSelectRef.current = true;
17663 if (isInputEvent(nativeEvent)) {
17664 if (nativeEvent.isComposing) {
17665 canAutoSelectRef.current = false;
17666 composingRef.current = true;
17667 }
17668 if (inline4) {
17669 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
17670 const caretAtEnd = selectionStart === value2.length;
17671 setCanInline(textInserted && caretAtEnd);
17672 }
17673 }
17674 if (setValueOnChangeProp(event)) {
17675 const isSameValue = value2 === store.getState().value;
17676 store.setValue(value2);
17677 queueMicrotask(() => {
17678 setSelectionRange(currentTarget, selectionStart, selectionEnd);
17679 });
17680 if (inline4 && autoSelect && isSameValue) {
17681 forceValueUpdate();
17682 }
17683 }
17684 if (showOnChangeProp(event)) {
17685 store.show();
17686 }
17687 if (!autoSelect || !canAutoSelectRef.current) {
17688 store.setActiveId(null);
17689 }
17690 });
17691 const onCompositionEndProp = props.onCompositionEnd;
17692 const onCompositionEnd = useEvent((event) => {
17693 canAutoSelectRef.current = true;
17694 composingRef.current = false;
17695 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
17696 if (event.defaultPrevented) return;
17697 if (!autoSelect) return;
17698 forceValueUpdate();
17699 });
17700 const onMouseDownProp = props.onMouseDown;
17701 const blurActiveItemOnClickProp = useBooleanEvent(
17702 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
17703 );
17704 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
17705 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
17706 const onMouseDown = useEvent((event) => {
17707 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
17708 if (event.defaultPrevented) return;
17709 if (event.button) return;
17710 if (event.ctrlKey) return;
17711 if (!store) return;
17712 if (blurActiveItemOnClickProp(event)) {
17713 store.setActiveId(null);
17714 }
17715 if (setValueOnClickProp(event)) {
17716 store.setValue(value);
17717 }
17718 if (showOnClickProp(event)) {
17719 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
17720 }
17721 });
17722 const onKeyDownProp = props.onKeyDown;
17723 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
17724 const onKeyDown = useEvent((event) => {
17725 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17726 if (!event.repeat) {
17727 canAutoSelectRef.current = false;
17728 }
17729 if (event.defaultPrevented) return;
17730 if (event.ctrlKey) return;
17731 if (event.altKey) return;
17732 if (event.shiftKey) return;
17733 if (event.metaKey) return;
17734 if (!store) return;
17735 const { open: open2 } = store.getState();
17736 if (open2) return;
17737 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
17738 if (showOnKeyPressProp(event)) {
17739 event.preventDefault();
17740 store.show();
17741 }
17742 }
17743 });
17744 const onBlurProp = props.onBlur;
17745 const onBlur = useEvent((event) => {
17746 canAutoSelectRef.current = false;
17747 onBlurProp == null ? void 0 : onBlurProp(event);
17748 if (event.defaultPrevented) return;
17749 });
17750 const id = useId4(props.id);
17751 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
17752 const isActiveItem = store.useState((state) => state.activeId === null);
17753 props = {
17754 id,
17755 role: "combobox",
17756 "aria-autocomplete": ariaAutoComplete,
17757 "aria-haspopup": getPopupRole(contentElement, "listbox"),
17758 "aria-expanded": open,
17759 "aria-controls": contentElement == null ? void 0 : contentElement.id,
17760 "data-active-item": isActiveItem || void 0,
17761 value,
17762 ...props,
17763 ref: useMergeRefs(ref, props.ref),
17764 onChange,
17765 onCompositionEnd,
17766 onMouseDown,
17767 onKeyDown,
17768 onBlur
17769 };
17770 props = useComposite({
17771 store,
17772 focusable: focusable2,
17773 ...props,
17774 // Enable inline autocomplete when the user moves from the combobox input
17775 // to an item.
17776 moveOnKeyPress: (event) => {
17777 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
17778 if (inline4) setCanInline(true);
17779 return true;
17780 }
17781 });
17782 props = usePopoverAnchor({ store, ...props });
17783 return { autoComplete: "off", ...props };
17784 }
17785 );
17786 var Combobox = forwardRef22(function Combobox2(props) {
17787 const htmlProps = useCombobox(props);
17788 return createElement3(TagName9, htmlProps);
17789 });
17790
17791 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
17792 var import_react21 = __toESM(require_react(), 1);
17793 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
17794 var TagName10 = "div";
17795 function isSelected(storeValue, itemValue) {
17796 if (itemValue == null) return;
17797 if (storeValue == null) return false;
17798 if (Array.isArray(storeValue)) {
17799 return storeValue.includes(itemValue);
17800 }
17801 return storeValue === itemValue;
17802 }
17803 function getItemRole(popupRole) {
17804 var _a;
17805 const itemRoleByPopupRole = {
17806 menu: "menuitem",
17807 listbox: "option",
17808 tree: "treeitem"
17809 };
17810 const key = popupRole;
17811 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
17812 }
17813 var useComboboxItem = createHook(
17814 function useComboboxItem2({
17815 store,
17816 value,
17817 hideOnClick,
17818 setValueOnClick,
17819 selectValueOnClick = true,
17820 resetValueOnSelect,
17821 focusOnHover = false,
17822 moveOnKeyPress = true,
17823 getItem: getItemProp,
17824 ...props
17825 }) {
17826 var _a;
17827 const context = useComboboxScopedContext();
17828 store = store || context;
17829 invariant(
17830 store,
17831 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
17832 );
17833 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
17834 resetValueOnSelectState: "resetValueOnSelect",
17835 multiSelectable(state) {
17836 return Array.isArray(state.selectedValue);
17837 },
17838 selected(state) {
17839 return isSelected(state.selectedValue, value);
17840 }
17841 });
17842 const getItem = (0, import_react21.useCallback)(
17843 (item) => {
17844 const nextItem = { ...item, value };
17845 if (getItemProp) {
17846 return getItemProp(nextItem);
17847 }
17848 return nextItem;
17849 },
17850 [value, getItemProp]
17851 );
17852 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
17853 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
17854 const onClickProp = props.onClick;
17855 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
17856 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
17857 const resetValueOnSelectProp = useBooleanEvent(
17858 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
17859 );
17860 const hideOnClickProp = useBooleanEvent(hideOnClick);
17861 const onClick = useEvent((event) => {
17862 onClickProp == null ? void 0 : onClickProp(event);
17863 if (event.defaultPrevented) return;
17864 if (isDownloading(event)) return;
17865 if (isOpeningInNewTab(event)) return;
17866 if (value != null) {
17867 if (selectValueOnClickProp(event)) {
17868 if (resetValueOnSelectProp(event)) {
17869 store == null ? void 0 : store.resetValue();
17870 }
17871 store == null ? void 0 : store.setSelectedValue((prevValue) => {
17872 if (!Array.isArray(prevValue)) return value;
17873 if (prevValue.includes(value)) {
17874 return prevValue.filter((v2) => v2 !== value);
17875 }
17876 return [...prevValue, value];
17877 });
17878 }
17879 if (setValueOnClickProp(event)) {
17880 store == null ? void 0 : store.setValue(value);
17881 }
17882 }
17883 if (hideOnClickProp(event)) {
17884 store == null ? void 0 : store.hide();
17885 }
17886 });
17887 const onKeyDownProp = props.onKeyDown;
17888 const onKeyDown = useEvent((event) => {
17889 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
17890 if (event.defaultPrevented) return;
17891 const baseElement = store == null ? void 0 : store.getState().baseElement;
17892 if (!baseElement) return;
17893 if (hasFocus(baseElement)) return;
17894 const printable = event.key.length === 1;
17895 if (printable || event.key === "Backspace" || event.key === "Delete") {
17896 queueMicrotask(() => baseElement.focus());
17897 if (isTextField(baseElement)) {
17898 store == null ? void 0 : store.setValue(baseElement.value);
17899 }
17900 }
17901 });
17902 if (multiSelectable && selected != null) {
17903 props = {
17904 "aria-selected": selected,
17905 ...props
17906 };
17907 }
17908 props = useWrapElement(
17909 props,
17910 (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
17911 [value, selected]
17912 );
17913 const popupRole = (0, import_react21.useContext)(ComboboxListRoleContext);
17914 props = {
17915 role: getItemRole(popupRole),
17916 children: value,
17917 ...props,
17918 onClick,
17919 onKeyDown
17920 };
17921 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
17922 props = useCompositeItem({
17923 store,
17924 ...props,
17925 getItem,
17926 // Dispatch a custom event on the combobox input when moving to an item
17927 // with the keyboard so the Combobox component can enable inline
17928 // autocompletion.
17929 moveOnKeyPress: (event) => {
17930 if (!moveOnKeyPressProp(event)) return false;
17931 const moveEvent = new Event("combobox-item-move");
17932 const baseElement = store == null ? void 0 : store.getState().baseElement;
17933 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
17934 return true;
17935 }
17936 });
17937 props = useCompositeHover({ store, focusOnHover, ...props });
17938 return props;
17939 }
17940 );
17941 var ComboboxItem = memo22(
17942 forwardRef22(function ComboboxItem2(props) {
17943 const htmlProps = useComboboxItem(props);
17944 return createElement3(TagName10, htmlProps);
17945 })
17946 );
17947
17948 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
17949 var import_react22 = __toESM(require_react(), 1);
17950 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
17951 var TagName11 = "span";
17952 function normalizeValue(value) {
17953 return normalizeString(value).toLowerCase();
17954 }
17955 function getOffsets(string, values) {
17956 const offsets = [];
17957 for (const value of values) {
17958 let pos = 0;
17959 const length = value.length;
17960 while (string.indexOf(value, pos) !== -1) {
17961 const index2 = string.indexOf(value, pos);
17962 if (index2 !== -1) {
17963 offsets.push([index2, length]);
17964 }
17965 pos = index2 + 1;
17966 }
17967 }
17968 return offsets;
17969 }
17970 function filterOverlappingOffsets(offsets) {
17971 return offsets.filter(([offset4, length], i2, arr) => {
17972 return !arr.some(
17973 ([o2, l2], j2) => j2 !== i2 && o2 <= offset4 && o2 + l2 >= offset4 + length
17974 );
17975 });
17976 }
17977 function sortOffsets(offsets) {
17978 return offsets.sort(([a2], [b2]) => a2 - b2);
17979 }
17980 function splitValue(itemValue, userValue) {
17981 if (!itemValue) return itemValue;
17982 if (!userValue) return itemValue;
17983 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
17984 const parts = [];
17985 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
17986 "span",
17987 {
17988 "data-autocomplete-value": autocomplete ? "" : void 0,
17989 "data-user-value": autocomplete ? void 0 : "",
17990 children: value
17991 },
17992 parts.length
17993 );
17994 const offsets = sortOffsets(
17995 filterOverlappingOffsets(
17996 // Convert userValues into a set to avoid duplicates
17997 getOffsets(normalizeValue(itemValue), new Set(userValues))
17998 )
17999 );
18000 if (!offsets.length) {
18001 parts.push(span(itemValue, true));
18002 return parts;
18003 }
18004 const [firstOffset] = offsets[0];
18005 const values = [
18006 itemValue.slice(0, firstOffset),
18007 ...offsets.flatMap(([offset4, length], i2) => {
18008 var _a;
18009 const value = itemValue.slice(offset4, offset4 + length);
18010 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
18011 const nextValue = itemValue.slice(offset4 + length, nextOffset);
18012 return [value, nextValue];
18013 })
18014 ];
18015 values.forEach((value, i2) => {
18016 if (!value) return;
18017 parts.push(span(value, i2 % 2 === 0));
18018 });
18019 return parts;
18020 }
18021 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
18022 const context = useComboboxScopedContext();
18023 store = store || context;
18024 const itemContext = (0, import_react22.useContext)(ComboboxItemValueContext);
18025 const itemValue = value != null ? value : itemContext;
18026 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
18027 const children = (0, import_react22.useMemo)(() => {
18028 if (!itemValue) return;
18029 if (!inputValue) return itemValue;
18030 return splitValue(itemValue, inputValue);
18031 }, [itemValue, inputValue]);
18032 props = {
18033 children,
18034 ...props
18035 };
18036 return removeUndefinedValues(props);
18037 });
18038 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
18039 const htmlProps = useComboboxItemValue(props);
18040 return createElement3(TagName11, htmlProps);
18041 });
18042
18043 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
18044 var TagName12 = "label";
18045 var useComboboxLabel = createHook(
18046 function useComboboxLabel2({ store, ...props }) {
18047 const context = useComboboxProviderContext();
18048 store = store || context;
18049 invariant(
18050 store,
18051 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
18052 );
18053 const comboboxId = store.useState((state) => {
18054 var _a;
18055 return (_a = state.baseElement) == null ? void 0 : _a.id;
18056 });
18057 props = {
18058 htmlFor: comboboxId,
18059 ...props
18060 };
18061 return removeUndefinedValues(props);
18062 }
18063 );
18064 var ComboboxLabel = memo22(
18065 forwardRef22(function ComboboxLabel2(props) {
18066 const htmlProps = useComboboxLabel(props);
18067 return createElement3(TagName12, htmlProps);
18068 })
18069 );
18070
18071 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
18072 var import_react23 = __toESM(require_react(), 1);
18073 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
18074 var TagName13 = "div";
18075 var useComboboxList = createHook(
18076 function useComboboxList2({ store, alwaysVisible, ...props }) {
18077 const scopedContext = useComboboxScopedContext(true);
18078 const context = useComboboxContext();
18079 store = store || context;
18080 const scopedContextSameStore = !!store && store === scopedContext;
18081 invariant(
18082 store,
18083 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
18084 );
18085 const ref = (0, import_react23.useRef)(null);
18086 const id = useId4(props.id);
18087 const mounted = store.useState("mounted");
18088 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
18089 const style = hidden ? { ...props.style, display: "none" } : props.style;
18090 const multiSelectable = store.useState(
18091 (state) => Array.isArray(state.selectedValue)
18092 );
18093 const role = useAttribute(ref, "role", props.role);
18094 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
18095 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
18096 const [hasListboxInside, setHasListboxInside] = (0, import_react23.useState)(false);
18097 const contentElement = store.useState("contentElement");
18098 useSafeLayoutEffect(() => {
18099 if (!mounted) return;
18100 const element = ref.current;
18101 if (!element) return;
18102 if (contentElement !== element) return;
18103 const callback = () => {
18104 setHasListboxInside(!!element.querySelector("[role='listbox']"));
18105 };
18106 const observer = new MutationObserver(callback);
18107 observer.observe(element, {
18108 subtree: true,
18109 childList: true,
18110 attributeFilter: ["role"]
18111 });
18112 callback();
18113 return () => observer.disconnect();
18114 }, [mounted, contentElement]);
18115 if (!hasListboxInside) {
18116 props = {
18117 role: "listbox",
18118 "aria-multiselectable": ariaMultiSelectable,
18119 ...props
18120 };
18121 }
18122 props = useWrapElement(
18123 props,
18124 (element) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
18125 [store, role]
18126 );
18127 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
18128 props = {
18129 id,
18130 hidden,
18131 ...props,
18132 ref: useMergeRefs(setContentElement, ref, props.ref),
18133 style
18134 };
18135 return removeUndefinedValues(props);
18136 }
18137 );
18138 var ComboboxList = forwardRef22(function ComboboxList2(props) {
18139 const htmlProps = useComboboxList(props);
18140 return createElement3(TagName13, htmlProps);
18141 });
18142
18143 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
18144 var import_react24 = __toESM(require_react(), 1);
18145 var TagValueContext = (0, import_react24.createContext)(null);
18146 var TagRemoveIdContext = (0, import_react24.createContext)(
18147 null
18148 );
18149 var ctx7 = createStoreContext(
18150 [CompositeContextProvider],
18151 [CompositeScopedContextProvider]
18152 );
18153 var useTagContext = ctx7.useContext;
18154 var useTagScopedContext = ctx7.useScopedContext;
18155 var useTagProviderContext = ctx7.useProviderContext;
18156 var TagContextProvider = ctx7.ContextProvider;
18157 var TagScopedContextProvider = ctx7.ScopedContextProvider;
18158
18159 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
18160 var isTouchSafari = isSafari2() && isTouchDevice();
18161 function createComboboxStore({
18162 tag,
18163 ...props
18164 } = {}) {
18165 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
18166 throwOnConflictingProps(props, store);
18167 const tagState = tag == null ? void 0 : tag.getState();
18168 const syncState = store == null ? void 0 : store.getState();
18169 const activeId = defaultValue(
18170 props.activeId,
18171 syncState == null ? void 0 : syncState.activeId,
18172 props.defaultActiveId,
18173 null
18174 );
18175 const composite = createCompositeStore({
18176 ...props,
18177 activeId,
18178 includesBaseElement: defaultValue(
18179 props.includesBaseElement,
18180 syncState == null ? void 0 : syncState.includesBaseElement,
18181 true
18182 ),
18183 orientation: defaultValue(
18184 props.orientation,
18185 syncState == null ? void 0 : syncState.orientation,
18186 "vertical"
18187 ),
18188 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
18189 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
18190 virtualFocus: defaultValue(
18191 props.virtualFocus,
18192 syncState == null ? void 0 : syncState.virtualFocus,
18193 true
18194 )
18195 });
18196 const popover = createPopoverStore({
18197 ...props,
18198 placement: defaultValue(
18199 props.placement,
18200 syncState == null ? void 0 : syncState.placement,
18201 "bottom-start"
18202 )
18203 });
18204 const value = defaultValue(
18205 props.value,
18206 syncState == null ? void 0 : syncState.value,
18207 props.defaultValue,
18208 ""
18209 );
18210 const selectedValue = defaultValue(
18211 props.selectedValue,
18212 syncState == null ? void 0 : syncState.selectedValue,
18213 tagState == null ? void 0 : tagState.values,
18214 props.defaultSelectedValue,
18215 ""
18216 );
18217 const multiSelectable = Array.isArray(selectedValue);
18218 const initialState = {
18219 ...composite.getState(),
18220 ...popover.getState(),
18221 value,
18222 selectedValue,
18223 resetValueOnSelect: defaultValue(
18224 props.resetValueOnSelect,
18225 syncState == null ? void 0 : syncState.resetValueOnSelect,
18226 multiSelectable
18227 ),
18228 resetValueOnHide: defaultValue(
18229 props.resetValueOnHide,
18230 syncState == null ? void 0 : syncState.resetValueOnHide,
18231 multiSelectable && !tag
18232 ),
18233 activeValue: syncState == null ? void 0 : syncState.activeValue
18234 };
18235 const combobox = createStore(initialState, composite, popover, store);
18236 if (isTouchSafari) {
18237 setup(
18238 combobox,
18239 () => sync(combobox, ["virtualFocus"], () => {
18240 combobox.setState("virtualFocus", false);
18241 })
18242 );
18243 }
18244 setup(combobox, () => {
18245 if (!tag) return;
18246 return chain(
18247 sync(combobox, ["selectedValue"], (state) => {
18248 if (!Array.isArray(state.selectedValue)) return;
18249 tag.setValues(state.selectedValue);
18250 }),
18251 sync(tag, ["values"], (state) => {
18252 combobox.setState("selectedValue", state.values);
18253 })
18254 );
18255 });
18256 setup(
18257 combobox,
18258 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
18259 if (!state.resetValueOnHide) return;
18260 if (state.mounted) return;
18261 combobox.setState("value", value);
18262 })
18263 );
18264 setup(
18265 combobox,
18266 () => sync(combobox, ["open"], (state) => {
18267 if (state.open) return;
18268 combobox.setState("activeId", activeId);
18269 combobox.setState("moves", 0);
18270 })
18271 );
18272 setup(
18273 combobox,
18274 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
18275 if (state.moves === prevState.moves) {
18276 combobox.setState("activeValue", void 0);
18277 }
18278 })
18279 );
18280 setup(
18281 combobox,
18282 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
18283 if (state.moves === prev.moves) return;
18284 const { activeId: activeId2 } = combobox.getState();
18285 const activeItem = composite.item(activeId2);
18286 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
18287 })
18288 );
18289 return {
18290 ...popover,
18291 ...composite,
18292 ...combobox,
18293 tag,
18294 setValue: (value2) => combobox.setState("value", value2),
18295 resetValue: () => combobox.setState("value", initialState.value),
18296 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
18297 };
18298 }
18299
18300 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
18301 function useComboboxStoreOptions(props) {
18302 const tag = useTagContext();
18303 props = {
18304 ...props,
18305 tag: props.tag !== void 0 ? props.tag : tag
18306 };
18307 return useCompositeStoreOptions(props);
18308 }
18309 function useComboboxStoreProps(store, update2, props) {
18310 useUpdateEffect(update2, [props.tag]);
18311 useStoreProps(store, props, "value", "setValue");
18312 useStoreProps(store, props, "selectedValue", "setSelectedValue");
18313 useStoreProps(store, props, "resetValueOnHide");
18314 useStoreProps(store, props, "resetValueOnSelect");
18315 return Object.assign(
18316 useCompositeStoreProps(
18317 usePopoverStoreProps(store, update2, props),
18318 update2,
18319 props
18320 ),
18321 { tag: props.tag }
18322 );
18323 }
18324 function useComboboxStore(props = {}) {
18325 props = useComboboxStoreOptions(props);
18326 const [store, update2] = useStore2(createComboboxStore, props);
18327 return useComboboxStoreProps(store, update2, props);
18328 }
18329
18330 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
18331 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
18332 function ComboboxProvider(props = {}) {
18333 const store = useComboboxStore(props);
18334 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxContextProvider, { value: store, children: props.children });
18335 }
18336
18337 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18338 var import_remove_accents = __toESM(require_remove_accents(), 1);
18339 var import_compose7 = __toESM(require_compose(), 1);
18340 var import_i18n22 = __toESM(require_i18n(), 1);
18341 var import_element40 = __toESM(require_element(), 1);
18342 var import_components18 = __toESM(require_components(), 1);
18343
18344 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
18345 var EMPTY_ARRAY3 = [];
18346 var getCurrentValue = (filterDefinition, currentFilter) => {
18347 if (filterDefinition.singleSelection) {
18348 return currentFilter?.value;
18349 }
18350 if (Array.isArray(currentFilter?.value)) {
18351 return currentFilter.value;
18352 }
18353 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
18354 return [currentFilter.value];
18355 }
18356 return EMPTY_ARRAY3;
18357 };
18358
18359 // packages/dataviews/build-module/hooks/use-elements.mjs
18360 var import_element39 = __toESM(require_element(), 1);
18361 var EMPTY_ARRAY4 = [];
18362 function useElements({
18363 elements,
18364 getElements
18365 }) {
18366 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
18367 const [records, setRecords] = (0, import_element39.useState)(staticElements);
18368 const [isLoading, setIsLoading] = (0, import_element39.useState)(false);
18369 (0, import_element39.useEffect)(() => {
18370 if (!getElements) {
18371 setRecords(staticElements);
18372 return;
18373 }
18374 let cancelled = false;
18375 setIsLoading(true);
18376 getElements().then((fetchedElements) => {
18377 if (!cancelled) {
18378 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
18379 setRecords(dynamicElements);
18380 }
18381 }).catch(() => {
18382 if (!cancelled) {
18383 setRecords(staticElements);
18384 }
18385 }).finally(() => {
18386 if (!cancelled) {
18387 setIsLoading(false);
18388 }
18389 });
18390 return () => {
18391 cancelled = true;
18392 };
18393 }, [getElements, staticElements]);
18394 return {
18395 elements: records,
18396 isLoading
18397 };
18398 }
18399
18400 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
18401 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
18402 function normalizeSearchInput(input = "") {
18403 return (0, import_remove_accents.default)(input.trim().toLowerCase());
18404 }
18405 var getNewValue = (filterDefinition, currentFilter, value) => {
18406 if (filterDefinition.singleSelection) {
18407 return value;
18408 }
18409 if (Array.isArray(currentFilter?.value)) {
18410 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
18411 }
18412 return [value];
18413 };
18414 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
18415 return `${prefix}-${filterElementValue}`;
18416 }
18417 var MultiSelectionOption = ({ selected }) => {
18418 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18419 "span",
18420 {
18421 className: clsx_default(
18422 "dataviews-filters__search-widget-listitem-multi-selection",
18423 { "is-selected": selected }
18424 ),
18425 children: selected && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Icon, { icon: check_default })
18426 }
18427 );
18428 };
18429 var SingleSelectionOption = ({ selected }) => {
18430 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18431 "span",
18432 {
18433 className: clsx_default(
18434 "dataviews-filters__search-widget-listitem-single-selection",
18435 { "is-selected": selected }
18436 )
18437 }
18438 );
18439 };
18440 function ListBox({ view, filter, onChangeView }) {
18441 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
18442 const [activeCompositeId, setActiveCompositeId] = (0, import_element40.useState)(
18443 // When there are one or less operators, the first item is set as active
18444 // (by setting the initial `activeId` to `undefined`).
18445 // With 2 or more operators, the focus is moved on the operators control
18446 // (by setting the initial `activeId` to `null`), meaning that there won't
18447 // be an active item initially. Focus is then managed via the
18448 // `onFocusVisible` callback.
18449 filter.operators?.length === 1 ? void 0 : null
18450 );
18451 const currentFilter = view.filters?.find(
18452 (f2) => f2.field === filter.field
18453 );
18454 const currentValue = getCurrentValue(filter, currentFilter);
18455 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18456 import_components18.Composite,
18457 {
18458 virtualFocus: true,
18459 focusLoop: true,
18460 activeId: activeCompositeId,
18461 setActiveId: setActiveCompositeId,
18462 role: "listbox",
18463 className: "dataviews-filters__search-widget-listbox",
18464 "aria-label": (0, import_i18n22.sprintf)(
18465 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
18466 (0, import_i18n22.__)("List of: %1$s"),
18467 filter.name
18468 ),
18469 onFocusVisible: () => {
18470 if (!activeCompositeId && filter.elements.length) {
18471 setActiveCompositeId(
18472 generateFilterElementCompositeItemId(
18473 baseId,
18474 filter.elements[0].value
18475 )
18476 );
18477 }
18478 },
18479 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Composite.Typeahead, {}),
18480 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18481 import_components18.Composite.Hover,
18482 {
18483 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18484 import_components18.Composite.Item,
18485 {
18486 id: generateFilterElementCompositeItemId(
18487 baseId,
18488 element.value
18489 ),
18490 render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18491 "div",
18492 {
18493 "aria-label": element.label,
18494 role: "option",
18495 className: "dataviews-filters__search-widget-listitem"
18496 }
18497 ),
18498 onClick: () => {
18499 const newFilters = currentFilter ? [
18500 ...(view.filters ?? []).map(
18501 (_filter) => {
18502 if (_filter.field === filter.field) {
18503 return {
18504 ..._filter,
18505 operator: currentFilter.operator || filter.operators[0],
18506 value: getNewValue(
18507 filter,
18508 currentFilter,
18509 element.value
18510 )
18511 };
18512 }
18513 return _filter;
18514 }
18515 )
18516 ] : [
18517 ...view.filters ?? [],
18518 {
18519 field: filter.field,
18520 operator: filter.operators[0],
18521 value: getNewValue(
18522 filter,
18523 currentFilter,
18524 element.value
18525 )
18526 }
18527 ];
18528 onChangeView({
18529 ...view,
18530 page: 1,
18531 filters: newFilters
18532 });
18533 }
18534 }
18535 ),
18536 children: [
18537 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18538 SingleSelectionOption,
18539 {
18540 selected: currentValue === element.value
18541 }
18542 ),
18543 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18544 MultiSelectionOption,
18545 {
18546 selected: currentValue.includes(element.value)
18547 }
18548 ),
18549 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18550 "span",
18551 {
18552 className: "dataviews-filters__search-widget-listitem-value",
18553 title: element.label,
18554 children: element.label
18555 }
18556 )
18557 ]
18558 },
18559 element.value
18560 ))
18561 }
18562 );
18563 }
18564 function ComboboxList22({ view, filter, onChangeView }) {
18565 const [searchValue, setSearchValue] = (0, import_element40.useState)("");
18566 const deferredSearchValue = (0, import_element40.useDeferredValue)(searchValue);
18567 const currentFilter = view.filters?.find(
18568 (_filter) => _filter.field === filter.field
18569 );
18570 const currentValue = getCurrentValue(filter, currentFilter);
18571 const matches = (0, import_element40.useMemo)(() => {
18572 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
18573 return filter.elements.filter(
18574 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
18575 );
18576 }, [filter.elements, deferredSearchValue]);
18577 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18578 ComboboxProvider,
18579 {
18580 selectedValue: currentValue,
18581 setSelectedValue: (value) => {
18582 const newFilters = currentFilter ? [
18583 ...(view.filters ?? []).map((_filter) => {
18584 if (_filter.field === filter.field) {
18585 return {
18586 ..._filter,
18587 operator: currentFilter.operator || filter.operators[0],
18588 value
18589 };
18590 }
18591 return _filter;
18592 })
18593 ] : [
18594 ...view.filters ?? [],
18595 {
18596 field: filter.field,
18597 operator: filter.operators[0],
18598 value
18599 }
18600 ];
18601 onChangeView({
18602 ...view,
18603 page: 1,
18604 filters: newFilters
18605 });
18606 },
18607 setValue: setSearchValue,
18608 children: [
18609 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
18610 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(ComboboxLabel, {}), children: (0, import_i18n22.__)("Search items") }),
18611 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18612 Combobox,
18613 {
18614 autoSelect: "always",
18615 placeholder: (0, import_i18n22.__)("Search"),
18616 className: "dataviews-filters__search-widget-filter-combobox__input"
18617 }
18618 ),
18619 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Icon, { icon: search_default }) })
18620 ] }),
18621 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18622 ComboboxList,
18623 {
18624 className: "dataviews-filters__search-widget-filter-combobox-list",
18625 alwaysVisible: true,
18626 children: [
18627 matches.map((element) => {
18628 return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18629 ComboboxItem,
18630 {
18631 resetValueOnSelect: false,
18632 value: element.value,
18633 className: "dataviews-filters__search-widget-listitem",
18634 hideOnClick: false,
18635 setValueOnClick: false,
18636 focusOnHover: true,
18637 children: [
18638 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18639 SingleSelectionOption,
18640 {
18641 selected: currentValue === element.value
18642 }
18643 ),
18644 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18645 MultiSelectionOption,
18646 {
18647 selected: currentValue.includes(
18648 element.value
18649 )
18650 }
18651 ),
18652 /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
18653 "span",
18654 {
18655 className: "dataviews-filters__search-widget-listitem-value",
18656 title: element.label,
18657 children: [
18658 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
18659 ComboboxItemValue,
18660 {
18661 className: "dataviews-filters__search-widget-filter-combobox-item-value",
18662 value: element.label
18663 }
18664 ),
18665 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
18666 ]
18667 }
18668 )
18669 ]
18670 },
18671 element.value
18672 );
18673 }),
18674 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("p", { children: (0, import_i18n22.__)("No results found") })
18675 ]
18676 }
18677 )
18678 ]
18679 }
18680 );
18681 }
18682 function SearchWidget(props) {
18683 const { elements, isLoading } = useElements({
18684 elements: props.filter.elements,
18685 getElements: props.filter.getElements
18686 });
18687 if (isLoading) {
18688 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components18.Spinner, {}) });
18689 }
18690 if (elements.length === 0) {
18691 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n22.__)("No elements found") });
18692 }
18693 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
18694 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
18695 }
18696
18697 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
18698 var import_es6 = __toESM(require_es6(), 1);
18699 var import_compose8 = __toESM(require_compose(), 1);
18700 var import_element41 = __toESM(require_element(), 1);
18701 var import_components19 = __toESM(require_components(), 1);
18702 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
18703 function InputWidget({
18704 filter,
18705 view,
18706 onChangeView,
18707 fields
18708 }) {
18709 const currentFilter = view.filters?.find(
18710 (f2) => f2.field === filter.field
18711 );
18712 const currentValue = getCurrentValue(filter, currentFilter);
18713 const field = (0, import_element41.useMemo)(() => {
18714 const currentField = fields.find((f2) => f2.id === filter.field);
18715 if (currentField) {
18716 return {
18717 ...currentField,
18718 // Deactivate validation for filters.
18719 isValid: {},
18720 // Filter controls are always enabled.
18721 isDisabled: () => false,
18722 // Filter controls are always visible.
18723 isVisible: () => true,
18724 // Configure getValue/setValue as if Item was a plain object.
18725 getValue: ({ item }) => item[currentField.id],
18726 setValue: ({ value }) => ({
18727 [currentField.id]: value
18728 })
18729 };
18730 }
18731 return currentField;
18732 }, [fields, filter.field]);
18733 const data = (0, import_element41.useMemo)(() => {
18734 return (view.filters ?? []).reduce(
18735 (acc, activeFilter) => {
18736 acc[activeFilter.field] = activeFilter.value;
18737 return acc;
18738 },
18739 {}
18740 );
18741 }, [view.filters]);
18742 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
18743 if (!field || !currentFilter) {
18744 return;
18745 }
18746 const nextValue = field.getValue({ item: updatedData });
18747 if ((0, import_es6.default)(nextValue, currentValue)) {
18748 return;
18749 }
18750 onChangeView({
18751 ...view,
18752 filters: (view.filters ?? []).map(
18753 (_filter) => _filter.field === filter.field ? {
18754 ..._filter,
18755 operator: currentFilter.operator || filter.operators[0],
18756 // Consider empty strings as undefined:
18757 //
18758 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
18759 // - empty string as value means "search empty string": returns only the records that have an empty string as value
18760 //
18761 // In practice, this means the filter will not be able to find an empty string as the value.
18762 value: nextValue === "" ? void 0 : nextValue
18763 } : _filter
18764 )
18765 });
18766 });
18767 if (!field || !field.Edit || !currentFilter) {
18768 return null;
18769 }
18770 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18771 import_components19.Flex,
18772 {
18773 className: "dataviews-filters__user-input-widget",
18774 gap: 2.5,
18775 direction: "column",
18776 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
18777 field.Edit,
18778 {
18779 hideLabelFromVision: true,
18780 data,
18781 field,
18782 operator: currentFilter.operator,
18783 onChange: handleChange
18784 }
18785 )
18786 }
18787 );
18788 }
18789
18790 // node_modules/date-fns/constants.js
18791 var daysInYear = 365.2425;
18792 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
18793 var minTime = -maxTime;
18794 var millisecondsInWeek = 6048e5;
18795 var millisecondsInDay = 864e5;
18796 var secondsInHour = 3600;
18797 var secondsInDay = secondsInHour * 24;
18798 var secondsInWeek = secondsInDay * 7;
18799 var secondsInYear = secondsInDay * daysInYear;
18800 var secondsInMonth = secondsInYear / 12;
18801 var secondsInQuarter = secondsInMonth * 3;
18802 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
18803
18804 // node_modules/date-fns/constructFrom.js
18805 function constructFrom(date, value) {
18806 if (typeof date === "function") return date(value);
18807 if (date && typeof date === "object" && constructFromSymbol in date)
18808 return date[constructFromSymbol](value);
18809 if (date instanceof Date) return new date.constructor(value);
18810 return new Date(value);
18811 }
18812
18813 // node_modules/date-fns/toDate.js
18814 function toDate(argument, context) {
18815 return constructFrom(context || argument, argument);
18816 }
18817
18818 // node_modules/date-fns/addDays.js
18819 function addDays(date, amount, options) {
18820 const _date = toDate(date, options?.in);
18821 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
18822 if (!amount) return _date;
18823 _date.setDate(_date.getDate() + amount);
18824 return _date;
18825 }
18826
18827 // node_modules/date-fns/addMonths.js
18828 function addMonths(date, amount, options) {
18829 const _date = toDate(date, options?.in);
18830 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
18831 if (!amount) {
18832 return _date;
18833 }
18834 const dayOfMonth = _date.getDate();
18835 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
18836 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
18837 const daysInMonth = endOfDesiredMonth.getDate();
18838 if (dayOfMonth >= daysInMonth) {
18839 return endOfDesiredMonth;
18840 } else {
18841 _date.setFullYear(
18842 endOfDesiredMonth.getFullYear(),
18843 endOfDesiredMonth.getMonth(),
18844 dayOfMonth
18845 );
18846 return _date;
18847 }
18848 }
18849
18850 // node_modules/date-fns/_lib/defaultOptions.js
18851 var defaultOptions = {};
18852 function getDefaultOptions() {
18853 return defaultOptions;
18854 }
18855
18856 // node_modules/date-fns/startOfWeek.js
18857 function startOfWeek(date, options) {
18858 const defaultOptions2 = getDefaultOptions();
18859 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
18860 const _date = toDate(date, options?.in);
18861 const day = _date.getDay();
18862 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
18863 _date.setDate(_date.getDate() - diff);
18864 _date.setHours(0, 0, 0, 0);
18865 return _date;
18866 }
18867
18868 // node_modules/date-fns/startOfISOWeek.js
18869 function startOfISOWeek(date, options) {
18870 return startOfWeek(date, { ...options, weekStartsOn: 1 });
18871 }
18872
18873 // node_modules/date-fns/getISOWeekYear.js
18874 function getISOWeekYear(date, options) {
18875 const _date = toDate(date, options?.in);
18876 const year = _date.getFullYear();
18877 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
18878 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
18879 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
18880 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
18881 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
18882 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
18883 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
18884 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
18885 if (_date.getTime() >= startOfNextYear.getTime()) {
18886 return year + 1;
18887 } else if (_date.getTime() >= startOfThisYear.getTime()) {
18888 return year;
18889 } else {
18890 return year - 1;
18891 }
18892 }
18893
18894 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
18895 function getTimezoneOffsetInMilliseconds(date) {
18896 const _date = toDate(date);
18897 const utcDate = new Date(
18898 Date.UTC(
18899 _date.getFullYear(),
18900 _date.getMonth(),
18901 _date.getDate(),
18902 _date.getHours(),
18903 _date.getMinutes(),
18904 _date.getSeconds(),
18905 _date.getMilliseconds()
18906 )
18907 );
18908 utcDate.setUTCFullYear(_date.getFullYear());
18909 return +date - +utcDate;
18910 }
18911
18912 // node_modules/date-fns/_lib/normalizeDates.js
18913 function normalizeDates(context, ...dates) {
18914 const normalize = constructFrom.bind(
18915 null,
18916 context || dates.find((date) => typeof date === "object")
18917 );
18918 return dates.map(normalize);
18919 }
18920
18921 // node_modules/date-fns/startOfDay.js
18922 function startOfDay(date, options) {
18923 const _date = toDate(date, options?.in);
18924 _date.setHours(0, 0, 0, 0);
18925 return _date;
18926 }
18927
18928 // node_modules/date-fns/differenceInCalendarDays.js
18929 function differenceInCalendarDays(laterDate, earlierDate, options) {
18930 const [laterDate_, earlierDate_] = normalizeDates(
18931 options?.in,
18932 laterDate,
18933 earlierDate
18934 );
18935 const laterStartOfDay = startOfDay(laterDate_);
18936 const earlierStartOfDay = startOfDay(earlierDate_);
18937 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
18938 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
18939 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
18940 }
18941
18942 // node_modules/date-fns/startOfISOWeekYear.js
18943 function startOfISOWeekYear(date, options) {
18944 const year = getISOWeekYear(date, options);
18945 const fourthOfJanuary = constructFrom(options?.in || date, 0);
18946 fourthOfJanuary.setFullYear(year, 0, 4);
18947 fourthOfJanuary.setHours(0, 0, 0, 0);
18948 return startOfISOWeek(fourthOfJanuary);
18949 }
18950
18951 // node_modules/date-fns/addWeeks.js
18952 function addWeeks(date, amount, options) {
18953 return addDays(date, amount * 7, options);
18954 }
18955
18956 // node_modules/date-fns/addYears.js
18957 function addYears(date, amount, options) {
18958 return addMonths(date, amount * 12, options);
18959 }
18960
18961 // node_modules/date-fns/isDate.js
18962 function isDate(value) {
18963 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
18964 }
18965
18966 // node_modules/date-fns/isValid.js
18967 function isValid(date) {
18968 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
18969 }
18970
18971 // node_modules/date-fns/startOfMonth.js
18972 function startOfMonth(date, options) {
18973 const _date = toDate(date, options?.in);
18974 _date.setDate(1);
18975 _date.setHours(0, 0, 0, 0);
18976 return _date;
18977 }
18978
18979 // node_modules/date-fns/startOfYear.js
18980 function startOfYear(date, options) {
18981 const date_ = toDate(date, options?.in);
18982 date_.setFullYear(date_.getFullYear(), 0, 1);
18983 date_.setHours(0, 0, 0, 0);
18984 return date_;
18985 }
18986
18987 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
18988 var formatDistanceLocale = {
18989 lessThanXSeconds: {
18990 one: "less than a second",
18991 other: "less than {{count}} seconds"
18992 },
18993 xSeconds: {
18994 one: "1 second",
18995 other: "{{count}} seconds"
18996 },
18997 halfAMinute: "half a minute",
18998 lessThanXMinutes: {
18999 one: "less than a minute",
19000 other: "less than {{count}} minutes"
19001 },
19002 xMinutes: {
19003 one: "1 minute",
19004 other: "{{count}} minutes"
19005 },
19006 aboutXHours: {
19007 one: "about 1 hour",
19008 other: "about {{count}} hours"
19009 },
19010 xHours: {
19011 one: "1 hour",
19012 other: "{{count}} hours"
19013 },
19014 xDays: {
19015 one: "1 day",
19016 other: "{{count}} days"
19017 },
19018 aboutXWeeks: {
19019 one: "about 1 week",
19020 other: "about {{count}} weeks"
19021 },
19022 xWeeks: {
19023 one: "1 week",
19024 other: "{{count}} weeks"
19025 },
19026 aboutXMonths: {
19027 one: "about 1 month",
19028 other: "about {{count}} months"
19029 },
19030 xMonths: {
19031 one: "1 month",
19032 other: "{{count}} months"
19033 },
19034 aboutXYears: {
19035 one: "about 1 year",
19036 other: "about {{count}} years"
19037 },
19038 xYears: {
19039 one: "1 year",
19040 other: "{{count}} years"
19041 },
19042 overXYears: {
19043 one: "over 1 year",
19044 other: "over {{count}} years"
19045 },
19046 almostXYears: {
19047 one: "almost 1 year",
19048 other: "almost {{count}} years"
19049 }
19050 };
19051 var formatDistance = (token, count, options) => {
19052 let result;
19053 const tokenValue = formatDistanceLocale[token];
19054 if (typeof tokenValue === "string") {
19055 result = tokenValue;
19056 } else if (count === 1) {
19057 result = tokenValue.one;
19058 } else {
19059 result = tokenValue.other.replace("{{count}}", count.toString());
19060 }
19061 if (options?.addSuffix) {
19062 if (options.comparison && options.comparison > 0) {
19063 return "in " + result;
19064 } else {
19065 return result + " ago";
19066 }
19067 }
19068 return result;
19069 };
19070
19071 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
19072 function buildFormatLongFn(args) {
19073 return (options = {}) => {
19074 const width = options.width ? String(options.width) : args.defaultWidth;
19075 const format6 = args.formats[width] || args.formats[args.defaultWidth];
19076 return format6;
19077 };
19078 }
19079
19080 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
19081 var dateFormats = {
19082 full: "EEEE, MMMM do, y",
19083 long: "MMMM do, y",
19084 medium: "MMM d, y",
19085 short: "MM/dd/yyyy"
19086 };
19087 var timeFormats = {
19088 full: "h:mm:ss a zzzz",
19089 long: "h:mm:ss a z",
19090 medium: "h:mm:ss a",
19091 short: "h:mm a"
19092 };
19093 var dateTimeFormats = {
19094 full: "{{date}} 'at' {{time}}",
19095 long: "{{date}} 'at' {{time}}",
19096 medium: "{{date}}, {{time}}",
19097 short: "{{date}}, {{time}}"
19098 };
19099 var formatLong = {
19100 date: buildFormatLongFn({
19101 formats: dateFormats,
19102 defaultWidth: "full"
19103 }),
19104 time: buildFormatLongFn({
19105 formats: timeFormats,
19106 defaultWidth: "full"
19107 }),
19108 dateTime: buildFormatLongFn({
19109 formats: dateTimeFormats,
19110 defaultWidth: "full"
19111 })
19112 };
19113
19114 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
19115 var formatRelativeLocale = {
19116 lastWeek: "'last' eeee 'at' p",
19117 yesterday: "'yesterday at' p",
19118 today: "'today at' p",
19119 tomorrow: "'tomorrow at' p",
19120 nextWeek: "eeee 'at' p",
19121 other: "P"
19122 };
19123 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
19124
19125 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
19126 function buildLocalizeFn(args) {
19127 return (value, options) => {
19128 const context = options?.context ? String(options.context) : "standalone";
19129 let valuesArray;
19130 if (context === "formatting" && args.formattingValues) {
19131 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
19132 const width = options?.width ? String(options.width) : defaultWidth;
19133 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
19134 } else {
19135 const defaultWidth = args.defaultWidth;
19136 const width = options?.width ? String(options.width) : args.defaultWidth;
19137 valuesArray = args.values[width] || args.values[defaultWidth];
19138 }
19139 const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
19140 return valuesArray[index2];
19141 };
19142 }
19143
19144 // node_modules/date-fns/locale/en-US/_lib/localize.js
19145 var eraValues = {
19146 narrow: ["B", "A"],
19147 abbreviated: ["BC", "AD"],
19148 wide: ["Before Christ", "Anno Domini"]
19149 };
19150 var quarterValues = {
19151 narrow: ["1", "2", "3", "4"],
19152 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
19153 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
19154 };
19155 var monthValues = {
19156 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
19157 abbreviated: [
19158 "Jan",
19159 "Feb",
19160 "Mar",
19161 "Apr",
19162 "May",
19163 "Jun",
19164 "Jul",
19165 "Aug",
19166 "Sep",
19167 "Oct",
19168 "Nov",
19169 "Dec"
19170 ],
19171 wide: [
19172 "January",
19173 "February",
19174 "March",
19175 "April",
19176 "May",
19177 "June",
19178 "July",
19179 "August",
19180 "September",
19181 "October",
19182 "November",
19183 "December"
19184 ]
19185 };
19186 var dayValues = {
19187 narrow: ["S", "M", "T", "W", "T", "F", "S"],
19188 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
19189 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
19190 wide: [
19191 "Sunday",
19192 "Monday",
19193 "Tuesday",
19194 "Wednesday",
19195 "Thursday",
19196 "Friday",
19197 "Saturday"
19198 ]
19199 };
19200 var dayPeriodValues = {
19201 narrow: {
19202 am: "a",
19203 pm: "p",
19204 midnight: "mi",
19205 noon: "n",
19206 morning: "morning",
19207 afternoon: "afternoon",
19208 evening: "evening",
19209 night: "night"
19210 },
19211 abbreviated: {
19212 am: "AM",
19213 pm: "PM",
19214 midnight: "midnight",
19215 noon: "noon",
19216 morning: "morning",
19217 afternoon: "afternoon",
19218 evening: "evening",
19219 night: "night"
19220 },
19221 wide: {
19222 am: "a.m.",
19223 pm: "p.m.",
19224 midnight: "midnight",
19225 noon: "noon",
19226 morning: "morning",
19227 afternoon: "afternoon",
19228 evening: "evening",
19229 night: "night"
19230 }
19231 };
19232 var formattingDayPeriodValues = {
19233 narrow: {
19234 am: "a",
19235 pm: "p",
19236 midnight: "mi",
19237 noon: "n",
19238 morning: "in the morning",
19239 afternoon: "in the afternoon",
19240 evening: "in the evening",
19241 night: "at night"
19242 },
19243 abbreviated: {
19244 am: "AM",
19245 pm: "PM",
19246 midnight: "midnight",
19247 noon: "noon",
19248 morning: "in the morning",
19249 afternoon: "in the afternoon",
19250 evening: "in the evening",
19251 night: "at night"
19252 },
19253 wide: {
19254 am: "a.m.",
19255 pm: "p.m.",
19256 midnight: "midnight",
19257 noon: "noon",
19258 morning: "in the morning",
19259 afternoon: "in the afternoon",
19260 evening: "in the evening",
19261 night: "at night"
19262 }
19263 };
19264 var ordinalNumber = (dirtyNumber, _options) => {
19265 const number = Number(dirtyNumber);
19266 const rem100 = number % 100;
19267 if (rem100 > 20 || rem100 < 10) {
19268 switch (rem100 % 10) {
19269 case 1:
19270 return number + "st";
19271 case 2:
19272 return number + "nd";
19273 case 3:
19274 return number + "rd";
19275 }
19276 }
19277 return number + "th";
19278 };
19279 var localize = {
19280 ordinalNumber,
19281 era: buildLocalizeFn({
19282 values: eraValues,
19283 defaultWidth: "wide"
19284 }),
19285 quarter: buildLocalizeFn({
19286 values: quarterValues,
19287 defaultWidth: "wide",
19288 argumentCallback: (quarter) => quarter - 1
19289 }),
19290 month: buildLocalizeFn({
19291 values: monthValues,
19292 defaultWidth: "wide"
19293 }),
19294 day: buildLocalizeFn({
19295 values: dayValues,
19296 defaultWidth: "wide"
19297 }),
19298 dayPeriod: buildLocalizeFn({
19299 values: dayPeriodValues,
19300 defaultWidth: "wide",
19301 formattingValues: formattingDayPeriodValues,
19302 defaultFormattingWidth: "wide"
19303 })
19304 };
19305
19306 // node_modules/date-fns/locale/_lib/buildMatchFn.js
19307 function buildMatchFn(args) {
19308 return (string, options = {}) => {
19309 const width = options.width;
19310 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
19311 const matchResult = string.match(matchPattern);
19312 if (!matchResult) {
19313 return null;
19314 }
19315 const matchedString = matchResult[0];
19316 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
19317 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
19318 // [TODO] -- I challenge you to fix the type
19319 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
19320 );
19321 let value;
19322 value = args.valueCallback ? args.valueCallback(key) : key;
19323 value = options.valueCallback ? (
19324 // [TODO] -- I challenge you to fix the type
19325 options.valueCallback(value)
19326 ) : value;
19327 const rest = string.slice(matchedString.length);
19328 return { value, rest };
19329 };
19330 }
19331 function findKey(object, predicate) {
19332 for (const key in object) {
19333 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
19334 return key;
19335 }
19336 }
19337 return void 0;
19338 }
19339 function findIndex(array, predicate) {
19340 for (let key = 0; key < array.length; key++) {
19341 if (predicate(array[key])) {
19342 return key;
19343 }
19344 }
19345 return void 0;
19346 }
19347
19348 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
19349 function buildMatchPatternFn(args) {
19350 return (string, options = {}) => {
19351 const matchResult = string.match(args.matchPattern);
19352 if (!matchResult) return null;
19353 const matchedString = matchResult[0];
19354 const parseResult = string.match(args.parsePattern);
19355 if (!parseResult) return null;
19356 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
19357 value = options.valueCallback ? options.valueCallback(value) : value;
19358 const rest = string.slice(matchedString.length);
19359 return { value, rest };
19360 };
19361 }
19362
19363 // node_modules/date-fns/locale/en-US/_lib/match.js
19364 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
19365 var parseOrdinalNumberPattern = /\d+/i;
19366 var matchEraPatterns = {
19367 narrow: /^(b|a)/i,
19368 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
19369 wide: /^(before christ|before common era|anno domini|common era)/i
19370 };
19371 var parseEraPatterns = {
19372 any: [/^b/i, /^(a|c)/i]
19373 };
19374 var matchQuarterPatterns = {
19375 narrow: /^[1234]/i,
19376 abbreviated: /^q[1234]/i,
19377 wide: /^[1234](th|st|nd|rd)? quarter/i
19378 };
19379 var parseQuarterPatterns = {
19380 any: [/1/i, /2/i, /3/i, /4/i]
19381 };
19382 var matchMonthPatterns = {
19383 narrow: /^[jfmasond]/i,
19384 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
19385 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
19386 };
19387 var parseMonthPatterns = {
19388 narrow: [
19389 /^j/i,
19390 /^f/i,
19391 /^m/i,
19392 /^a/i,
19393 /^m/i,
19394 /^j/i,
19395 /^j/i,
19396 /^a/i,
19397 /^s/i,
19398 /^o/i,
19399 /^n/i,
19400 /^d/i
19401 ],
19402 any: [
19403 /^ja/i,
19404 /^f/i,
19405 /^mar/i,
19406 /^ap/i,
19407 /^may/i,
19408 /^jun/i,
19409 /^jul/i,
19410 /^au/i,
19411 /^s/i,
19412 /^o/i,
19413 /^n/i,
19414 /^d/i
19415 ]
19416 };
19417 var matchDayPatterns = {
19418 narrow: /^[smtwf]/i,
19419 short: /^(su|mo|tu|we|th|fr|sa)/i,
19420 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
19421 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
19422 };
19423 var parseDayPatterns = {
19424 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
19425 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
19426 };
19427 var matchDayPeriodPatterns = {
19428 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
19429 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
19430 };
19431 var parseDayPeriodPatterns = {
19432 any: {
19433 am: /^a/i,
19434 pm: /^p/i,
19435 midnight: /^mi/i,
19436 noon: /^no/i,
19437 morning: /morning/i,
19438 afternoon: /afternoon/i,
19439 evening: /evening/i,
19440 night: /night/i
19441 }
19442 };
19443 var match = {
19444 ordinalNumber: buildMatchPatternFn({
19445 matchPattern: matchOrdinalNumberPattern,
19446 parsePattern: parseOrdinalNumberPattern,
19447 valueCallback: (value) => parseInt(value, 10)
19448 }),
19449 era: buildMatchFn({
19450 matchPatterns: matchEraPatterns,
19451 defaultMatchWidth: "wide",
19452 parsePatterns: parseEraPatterns,
19453 defaultParseWidth: "any"
19454 }),
19455 quarter: buildMatchFn({
19456 matchPatterns: matchQuarterPatterns,
19457 defaultMatchWidth: "wide",
19458 parsePatterns: parseQuarterPatterns,
19459 defaultParseWidth: "any",
19460 valueCallback: (index2) => index2 + 1
19461 }),
19462 month: buildMatchFn({
19463 matchPatterns: matchMonthPatterns,
19464 defaultMatchWidth: "wide",
19465 parsePatterns: parseMonthPatterns,
19466 defaultParseWidth: "any"
19467 }),
19468 day: buildMatchFn({
19469 matchPatterns: matchDayPatterns,
19470 defaultMatchWidth: "wide",
19471 parsePatterns: parseDayPatterns,
19472 defaultParseWidth: "any"
19473 }),
19474 dayPeriod: buildMatchFn({
19475 matchPatterns: matchDayPeriodPatterns,
19476 defaultMatchWidth: "any",
19477 parsePatterns: parseDayPeriodPatterns,
19478 defaultParseWidth: "any"
19479 })
19480 };
19481
19482 // node_modules/date-fns/locale/en-US.js
19483 var enUS = {
19484 code: "en-US",
19485 formatDistance,
19486 formatLong,
19487 formatRelative,
19488 localize,
19489 match,
19490 options: {
19491 weekStartsOn: 0,
19492 firstWeekContainsDate: 1
19493 }
19494 };
19495
19496 // node_modules/date-fns/getDayOfYear.js
19497 function getDayOfYear(date, options) {
19498 const _date = toDate(date, options?.in);
19499 const diff = differenceInCalendarDays(_date, startOfYear(_date));
19500 const dayOfYear = diff + 1;
19501 return dayOfYear;
19502 }
19503
19504 // node_modules/date-fns/getISOWeek.js
19505 function getISOWeek(date, options) {
19506 const _date = toDate(date, options?.in);
19507 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
19508 return Math.round(diff / millisecondsInWeek) + 1;
19509 }
19510
19511 // node_modules/date-fns/getWeekYear.js
19512 function getWeekYear(date, options) {
19513 const _date = toDate(date, options?.in);
19514 const year = _date.getFullYear();
19515 const defaultOptions2 = getDefaultOptions();
19516 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19517 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
19518 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
19519 firstWeekOfNextYear.setHours(0, 0, 0, 0);
19520 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
19521 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
19522 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
19523 firstWeekOfThisYear.setHours(0, 0, 0, 0);
19524 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
19525 if (+_date >= +startOfNextYear) {
19526 return year + 1;
19527 } else if (+_date >= +startOfThisYear) {
19528 return year;
19529 } else {
19530 return year - 1;
19531 }
19532 }
19533
19534 // node_modules/date-fns/startOfWeekYear.js
19535 function startOfWeekYear(date, options) {
19536 const defaultOptions2 = getDefaultOptions();
19537 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
19538 const year = getWeekYear(date, options);
19539 const firstWeek = constructFrom(options?.in || date, 0);
19540 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
19541 firstWeek.setHours(0, 0, 0, 0);
19542 const _date = startOfWeek(firstWeek, options);
19543 return _date;
19544 }
19545
19546 // node_modules/date-fns/getWeek.js
19547 function getWeek(date, options) {
19548 const _date = toDate(date, options?.in);
19549 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
19550 return Math.round(diff / millisecondsInWeek) + 1;
19551 }
19552
19553 // node_modules/date-fns/_lib/addLeadingZeros.js
19554 function addLeadingZeros(number, targetLength) {
19555 const sign = number < 0 ? "-" : "";
19556 const output = Math.abs(number).toString().padStart(targetLength, "0");
19557 return sign + output;
19558 }
19559
19560 // node_modules/date-fns/_lib/format/lightFormatters.js
19561 var lightFormatters = {
19562 // Year
19563 y(date, token) {
19564 const signedYear = date.getFullYear();
19565 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19566 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
19567 },
19568 // Month
19569 M(date, token) {
19570 const month = date.getMonth();
19571 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
19572 },
19573 // Day of the month
19574 d(date, token) {
19575 return addLeadingZeros(date.getDate(), token.length);
19576 },
19577 // AM or PM
19578 a(date, token) {
19579 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
19580 switch (token) {
19581 case "a":
19582 case "aa":
19583 return dayPeriodEnumValue.toUpperCase();
19584 case "aaa":
19585 return dayPeriodEnumValue;
19586 case "aaaaa":
19587 return dayPeriodEnumValue[0];
19588 case "aaaa":
19589 default:
19590 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
19591 }
19592 },
19593 // Hour [1-12]
19594 h(date, token) {
19595 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
19596 },
19597 // Hour [0-23]
19598 H(date, token) {
19599 return addLeadingZeros(date.getHours(), token.length);
19600 },
19601 // Minute
19602 m(date, token) {
19603 return addLeadingZeros(date.getMinutes(), token.length);
19604 },
19605 // Second
19606 s(date, token) {
19607 return addLeadingZeros(date.getSeconds(), token.length);
19608 },
19609 // Fraction of second
19610 S(date, token) {
19611 const numberOfDigits = token.length;
19612 const milliseconds = date.getMilliseconds();
19613 const fractionalSeconds = Math.trunc(
19614 milliseconds * Math.pow(10, numberOfDigits - 3)
19615 );
19616 return addLeadingZeros(fractionalSeconds, token.length);
19617 }
19618 };
19619
19620 // node_modules/date-fns/_lib/format/formatters.js
19621 var dayPeriodEnum = {
19622 am: "am",
19623 pm: "pm",
19624 midnight: "midnight",
19625 noon: "noon",
19626 morning: "morning",
19627 afternoon: "afternoon",
19628 evening: "evening",
19629 night: "night"
19630 };
19631 var formatters = {
19632 // Era
19633 G: function(date, token, localize2) {
19634 const era = date.getFullYear() > 0 ? 1 : 0;
19635 switch (token) {
19636 // AD, BC
19637 case "G":
19638 case "GG":
19639 case "GGG":
19640 return localize2.era(era, { width: "abbreviated" });
19641 // A, B
19642 case "GGGGG":
19643 return localize2.era(era, { width: "narrow" });
19644 // Anno Domini, Before Christ
19645 case "GGGG":
19646 default:
19647 return localize2.era(era, { width: "wide" });
19648 }
19649 },
19650 // Year
19651 y: function(date, token, localize2) {
19652 if (token === "yo") {
19653 const signedYear = date.getFullYear();
19654 const year = signedYear > 0 ? signedYear : 1 - signedYear;
19655 return localize2.ordinalNumber(year, { unit: "year" });
19656 }
19657 return lightFormatters.y(date, token);
19658 },
19659 // Local week-numbering year
19660 Y: function(date, token, localize2, options) {
19661 const signedWeekYear = getWeekYear(date, options);
19662 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
19663 if (token === "YY") {
19664 const twoDigitYear = weekYear % 100;
19665 return addLeadingZeros(twoDigitYear, 2);
19666 }
19667 if (token === "Yo") {
19668 return localize2.ordinalNumber(weekYear, { unit: "year" });
19669 }
19670 return addLeadingZeros(weekYear, token.length);
19671 },
19672 // ISO week-numbering year
19673 R: function(date, token) {
19674 const isoWeekYear = getISOWeekYear(date);
19675 return addLeadingZeros(isoWeekYear, token.length);
19676 },
19677 // Extended year. This is a single number designating the year of this calendar system.
19678 // The main difference between `y` and `u` localizers are B.C. years:
19679 // | Year | `y` | `u` |
19680 // |------|-----|-----|
19681 // | AC 1 | 1 | 1 |
19682 // | BC 1 | 1 | 0 |
19683 // | BC 2 | 2 | -1 |
19684 // Also `yy` always returns the last two digits of a year,
19685 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
19686 u: function(date, token) {
19687 const year = date.getFullYear();
19688 return addLeadingZeros(year, token.length);
19689 },
19690 // Quarter
19691 Q: function(date, token, localize2) {
19692 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19693 switch (token) {
19694 // 1, 2, 3, 4
19695 case "Q":
19696 return String(quarter);
19697 // 01, 02, 03, 04
19698 case "QQ":
19699 return addLeadingZeros(quarter, 2);
19700 // 1st, 2nd, 3rd, 4th
19701 case "Qo":
19702 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19703 // Q1, Q2, Q3, Q4
19704 case "QQQ":
19705 return localize2.quarter(quarter, {
19706 width: "abbreviated",
19707 context: "formatting"
19708 });
19709 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
19710 case "QQQQQ":
19711 return localize2.quarter(quarter, {
19712 width: "narrow",
19713 context: "formatting"
19714 });
19715 // 1st quarter, 2nd quarter, ...
19716 case "QQQQ":
19717 default:
19718 return localize2.quarter(quarter, {
19719 width: "wide",
19720 context: "formatting"
19721 });
19722 }
19723 },
19724 // Stand-alone quarter
19725 q: function(date, token, localize2) {
19726 const quarter = Math.ceil((date.getMonth() + 1) / 3);
19727 switch (token) {
19728 // 1, 2, 3, 4
19729 case "q":
19730 return String(quarter);
19731 // 01, 02, 03, 04
19732 case "qq":
19733 return addLeadingZeros(quarter, 2);
19734 // 1st, 2nd, 3rd, 4th
19735 case "qo":
19736 return localize2.ordinalNumber(quarter, { unit: "quarter" });
19737 // Q1, Q2, Q3, Q4
19738 case "qqq":
19739 return localize2.quarter(quarter, {
19740 width: "abbreviated",
19741 context: "standalone"
19742 });
19743 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
19744 case "qqqqq":
19745 return localize2.quarter(quarter, {
19746 width: "narrow",
19747 context: "standalone"
19748 });
19749 // 1st quarter, 2nd quarter, ...
19750 case "qqqq":
19751 default:
19752 return localize2.quarter(quarter, {
19753 width: "wide",
19754 context: "standalone"
19755 });
19756 }
19757 },
19758 // Month
19759 M: function(date, token, localize2) {
19760 const month = date.getMonth();
19761 switch (token) {
19762 case "M":
19763 case "MM":
19764 return lightFormatters.M(date, token);
19765 // 1st, 2nd, ..., 12th
19766 case "Mo":
19767 return localize2.ordinalNumber(month + 1, { unit: "month" });
19768 // Jan, Feb, ..., Dec
19769 case "MMM":
19770 return localize2.month(month, {
19771 width: "abbreviated",
19772 context: "formatting"
19773 });
19774 // J, F, ..., D
19775 case "MMMMM":
19776 return localize2.month(month, {
19777 width: "narrow",
19778 context: "formatting"
19779 });
19780 // January, February, ..., December
19781 case "MMMM":
19782 default:
19783 return localize2.month(month, { width: "wide", context: "formatting" });
19784 }
19785 },
19786 // Stand-alone month
19787 L: function(date, token, localize2) {
19788 const month = date.getMonth();
19789 switch (token) {
19790 // 1, 2, ..., 12
19791 case "L":
19792 return String(month + 1);
19793 // 01, 02, ..., 12
19794 case "LL":
19795 return addLeadingZeros(month + 1, 2);
19796 // 1st, 2nd, ..., 12th
19797 case "Lo":
19798 return localize2.ordinalNumber(month + 1, { unit: "month" });
19799 // Jan, Feb, ..., Dec
19800 case "LLL":
19801 return localize2.month(month, {
19802 width: "abbreviated",
19803 context: "standalone"
19804 });
19805 // J, F, ..., D
19806 case "LLLLL":
19807 return localize2.month(month, {
19808 width: "narrow",
19809 context: "standalone"
19810 });
19811 // January, February, ..., December
19812 case "LLLL":
19813 default:
19814 return localize2.month(month, { width: "wide", context: "standalone" });
19815 }
19816 },
19817 // Local week of year
19818 w: function(date, token, localize2, options) {
19819 const week = getWeek(date, options);
19820 if (token === "wo") {
19821 return localize2.ordinalNumber(week, { unit: "week" });
19822 }
19823 return addLeadingZeros(week, token.length);
19824 },
19825 // ISO week of year
19826 I: function(date, token, localize2) {
19827 const isoWeek = getISOWeek(date);
19828 if (token === "Io") {
19829 return localize2.ordinalNumber(isoWeek, { unit: "week" });
19830 }
19831 return addLeadingZeros(isoWeek, token.length);
19832 },
19833 // Day of the month
19834 d: function(date, token, localize2) {
19835 if (token === "do") {
19836 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
19837 }
19838 return lightFormatters.d(date, token);
19839 },
19840 // Day of year
19841 D: function(date, token, localize2) {
19842 const dayOfYear = getDayOfYear(date);
19843 if (token === "Do") {
19844 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
19845 }
19846 return addLeadingZeros(dayOfYear, token.length);
19847 },
19848 // Day of week
19849 E: function(date, token, localize2) {
19850 const dayOfWeek = date.getDay();
19851 switch (token) {
19852 // Tue
19853 case "E":
19854 case "EE":
19855 case "EEE":
19856 return localize2.day(dayOfWeek, {
19857 width: "abbreviated",
19858 context: "formatting"
19859 });
19860 // T
19861 case "EEEEE":
19862 return localize2.day(dayOfWeek, {
19863 width: "narrow",
19864 context: "formatting"
19865 });
19866 // Tu
19867 case "EEEEEE":
19868 return localize2.day(dayOfWeek, {
19869 width: "short",
19870 context: "formatting"
19871 });
19872 // Tuesday
19873 case "EEEE":
19874 default:
19875 return localize2.day(dayOfWeek, {
19876 width: "wide",
19877 context: "formatting"
19878 });
19879 }
19880 },
19881 // Local day of week
19882 e: function(date, token, localize2, options) {
19883 const dayOfWeek = date.getDay();
19884 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
19885 switch (token) {
19886 // Numerical value (Nth day of week with current locale or weekStartsOn)
19887 case "e":
19888 return String(localDayOfWeek);
19889 // Padded numerical value
19890 case "ee":
19891 return addLeadingZeros(localDayOfWeek, 2);
19892 // 1st, 2nd, ..., 7th
19893 case "eo":
19894 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
19895 case "eee":
19896 return localize2.day(dayOfWeek, {
19897 width: "abbreviated",
19898 context: "formatting"
19899 });
19900 // T
19901 case "eeeee":
19902 return localize2.day(dayOfWeek, {
19903 width: "narrow",
19904 context: "formatting"
19905 });
19906 // Tu
19907 case "eeeeee":
19908 return localize2.day(dayOfWeek, {
19909 width: "short",
19910 context: "formatting"
19911 });
19912 // Tuesday
19913 case "eeee":
19914 default:
19915 return localize2.day(dayOfWeek, {
19916 width: "wide",
19917 context: "formatting"
19918 });
19919 }
19920 },
19921 // Stand-alone local day of week
19922 c: function(date, token, localize2, options) {
19923 const dayOfWeek = date.getDay();
19924 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
19925 switch (token) {
19926 // Numerical value (same as in `e`)
19927 case "c":
19928 return String(localDayOfWeek);
19929 // Padded numerical value
19930 case "cc":
19931 return addLeadingZeros(localDayOfWeek, token.length);
19932 // 1st, 2nd, ..., 7th
19933 case "co":
19934 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
19935 case "ccc":
19936 return localize2.day(dayOfWeek, {
19937 width: "abbreviated",
19938 context: "standalone"
19939 });
19940 // T
19941 case "ccccc":
19942 return localize2.day(dayOfWeek, {
19943 width: "narrow",
19944 context: "standalone"
19945 });
19946 // Tu
19947 case "cccccc":
19948 return localize2.day(dayOfWeek, {
19949 width: "short",
19950 context: "standalone"
19951 });
19952 // Tuesday
19953 case "cccc":
19954 default:
19955 return localize2.day(dayOfWeek, {
19956 width: "wide",
19957 context: "standalone"
19958 });
19959 }
19960 },
19961 // ISO day of week
19962 i: function(date, token, localize2) {
19963 const dayOfWeek = date.getDay();
19964 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
19965 switch (token) {
19966 // 2
19967 case "i":
19968 return String(isoDayOfWeek);
19969 // 02
19970 case "ii":
19971 return addLeadingZeros(isoDayOfWeek, token.length);
19972 // 2nd
19973 case "io":
19974 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
19975 // Tue
19976 case "iii":
19977 return localize2.day(dayOfWeek, {
19978 width: "abbreviated",
19979 context: "formatting"
19980 });
19981 // T
19982 case "iiiii":
19983 return localize2.day(dayOfWeek, {
19984 width: "narrow",
19985 context: "formatting"
19986 });
19987 // Tu
19988 case "iiiiii":
19989 return localize2.day(dayOfWeek, {
19990 width: "short",
19991 context: "formatting"
19992 });
19993 // Tuesday
19994 case "iiii":
19995 default:
19996 return localize2.day(dayOfWeek, {
19997 width: "wide",
19998 context: "formatting"
19999 });
20000 }
20001 },
20002 // AM or PM
20003 a: function(date, token, localize2) {
20004 const hours = date.getHours();
20005 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20006 switch (token) {
20007 case "a":
20008 case "aa":
20009 return localize2.dayPeriod(dayPeriodEnumValue, {
20010 width: "abbreviated",
20011 context: "formatting"
20012 });
20013 case "aaa":
20014 return localize2.dayPeriod(dayPeriodEnumValue, {
20015 width: "abbreviated",
20016 context: "formatting"
20017 }).toLowerCase();
20018 case "aaaaa":
20019 return localize2.dayPeriod(dayPeriodEnumValue, {
20020 width: "narrow",
20021 context: "formatting"
20022 });
20023 case "aaaa":
20024 default:
20025 return localize2.dayPeriod(dayPeriodEnumValue, {
20026 width: "wide",
20027 context: "formatting"
20028 });
20029 }
20030 },
20031 // AM, PM, midnight, noon
20032 b: function(date, token, localize2) {
20033 const hours = date.getHours();
20034 let dayPeriodEnumValue;
20035 if (hours === 12) {
20036 dayPeriodEnumValue = dayPeriodEnum.noon;
20037 } else if (hours === 0) {
20038 dayPeriodEnumValue = dayPeriodEnum.midnight;
20039 } else {
20040 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
20041 }
20042 switch (token) {
20043 case "b":
20044 case "bb":
20045 return localize2.dayPeriod(dayPeriodEnumValue, {
20046 width: "abbreviated",
20047 context: "formatting"
20048 });
20049 case "bbb":
20050 return localize2.dayPeriod(dayPeriodEnumValue, {
20051 width: "abbreviated",
20052 context: "formatting"
20053 }).toLowerCase();
20054 case "bbbbb":
20055 return localize2.dayPeriod(dayPeriodEnumValue, {
20056 width: "narrow",
20057 context: "formatting"
20058 });
20059 case "bbbb":
20060 default:
20061 return localize2.dayPeriod(dayPeriodEnumValue, {
20062 width: "wide",
20063 context: "formatting"
20064 });
20065 }
20066 },
20067 // in the morning, in the afternoon, in the evening, at night
20068 B: function(date, token, localize2) {
20069 const hours = date.getHours();
20070 let dayPeriodEnumValue;
20071 if (hours >= 17) {
20072 dayPeriodEnumValue = dayPeriodEnum.evening;
20073 } else if (hours >= 12) {
20074 dayPeriodEnumValue = dayPeriodEnum.afternoon;
20075 } else if (hours >= 4) {
20076 dayPeriodEnumValue = dayPeriodEnum.morning;
20077 } else {
20078 dayPeriodEnumValue = dayPeriodEnum.night;
20079 }
20080 switch (token) {
20081 case "B":
20082 case "BB":
20083 case "BBB":
20084 return localize2.dayPeriod(dayPeriodEnumValue, {
20085 width: "abbreviated",
20086 context: "formatting"
20087 });
20088 case "BBBBB":
20089 return localize2.dayPeriod(dayPeriodEnumValue, {
20090 width: "narrow",
20091 context: "formatting"
20092 });
20093 case "BBBB":
20094 default:
20095 return localize2.dayPeriod(dayPeriodEnumValue, {
20096 width: "wide",
20097 context: "formatting"
20098 });
20099 }
20100 },
20101 // Hour [1-12]
20102 h: function(date, token, localize2) {
20103 if (token === "ho") {
20104 let hours = date.getHours() % 12;
20105 if (hours === 0) hours = 12;
20106 return localize2.ordinalNumber(hours, { unit: "hour" });
20107 }
20108 return lightFormatters.h(date, token);
20109 },
20110 // Hour [0-23]
20111 H: function(date, token, localize2) {
20112 if (token === "Ho") {
20113 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
20114 }
20115 return lightFormatters.H(date, token);
20116 },
20117 // Hour [0-11]
20118 K: function(date, token, localize2) {
20119 const hours = date.getHours() % 12;
20120 if (token === "Ko") {
20121 return localize2.ordinalNumber(hours, { unit: "hour" });
20122 }
20123 return addLeadingZeros(hours, token.length);
20124 },
20125 // Hour [1-24]
20126 k: function(date, token, localize2) {
20127 let hours = date.getHours();
20128 if (hours === 0) hours = 24;
20129 if (token === "ko") {
20130 return localize2.ordinalNumber(hours, { unit: "hour" });
20131 }
20132 return addLeadingZeros(hours, token.length);
20133 },
20134 // Minute
20135 m: function(date, token, localize2) {
20136 if (token === "mo") {
20137 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
20138 }
20139 return lightFormatters.m(date, token);
20140 },
20141 // Second
20142 s: function(date, token, localize2) {
20143 if (token === "so") {
20144 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
20145 }
20146 return lightFormatters.s(date, token);
20147 },
20148 // Fraction of second
20149 S: function(date, token) {
20150 return lightFormatters.S(date, token);
20151 },
20152 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
20153 X: function(date, token, _localize) {
20154 const timezoneOffset = date.getTimezoneOffset();
20155 if (timezoneOffset === 0) {
20156 return "Z";
20157 }
20158 switch (token) {
20159 // Hours and optional minutes
20160 case "X":
20161 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20162 // Hours, minutes and optional seconds without `:` delimiter
20163 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20164 // so this token always has the same output as `XX`
20165 case "XXXX":
20166 case "XX":
20167 return formatTimezone(timezoneOffset);
20168 // Hours, minutes and optional seconds with `:` delimiter
20169 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20170 // so this token always has the same output as `XXX`
20171 case "XXXXX":
20172 case "XXX":
20173 // Hours and minutes with `:` delimiter
20174 default:
20175 return formatTimezone(timezoneOffset, ":");
20176 }
20177 },
20178 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
20179 x: function(date, token, _localize) {
20180 const timezoneOffset = date.getTimezoneOffset();
20181 switch (token) {
20182 // Hours and optional minutes
20183 case "x":
20184 return formatTimezoneWithOptionalMinutes(timezoneOffset);
20185 // Hours, minutes and optional seconds without `:` delimiter
20186 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20187 // so this token always has the same output as `xx`
20188 case "xxxx":
20189 case "xx":
20190 return formatTimezone(timezoneOffset);
20191 // Hours, minutes and optional seconds with `:` delimiter
20192 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
20193 // so this token always has the same output as `xxx`
20194 case "xxxxx":
20195 case "xxx":
20196 // Hours and minutes with `:` delimiter
20197 default:
20198 return formatTimezone(timezoneOffset, ":");
20199 }
20200 },
20201 // Timezone (GMT)
20202 O: function(date, token, _localize) {
20203 const timezoneOffset = date.getTimezoneOffset();
20204 switch (token) {
20205 // Short
20206 case "O":
20207 case "OO":
20208 case "OOO":
20209 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20210 // Long
20211 case "OOOO":
20212 default:
20213 return "GMT" + formatTimezone(timezoneOffset, ":");
20214 }
20215 },
20216 // Timezone (specific non-location)
20217 z: function(date, token, _localize) {
20218 const timezoneOffset = date.getTimezoneOffset();
20219 switch (token) {
20220 // Short
20221 case "z":
20222 case "zz":
20223 case "zzz":
20224 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
20225 // Long
20226 case "zzzz":
20227 default:
20228 return "GMT" + formatTimezone(timezoneOffset, ":");
20229 }
20230 },
20231 // Seconds timestamp
20232 t: function(date, token, _localize) {
20233 const timestamp = Math.trunc(+date / 1e3);
20234 return addLeadingZeros(timestamp, token.length);
20235 },
20236 // Milliseconds timestamp
20237 T: function(date, token, _localize) {
20238 return addLeadingZeros(+date, token.length);
20239 }
20240 };
20241 function formatTimezoneShort(offset4, delimiter = "") {
20242 const sign = offset4 > 0 ? "-" : "+";
20243 const absOffset = Math.abs(offset4);
20244 const hours = Math.trunc(absOffset / 60);
20245 const minutes = absOffset % 60;
20246 if (minutes === 0) {
20247 return sign + String(hours);
20248 }
20249 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
20250 }
20251 function formatTimezoneWithOptionalMinutes(offset4, delimiter) {
20252 if (offset4 % 60 === 0) {
20253 const sign = offset4 > 0 ? "-" : "+";
20254 return sign + addLeadingZeros(Math.abs(offset4) / 60, 2);
20255 }
20256 return formatTimezone(offset4, delimiter);
20257 }
20258 function formatTimezone(offset4, delimiter = "") {
20259 const sign = offset4 > 0 ? "-" : "+";
20260 const absOffset = Math.abs(offset4);
20261 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
20262 const minutes = addLeadingZeros(absOffset % 60, 2);
20263 return sign + hours + delimiter + minutes;
20264 }
20265
20266 // node_modules/date-fns/_lib/format/longFormatters.js
20267 var dateLongFormatter = (pattern, formatLong2) => {
20268 switch (pattern) {
20269 case "P":
20270 return formatLong2.date({ width: "short" });
20271 case "PP":
20272 return formatLong2.date({ width: "medium" });
20273 case "PPP":
20274 return formatLong2.date({ width: "long" });
20275 case "PPPP":
20276 default:
20277 return formatLong2.date({ width: "full" });
20278 }
20279 };
20280 var timeLongFormatter = (pattern, formatLong2) => {
20281 switch (pattern) {
20282 case "p":
20283 return formatLong2.time({ width: "short" });
20284 case "pp":
20285 return formatLong2.time({ width: "medium" });
20286 case "ppp":
20287 return formatLong2.time({ width: "long" });
20288 case "pppp":
20289 default:
20290 return formatLong2.time({ width: "full" });
20291 }
20292 };
20293 var dateTimeLongFormatter = (pattern, formatLong2) => {
20294 const matchResult = pattern.match(/(P+)(p+)?/) || [];
20295 const datePattern = matchResult[1];
20296 const timePattern = matchResult[2];
20297 if (!timePattern) {
20298 return dateLongFormatter(pattern, formatLong2);
20299 }
20300 let dateTimeFormat;
20301 switch (datePattern) {
20302 case "P":
20303 dateTimeFormat = formatLong2.dateTime({ width: "short" });
20304 break;
20305 case "PP":
20306 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
20307 break;
20308 case "PPP":
20309 dateTimeFormat = formatLong2.dateTime({ width: "long" });
20310 break;
20311 case "PPPP":
20312 default:
20313 dateTimeFormat = formatLong2.dateTime({ width: "full" });
20314 break;
20315 }
20316 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
20317 };
20318 var longFormatters = {
20319 p: timeLongFormatter,
20320 P: dateTimeLongFormatter
20321 };
20322
20323 // node_modules/date-fns/_lib/protectedTokens.js
20324 var dayOfYearTokenRE = /^D+$/;
20325 var weekYearTokenRE = /^Y+$/;
20326 var throwTokens = ["D", "DD", "YY", "YYYY"];
20327 function isProtectedDayOfYearToken(token) {
20328 return dayOfYearTokenRE.test(token);
20329 }
20330 function isProtectedWeekYearToken(token) {
20331 return weekYearTokenRE.test(token);
20332 }
20333 function warnOrThrowProtectedError(token, format6, input) {
20334 const _message = message(token, format6, input);
20335 console.warn(_message);
20336 if (throwTokens.includes(token)) throw new RangeError(_message);
20337 }
20338 function message(token, format6, input) {
20339 const subject = token[0] === "Y" ? "years" : "days of the month";
20340 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`;
20341 }
20342
20343 // node_modules/date-fns/format.js
20344 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
20345 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
20346 var escapedStringRegExp = /^'([^]*?)'?$/;
20347 var doubleQuoteRegExp = /''/g;
20348 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
20349 function format(date, formatStr, options) {
20350 const defaultOptions2 = getDefaultOptions();
20351 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
20352 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
20353 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
20354 const originalDate = toDate(date, options?.in);
20355 if (!isValid(originalDate)) {
20356 throw new RangeError("Invalid time value");
20357 }
20358 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
20359 const firstCharacter = substring[0];
20360 if (firstCharacter === "p" || firstCharacter === "P") {
20361 const longFormatter = longFormatters[firstCharacter];
20362 return longFormatter(substring, locale.formatLong);
20363 }
20364 return substring;
20365 }).join("").match(formattingTokensRegExp).map((substring) => {
20366 if (substring === "''") {
20367 return { isToken: false, value: "'" };
20368 }
20369 const firstCharacter = substring[0];
20370 if (firstCharacter === "'") {
20371 return { isToken: false, value: cleanEscapedString(substring) };
20372 }
20373 if (formatters[firstCharacter]) {
20374 return { isToken: true, value: substring };
20375 }
20376 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
20377 throw new RangeError(
20378 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
20379 );
20380 }
20381 return { isToken: false, value: substring };
20382 });
20383 if (locale.localize.preprocessor) {
20384 parts = locale.localize.preprocessor(originalDate, parts);
20385 }
20386 const formatterOptions = {
20387 firstWeekContainsDate,
20388 weekStartsOn,
20389 locale
20390 };
20391 return parts.map((part) => {
20392 if (!part.isToken) return part.value;
20393 const token = part.value;
20394 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
20395 warnOrThrowProtectedError(token, formatStr, String(date));
20396 }
20397 const formatter = formatters[token[0]];
20398 return formatter(originalDate, token, locale.localize, formatterOptions);
20399 }).join("");
20400 }
20401 function cleanEscapedString(input) {
20402 const matched = input.match(escapedStringRegExp);
20403 if (!matched) {
20404 return input;
20405 }
20406 return matched[1].replace(doubleQuoteRegExp, "'");
20407 }
20408
20409 // node_modules/date-fns/subDays.js
20410 function subDays(date, amount, options) {
20411 return addDays(date, -amount, options);
20412 }
20413
20414 // node_modules/date-fns/subMonths.js
20415 function subMonths(date, amount, options) {
20416 return addMonths(date, -amount, options);
20417 }
20418
20419 // node_modules/date-fns/subWeeks.js
20420 function subWeeks(date, amount, options) {
20421 return addWeeks(date, -amount, options);
20422 }
20423
20424 // node_modules/date-fns/subYears.js
20425 function subYears(date, amount, options) {
20426 return addYears(date, -amount, options);
20427 }
20428
20429 // packages/dataviews/build-module/utils/operators.mjs
20430 var import_i18n23 = __toESM(require_i18n(), 1);
20431 var import_element42 = __toESM(require_element(), 1);
20432 var import_date = __toESM(require_date(), 1);
20433 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
20434 var filterTextWrappers = {
20435 Name: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
20436 Value: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
20437 };
20438 function getRelativeDate(value, unit) {
20439 switch (unit) {
20440 case "days":
20441 return subDays(/* @__PURE__ */ new Date(), value);
20442 case "weeks":
20443 return subWeeks(/* @__PURE__ */ new Date(), value);
20444 case "months":
20445 return subMonths(/* @__PURE__ */ new Date(), value);
20446 case "years":
20447 return subYears(/* @__PURE__ */ new Date(), value);
20448 default:
20449 return /* @__PURE__ */ new Date();
20450 }
20451 }
20452 var isNoneOperatorDefinition = {
20453 /* translators: DataViews operator name */
20454 label: (0, import_i18n23.__)("Is none of"),
20455 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20456 (0, import_i18n23.sprintf)(
20457 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
20458 (0, import_i18n23.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
20459 filter.name,
20460 activeElements.map((element) => element.label).join(", ")
20461 ),
20462 filterTextWrappers
20463 ),
20464 filter: ((item, field, filterValue) => {
20465 if (!filterValue?.length) {
20466 return true;
20467 }
20468 const fieldValue = field.getValue({ item });
20469 if (Array.isArray(fieldValue)) {
20470 return !filterValue.some(
20471 (fv) => fieldValue.includes(fv)
20472 );
20473 } else if (typeof fieldValue === "string") {
20474 return !filterValue.includes(fieldValue);
20475 }
20476 return false;
20477 }),
20478 selection: "multi"
20479 };
20480 var OPERATORS = [
20481 {
20482 name: OPERATOR_IS_ANY,
20483 /* translators: DataViews operator name */
20484 label: (0, import_i18n23.__)("Includes"),
20485 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20486 (0, import_i18n23.sprintf)(
20487 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
20488 (0, import_i18n23.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
20489 filter.name,
20490 activeElements.map((element) => element.label).join(", ")
20491 ),
20492 filterTextWrappers
20493 ),
20494 filter(item, field, filterValue) {
20495 if (!filterValue?.length) {
20496 return true;
20497 }
20498 const fieldValue = field.getValue({ item });
20499 if (Array.isArray(fieldValue)) {
20500 return filterValue.some(
20501 (fv) => fieldValue.includes(fv)
20502 );
20503 } else if (typeof fieldValue === "string") {
20504 return filterValue.includes(fieldValue);
20505 }
20506 return false;
20507 },
20508 selection: "multi"
20509 },
20510 {
20511 name: OPERATOR_IS_NONE,
20512 ...isNoneOperatorDefinition
20513 },
20514 {
20515 name: OPERATOR_IS_ALL,
20516 /* translators: DataViews operator name */
20517 label: (0, import_i18n23.__)("Includes all"),
20518 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20519 (0, import_i18n23.sprintf)(
20520 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
20521 (0, import_i18n23.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
20522 filter.name,
20523 activeElements.map((element) => element.label).join(", ")
20524 ),
20525 filterTextWrappers
20526 ),
20527 filter(item, field, filterValue) {
20528 if (!filterValue?.length) {
20529 return true;
20530 }
20531 return filterValue.every((value) => {
20532 return field.getValue({ item })?.includes(value);
20533 });
20534 },
20535 selection: "multi"
20536 },
20537 {
20538 name: OPERATOR_IS_NOT_ALL,
20539 ...isNoneOperatorDefinition
20540 },
20541 {
20542 name: OPERATOR_BETWEEN,
20543 /* translators: DataViews operator name */
20544 label: (0, import_i18n23.__)("Between (inc)"),
20545 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20546 (0, import_i18n23.sprintf)(
20547 /* 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". */
20548 (0, import_i18n23.__)(
20549 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
20550 ),
20551 filter.name,
20552 activeElements[0].label[0],
20553 activeElements[0].label[1]
20554 ),
20555 filterTextWrappers
20556 ),
20557 filter(item, field, filterValue) {
20558 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
20559 return true;
20560 }
20561 const fieldValue = field.getValue({ item });
20562 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
20563 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
20564 }
20565 return false;
20566 },
20567 selection: "custom"
20568 },
20569 {
20570 name: OPERATOR_IN_THE_PAST,
20571 /* translators: DataViews operator name */
20572 label: (0, import_i18n23.__)("In the past"),
20573 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20574 (0, import_i18n23.sprintf)(
20575 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
20576 (0, import_i18n23.__)(
20577 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
20578 ),
20579 filter.name,
20580 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20581 ),
20582 filterTextWrappers
20583 ),
20584 filter(item, field, filterValue) {
20585 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20586 return true;
20587 }
20588 const targetDate = getRelativeDate(
20589 filterValue.value,
20590 filterValue.unit
20591 );
20592 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20593 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
20594 },
20595 selection: "custom"
20596 },
20597 {
20598 name: OPERATOR_OVER,
20599 /* translators: DataViews operator name */
20600 label: (0, import_i18n23.__)("Over"),
20601 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20602 (0, import_i18n23.sprintf)(
20603 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
20604 (0, import_i18n23.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
20605 filter.name,
20606 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
20607 ),
20608 filterTextWrappers
20609 ),
20610 filter(item, field, filterValue) {
20611 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
20612 return true;
20613 }
20614 const targetDate = getRelativeDate(
20615 filterValue.value,
20616 filterValue.unit
20617 );
20618 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
20619 return fieldValue < targetDate;
20620 },
20621 selection: "custom"
20622 },
20623 {
20624 name: OPERATOR_IS,
20625 /* translators: DataViews operator name */
20626 label: (0, import_i18n23.__)("Is"),
20627 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20628 (0, import_i18n23.sprintf)(
20629 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
20630 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
20631 filter.name,
20632 activeElements[0].label
20633 ),
20634 filterTextWrappers
20635 ),
20636 filter(item, field, filterValue) {
20637 return filterValue === field.getValue({ item }) || filterValue === void 0;
20638 },
20639 selection: "single"
20640 },
20641 {
20642 name: OPERATOR_IS_NOT,
20643 /* translators: DataViews operator name */
20644 label: (0, import_i18n23.__)("Is not"),
20645 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20646 (0, import_i18n23.sprintf)(
20647 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
20648 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
20649 filter.name,
20650 activeElements[0].label
20651 ),
20652 filterTextWrappers
20653 ),
20654 filter(item, field, filterValue) {
20655 return filterValue !== field.getValue({ item });
20656 },
20657 selection: "single"
20658 },
20659 {
20660 name: OPERATOR_LESS_THAN,
20661 /* translators: DataViews operator name */
20662 label: (0, import_i18n23.__)("Less than"),
20663 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20664 (0, import_i18n23.sprintf)(
20665 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
20666 (0, import_i18n23.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
20667 filter.name,
20668 activeElements[0].label
20669 ),
20670 filterTextWrappers
20671 ),
20672 filter(item, field, filterValue) {
20673 if (filterValue === void 0) {
20674 return true;
20675 }
20676 const fieldValue = field.getValue({ item });
20677 return fieldValue < filterValue;
20678 },
20679 selection: "single"
20680 },
20681 {
20682 name: OPERATOR_GREATER_THAN,
20683 /* translators: DataViews operator name */
20684 label: (0, import_i18n23.__)("Greater than"),
20685 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20686 (0, import_i18n23.sprintf)(
20687 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
20688 (0, import_i18n23.__)(
20689 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
20690 ),
20691 filter.name,
20692 activeElements[0].label
20693 ),
20694 filterTextWrappers
20695 ),
20696 filter(item, field, filterValue) {
20697 if (filterValue === void 0) {
20698 return true;
20699 }
20700 const fieldValue = field.getValue({ item });
20701 return fieldValue > filterValue;
20702 },
20703 selection: "single"
20704 },
20705 {
20706 name: OPERATOR_LESS_THAN_OR_EQUAL,
20707 /* translators: DataViews operator name */
20708 label: (0, import_i18n23.__)("Less than or equal"),
20709 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20710 (0, import_i18n23.sprintf)(
20711 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
20712 (0, import_i18n23.__)(
20713 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
20714 ),
20715 filter.name,
20716 activeElements[0].label
20717 ),
20718 filterTextWrappers
20719 ),
20720 filter(item, field, filterValue) {
20721 if (filterValue === void 0) {
20722 return true;
20723 }
20724 const fieldValue = field.getValue({ item });
20725 return fieldValue <= filterValue;
20726 },
20727 selection: "single"
20728 },
20729 {
20730 name: OPERATOR_GREATER_THAN_OR_EQUAL,
20731 /* translators: DataViews operator name */
20732 label: (0, import_i18n23.__)("Greater than or equal"),
20733 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20734 (0, import_i18n23.sprintf)(
20735 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
20736 (0, import_i18n23.__)(
20737 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
20738 ),
20739 filter.name,
20740 activeElements[0].label
20741 ),
20742 filterTextWrappers
20743 ),
20744 filter(item, field, filterValue) {
20745 if (filterValue === void 0) {
20746 return true;
20747 }
20748 const fieldValue = field.getValue({ item });
20749 return fieldValue >= filterValue;
20750 },
20751 selection: "single"
20752 },
20753 {
20754 name: OPERATOR_BEFORE,
20755 /* translators: DataViews operator name */
20756 label: (0, import_i18n23.__)("Before"),
20757 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20758 (0, import_i18n23.sprintf)(
20759 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
20760 (0, import_i18n23.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
20761 filter.name,
20762 activeElements[0].label
20763 ),
20764 filterTextWrappers
20765 ),
20766 filter(item, field, filterValue) {
20767 if (filterValue === void 0) {
20768 return true;
20769 }
20770 const filterDate = (0, import_date.getDate)(filterValue);
20771 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20772 return fieldDate < filterDate;
20773 },
20774 selection: "single"
20775 },
20776 {
20777 name: OPERATOR_AFTER,
20778 /* translators: DataViews operator name */
20779 label: (0, import_i18n23.__)("After"),
20780 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20781 (0, import_i18n23.sprintf)(
20782 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
20783 (0, import_i18n23.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
20784 filter.name,
20785 activeElements[0].label
20786 ),
20787 filterTextWrappers
20788 ),
20789 filter(item, field, filterValue) {
20790 if (filterValue === void 0) {
20791 return true;
20792 }
20793 const filterDate = (0, import_date.getDate)(filterValue);
20794 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20795 return fieldDate > filterDate;
20796 },
20797 selection: "single"
20798 },
20799 {
20800 name: OPERATOR_BEFORE_INC,
20801 /* translators: DataViews operator name */
20802 label: (0, import_i18n23.__)("Before (inc)"),
20803 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20804 (0, import_i18n23.sprintf)(
20805 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
20806 (0, import_i18n23.__)(
20807 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
20808 ),
20809 filter.name,
20810 activeElements[0].label
20811 ),
20812 filterTextWrappers
20813 ),
20814 filter(item, field, filterValue) {
20815 if (filterValue === void 0) {
20816 return true;
20817 }
20818 const filterDate = (0, import_date.getDate)(filterValue);
20819 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20820 return fieldDate <= filterDate;
20821 },
20822 selection: "single"
20823 },
20824 {
20825 name: OPERATOR_AFTER_INC,
20826 /* translators: DataViews operator name */
20827 label: (0, import_i18n23.__)("After (inc)"),
20828 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20829 (0, import_i18n23.sprintf)(
20830 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
20831 (0, import_i18n23.__)(
20832 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
20833 ),
20834 filter.name,
20835 activeElements[0].label
20836 ),
20837 filterTextWrappers
20838 ),
20839 filter(item, field, filterValue) {
20840 if (filterValue === void 0) {
20841 return true;
20842 }
20843 const filterDate = (0, import_date.getDate)(filterValue);
20844 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20845 return fieldDate >= filterDate;
20846 },
20847 selection: "single"
20848 },
20849 {
20850 name: OPERATOR_CONTAINS,
20851 /* translators: DataViews operator name */
20852 label: (0, import_i18n23.__)("Contains"),
20853 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20854 (0, import_i18n23.sprintf)(
20855 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
20856 (0, import_i18n23.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
20857 filter.name,
20858 activeElements[0].label
20859 ),
20860 filterTextWrappers
20861 ),
20862 filter(item, field, filterValue) {
20863 if (filterValue === void 0) {
20864 return true;
20865 }
20866 const fieldValue = field.getValue({ item });
20867 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
20868 },
20869 selection: "single"
20870 },
20871 {
20872 name: OPERATOR_NOT_CONTAINS,
20873 /* translators: DataViews operator name */
20874 label: (0, import_i18n23.__)("Doesn't contain"),
20875 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20876 (0, import_i18n23.sprintf)(
20877 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
20878 (0, import_i18n23.__)(
20879 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
20880 ),
20881 filter.name,
20882 activeElements[0].label
20883 ),
20884 filterTextWrappers
20885 ),
20886 filter(item, field, filterValue) {
20887 if (filterValue === void 0) {
20888 return true;
20889 }
20890 const fieldValue = field.getValue({ item });
20891 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
20892 },
20893 selection: "single"
20894 },
20895 {
20896 name: OPERATOR_STARTS_WITH,
20897 /* translators: DataViews operator name */
20898 label: (0, import_i18n23.__)("Starts with"),
20899 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20900 (0, import_i18n23.sprintf)(
20901 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
20902 (0, import_i18n23.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
20903 filter.name,
20904 activeElements[0].label
20905 ),
20906 filterTextWrappers
20907 ),
20908 filter(item, field, filterValue) {
20909 if (filterValue === void 0) {
20910 return true;
20911 }
20912 const fieldValue = field.getValue({ item });
20913 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
20914 },
20915 selection: "single"
20916 },
20917 {
20918 name: OPERATOR_ON,
20919 /* translators: DataViews operator name */
20920 label: (0, import_i18n23.__)("On"),
20921 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20922 (0, import_i18n23.sprintf)(
20923 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
20924 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
20925 filter.name,
20926 activeElements[0].label
20927 ),
20928 filterTextWrappers
20929 ),
20930 filter(item, field, filterValue) {
20931 if (filterValue === void 0) {
20932 return true;
20933 }
20934 const filterDate = (0, import_date.getDate)(filterValue);
20935 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20936 return filterDate.getTime() === fieldDate.getTime();
20937 },
20938 selection: "single"
20939 },
20940 {
20941 name: OPERATOR_NOT_ON,
20942 /* translators: DataViews operator name */
20943 label: (0, import_i18n23.__)("Not on"),
20944 filterText: (filter, activeElements) => (0, import_element42.createInterpolateElement)(
20945 (0, import_i18n23.sprintf)(
20946 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
20947 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
20948 filter.name,
20949 activeElements[0].label
20950 ),
20951 filterTextWrappers
20952 ),
20953 filter(item, field, filterValue) {
20954 if (filterValue === void 0) {
20955 return true;
20956 }
20957 const filterDate = (0, import_date.getDate)(filterValue);
20958 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
20959 return filterDate.getTime() !== fieldDate.getTime();
20960 },
20961 selection: "single"
20962 }
20963 ];
20964 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
20965 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
20966 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
20967 (op) => op.name === name
20968 );
20969 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
20970
20971 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
20972 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
20973 var ENTER = "Enter";
20974 var SPACE = " ";
20975 var FilterText = ({
20976 activeElements,
20977 filterInView,
20978 filter
20979 }) => {
20980 if (activeElements === void 0 || activeElements.length === 0) {
20981 return filter.name;
20982 }
20983 const operator = getOperatorByName(filterInView?.operator);
20984 if (operator !== void 0) {
20985 return operator.filterText(filter, activeElements);
20986 }
20987 return (0, import_i18n24.sprintf)(
20988 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
20989 (0, import_i18n24.__)("Unknown status for %1$s"),
20990 filter.name
20991 );
20992 };
20993 function OperatorSelector({
20994 filter,
20995 view,
20996 onChangeView
20997 }) {
20998 const operatorOptions = filter.operators?.map((operator) => ({
20999 value: operator,
21000 label: getOperatorByName(operator)?.label || operator
21001 }));
21002 const currentFilter = view.filters?.find(
21003 (_filter) => _filter.field === filter.field
21004 );
21005 const value = currentFilter?.operator || filter.operators[0];
21006 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
21007 Stack,
21008 {
21009 direction: "row",
21010 gap: "sm",
21011 justify: "flex-start",
21012 className: "dataviews-filters__summary-operators-container",
21013 align: "center",
21014 children: [
21015 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
21016 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21017 import_components20.SelectControl,
21018 {
21019 className: "dataviews-filters__summary-operators-filter-select",
21020 label: (0, import_i18n24.__)("Conditions"),
21021 value,
21022 options: operatorOptions,
21023 onChange: (newValue) => {
21024 const newOperator = newValue;
21025 const currentOperator = currentFilter?.operator;
21026 const newFilters = currentFilter ? [
21027 ...(view.filters ?? []).map(
21028 (_filter) => {
21029 if (_filter.field === filter.field) {
21030 const currentOpSelectionModel = getOperatorByName(
21031 currentOperator
21032 )?.selection;
21033 const newOpSelectionModel = getOperatorByName(
21034 newOperator
21035 )?.selection;
21036 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
21037 currentOpSelectionModel,
21038 newOpSelectionModel
21039 ].includes("custom");
21040 return {
21041 ..._filter,
21042 value: shouldResetValue ? void 0 : _filter.value,
21043 operator: newOperator
21044 };
21045 }
21046 return _filter;
21047 }
21048 )
21049 ] : [
21050 ...view.filters ?? [],
21051 {
21052 field: filter.field,
21053 operator: newOperator,
21054 value: void 0
21055 }
21056 ];
21057 onChangeView({
21058 ...view,
21059 page: 1,
21060 filters: newFilters
21061 });
21062 },
21063 size: "small",
21064 variant: "minimal",
21065 hideLabelFromVision: true
21066 }
21067 )
21068 ]
21069 }
21070 );
21071 }
21072 function Filter({
21073 addFilterRef,
21074 openedFilter,
21075 fields,
21076 ...commonProps
21077 }) {
21078 const toggleRef = (0, import_element43.useRef)(null);
21079 const { filter, view, onChangeView } = commonProps;
21080 const filterInView = view.filters?.find(
21081 (f2) => f2.field === filter.field
21082 );
21083 let activeElements = [];
21084 const field = (0, import_element43.useMemo)(() => {
21085 const currentField = fields.find((f2) => f2.id === filter.field);
21086 if (currentField) {
21087 return {
21088 ...currentField,
21089 // Configure getValue as if Item was a plain object.
21090 // See related input-widget.tsx
21091 getValue: ({ item }) => item[currentField.id]
21092 };
21093 }
21094 return currentField;
21095 }, [fields, filter.field]);
21096 const { elements } = useElements({
21097 elements: filter.elements,
21098 getElements: filter.getElements
21099 });
21100 if (elements.length > 0) {
21101 activeElements = elements.filter((element) => {
21102 if (filter.singleSelection) {
21103 return element.value === filterInView?.value;
21104 }
21105 return filterInView?.value?.includes(element.value);
21106 });
21107 } else if (Array.isArray(filterInView?.value)) {
21108 const label = filterInView.value.map((v2) => {
21109 const formattedValue = field?.getValueFormatted({
21110 item: { [field.id]: v2 },
21111 field
21112 });
21113 return formattedValue || String(v2);
21114 });
21115 activeElements = [
21116 {
21117 value: filterInView.value,
21118 // @ts-ignore
21119 label
21120 }
21121 ];
21122 } else if (typeof filterInView?.value === "object") {
21123 activeElements = [
21124 { value: filterInView.value, label: filterInView.value }
21125 ];
21126 } else if (filterInView?.value !== void 0) {
21127 const label = field !== void 0 ? field.getValueFormatted({
21128 item: { [field.id]: filterInView.value },
21129 field
21130 }) : String(filterInView.value);
21131 activeElements = [
21132 {
21133 value: filterInView.value,
21134 label
21135 }
21136 ];
21137 }
21138 const isPrimary = filter.isPrimary;
21139 const isLocked = filterInView?.isLocked;
21140 const hasValues = !isLocked && filterInView?.value !== void 0;
21141 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
21142 const resetOrRemoveLabel = isPrimary ? (0, import_i18n24.__)("Reset") : (0, import_i18n24.__)("Remove");
21143 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21144 import_components20.Dropdown,
21145 {
21146 defaultOpen: openedFilter === filter.field,
21147 contentClassName: "dataviews-filters__summary-popover",
21148 popoverProps: { placement: "bottom-start", role: "dialog" },
21149 onClose: () => {
21150 toggleRef.current?.focus();
21151 },
21152 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
21153 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(tooltip_exports.Root, { children: [
21154 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21155 tooltip_exports.Trigger,
21156 {
21157 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21158 "div",
21159 {
21160 className: clsx_default(
21161 "dataviews-filters__summary-chip",
21162 {
21163 "has-reset": canResetOrRemove,
21164 "has-values": hasValues,
21165 "is-not-clickable": isLocked
21166 }
21167 ),
21168 role: "button",
21169 tabIndex: isLocked ? -1 : 0,
21170 onClick: () => {
21171 if (!isLocked) {
21172 onToggle();
21173 }
21174 },
21175 onKeyDown: (event) => {
21176 if (!isLocked && [ENTER, SPACE].includes(
21177 event.key
21178 )) {
21179 onToggle();
21180 event.preventDefault();
21181 }
21182 },
21183 "aria-disabled": isLocked,
21184 "aria-pressed": isOpen,
21185 "aria-expanded": isOpen,
21186 ref: toggleRef,
21187 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21188 FilterText,
21189 {
21190 activeElements,
21191 filterInView,
21192 filter
21193 }
21194 )
21195 }
21196 )
21197 }
21198 ),
21199 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(tooltip_exports.Popup, { children: (0, import_i18n24.sprintf)(
21200 /* translators: 1: Filter name. */
21201 (0, import_i18n24.__)("Filter by: %1$s"),
21202 filter.name.toLowerCase()
21203 ) })
21204 ] }),
21205 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(tooltip_exports.Root, { children: [
21206 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21207 tooltip_exports.Trigger,
21208 {
21209 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21210 "button",
21211 {
21212 className: clsx_default(
21213 "dataviews-filters__summary-chip-remove",
21214 { "has-values": hasValues }
21215 ),
21216 "aria-label": resetOrRemoveLabel,
21217 onClick: () => {
21218 onChangeView({
21219 ...view,
21220 page: 1,
21221 filters: view.filters?.filter(
21222 (_filter) => _filter.field !== filter.field
21223 )
21224 });
21225 if (!isPrimary) {
21226 addFilterRef.current?.focus();
21227 } else {
21228 toggleRef.current?.focus();
21229 }
21230 },
21231 children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Icon, { icon: close_small_default })
21232 }
21233 )
21234 }
21235 ),
21236 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(tooltip_exports.Popup, { children: resetOrRemoveLabel })
21237 ] })
21238 ] }),
21239 renderContent: () => {
21240 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
21241 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(OperatorSelector, { ...commonProps }),
21242 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
21243 SearchWidget,
21244 {
21245 ...commonProps,
21246 filter: {
21247 ...commonProps.filter,
21248 elements
21249 }
21250 }
21251 ) : /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(InputWidget, { ...commonProps, fields })
21252 ] });
21253 }
21254 }
21255 );
21256 }
21257
21258 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
21259 var import_components21 = __toESM(require_components(), 1);
21260 var import_i18n25 = __toESM(require_i18n(), 1);
21261 var import_element44 = __toESM(require_element(), 1);
21262 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
21263 var { Menu: Menu4 } = unlock3(import_components21.privateApis);
21264 function AddFilterMenu({
21265 filters,
21266 view,
21267 onChangeView,
21268 setOpenedFilter,
21269 triggerProps
21270 }) {
21271 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21272 return /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Menu4, { children: [
21273 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Menu4.TriggerButton, { ...triggerProps }),
21274 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
21275 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21276 Menu4.Item,
21277 {
21278 onClick: () => {
21279 setOpenedFilter(filter.field);
21280 onChangeView({
21281 ...view,
21282 page: 1,
21283 filters: [
21284 ...view.filters || [],
21285 {
21286 field: filter.field,
21287 value: void 0,
21288 operator: filter.operators[0]
21289 }
21290 ]
21291 });
21292 },
21293 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Menu4.ItemLabel, { children: filter.name })
21294 },
21295 filter.field
21296 );
21297 }) })
21298 ] });
21299 }
21300 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
21301 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
21302 return null;
21303 }
21304 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
21305 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21306 AddFilterMenu,
21307 {
21308 triggerProps: {
21309 render: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
21310 import_components21.Button,
21311 {
21312 accessibleWhenDisabled: true,
21313 size: "compact",
21314 className: "dataviews-filters-button",
21315 variant: "tertiary",
21316 disabled: !inactiveFilters.length,
21317 ref
21318 }
21319 ),
21320 children: (0, import_i18n25.__)("Add filter")
21321 },
21322 ...{ filters, view, onChangeView, setOpenedFilter }
21323 }
21324 );
21325 }
21326 var add_filter_default = (0, import_element44.forwardRef)(AddFilter);
21327
21328 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
21329 var import_components22 = __toESM(require_components(), 1);
21330 var import_i18n26 = __toESM(require_i18n(), 1);
21331 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
21332 function ResetFilter({
21333 filters,
21334 view,
21335 onChangeView
21336 }) {
21337 const isPrimary = (field) => filters.some(
21338 (_filter) => _filter.field === field && _filter.isPrimary
21339 );
21340 const isDisabled = !view.search && !view.filters?.some(
21341 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
21342 );
21343 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
21344 import_components22.Button,
21345 {
21346 disabled: isDisabled,
21347 accessibleWhenDisabled: true,
21348 size: "compact",
21349 variant: "tertiary",
21350 className: "dataviews-filters__reset-button",
21351 onClick: () => {
21352 onChangeView({
21353 ...view,
21354 page: 1,
21355 search: "",
21356 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
21357 });
21358 },
21359 children: (0, import_i18n26.__)("Reset")
21360 }
21361 );
21362 }
21363
21364 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
21365 var import_element45 = __toESM(require_element(), 1);
21366 function useFilters(fields, view) {
21367 return (0, import_element45.useMemo)(() => {
21368 const filters = [];
21369 fields.forEach((field) => {
21370 if (field.filterBy === false || !field.hasElements && !field.Edit) {
21371 return;
21372 }
21373 const operators = field.filterBy.operators;
21374 const isPrimary = !!field.filterBy?.isPrimary;
21375 const isLocked = view.filters?.some(
21376 (f2) => f2.field === field.id && !!f2.isLocked
21377 ) ?? false;
21378 filters.push({
21379 field: field.id,
21380 name: field.label,
21381 elements: field.elements,
21382 getElements: field.getElements,
21383 hasElements: field.hasElements,
21384 singleSelection: operators.some(
21385 (op) => isSingleSelectionOperator(op)
21386 ),
21387 operators,
21388 isVisible: isLocked || isPrimary || !!view.filters?.some(
21389 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
21390 ),
21391 isPrimary,
21392 isLocked
21393 });
21394 });
21395 filters.sort((a2, b2) => {
21396 if (a2.isLocked && !b2.isLocked) {
21397 return -1;
21398 }
21399 if (!a2.isLocked && b2.isLocked) {
21400 return 1;
21401 }
21402 if (a2.isPrimary && !b2.isPrimary) {
21403 return -1;
21404 }
21405 if (!a2.isPrimary && b2.isPrimary) {
21406 return 1;
21407 }
21408 return a2.name.localeCompare(b2.name);
21409 });
21410 return filters;
21411 }, [fields, view]);
21412 }
21413 var use_filters_default = useFilters;
21414
21415 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
21416 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
21417 function Filters({ className }) {
21418 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element46.useContext)(dataviews_context_default);
21419 const addFilterRef = (0, import_element46.useRef)(null);
21420 const filters = use_filters_default(fields, view);
21421 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21422 add_filter_default,
21423 {
21424 filters,
21425 view,
21426 onChangeView,
21427 ref: addFilterRef,
21428 setOpenedFilter
21429 },
21430 "add-filter"
21431 );
21432 const visibleFilters = filters.filter((filter) => filter.isVisible);
21433 if (visibleFilters.length === 0) {
21434 return null;
21435 }
21436 const filterComponents = [
21437 ...visibleFilters.map((filter) => {
21438 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21439 Filter,
21440 {
21441 filter,
21442 view,
21443 fields,
21444 onChangeView,
21445 addFilterRef,
21446 openedFilter
21447 },
21448 filter.field
21449 );
21450 }),
21451 addFilter
21452 ];
21453 filterComponents.push(
21454 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21455 ResetFilter,
21456 {
21457 filters,
21458 view,
21459 onChangeView
21460 },
21461 "reset-filters"
21462 )
21463 );
21464 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
21465 Stack,
21466 {
21467 direction: "row",
21468 justify: "flex-start",
21469 gap: "sm",
21470 style: { width: "fit-content" },
21471 wrap: "wrap",
21472 className,
21473 children: filterComponents
21474 }
21475 );
21476 }
21477 var filters_default = (0, import_element46.memo)(Filters);
21478
21479 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
21480 var import_element47 = __toESM(require_element(), 1);
21481 var import_components23 = __toESM(require_components(), 1);
21482 var import_i18n27 = __toESM(require_i18n(), 1);
21483 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
21484 function FiltersToggle() {
21485 const {
21486 filters,
21487 view,
21488 onChangeView,
21489 setOpenedFilter,
21490 isShowingFilter,
21491 setIsShowingFilter
21492 } = (0, import_element47.useContext)(dataviews_context_default);
21493 const buttonRef = (0, import_element47.useRef)(null);
21494 const onChangeViewWithFilterVisibility = (0, import_element47.useCallback)(
21495 (_view) => {
21496 onChangeView(_view);
21497 setIsShowingFilter(true);
21498 },
21499 [onChangeView, setIsShowingFilter]
21500 );
21501 if (filters.length === 0) {
21502 return null;
21503 }
21504 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
21505 const addFilterButtonProps = {
21506 label: (0, import_i18n27.__)("Add filter"),
21507 "aria-expanded": false,
21508 isPressed: false
21509 };
21510 const toggleFiltersButtonProps = {
21511 label: (0, import_i18n27._x)("Filter", "verb"),
21512 "aria-expanded": isShowingFilter,
21513 isPressed: isShowingFilter,
21514 onClick: () => {
21515 if (!isShowingFilter) {
21516 setOpenedFilter(null);
21517 }
21518 setIsShowingFilter(!isShowingFilter);
21519 }
21520 };
21521 const hasPrimaryOrLockedFilters = filters.some(
21522 (filter) => filter.isPrimary || filter.isLocked
21523 );
21524 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21525 import_components23.Button,
21526 {
21527 ref: buttonRef,
21528 className: "dataviews-filters__visibility-toggle",
21529 size: "compact",
21530 icon: funnel_default,
21531 disabled: hasPrimaryOrLockedFilters,
21532 accessibleWhenDisabled: true,
21533 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
21534 }
21535 );
21536 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21537 AddFilterMenu,
21538 {
21539 filters,
21540 view,
21541 onChangeView: onChangeViewWithFilterVisibility,
21542 setOpenedFilter,
21543 triggerProps: { render: buttonComponent }
21544 }
21545 ) : /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
21546 FilterVisibilityToggle,
21547 {
21548 buttonRef,
21549 filtersCount: view.filters?.length,
21550 children: buttonComponent
21551 }
21552 ) });
21553 }
21554 function FilterVisibilityToggle({
21555 buttonRef,
21556 filtersCount,
21557 children
21558 }) {
21559 (0, import_element47.useEffect)(
21560 () => () => {
21561 buttonRef.current?.focus();
21562 },
21563 [buttonRef]
21564 );
21565 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_jsx_runtime78.Fragment, { children: [
21566 children,
21567 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
21568 ] });
21569 }
21570 var toggle_default = FiltersToggle;
21571
21572 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
21573 var import_element48 = __toESM(require_element(), 1);
21574 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
21575 function FiltersToggled(props) {
21576 const { isShowingFilter } = (0, import_element48.useContext)(dataviews_context_default);
21577 if (!isShowingFilter) {
21578 return null;
21579 }
21580 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(filters_default, { ...props });
21581 }
21582 var filters_toggled_default = FiltersToggled;
21583
21584 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
21585 var import_element49 = __toESM(require_element(), 1);
21586 var import_components24 = __toESM(require_components(), 1);
21587 var import_i18n28 = __toESM(require_i18n(), 1);
21588 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
21589 function DataViewsLayout({ className }) {
21590 const {
21591 actions = [],
21592 data,
21593 fields,
21594 getItemId,
21595 getItemLevel,
21596 hasInitiallyLoaded,
21597 isLoading,
21598 view,
21599 onChangeView,
21600 selection,
21601 onChangeSelection,
21602 setOpenedFilter,
21603 onClickItem,
21604 isItemClickable,
21605 renderItemLink,
21606 defaultLayouts,
21607 containerRef,
21608 empty = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: (0, import_i18n28.__)("No results") })
21609 } = (0, import_element49.useContext)(dataviews_context_default);
21610 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
21611 delay: 200
21612 });
21613 if (!hasInitiallyLoaded) {
21614 if (!isDelayedInitialLoading) {
21615 return null;
21616 }
21617 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_components24.Spinner, {}) }) });
21618 }
21619 const ViewComponent = VIEW_LAYOUTS.find(
21620 (v2) => v2.type === view.type && defaultLayouts[v2.type]
21621 )?.component;
21622 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
21623 ViewComponent,
21624 {
21625 className,
21626 actions,
21627 data,
21628 fields,
21629 getItemId,
21630 getItemLevel,
21631 isLoading,
21632 onChangeView,
21633 onChangeSelection,
21634 selection,
21635 setOpenedFilter,
21636 onClickItem,
21637 renderItemLink,
21638 isItemClickable,
21639 view,
21640 empty
21641 }
21642 ) });
21643 }
21644
21645 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
21646 var import_element50 = __toESM(require_element(), 1);
21647 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
21648 var EMPTY_ARRAY5 = [];
21649 function DataViewsFooter() {
21650 const {
21651 view,
21652 paginationInfo: { totalItems = 0, totalPages },
21653 data,
21654 actions = EMPTY_ARRAY5,
21655 isLoading,
21656 hasInitiallyLoaded
21657 } = (0, import_element50.useContext)(dataviews_context_default);
21658 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
21659 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
21660 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
21661 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
21662 return null;
21663 }
21664 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
21665 "div",
21666 {
21667 className: "dataviews-footer",
21668 inert: isRefreshing ? "true" : void 0,
21669 children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
21670 Stack,
21671 {
21672 direction: "row",
21673 justify: "end",
21674 align: "center",
21675 className: clsx_default("dataviews-footer__content", {
21676 "is-refreshing": isDelayedRefreshing
21677 }),
21678 gap: "sm",
21679 children: [
21680 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(BulkActionsFooter, {}),
21681 /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(dataviews_pagination_default, {})
21682 ]
21683 }
21684 )
21685 }
21686 );
21687 }
21688
21689 // packages/dataviews/build-module/components/dataviews-search/index.mjs
21690 var import_i18n29 = __toESM(require_i18n(), 1);
21691 var import_element51 = __toESM(require_element(), 1);
21692 var import_components25 = __toESM(require_components(), 1);
21693 var import_compose9 = __toESM(require_compose(), 1);
21694 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
21695 var DataViewsSearch = (0, import_element51.memo)(function Search({ label }) {
21696 const { view, onChangeView } = (0, import_element51.useContext)(dataviews_context_default);
21697 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
21698 view.search
21699 );
21700 (0, import_element51.useEffect)(() => {
21701 if (view.search !== debouncedSearch) {
21702 setSearch(view.search ?? "");
21703 }
21704 }, [view.search, setSearch]);
21705 const onChangeViewRef = (0, import_element51.useRef)(onChangeView);
21706 const viewRef = (0, import_element51.useRef)(view);
21707 (0, import_element51.useEffect)(() => {
21708 onChangeViewRef.current = onChangeView;
21709 viewRef.current = view;
21710 }, [onChangeView, view]);
21711 (0, import_element51.useEffect)(() => {
21712 if (debouncedSearch !== viewRef.current?.search) {
21713 onChangeViewRef.current({
21714 ...viewRef.current,
21715 page: view.page ? 1 : void 0,
21716 startPosition: view.startPosition ? 1 : void 0,
21717 search: debouncedSearch
21718 });
21719 }
21720 }, [debouncedSearch]);
21721 const searchLabel = label || (0, import_i18n29.__)("Search");
21722 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
21723 import_components25.SearchControl,
21724 {
21725 className: "dataviews-search",
21726 onChange: setSearch,
21727 value: search,
21728 label: searchLabel,
21729 placeholder: searchLabel,
21730 size: "compact"
21731 }
21732 );
21733 });
21734 var dataviews_search_default = DataViewsSearch;
21735
21736 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
21737 var import_components26 = __toESM(require_components(), 1);
21738 var import_i18n30 = __toESM(require_i18n(), 1);
21739 var import_element52 = __toESM(require_element(), 1);
21740 var import_warning = __toESM(require_warning(), 1);
21741 var import_compose10 = __toESM(require_compose(), 1);
21742 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
21743 var { Menu: Menu5 } = unlock3(import_components26.privateApis);
21744 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
21745 className: "dataviews-config__popover",
21746 placement: "bottom-end",
21747 offset: 9
21748 };
21749 function ViewTypeMenu() {
21750 const { view, onChangeView, defaultLayouts } = (0, import_element52.useContext)(dataviews_context_default);
21751 const availableLayouts = Object.keys(defaultLayouts);
21752 if (availableLayouts.length <= 1) {
21753 return null;
21754 }
21755 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
21756 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Menu5, { children: [
21757 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21758 Menu5.TriggerButton,
21759 {
21760 render: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21761 import_components26.Button,
21762 {
21763 size: "compact",
21764 icon: activeView?.icon,
21765 label: (0, import_i18n30.__)("Layout")
21766 }
21767 )
21768 }
21769 ),
21770 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
21771 const config = VIEW_LAYOUTS.find(
21772 (v2) => v2.type === layout
21773 );
21774 if (!config) {
21775 return null;
21776 }
21777 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21778 Menu5.RadioItem,
21779 {
21780 value: layout,
21781 name: "view-actions-available-view",
21782 checked: layout === view.type,
21783 hideOnClick: true,
21784 onChange: (e2) => {
21785 switch (e2.target.value) {
21786 case "list":
21787 case "grid":
21788 case "table":
21789 case "pickerGrid":
21790 case "pickerTable":
21791 case "activity":
21792 const viewWithoutLayout = { ...view };
21793 if ("layout" in viewWithoutLayout) {
21794 delete viewWithoutLayout.layout;
21795 }
21796 return onChangeView({
21797 ...viewWithoutLayout,
21798 type: e2.target.value,
21799 ...defaultLayouts[e2.target.value]
21800 });
21801 }
21802 (0, import_warning.default)("Invalid dataview");
21803 },
21804 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(Menu5.ItemLabel, { children: config.label })
21805 },
21806 layout
21807 );
21808 }) })
21809 ] });
21810 }
21811 function SortFieldControl() {
21812 const { view, fields, onChangeView } = (0, import_element52.useContext)(dataviews_context_default);
21813 const orderOptions = (0, import_element52.useMemo)(() => {
21814 const sortableFields = fields.filter(
21815 (field) => field.enableSorting !== false
21816 );
21817 return sortableFields.map((field) => {
21818 return {
21819 label: field.label,
21820 value: field.id
21821 };
21822 });
21823 }, [fields]);
21824 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21825 import_components26.SelectControl,
21826 {
21827 __next40pxDefaultSize: true,
21828 label: (0, import_i18n30.__)("Sort by"),
21829 value: view.sort?.field,
21830 options: orderOptions,
21831 onChange: (value) => {
21832 onChangeView({
21833 ...view,
21834 sort: {
21835 direction: view?.sort?.direction || "desc",
21836 field: value
21837 },
21838 showLevels: false
21839 });
21840 }
21841 }
21842 );
21843 }
21844 function SortDirectionControl() {
21845 const { view, fields, onChangeView } = (0, import_element52.useContext)(dataviews_context_default);
21846 const sortableFields = fields.filter(
21847 (field) => field.enableSorting !== false
21848 );
21849 if (sortableFields.length === 0) {
21850 return null;
21851 }
21852 let value = view.sort?.direction;
21853 if (!value && view.sort?.field) {
21854 value = "desc";
21855 }
21856 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21857 import_components26.__experimentalToggleGroupControl,
21858 {
21859 className: "dataviews-view-config__sort-direction",
21860 __next40pxDefaultSize: true,
21861 isBlock: true,
21862 label: (0, import_i18n30.__)("Order"),
21863 value,
21864 onChange: (newDirection) => {
21865 if (newDirection === "asc" || newDirection === "desc") {
21866 onChangeView({
21867 ...view,
21868 sort: {
21869 direction: newDirection,
21870 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
21871 fields.find(
21872 (field) => field.enableSorting !== false
21873 )?.id || ""
21874 },
21875 showLevels: false
21876 });
21877 return;
21878 }
21879 (0, import_warning.default)("Invalid direction");
21880 },
21881 children: SORTING_DIRECTIONS.map((direction) => {
21882 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21883 import_components26.__experimentalToggleGroupControlOptionIcon,
21884 {
21885 value: direction,
21886 icon: sortIcons[direction],
21887 label: sortLabels[direction]
21888 },
21889 direction
21890 );
21891 })
21892 }
21893 );
21894 }
21895 function ItemsPerPageControl() {
21896 const { view, config, onChangeView } = (0, import_element52.useContext)(dataviews_context_default);
21897 const { infiniteScrollEnabled } = view;
21898 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
21899 return null;
21900 }
21901 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21902 import_components26.__experimentalToggleGroupControl,
21903 {
21904 __next40pxDefaultSize: true,
21905 isBlock: true,
21906 label: (0, import_i18n30.__)("Items per page"),
21907 value: view.perPage || 10,
21908 disabled: !view?.sort?.field,
21909 onChange: (newItemsPerPage) => {
21910 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
21911 onChangeView({
21912 ...view,
21913 perPage: newItemsPerPageNumber,
21914 page: 1
21915 });
21916 },
21917 children: config.perPageSizes.map((value) => {
21918 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21919 import_components26.__experimentalToggleGroupControlOption,
21920 {
21921 value,
21922 label: value.toString()
21923 },
21924 value
21925 );
21926 })
21927 }
21928 );
21929 }
21930 function ResetViewButton() {
21931 const { onReset } = (0, import_element52.useContext)(dataviews_context_default);
21932 if (onReset === void 0) {
21933 return null;
21934 }
21935 const isDisabled = onReset === false;
21936 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21937 import_components26.Button,
21938 {
21939 variant: "tertiary",
21940 size: "compact",
21941 disabled: isDisabled,
21942 accessibleWhenDisabled: true,
21943 className: "dataviews-view-config__reset-button",
21944 onClick: () => {
21945 if (typeof onReset === "function") {
21946 onReset();
21947 }
21948 },
21949 children: (0, import_i18n30.__)("Reset view")
21950 }
21951 );
21952 }
21953 function DataviewsViewConfigDropdown() {
21954 const { view, onReset } = (0, import_element52.useContext)(dataviews_context_default);
21955 const popoverId = (0, import_compose10.useInstanceId)(
21956 _DataViewsViewConfig,
21957 "dataviews-view-config-dropdown"
21958 );
21959 const activeLayout = VIEW_LAYOUTS.find(
21960 (layout) => layout.type === view.type
21961 );
21962 const isModified = typeof onReset === "function";
21963 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21964 import_components26.Dropdown,
21965 {
21966 expandOnMobile: true,
21967 popoverProps: {
21968 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
21969 id: popoverId
21970 },
21971 renderToggle: ({ onToggle, isOpen }) => {
21972 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
21973 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21974 import_components26.Button,
21975 {
21976 size: "compact",
21977 icon: cog_default,
21978 label: (0, import_i18n30._x)(
21979 "View options",
21980 "View is used as a noun"
21981 ),
21982 onClick: onToggle,
21983 "aria-expanded": isOpen ? "true" : "false",
21984 "aria-controls": popoverId
21985 }
21986 ),
21987 isModified && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
21988 ] });
21989 },
21990 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
21991 import_components26.__experimentalDropdownContentWrapper,
21992 {
21993 paddingSize: "medium",
21994 className: "dataviews-config__popover-content-wrapper",
21995 children: /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
21996 Stack,
21997 {
21998 direction: "column",
21999 className: "dataviews-view-config",
22000 gap: "xl",
22001 children: [
22002 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22003 Stack,
22004 {
22005 direction: "row",
22006 justify: "space-between",
22007 align: "center",
22008 className: "dataviews-view-config__header",
22009 children: [
22010 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
22011 import_components26.__experimentalHeading,
22012 {
22013 level: 2,
22014 className: "dataviews-settings-section__title",
22015 children: (0, import_i18n30.__)("Appearance")
22016 }
22017 ),
22018 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ResetViewButton, {})
22019 ]
22020 }
22021 ),
22022 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22023 /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(
22024 Stack,
22025 {
22026 direction: "row",
22027 gap: "sm",
22028 className: "dataviews-view-config__sort-controls",
22029 children: [
22030 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SortFieldControl, {}),
22031 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(SortDirectionControl, {})
22032 ]
22033 }
22034 ),
22035 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(activeLayout.viewConfigOptions, {}),
22036 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ItemsPerPageControl, {}),
22037 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(PropertiesSection, {})
22038 ] })
22039 ]
22040 }
22041 )
22042 }
22043 )
22044 }
22045 );
22046 }
22047 function _DataViewsViewConfig() {
22048 return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [
22049 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(ViewTypeMenu, {}),
22050 /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(DataviewsViewConfigDropdown, {})
22051 ] });
22052 }
22053 var DataViewsViewConfig = (0, import_element52.memo)(_DataViewsViewConfig);
22054 var dataviews_view_config_default = DataViewsViewConfig;
22055
22056 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22057 var import_components27 = __toESM(require_components(), 1);
22058 var import_element53 = __toESM(require_element(), 1);
22059
22060 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
22061 function getCustomValidity(isValid2, validity) {
22062 let customValidity;
22063 if (isValid2?.required && validity?.required) {
22064 customValidity = validity?.required?.message ? validity.required : void 0;
22065 } else if (isValid2?.pattern && validity?.pattern) {
22066 customValidity = validity.pattern;
22067 } else if (isValid2?.min && validity?.min) {
22068 customValidity = validity.min;
22069 } else if (isValid2?.max && validity?.max) {
22070 customValidity = validity.max;
22071 } else if (isValid2?.minLength && validity?.minLength) {
22072 customValidity = validity.minLength;
22073 } else if (isValid2?.maxLength && validity?.maxLength) {
22074 customValidity = validity.maxLength;
22075 } else if (isValid2?.elements && validity?.elements) {
22076 customValidity = validity.elements;
22077 } else if (validity?.custom) {
22078 customValidity = validity.custom;
22079 }
22080 return customValidity;
22081 }
22082
22083 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
22084 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
22085 var { ValidatedCheckboxControl } = unlock3(import_components27.privateApis);
22086 function Checkbox({
22087 field,
22088 onChange,
22089 data,
22090 hideLabelFromVision,
22091 markWhenOptional,
22092 validity
22093 }) {
22094 const { getValue, setValue, label, description, isValid: isValid2 } = field;
22095 const disabled2 = field.isDisabled({ item: data, field });
22096 const onChangeControl = (0, import_element53.useCallback)(() => {
22097 onChange(
22098 setValue({ item: data, value: !getValue({ item: data }) })
22099 );
22100 }, [data, getValue, onChange, setValue]);
22101 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
22102 ValidatedCheckboxControl,
22103 {
22104 required: !!field.isValid?.required,
22105 markWhenOptional,
22106 customValidity: getCustomValidity(isValid2, validity),
22107 hidden: hideLabelFromVision,
22108 label,
22109 help: description,
22110 checked: getValue({ item: data }),
22111 onChange: onChangeControl,
22112 disabled: disabled2
22113 }
22114 );
22115 }
22116
22117 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
22118 var import_components28 = __toESM(require_components(), 1);
22119 var import_element54 = __toESM(require_element(), 1);
22120 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
22121 var { ValidatedComboboxControl } = unlock3(import_components28.privateApis);
22122 function Combobox3({
22123 data,
22124 field,
22125 onChange,
22126 hideLabelFromVision,
22127 validity
22128 }) {
22129 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
22130 const value = getValue({ item: data }) ?? "";
22131 const onChangeControl = (0, import_element54.useCallback)(
22132 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
22133 [data, onChange, setValue]
22134 );
22135 const { elements, isLoading } = useElements({
22136 elements: field.elements,
22137 getElements: field.getElements
22138 });
22139 if (isLoading) {
22140 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_components28.Spinner, {});
22141 }
22142 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
22143 ValidatedComboboxControl,
22144 {
22145 required: !!field.isValid?.required,
22146 customValidity: getCustomValidity(isValid2, validity),
22147 label,
22148 value,
22149 help: description,
22150 placeholder,
22151 options: elements,
22152 onChange: onChangeControl,
22153 hideLabelFromVision,
22154 allowReset: true,
22155 expandOnFocus: true
22156 }
22157 );
22158 }
22159
22160 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22161 var import_components30 = __toESM(require_components(), 1);
22162 var import_element57 = __toESM(require_element(), 1);
22163 var import_i18n32 = __toESM(require_i18n(), 1);
22164 var import_date3 = __toESM(require_date(), 1);
22165
22166 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
22167 var import_components29 = __toESM(require_components(), 1);
22168 var import_element55 = __toESM(require_element(), 1);
22169 var import_i18n31 = __toESM(require_i18n(), 1);
22170 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
22171 var TIME_UNITS_OPTIONS = {
22172 [OPERATOR_IN_THE_PAST]: [
22173 { value: "days", label: (0, import_i18n31.__)("Days") },
22174 { value: "weeks", label: (0, import_i18n31.__)("Weeks") },
22175 { value: "months", label: (0, import_i18n31.__)("Months") },
22176 { value: "years", label: (0, import_i18n31.__)("Years") }
22177 ],
22178 [OPERATOR_OVER]: [
22179 { value: "days", label: (0, import_i18n31.__)("Days ago") },
22180 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") },
22181 { value: "months", label: (0, import_i18n31.__)("Months ago") },
22182 { value: "years", label: (0, import_i18n31.__)("Years ago") }
22183 ]
22184 };
22185 function RelativeDateControl({
22186 className,
22187 data,
22188 field,
22189 onChange,
22190 hideLabelFromVision,
22191 operator
22192 }) {
22193 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
22194 const { id, label, description, getValue, setValue } = field;
22195 const disabled2 = field.isDisabled({ item: data, field });
22196 const fieldValue = getValue({ item: data });
22197 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
22198 const onChangeValue = (0, import_element55.useCallback)(
22199 (newValue) => onChange(
22200 setValue({
22201 item: data,
22202 value: { value: Number(newValue), unit }
22203 })
22204 ),
22205 [onChange, setValue, data, unit]
22206 );
22207 const onChangeUnit = (0, import_element55.useCallback)(
22208 (newUnit) => onChange(
22209 setValue({
22210 item: data,
22211 value: { value: relValue, unit: newUnit }
22212 })
22213 ),
22214 [onChange, setValue, data, relValue]
22215 );
22216 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22217 import_components29.BaseControl,
22218 {
22219 id,
22220 className: clsx_default(className, "dataviews-controls__relative-date"),
22221 label,
22222 hideLabelFromVision,
22223 help: description,
22224 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Stack, { direction: "row", gap: "sm", children: [
22225 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22226 import_components29.__experimentalNumberControl,
22227 {
22228 __next40pxDefaultSize: true,
22229 className: "dataviews-controls__relative-date-number",
22230 spinControls: "none",
22231 min: 1,
22232 step: 1,
22233 value: relValue,
22234 onChange: onChangeValue,
22235 disabled: disabled2
22236 }
22237 ),
22238 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
22239 import_components29.SelectControl,
22240 {
22241 className: "dataviews-controls__relative-date-unit",
22242 __next40pxDefaultSize: true,
22243 label: (0, import_i18n31.__)("Unit"),
22244 value: unit,
22245 options,
22246 onChange: onChangeUnit,
22247 hideLabelFromVision: true,
22248 disabled: disabled2
22249 }
22250 )
22251 ] })
22252 }
22253 );
22254 }
22255
22256 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
22257 var import_element56 = __toESM(require_element(), 1);
22258 function useDisabledDateMatchers(isValid2, parseDateFn) {
22259 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
22260 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
22261 const disabledMatchers = (0, import_element56.useMemo)(() => {
22262 const matchers = [];
22263 if (minConstraint) {
22264 const minDate = parseDateFn(minConstraint);
22265 if (minDate) {
22266 matchers.push({ before: minDate });
22267 }
22268 }
22269 if (maxConstraint) {
22270 const maxDate = parseDateFn(maxConstraint);
22271 if (maxDate) {
22272 matchers.push({ after: maxDate });
22273 }
22274 }
22275 return matchers.length > 0 ? matchers : void 0;
22276 }, [minConstraint, maxConstraint, parseDateFn]);
22277 return { minConstraint, maxConstraint, disabledMatchers };
22278 }
22279
22280 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
22281 var import_date2 = __toESM(require_date(), 1);
22282 function parseDateTime(dateTimeString) {
22283 if (!dateTimeString) {
22284 return null;
22285 }
22286 const parsed = (0, import_date2.getDate)(dateTimeString);
22287 return parsed && isValid(parsed) ? parsed : null;
22288 }
22289
22290 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
22291 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
22292 var { DateCalendar, ValidatedInputControl } = unlock3(import_components30.privateApis);
22293 var formatDateTime = (value) => {
22294 if (!value) {
22295 return "";
22296 }
22297 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
22298 };
22299 function CalendarDateTimeControl({
22300 data,
22301 field,
22302 onChange,
22303 hideLabelFromVision,
22304 markWhenOptional,
22305 validity,
22306 config
22307 }) {
22308 const { compact } = config || {};
22309 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
22310 const disabled2 = field.isDisabled({ item: data, field });
22311 const fieldValue = getValue({ item: data });
22312 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22313 const [calendarMonth, setCalendarMonth] = (0, import_element57.useState)(() => {
22314 const parsedDate = parseDateTime(value);
22315 return parsedDate || /* @__PURE__ */ new Date();
22316 });
22317 const inputControlRef = (0, import_element57.useRef)(null);
22318 const validationTimeoutRef = (0, import_element57.useRef)(void 0);
22319 const previousFocusRef = (0, import_element57.useRef)(null);
22320 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
22321 const onChangeCallback = (0, import_element57.useCallback)(
22322 (newValue) => onChange(setValue({ item: data, value: newValue })),
22323 [data, onChange, setValue]
22324 );
22325 (0, import_element57.useEffect)(() => {
22326 return () => {
22327 if (validationTimeoutRef.current) {
22328 clearTimeout(validationTimeoutRef.current);
22329 }
22330 };
22331 }, []);
22332 const onSelectDate = (0, import_element57.useCallback)(
22333 (newDate) => {
22334 let dateTimeValue;
22335 if (newDate) {
22336 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
22337 let wpTime;
22338 if (value) {
22339 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
22340 } else {
22341 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
22342 }
22343 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
22344 dateTimeValue = finalDateTime.toISOString();
22345 onChangeCallback(dateTimeValue);
22346 if (validationTimeoutRef.current) {
22347 clearTimeout(validationTimeoutRef.current);
22348 }
22349 } else {
22350 onChangeCallback(void 0);
22351 }
22352 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
22353 validationTimeoutRef.current = setTimeout(() => {
22354 if (inputControlRef.current) {
22355 inputControlRef.current.focus();
22356 inputControlRef.current.blur();
22357 onChangeCallback(dateTimeValue);
22358 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
22359 previousFocusRef.current.focus();
22360 }
22361 }
22362 }, 0);
22363 },
22364 [onChangeCallback, value]
22365 );
22366 const handleManualDateTimeChange = (0, import_element57.useCallback)(
22367 (newValue) => {
22368 if (newValue) {
22369 const dateTime = (0, import_date3.getDate)(newValue);
22370 onChangeCallback(dateTime.toISOString());
22371 const parsedDate = parseDateTime(dateTime.toISOString());
22372 if (parsedDate) {
22373 setCalendarMonth(parsedDate);
22374 }
22375 } else {
22376 onChangeCallback(void 0);
22377 }
22378 },
22379 [onChangeCallback]
22380 );
22381 const { format: fieldFormat } = field;
22382 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
22383 const {
22384 timezone: { string: timezoneString }
22385 } = (0, import_date3.getSettings)();
22386 let displayLabel = label;
22387 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
22388 displayLabel = `${label} (${(0, import_i18n32.__)("Required")})`;
22389 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
22390 displayLabel = `${label} (${(0, import_i18n32.__)("Optional")})`;
22391 }
22392 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22393 import_components30.BaseControl,
22394 {
22395 id,
22396 label: displayLabel,
22397 help: description,
22398 hideLabelFromVision,
22399 children: /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22400 /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22401 ValidatedInputControl,
22402 {
22403 ref: inputControlRef,
22404 __next40pxDefaultSize: true,
22405 required: !!isValid2?.required,
22406 customValidity: getCustomValidity(isValid2, validity),
22407 type: "datetime-local",
22408 label: (0, import_i18n32.__)("Date time"),
22409 hideLabelFromVision: true,
22410 value: formatDateTime(value),
22411 onChange: handleManualDateTimeChange,
22412 disabled: disabled2,
22413 min: minConstraint ? formatDateTime(minConstraint) : void 0,
22414 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
22415 }
22416 ),
22417 !compact && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22418 DateCalendar,
22419 {
22420 style: { width: "100%" },
22421 selected: value ? parseDateTime(value) || void 0 : void 0,
22422 onSelect: onSelectDate,
22423 month: calendarMonth,
22424 onMonthChange: setCalendarMonth,
22425 timeZone: timezoneString || void 0,
22426 weekStartsOn,
22427 disabled: disabled2 || disabledMatchers
22428 }
22429 )
22430 ] })
22431 }
22432 );
22433 }
22434 function DateTime({
22435 data,
22436 field,
22437 onChange,
22438 hideLabelFromVision,
22439 markWhenOptional,
22440 operator,
22441 validity,
22442 config
22443 }) {
22444 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
22445 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22446 RelativeDateControl,
22447 {
22448 className: "dataviews-controls__datetime",
22449 data,
22450 field,
22451 onChange,
22452 hideLabelFromVision,
22453 operator
22454 }
22455 );
22456 }
22457 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
22458 CalendarDateTimeControl,
22459 {
22460 data,
22461 field,
22462 onChange,
22463 hideLabelFromVision,
22464 markWhenOptional,
22465 validity,
22466 config
22467 }
22468 );
22469 }
22470
22471 // packages/dataviews/build-module/components/dataform-controls/date.mjs
22472 var import_components31 = __toESM(require_components(), 1);
22473 var import_element58 = __toESM(require_element(), 1);
22474 var import_i18n33 = __toESM(require_i18n(), 1);
22475 var import_date4 = __toESM(require_date(), 1);
22476 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
22477 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components31.privateApis);
22478 var DATE_PRESETS = [
22479 {
22480 id: "today",
22481 label: (0, import_i18n33.__)("Today"),
22482 getValue: () => (0, import_date4.getDate)(null)
22483 },
22484 {
22485 id: "yesterday",
22486 label: (0, import_i18n33.__)("Yesterday"),
22487 getValue: () => {
22488 const today = (0, import_date4.getDate)(null);
22489 return subDays(today, 1);
22490 }
22491 },
22492 {
22493 id: "past-week",
22494 label: (0, import_i18n33.__)("Past week"),
22495 getValue: () => {
22496 const today = (0, import_date4.getDate)(null);
22497 return subDays(today, 7);
22498 }
22499 },
22500 {
22501 id: "past-month",
22502 label: (0, import_i18n33.__)("Past month"),
22503 getValue: () => {
22504 const today = (0, import_date4.getDate)(null);
22505 return subMonths(today, 1);
22506 }
22507 }
22508 ];
22509 var DATE_RANGE_PRESETS = [
22510 {
22511 id: "last-7-days",
22512 label: (0, import_i18n33.__)("Last 7 days"),
22513 getValue: () => {
22514 const today = (0, import_date4.getDate)(null);
22515 return [subDays(today, 7), today];
22516 }
22517 },
22518 {
22519 id: "last-30-days",
22520 label: (0, import_i18n33.__)("Last 30 days"),
22521 getValue: () => {
22522 const today = (0, import_date4.getDate)(null);
22523 return [subDays(today, 30), today];
22524 }
22525 },
22526 {
22527 id: "month-to-date",
22528 label: (0, import_i18n33.__)("Month to date"),
22529 getValue: () => {
22530 const today = (0, import_date4.getDate)(null);
22531 return [startOfMonth(today), today];
22532 }
22533 },
22534 {
22535 id: "last-year",
22536 label: (0, import_i18n33.__)("Last year"),
22537 getValue: () => {
22538 const today = (0, import_date4.getDate)(null);
22539 return [subYears(today, 1), today];
22540 }
22541 },
22542 {
22543 id: "year-to-date",
22544 label: (0, import_i18n33.__)("Year to date"),
22545 getValue: () => {
22546 const today = (0, import_date4.getDate)(null);
22547 return [startOfYear(today), today];
22548 }
22549 }
22550 ];
22551 var parseDate = (dateString) => {
22552 if (!dateString) {
22553 return null;
22554 }
22555 const parsed = (0, import_date4.getDate)(dateString);
22556 return parsed && isValid(parsed) ? parsed : null;
22557 };
22558 var formatDate = (date) => {
22559 if (!date) {
22560 return "";
22561 }
22562 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
22563 };
22564 function ValidatedDateControl({
22565 field,
22566 validity,
22567 inputRefs,
22568 isTouched,
22569 setIsTouched,
22570 children
22571 }) {
22572 const { isValid: isValid2 } = field;
22573 const [customValidity, setCustomValidity] = (0, import_element58.useState)(void 0);
22574 const validateRefs = (0, import_element58.useCallback)(() => {
22575 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22576 for (const ref of refs) {
22577 const input = ref.current;
22578 if (input && !input.validity.valid) {
22579 setCustomValidity({
22580 type: "invalid",
22581 message: input.validationMessage
22582 });
22583 return;
22584 }
22585 }
22586 setCustomValidity(void 0);
22587 }, [inputRefs]);
22588 (0, import_element58.useEffect)(() => {
22589 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22590 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22591 for (const ref of refs) {
22592 const input = ref.current;
22593 if (input) {
22594 input.setCustomValidity(
22595 result?.type === "invalid" && result.message ? result.message : ""
22596 );
22597 }
22598 }
22599 }, [inputRefs, isValid2, validity]);
22600 (0, import_element58.useEffect)(() => {
22601 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
22602 const handleInvalid = (event) => {
22603 event.preventDefault();
22604 setIsTouched(true);
22605 };
22606 for (const ref of refs) {
22607 ref.current?.addEventListener("invalid", handleInvalid);
22608 }
22609 return () => {
22610 for (const ref of refs) {
22611 ref.current?.removeEventListener("invalid", handleInvalid);
22612 }
22613 };
22614 }, [inputRefs, setIsTouched]);
22615 (0, import_element58.useEffect)(() => {
22616 if (!isTouched) {
22617 return;
22618 }
22619 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
22620 if (result) {
22621 setCustomValidity(result);
22622 } else {
22623 validateRefs();
22624 }
22625 }, [isTouched, isValid2, validity, validateRefs]);
22626 const onBlur = (event) => {
22627 if (isTouched) {
22628 return;
22629 }
22630 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
22631 setIsTouched(true);
22632 }
22633 };
22634 return /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { onBlur, children: [
22635 children,
22636 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22637 "p",
22638 {
22639 className: clsx_default(
22640 "components-validated-control__indicator",
22641 customValidity.type === "invalid" ? "is-invalid" : void 0
22642 ),
22643 children: [
22644 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22645 import_components31.Icon,
22646 {
22647 className: "components-validated-control__indicator-icon",
22648 icon: error_default,
22649 size: 16,
22650 fill: "currentColor"
22651 }
22652 ),
22653 customValidity.message
22654 ]
22655 }
22656 ) })
22657 ] });
22658 }
22659 function CalendarDateControl({
22660 data,
22661 field,
22662 onChange,
22663 hideLabelFromVision,
22664 markWhenOptional,
22665 validity
22666 }) {
22667 const {
22668 id,
22669 label,
22670 description,
22671 setValue,
22672 getValue,
22673 isValid: isValid2,
22674 format: fieldFormat
22675 } = field;
22676 const disabled2 = field.isDisabled({ item: data, field });
22677 const [selectedPresetId, setSelectedPresetId] = (0, import_element58.useState)(
22678 null
22679 );
22680 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
22681 const fieldValue = getValue({ item: data });
22682 const value = typeof fieldValue === "string" ? fieldValue : void 0;
22683 const [calendarMonth, setCalendarMonth] = (0, import_element58.useState)(() => {
22684 const parsedDate = parseDate(value);
22685 return parsedDate || /* @__PURE__ */ new Date();
22686 });
22687 const [isTouched, setIsTouched] = (0, import_element58.useState)(false);
22688 const validityTargetRef = (0, import_element58.useRef)(null);
22689 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
22690 const onChangeCallback = (0, import_element58.useCallback)(
22691 (newValue) => onChange(setValue({ item: data, value: newValue })),
22692 [data, onChange, setValue]
22693 );
22694 const onSelectDate = (0, import_element58.useCallback)(
22695 (newDate) => {
22696 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
22697 onChangeCallback(dateValue);
22698 setSelectedPresetId(null);
22699 setIsTouched(true);
22700 },
22701 [onChangeCallback]
22702 );
22703 const handlePresetClick = (0, import_element58.useCallback)(
22704 (preset) => {
22705 const presetDate = preset.getValue();
22706 const dateValue = formatDate(presetDate);
22707 setCalendarMonth(presetDate);
22708 onChangeCallback(dateValue);
22709 setSelectedPresetId(preset.id);
22710 setIsTouched(true);
22711 },
22712 [onChangeCallback]
22713 );
22714 const handleManualDateChange = (0, import_element58.useCallback)(
22715 (newValue) => {
22716 onChangeCallback(newValue);
22717 if (newValue) {
22718 const parsedDate = parseDate(newValue);
22719 if (parsedDate) {
22720 setCalendarMonth(parsedDate);
22721 }
22722 }
22723 setSelectedPresetId(null);
22724 setIsTouched(true);
22725 },
22726 [onChangeCallback]
22727 );
22728 const {
22729 timezone: { string: timezoneString }
22730 } = (0, import_date4.getSettings)();
22731 let displayLabel = label;
22732 if (isValid2?.required && !markWhenOptional) {
22733 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22734 } else if (!isValid2?.required && markWhenOptional) {
22735 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22736 }
22737 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22738 ValidatedDateControl,
22739 {
22740 field,
22741 validity,
22742 inputRefs: validityTargetRef,
22743 isTouched,
22744 setIsTouched,
22745 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22746 import_components31.BaseControl,
22747 {
22748 id,
22749 className: "dataviews-controls__date",
22750 label: displayLabel,
22751 help: description,
22752 hideLabelFromVision,
22753 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22754 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22755 Stack,
22756 {
22757 direction: "row",
22758 gap: "sm",
22759 wrap: "wrap",
22760 justify: "flex-start",
22761 children: [
22762 DATE_PRESETS.map((preset) => {
22763 const isSelected2 = selectedPresetId === preset.id;
22764 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22765 import_components31.Button,
22766 {
22767 className: "dataviews-controls__date-preset",
22768 variant: "tertiary",
22769 isPressed: isSelected2,
22770 size: "small",
22771 disabled: disabled2,
22772 accessibleWhenDisabled: true,
22773 onClick: () => handlePresetClick(preset),
22774 children: preset.label
22775 },
22776 preset.id
22777 );
22778 }),
22779 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22780 import_components31.Button,
22781 {
22782 className: "dataviews-controls__date-preset",
22783 variant: "tertiary",
22784 isPressed: !selectedPresetId,
22785 size: "small",
22786 disabled: !!selectedPresetId || disabled2,
22787 accessibleWhenDisabled: true,
22788 children: (0, import_i18n33.__)("Custom")
22789 }
22790 )
22791 ]
22792 }
22793 ),
22794 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22795 import_components31.__experimentalInputControl,
22796 {
22797 __next40pxDefaultSize: true,
22798 ref: validityTargetRef,
22799 type: "date",
22800 label: (0, import_i18n33.__)("Date"),
22801 hideLabelFromVision: true,
22802 value,
22803 onChange: handleManualDateChange,
22804 required: !!field.isValid?.required,
22805 disabled: disabled2,
22806 min: minConstraint,
22807 max: maxConstraint
22808 }
22809 ),
22810 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22811 DateCalendar2,
22812 {
22813 style: { width: "100%" },
22814 selected: value ? parseDate(value) || void 0 : void 0,
22815 onSelect: onSelectDate,
22816 month: calendarMonth,
22817 onMonthChange: setCalendarMonth,
22818 timeZone: timezoneString || void 0,
22819 weekStartsOn,
22820 disabled: disabled2 || disabledMatchers,
22821 disableNavigation: disabled2
22822 }
22823 )
22824 ] })
22825 }
22826 )
22827 }
22828 );
22829 }
22830 function CalendarDateRangeControl({
22831 data,
22832 field,
22833 onChange,
22834 hideLabelFromVision,
22835 markWhenOptional,
22836 validity
22837 }) {
22838 const {
22839 id,
22840 label,
22841 description,
22842 getValue,
22843 setValue,
22844 isValid: isValid2,
22845 format: fieldFormat
22846 } = field;
22847 const disabled2 = field.isDisabled({ item: data, field });
22848 let value;
22849 const fieldValue = getValue({ item: data });
22850 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
22851 value = fieldValue;
22852 }
22853 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
22854 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
22855 const onChangeCallback = (0, import_element58.useCallback)(
22856 (newValue) => {
22857 onChange(
22858 setValue({
22859 item: data,
22860 value: newValue
22861 })
22862 );
22863 },
22864 [data, onChange, setValue]
22865 );
22866 const [selectedPresetId, setSelectedPresetId] = (0, import_element58.useState)(
22867 null
22868 );
22869 const selectedRange = (0, import_element58.useMemo)(() => {
22870 if (!value) {
22871 return { from: void 0, to: void 0 };
22872 }
22873 const [from, to] = value;
22874 return {
22875 from: parseDate(from) || void 0,
22876 to: parseDate(to) || void 0
22877 };
22878 }, [value]);
22879 const [calendarMonth, setCalendarMonth] = (0, import_element58.useState)(() => {
22880 return selectedRange.from || /* @__PURE__ */ new Date();
22881 });
22882 const [isTouched, setIsTouched] = (0, import_element58.useState)(false);
22883 const fromInputRef = (0, import_element58.useRef)(null);
22884 const toInputRef = (0, import_element58.useRef)(null);
22885 const updateDateRange = (0, import_element58.useCallback)(
22886 (fromDate, toDate2) => {
22887 if (fromDate && toDate2) {
22888 onChangeCallback([
22889 formatDate(fromDate),
22890 formatDate(toDate2)
22891 ]);
22892 } else if (!fromDate && !toDate2) {
22893 onChangeCallback(void 0);
22894 }
22895 },
22896 [onChangeCallback]
22897 );
22898 const onSelectCalendarRange = (0, import_element58.useCallback)(
22899 (newRange) => {
22900 updateDateRange(newRange?.from, newRange?.to);
22901 setSelectedPresetId(null);
22902 setIsTouched(true);
22903 },
22904 [updateDateRange]
22905 );
22906 const handlePresetClick = (0, import_element58.useCallback)(
22907 (preset) => {
22908 const [startDate, endDate] = preset.getValue();
22909 setCalendarMonth(startDate);
22910 updateDateRange(startDate, endDate);
22911 setSelectedPresetId(preset.id);
22912 setIsTouched(true);
22913 },
22914 [updateDateRange]
22915 );
22916 const handleManualDateChange = (0, import_element58.useCallback)(
22917 (fromOrTo, newValue) => {
22918 const [currentFrom, currentTo] = value || [
22919 void 0,
22920 void 0
22921 ];
22922 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
22923 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
22924 updateDateRange(updatedFrom, updatedTo);
22925 if (newValue) {
22926 const parsedDate = parseDate(newValue);
22927 if (parsedDate) {
22928 setCalendarMonth(parsedDate);
22929 }
22930 }
22931 setSelectedPresetId(null);
22932 setIsTouched(true);
22933 },
22934 [value, updateDateRange]
22935 );
22936 const { timezone } = (0, import_date4.getSettings)();
22937 let displayLabel = label;
22938 if (field.isValid?.required && !markWhenOptional) {
22939 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
22940 } else if (!field.isValid?.required && markWhenOptional) {
22941 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
22942 }
22943 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22944 ValidatedDateControl,
22945 {
22946 field,
22947 validity,
22948 inputRefs: [fromInputRef, toInputRef],
22949 isTouched,
22950 setIsTouched,
22951 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22952 import_components31.BaseControl,
22953 {
22954 id,
22955 className: "dataviews-controls__date",
22956 label: displayLabel,
22957 help: description,
22958 hideLabelFromVision,
22959 children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(Stack, { direction: "column", gap: "lg", children: [
22960 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
22961 Stack,
22962 {
22963 direction: "row",
22964 gap: "sm",
22965 wrap: "wrap",
22966 justify: "flex-start",
22967 children: [
22968 DATE_RANGE_PRESETS.map((preset) => {
22969 const isSelected2 = selectedPresetId === preset.id;
22970 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22971 import_components31.Button,
22972 {
22973 className: "dataviews-controls__date-preset",
22974 variant: "tertiary",
22975 isPressed: isSelected2,
22976 size: "small",
22977 disabled: disabled2,
22978 accessibleWhenDisabled: true,
22979 onClick: () => handlePresetClick(preset),
22980 children: preset.label
22981 },
22982 preset.id
22983 );
22984 }),
22985 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
22986 import_components31.Button,
22987 {
22988 className: "dataviews-controls__date-preset",
22989 variant: "tertiary",
22990 isPressed: !selectedPresetId,
22991 size: "small",
22992 accessibleWhenDisabled: true,
22993 disabled: !!selectedPresetId || disabled2,
22994 children: (0, import_i18n33.__)("Custom")
22995 }
22996 )
22997 ]
22998 }
22999 ),
23000 /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)(
23001 Stack,
23002 {
23003 direction: "row",
23004 gap: "sm",
23005 justify: "space-between",
23006 className: "dataviews-controls__date-range-inputs",
23007 children: [
23008 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23009 import_components31.__experimentalInputControl,
23010 {
23011 __next40pxDefaultSize: true,
23012 ref: fromInputRef,
23013 type: "date",
23014 label: (0, import_i18n33.__)("From"),
23015 hideLabelFromVision: true,
23016 value: value?.[0],
23017 onChange: (newValue) => handleManualDateChange("from", newValue),
23018 required: !!field.isValid?.required,
23019 disabled: disabled2,
23020 min: minConstraint,
23021 max: maxConstraint
23022 }
23023 ),
23024 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23025 import_components31.__experimentalInputControl,
23026 {
23027 __next40pxDefaultSize: true,
23028 ref: toInputRef,
23029 type: "date",
23030 label: (0, import_i18n33.__)("To"),
23031 hideLabelFromVision: true,
23032 value: value?.[1],
23033 onChange: (newValue) => handleManualDateChange("to", newValue),
23034 required: !!field.isValid?.required,
23035 disabled: disabled2,
23036 min: minConstraint,
23037 max: maxConstraint
23038 }
23039 )
23040 ]
23041 }
23042 ),
23043 /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23044 DateRangeCalendar,
23045 {
23046 style: { width: "100%" },
23047 selected: selectedRange,
23048 onSelect: onSelectCalendarRange,
23049 month: calendarMonth,
23050 onMonthChange: setCalendarMonth,
23051 timeZone: timezone.string || void 0,
23052 weekStartsOn,
23053 disabled: disabled2 || disabledMatchers
23054 }
23055 )
23056 ] })
23057 }
23058 )
23059 }
23060 );
23061 }
23062 function DateControl({
23063 data,
23064 field,
23065 onChange,
23066 hideLabelFromVision,
23067 markWhenOptional,
23068 operator,
23069 validity
23070 }) {
23071 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
23072 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23073 RelativeDateControl,
23074 {
23075 className: "dataviews-controls__date",
23076 data,
23077 field,
23078 onChange,
23079 hideLabelFromVision,
23080 operator
23081 }
23082 );
23083 }
23084 if (operator === OPERATOR_BETWEEN) {
23085 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23086 CalendarDateRangeControl,
23087 {
23088 data,
23089 field,
23090 onChange,
23091 hideLabelFromVision,
23092 markWhenOptional,
23093 validity
23094 }
23095 );
23096 }
23097 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
23098 CalendarDateControl,
23099 {
23100 data,
23101 field,
23102 onChange,
23103 hideLabelFromVision,
23104 markWhenOptional,
23105 validity
23106 }
23107 );
23108 }
23109
23110 // packages/dataviews/build-module/components/dataform-controls/select.mjs
23111 var import_components32 = __toESM(require_components(), 1);
23112 var import_element59 = __toESM(require_element(), 1);
23113 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
23114 var { ValidatedSelectControl } = unlock3(import_components32.privateApis);
23115 function Select({
23116 data,
23117 field,
23118 onChange,
23119 hideLabelFromVision,
23120 markWhenOptional,
23121 validity
23122 }) {
23123 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
23124 const disabled2 = field.isDisabled({ item: data, field });
23125 const isMultiple = type === "array";
23126 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
23127 const onChangeControl = (0, import_element59.useCallback)(
23128 (newValue) => onChange(setValue({ item: data, value: newValue })),
23129 [data, onChange, setValue]
23130 );
23131 const { elements, isLoading } = useElements({
23132 elements: field.elements,
23133 getElements: field.getElements
23134 });
23135 if (isLoading) {
23136 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components32.Spinner, {});
23137 }
23138 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
23139 ValidatedSelectControl,
23140 {
23141 required: !!field.isValid?.required,
23142 markWhenOptional,
23143 customValidity: getCustomValidity(isValid2, validity),
23144 label,
23145 value,
23146 help: description,
23147 options: elements,
23148 onChange: onChangeControl,
23149 __next40pxDefaultSize: true,
23150 hideLabelFromVision,
23151 multiple: isMultiple,
23152 disabled: disabled2
23153 }
23154 );
23155 }
23156
23157 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
23158 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
23159 var ELEMENTS_THRESHOLD = 10;
23160 function AdaptiveSelect(props) {
23161 const { field } = props;
23162 const { elements } = useElements({
23163 elements: field.elements,
23164 getElements: field.getElements
23165 });
23166 if (elements.length >= ELEMENTS_THRESHOLD) {
23167 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Combobox3, { ...props });
23168 }
23169 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(Select, { ...props });
23170 }
23171
23172 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23173 var import_components34 = __toESM(require_components(), 1);
23174
23175 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
23176 var import_components33 = __toESM(require_components(), 1);
23177 var import_element60 = __toESM(require_element(), 1);
23178 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
23179 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components33.privateApis);
23180 function ValidatedText({
23181 data,
23182 field,
23183 onChange,
23184 hideLabelFromVision,
23185 markWhenOptional,
23186 type,
23187 prefix,
23188 suffix,
23189 validity
23190 }) {
23191 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23192 const value = getValue({ item: data });
23193 const disabled2 = field.isDisabled({ item: data, field });
23194 const onChangeControl = (0, import_element60.useCallback)(
23195 (newValue) => onChange(
23196 setValue({
23197 item: data,
23198 value: newValue
23199 })
23200 ),
23201 [data, setValue, onChange]
23202 );
23203 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
23204 ValidatedInputControl2,
23205 {
23206 required: !!isValid2.required,
23207 markWhenOptional,
23208 customValidity: getCustomValidity(isValid2, validity),
23209 label,
23210 placeholder,
23211 value: value ?? "",
23212 help: description,
23213 onChange: onChangeControl,
23214 hideLabelFromVision,
23215 type,
23216 prefix,
23217 suffix,
23218 disabled: disabled2,
23219 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
23220 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23221 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23222 __next40pxDefaultSize: true
23223 }
23224 );
23225 }
23226
23227 // packages/dataviews/build-module/components/dataform-controls/email.mjs
23228 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
23229 function Email({
23230 data,
23231 field,
23232 onChange,
23233 hideLabelFromVision,
23234 markWhenOptional,
23235 validity
23236 }) {
23237 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
23238 ValidatedText,
23239 {
23240 ...{
23241 data,
23242 field,
23243 onChange,
23244 hideLabelFromVision,
23245 markWhenOptional,
23246 validity,
23247 type: "email",
23248 prefix: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components34.Icon, { icon: envelope_default }) })
23249 }
23250 }
23251 );
23252 }
23253
23254 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
23255 var import_components35 = __toESM(require_components(), 1);
23256 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
23257 function Telephone({
23258 data,
23259 field,
23260 onChange,
23261 hideLabelFromVision,
23262 markWhenOptional,
23263 validity
23264 }) {
23265 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
23266 ValidatedText,
23267 {
23268 ...{
23269 data,
23270 field,
23271 onChange,
23272 hideLabelFromVision,
23273 markWhenOptional,
23274 validity,
23275 type: "tel",
23276 prefix: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components35.Icon, { icon: mobile_default }) })
23277 }
23278 }
23279 );
23280 }
23281
23282 // packages/dataviews/build-module/components/dataform-controls/url.mjs
23283 var import_components36 = __toESM(require_components(), 1);
23284 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
23285 function Url({
23286 data,
23287 field,
23288 onChange,
23289 hideLabelFromVision,
23290 markWhenOptional,
23291 validity
23292 }) {
23293 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
23294 ValidatedText,
23295 {
23296 ...{
23297 data,
23298 field,
23299 onChange,
23300 hideLabelFromVision,
23301 markWhenOptional,
23302 validity,
23303 type: "url",
23304 prefix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components36.Icon, { icon: link_default }) })
23305 }
23306 }
23307 );
23308 }
23309
23310 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
23311 var import_components37 = __toESM(require_components(), 1);
23312 var import_element61 = __toESM(require_element(), 1);
23313 var import_i18n34 = __toESM(require_i18n(), 1);
23314 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
23315 var { ValidatedNumberControl } = unlock3(import_components37.privateApis);
23316 function toNumberOrEmpty(value) {
23317 if (value === "" || value === void 0) {
23318 return "";
23319 }
23320 const number = Number(value);
23321 return Number.isFinite(number) ? number : "";
23322 }
23323 function BetweenControls({
23324 value,
23325 onChange,
23326 hideLabelFromVision,
23327 step
23328 }) {
23329 const [min2 = "", max2 = ""] = value;
23330 const onChangeMin = (0, import_element61.useCallback)(
23331 (newValue) => onChange([toNumberOrEmpty(newValue), max2]),
23332 [onChange, max2]
23333 );
23334 const onChangeMax = (0, import_element61.useCallback)(
23335 (newValue) => onChange([min2, toNumberOrEmpty(newValue)]),
23336 [onChange, min2]
23337 );
23338 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23339 import_components37.BaseControl,
23340 {
23341 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."),
23342 children: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
23343 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23344 import_components37.__experimentalNumberControl,
23345 {
23346 label: (0, import_i18n34.__)("Min."),
23347 value: min2,
23348 max: max2 ? Number(max2) - step : void 0,
23349 onChange: onChangeMin,
23350 __next40pxDefaultSize: true,
23351 hideLabelFromVision,
23352 step
23353 }
23354 ),
23355 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23356 import_components37.__experimentalNumberControl,
23357 {
23358 label: (0, import_i18n34.__)("Max."),
23359 value: max2,
23360 min: min2 ? Number(min2) + step : void 0,
23361 onChange: onChangeMax,
23362 __next40pxDefaultSize: true,
23363 hideLabelFromVision,
23364 step
23365 }
23366 )
23367 ] })
23368 }
23369 );
23370 }
23371 function ValidatedNumber({
23372 data,
23373 field,
23374 onChange,
23375 hideLabelFromVision,
23376 markWhenOptional,
23377 operator,
23378 validity
23379 }) {
23380 const decimals = field.format?.decimals ?? 0;
23381 const step = Math.pow(10, Math.abs(decimals) * -1);
23382 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23383 const value = getValue({ item: data }) ?? "";
23384 const disabled2 = field.isDisabled({ item: data, field });
23385 const onChangeControl = (0, import_element61.useCallback)(
23386 (newValue) => {
23387 onChange(
23388 setValue({
23389 item: data,
23390 // Do not convert an empty string or undefined to a number,
23391 // otherwise there's a mismatch between the UI control (empty)
23392 // and the data relied by onChange (0).
23393 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
23394 })
23395 );
23396 },
23397 [data, onChange, setValue]
23398 );
23399 const onChangeBetweenControls = (0, import_element61.useCallback)(
23400 (newValue) => {
23401 onChange(
23402 setValue({
23403 item: data,
23404 value: newValue
23405 })
23406 );
23407 },
23408 [data, onChange, setValue]
23409 );
23410 if (operator === OPERATOR_BETWEEN) {
23411 let valueBetween = ["", ""];
23412 if (Array.isArray(value) && value.length === 2 && value.every(
23413 (element) => typeof element === "number" || element === ""
23414 )) {
23415 valueBetween = value;
23416 }
23417 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23418 BetweenControls,
23419 {
23420 value: valueBetween,
23421 onChange: onChangeBetweenControls,
23422 hideLabelFromVision,
23423 step
23424 }
23425 );
23426 }
23427 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
23428 ValidatedNumberControl,
23429 {
23430 required: !!isValid2.required,
23431 markWhenOptional,
23432 customValidity: getCustomValidity(isValid2, validity),
23433 label,
23434 help: description,
23435 value,
23436 onChange: onChangeControl,
23437 __next40pxDefaultSize: true,
23438 hideLabelFromVision,
23439 step,
23440 min: isValid2.min ? isValid2.min.constraint : void 0,
23441 max: isValid2.max ? isValid2.max.constraint : void 0,
23442 disabled: disabled2
23443 }
23444 );
23445 }
23446
23447 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
23448 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
23449 function Integer(props) {
23450 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(ValidatedNumber, { ...props });
23451 }
23452
23453 // packages/dataviews/build-module/components/dataform-controls/number.mjs
23454 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
23455 function Number2(props) {
23456 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(ValidatedNumber, { ...props });
23457 }
23458
23459 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
23460 var import_components38 = __toESM(require_components(), 1);
23461 var import_element62 = __toESM(require_element(), 1);
23462 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
23463 var { ValidatedRadioControl } = unlock3(import_components38.privateApis);
23464 function Radio({
23465 data,
23466 field,
23467 onChange,
23468 hideLabelFromVision,
23469 markWhenOptional,
23470 validity
23471 }) {
23472 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23473 const disabled2 = field.isDisabled({ item: data, field });
23474 const { elements, isLoading } = useElements({
23475 elements: field.elements,
23476 getElements: field.getElements
23477 });
23478 const value = getValue({ item: data });
23479 const onChangeControl = (0, import_element62.useCallback)(
23480 (newValue) => onChange(setValue({ item: data, value: newValue })),
23481 [data, onChange, setValue]
23482 );
23483 if (isLoading) {
23484 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_components38.Spinner, {});
23485 }
23486 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
23487 ValidatedRadioControl,
23488 {
23489 required: !!field.isValid?.required,
23490 markWhenOptional,
23491 customValidity: getCustomValidity(isValid2, validity),
23492 label,
23493 help: description,
23494 onChange: onChangeControl,
23495 options: elements,
23496 selected: value,
23497 hideLabelFromVision,
23498 disabled: disabled2
23499 }
23500 );
23501 }
23502
23503 // packages/dataviews/build-module/components/dataform-controls/text.mjs
23504 var import_element63 = __toESM(require_element(), 1);
23505 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
23506 function Text3({
23507 data,
23508 field,
23509 onChange,
23510 hideLabelFromVision,
23511 markWhenOptional,
23512 config,
23513 validity
23514 }) {
23515 const { prefix, suffix } = config || {};
23516 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
23517 ValidatedText,
23518 {
23519 ...{
23520 data,
23521 field,
23522 onChange,
23523 hideLabelFromVision,
23524 markWhenOptional,
23525 validity,
23526 prefix: prefix ? (0, import_element63.createElement)(prefix) : void 0,
23527 suffix: suffix ? (0, import_element63.createElement)(suffix) : void 0
23528 }
23529 }
23530 );
23531 }
23532
23533 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
23534 var import_components39 = __toESM(require_components(), 1);
23535 var import_element64 = __toESM(require_element(), 1);
23536 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
23537 var { ValidatedToggleControl } = unlock3(import_components39.privateApis);
23538 function Toggle({
23539 field,
23540 onChange,
23541 data,
23542 hideLabelFromVision,
23543 markWhenOptional,
23544 validity
23545 }) {
23546 const { label, description, getValue, setValue, isValid: isValid2 } = field;
23547 const disabled2 = field.isDisabled({ item: data, field });
23548 const onChangeControl = (0, import_element64.useCallback)(() => {
23549 onChange(
23550 setValue({ item: data, value: !getValue({ item: data }) })
23551 );
23552 }, [onChange, setValue, data, getValue]);
23553 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
23554 ValidatedToggleControl,
23555 {
23556 required: !!isValid2.required,
23557 markWhenOptional,
23558 customValidity: getCustomValidity(isValid2, validity),
23559 hidden: hideLabelFromVision,
23560 label,
23561 help: description,
23562 checked: getValue({ item: data }),
23563 onChange: onChangeControl,
23564 disabled: disabled2
23565 }
23566 );
23567 }
23568
23569 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
23570 var import_components40 = __toESM(require_components(), 1);
23571 var import_element65 = __toESM(require_element(), 1);
23572 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
23573 var { ValidatedTextareaControl } = unlock3(import_components40.privateApis);
23574 function Textarea({
23575 data,
23576 field,
23577 onChange,
23578 hideLabelFromVision,
23579 markWhenOptional,
23580 config,
23581 validity
23582 }) {
23583 const { rows = 4 } = config || {};
23584 const disabled2 = field.isDisabled({ item: data, field });
23585 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23586 const value = field.getValue({ item: data });
23587 const onChangeControl = (0, import_element65.useCallback)(
23588 (newValue) => onChange(setValue({ item: data, value: newValue })),
23589 [data, onChange, setValue]
23590 );
23591 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
23592 ValidatedTextareaControl,
23593 {
23594 required: !!isValid2.required,
23595 markWhenOptional,
23596 customValidity: getCustomValidity(isValid2, validity),
23597 label,
23598 placeholder,
23599 value: value ?? "",
23600 help: description,
23601 onChange: onChangeControl,
23602 rows,
23603 disabled: disabled2,
23604 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
23605 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
23606 __next40pxDefaultSize: true,
23607 hideLabelFromVision
23608 }
23609 );
23610 }
23611
23612 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
23613 var import_components41 = __toESM(require_components(), 1);
23614 var import_element66 = __toESM(require_element(), 1);
23615 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
23616 var { ValidatedToggleGroupControl } = unlock3(import_components41.privateApis);
23617 function ToggleGroup({
23618 data,
23619 field,
23620 onChange,
23621 hideLabelFromVision,
23622 markWhenOptional,
23623 validity
23624 }) {
23625 const { getValue, setValue, isValid: isValid2 } = field;
23626 const disabled2 = field.isDisabled({ item: data, field });
23627 const value = getValue({ item: data });
23628 const onChangeControl = (0, import_element66.useCallback)(
23629 (newValue) => onChange(setValue({ item: data, value: newValue })),
23630 [data, onChange, setValue]
23631 );
23632 const { elements, isLoading } = useElements({
23633 elements: field.elements,
23634 getElements: field.getElements
23635 });
23636 if (isLoading) {
23637 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components41.Spinner, {});
23638 }
23639 if (elements.length === 0) {
23640 return null;
23641 }
23642 const selectedOption = elements.find((el) => el.value === value);
23643 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23644 ValidatedToggleGroupControl,
23645 {
23646 required: !!field.isValid?.required,
23647 markWhenOptional,
23648 customValidity: getCustomValidity(isValid2, validity),
23649 __next40pxDefaultSize: true,
23650 isBlock: true,
23651 label: field.label,
23652 help: selectedOption?.description || field.description,
23653 onChange: onChangeControl,
23654 value,
23655 hideLabelFromVision,
23656 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
23657 import_components41.__experimentalToggleGroupControlOption,
23658 {
23659 label: el.label,
23660 value: el.value,
23661 disabled: disabled2
23662 },
23663 el.value
23664 ))
23665 }
23666 );
23667 }
23668
23669 // packages/dataviews/build-module/components/dataform-controls/array.mjs
23670 var import_components42 = __toESM(require_components(), 1);
23671 var import_element67 = __toESM(require_element(), 1);
23672 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
23673 var { ValidatedFormTokenField } = unlock3(import_components42.privateApis);
23674 function ArrayControl({
23675 data,
23676 field,
23677 onChange,
23678 hideLabelFromVision,
23679 markWhenOptional,
23680 validity
23681 }) {
23682 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
23683 const value = getValue({ item: data });
23684 const disabled2 = field.isDisabled({ item: data, field });
23685 const { elements, isLoading } = useElements({
23686 elements: field.elements,
23687 getElements: field.getElements
23688 });
23689 const arrayValueAsElements = (0, import_element67.useMemo)(
23690 () => Array.isArray(value) ? value.map((token) => {
23691 const element = elements?.find(
23692 (suggestion) => suggestion.value === token
23693 );
23694 return element || { value: token, label: token };
23695 }) : [],
23696 [value, elements]
23697 );
23698 const onChangeControl = (0, import_element67.useCallback)(
23699 (tokens) => {
23700 const valueTokens = tokens.map((token) => {
23701 if (typeof token === "object" && "value" in token) {
23702 return token.value;
23703 }
23704 return token;
23705 });
23706 onChange(setValue({ item: data, value: valueTokens }));
23707 },
23708 [onChange, setValue, data]
23709 );
23710 if (isLoading) {
23711 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_components42.Spinner, {});
23712 }
23713 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
23714 ValidatedFormTokenField,
23715 {
23716 required: !!isValid2?.required,
23717 markWhenOptional,
23718 customValidity: getCustomValidity(isValid2, validity),
23719 label: hideLabelFromVision ? void 0 : label,
23720 value: arrayValueAsElements,
23721 onChange: onChangeControl,
23722 placeholder,
23723 suggestions: elements?.map((element) => element.value),
23724 disabled: disabled2,
23725 __experimentalValidateInput: (token) => {
23726 if (field.isValid?.elements && elements) {
23727 return elements.some(
23728 (element) => element.value === token || element.label === token
23729 );
23730 }
23731 return true;
23732 },
23733 __experimentalExpandOnFocus: elements && elements.length > 0,
23734 help: description ?? (field.isValid?.elements ? "" : void 0),
23735 displayTransform: (token) => {
23736 if (typeof token === "object" && "label" in token) {
23737 return token.label;
23738 }
23739 if (typeof token === "string" && elements) {
23740 const element = elements.find(
23741 (el) => el.value === token
23742 );
23743 return element?.label || token;
23744 }
23745 return token;
23746 },
23747 __experimentalRenderItem: ({ item }) => {
23748 if (typeof item === "string" && elements) {
23749 const element = elements.find(
23750 (el) => el.value === item
23751 );
23752 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { children: element?.label || item });
23753 }
23754 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { children: item });
23755 }
23756 }
23757 );
23758 }
23759
23760 // node_modules/colord/index.mjs
23761 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
23762 var t = function(r3) {
23763 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
23764 };
23765 var n = function(r3, t2, n2) {
23766 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
23767 };
23768 var e = function(r3, t2, n2) {
23769 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
23770 };
23771 var u = function(r3) {
23772 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
23773 };
23774 var a = function(r3) {
23775 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
23776 };
23777 var o = function(r3) {
23778 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
23779 };
23780 var i = /^#([0-9a-f]{3,8})$/i;
23781 var s = function(r3) {
23782 var t2 = r3.toString(16);
23783 return t2.length < 2 ? "0" + t2 : t2;
23784 };
23785 var h = function(r3) {
23786 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;
23787 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
23788 };
23789 var b = function(r3) {
23790 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
23791 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
23792 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;
23793 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 };
23794 };
23795 var g = function(r3) {
23796 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
23797 };
23798 var d = function(r3) {
23799 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
23800 };
23801 var f = function(r3) {
23802 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 }));
23803 var t2, n2, e2;
23804 };
23805 var c = function(r3) {
23806 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 };
23807 var t2, n2, e2, u2;
23808 };
23809 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23810 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23811 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23812 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
23813 var y = { string: [[function(r3) {
23814 var t2 = i.exec(r3);
23815 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;
23816 }, "hex"], [function(r3) {
23817 var t2 = v.exec(r3) || m.exec(r3);
23818 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;
23819 }, "rgb"], [function(t2) {
23820 var n2 = l.exec(t2) || p.exec(t2);
23821 if (!n2) return null;
23822 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) });
23823 return f(a2);
23824 }, "hsl"]], object: [[function(r3) {
23825 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
23826 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
23827 }, "rgb"], [function(r3) {
23828 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
23829 if (!t(n2) || !t(e2) || !t(u2)) return null;
23830 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
23831 return f(i2);
23832 }, "hsl"], [function(r3) {
23833 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
23834 if (!t(n2) || !t(a2) || !t(o2)) return null;
23835 var h2 = (function(r4) {
23836 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
23837 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
23838 return b(h2);
23839 }, "hsv"]] };
23840 var N = function(r3, t2) {
23841 for (var n2 = 0; n2 < t2.length; n2++) {
23842 var e2 = t2[n2][0](r3);
23843 if (e2) return [e2, t2[n2][1]];
23844 }
23845 return [null, void 0];
23846 };
23847 var x = function(r3) {
23848 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
23849 };
23850 var M = function(r3, t2) {
23851 var n2 = c(r3);
23852 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
23853 };
23854 var H = function(r3) {
23855 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
23856 };
23857 var $ = function(r3, t2) {
23858 var n2 = c(r3);
23859 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
23860 };
23861 var j = (function() {
23862 function r3(r4) {
23863 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
23864 }
23865 return r3.prototype.isValid = function() {
23866 return null !== this.parsed;
23867 }, r3.prototype.brightness = function() {
23868 return n(H(this.rgba), 2);
23869 }, r3.prototype.isDark = function() {
23870 return H(this.rgba) < 0.5;
23871 }, r3.prototype.isLight = function() {
23872 return H(this.rgba) >= 0.5;
23873 }, r3.prototype.toHex = function() {
23874 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;
23875 var r4, t2, e2, u2, a2, i2;
23876 }, r3.prototype.toRgb = function() {
23877 return o(this.rgba);
23878 }, r3.prototype.toRgbString = function() {
23879 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 + ")";
23880 var r4, t2, n2, e2, u2;
23881 }, r3.prototype.toHsl = function() {
23882 return d(c(this.rgba));
23883 }, r3.prototype.toHslString = function() {
23884 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 + "%)";
23885 var r4, t2, n2, e2, u2;
23886 }, r3.prototype.toHsv = function() {
23887 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
23888 var r4;
23889 }, r3.prototype.invert = function() {
23890 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
23891 var r4;
23892 }, r3.prototype.saturate = function(r4) {
23893 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
23894 }, r3.prototype.desaturate = function(r4) {
23895 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
23896 }, r3.prototype.grayscale = function() {
23897 return w(M(this.rgba, -1));
23898 }, r3.prototype.lighten = function(r4) {
23899 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
23900 }, r3.prototype.darken = function(r4) {
23901 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
23902 }, r3.prototype.rotate = function(r4) {
23903 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
23904 }, r3.prototype.alpha = function(r4) {
23905 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
23906 var t2;
23907 }, r3.prototype.hue = function(r4) {
23908 var t2 = c(this.rgba);
23909 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
23910 }, r3.prototype.isEqual = function(r4) {
23911 return this.toHex() === w(r4).toHex();
23912 }, r3;
23913 })();
23914 var w = function(r3) {
23915 return r3 instanceof j ? r3 : new j(r3);
23916 };
23917
23918 // packages/dataviews/build-module/components/dataform-controls/color.mjs
23919 var import_components43 = __toESM(require_components(), 1);
23920 var import_element68 = __toESM(require_element(), 1);
23921 var import_i18n35 = __toESM(require_i18n(), 1);
23922 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
23923 var { ValidatedInputControl: ValidatedInputControl3 } = unlock3(import_components43.privateApis);
23924 var ColorPickerDropdown = ({
23925 color,
23926 onColorChange,
23927 disabled: disabled2
23928 }) => {
23929 const validColor = color && w(color).isValid() ? color : "#ffffff";
23930 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23931 import_components43.Dropdown,
23932 {
23933 className: "dataviews-controls__color-picker-dropdown",
23934 popoverProps: { resize: false },
23935 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23936 import_components43.Button,
23937 {
23938 onClick: onToggle,
23939 "aria-label": (0, import_i18n35.__)("Open color picker"),
23940 size: "small",
23941 disabled: disabled2,
23942 accessibleWhenDisabled: true,
23943 icon: () => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
23944 }
23945 ),
23946 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23947 import_components43.ColorPicker,
23948 {
23949 color: validColor,
23950 onChange: onColorChange,
23951 enableAlpha: true
23952 }
23953 ) })
23954 }
23955 );
23956 };
23957 function Color({
23958 data,
23959 field,
23960 onChange,
23961 hideLabelFromVision,
23962 markWhenOptional,
23963 validity
23964 }) {
23965 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
23966 const disabled2 = field.isDisabled({ item: data, field });
23967 const value = field.getValue({ item: data }) || "";
23968 const handleColorChange = (0, import_element68.useCallback)(
23969 (newColor) => {
23970 onChange(setValue({ item: data, value: newColor }));
23971 },
23972 [data, onChange, setValue]
23973 );
23974 const handleInputChange = (0, import_element68.useCallback)(
23975 (newValue) => {
23976 onChange(setValue({ item: data, value: newValue || "" }));
23977 },
23978 [data, onChange, setValue]
23979 );
23980 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23981 ValidatedInputControl3,
23982 {
23983 required: !!field.isValid?.required,
23984 markWhenOptional,
23985 customValidity: getCustomValidity(isValid2, validity),
23986 label,
23987 placeholder,
23988 value,
23989 help: description,
23990 onChange: handleInputChange,
23991 hideLabelFromVision,
23992 type: "text",
23993 disabled: disabled2,
23994 prefix: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
23995 ColorPickerDropdown,
23996 {
23997 color: value,
23998 onColorChange: handleColorChange,
23999 disabled: disabled2
24000 }
24001 ) })
24002 }
24003 );
24004 }
24005
24006 // packages/dataviews/build-module/components/dataform-controls/password.mjs
24007 var import_components44 = __toESM(require_components(), 1);
24008 var import_element69 = __toESM(require_element(), 1);
24009 var import_i18n36 = __toESM(require_i18n(), 1);
24010 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
24011 function Password({
24012 data,
24013 field,
24014 onChange,
24015 hideLabelFromVision,
24016 markWhenOptional,
24017 validity
24018 }) {
24019 const [isVisible2, setIsVisible] = (0, import_element69.useState)(false);
24020 const disabled2 = field.isDisabled({ item: data, field });
24021 const toggleVisibility = (0, import_element69.useCallback)(() => {
24022 setIsVisible((prev) => !prev);
24023 }, []);
24024 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24025 ValidatedText,
24026 {
24027 ...{
24028 data,
24029 field,
24030 onChange,
24031 hideLabelFromVision,
24032 markWhenOptional,
24033 validity,
24034 type: isVisible2 ? "text" : "password",
24035 suffix: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
24036 import_components44.Button,
24037 {
24038 icon: isVisible2 ? unseen_default : seen_default,
24039 onClick: toggleVisibility,
24040 size: "small",
24041 label: isVisible2 ? (0, import_i18n36.__)("Hide password") : (0, import_i18n36.__)("Show password"),
24042 disabled: disabled2,
24043 accessibleWhenDisabled: true
24044 }
24045 ) })
24046 }
24047 }
24048 );
24049 }
24050
24051 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
24052 function hasElements(field) {
24053 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
24054 }
24055
24056 // packages/dataviews/build-module/components/dataform-controls/index.mjs
24057 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
24058 var FORM_CONTROLS = {
24059 adaptiveSelect: AdaptiveSelect,
24060 array: ArrayControl,
24061 checkbox: Checkbox,
24062 color: Color,
24063 combobox: Combobox3,
24064 datetime: DateTime,
24065 date: DateControl,
24066 email: Email,
24067 telephone: Telephone,
24068 url: Url,
24069 integer: Integer,
24070 number: Number2,
24071 password: Password,
24072 radio: Radio,
24073 select: Select,
24074 text: Text3,
24075 toggle: Toggle,
24076 textarea: Textarea,
24077 toggleGroup: ToggleGroup
24078 };
24079 function isEditConfig(value) {
24080 return value && typeof value === "object" && typeof value.control === "string";
24081 }
24082 function createConfiguredControl(config) {
24083 const { control, ...controlConfig } = config;
24084 const BaseControlType = getControlByType(control);
24085 if (BaseControlType === null) {
24086 return null;
24087 }
24088 return function ConfiguredControl(props) {
24089 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(BaseControlType, { ...props, config: controlConfig });
24090 };
24091 }
24092 function getControl(field, fallback) {
24093 if (typeof field.Edit === "function") {
24094 return field.Edit;
24095 }
24096 if (typeof field.Edit === "string") {
24097 return getControlByType(field.Edit);
24098 }
24099 if (isEditConfig(field.Edit)) {
24100 return createConfiguredControl(field.Edit);
24101 }
24102 if (hasElements(field) && field.type !== "array") {
24103 return getControlByType("adaptiveSelect");
24104 }
24105 if (fallback === null) {
24106 return null;
24107 }
24108 return getControlByType(fallback);
24109 }
24110 function getControlByType(type) {
24111 if (Object.keys(FORM_CONTROLS).includes(type)) {
24112 return FORM_CONTROLS[type];
24113 }
24114 return null;
24115 }
24116
24117 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
24118 function getFilterBy(field, defaultOperators, validOperators) {
24119 if (field.filterBy === false) {
24120 return false;
24121 }
24122 const operators = field.filterBy?.operators?.filter(
24123 (op) => validOperators.includes(op)
24124 ) ?? defaultOperators;
24125 if (operators.length === 0) {
24126 return false;
24127 }
24128 return {
24129 isPrimary: !!field.filterBy?.isPrimary,
24130 operators
24131 };
24132 }
24133 var get_filter_by_default = getFilterBy;
24134
24135 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
24136 var getValueFromId = (id) => ({ item }) => {
24137 const path = id.split(".");
24138 let value = item;
24139 for (const segment of path) {
24140 if (value.hasOwnProperty(segment)) {
24141 value = value[segment];
24142 } else {
24143 value = void 0;
24144 }
24145 }
24146 return value;
24147 };
24148 var get_value_from_id_default = getValueFromId;
24149
24150 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
24151 var setValueFromId = (id) => ({ value }) => {
24152 const path = id.split(".");
24153 const result = {};
24154 let current = result;
24155 for (const segment of path.slice(0, -1)) {
24156 current[segment] = {};
24157 current = current[segment];
24158 }
24159 current[path.at(-1)] = value;
24160 return result;
24161 };
24162 var set_value_from_id_default = setValueFromId;
24163
24164 // packages/dataviews/build-module/field-types/email.mjs
24165 var import_i18n37 = __toESM(require_i18n(), 1);
24166
24167 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
24168 function RenderFromElements({
24169 item,
24170 field
24171 }) {
24172 const { elements, isLoading } = useElements({
24173 elements: field.elements,
24174 getElements: field.getElements
24175 });
24176 const value = field.getValue({ item });
24177 if (isLoading) {
24178 return value;
24179 }
24180 if (elements.length === 0) {
24181 return value;
24182 }
24183 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
24184 }
24185
24186 // packages/dataviews/build-module/field-types/utils/render-default.mjs
24187 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
24188 function render({
24189 item,
24190 field
24191 }) {
24192 if (field.hasElements) {
24193 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(RenderFromElements, { item, field });
24194 }
24195 return field.getValueFormatted({ item, field });
24196 }
24197
24198 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
24199 var sort_text_default = (a2, b2, direction) => {
24200 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
24201 };
24202
24203 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
24204 function isValidRequired(item, field) {
24205 const value = field.getValue({ item });
24206 return ![void 0, "", null].includes(value);
24207 }
24208
24209 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
24210 function isValidMinLength(item, field) {
24211 if (typeof field.isValid.minLength?.constraint !== "number") {
24212 return false;
24213 }
24214 const value = field.getValue({ item });
24215 if ([void 0, "", null].includes(value)) {
24216 return true;
24217 }
24218 return String(value).length >= field.isValid.minLength.constraint;
24219 }
24220
24221 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
24222 function isValidMaxLength(item, field) {
24223 if (typeof field.isValid.maxLength?.constraint !== "number") {
24224 return false;
24225 }
24226 const value = field.getValue({ item });
24227 if ([void 0, "", null].includes(value)) {
24228 return true;
24229 }
24230 return String(value).length <= field.isValid.maxLength.constraint;
24231 }
24232
24233 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
24234 function isValidPattern(item, field) {
24235 if (field.isValid.pattern?.constraint === void 0) {
24236 return true;
24237 }
24238 try {
24239 const regexp = new RegExp(field.isValid.pattern.constraint);
24240 const value = field.getValue({ item });
24241 if ([void 0, "", null].includes(value)) {
24242 return true;
24243 }
24244 return regexp.test(String(value));
24245 } catch {
24246 return false;
24247 }
24248 }
24249
24250 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
24251 function isValidElements(item, field) {
24252 const elements = field.elements ?? [];
24253 const validValues = elements.map((el) => el.value);
24254 if (validValues.length === 0) {
24255 return true;
24256 }
24257 const value = field.getValue({ item });
24258 return [].concat(value).every((v2) => validValues.includes(v2));
24259 }
24260
24261 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
24262 function getValueFormatted({
24263 item,
24264 field
24265 }) {
24266 return field.getValue({ item });
24267 }
24268 var get_value_formatted_default_default = getValueFormatted;
24269
24270 // packages/dataviews/build-module/field-types/email.mjs
24271 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])?)*$/;
24272 function isValidCustom(item, field) {
24273 const value = field.getValue({ item });
24274 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
24275 return (0, import_i18n37.__)("Value must be a valid email address.");
24276 }
24277 return null;
24278 }
24279 var email_default = {
24280 type: "email",
24281 render,
24282 Edit: "email",
24283 sort: sort_text_default,
24284 enableSorting: true,
24285 enableGlobalSearch: false,
24286 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24287 validOperators: [
24288 OPERATOR_IS,
24289 OPERATOR_IS_NOT,
24290 OPERATOR_CONTAINS,
24291 OPERATOR_NOT_CONTAINS,
24292 OPERATOR_STARTS_WITH,
24293 // Multiple selection
24294 OPERATOR_IS_ANY,
24295 OPERATOR_IS_NONE,
24296 OPERATOR_IS_ALL,
24297 OPERATOR_IS_NOT_ALL
24298 ],
24299 format: {},
24300 getValueFormatted: get_value_formatted_default_default,
24301 validate: {
24302 required: isValidRequired,
24303 pattern: isValidPattern,
24304 minLength: isValidMinLength,
24305 maxLength: isValidMaxLength,
24306 elements: isValidElements,
24307 custom: isValidCustom
24308 }
24309 };
24310
24311 // packages/dataviews/build-module/field-types/integer.mjs
24312 var import_i18n38 = __toESM(require_i18n(), 1);
24313
24314 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
24315 var sort_number_default = (a2, b2, direction) => {
24316 return direction === "asc" ? a2 - b2 : b2 - a2;
24317 };
24318
24319 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
24320 function isValidMin(item, field) {
24321 if (typeof field.isValid.min?.constraint !== "number") {
24322 return false;
24323 }
24324 const value = field.getValue({ item });
24325 if ([void 0, "", null].includes(value)) {
24326 return true;
24327 }
24328 return Number(value) >= field.isValid.min.constraint;
24329 }
24330
24331 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
24332 function isValidMax(item, field) {
24333 if (typeof field.isValid.max?.constraint !== "number") {
24334 return false;
24335 }
24336 const value = field.getValue({ item });
24337 if ([void 0, "", null].includes(value)) {
24338 return true;
24339 }
24340 return Number(value) <= field.isValid.max.constraint;
24341 }
24342
24343 // packages/dataviews/build-module/field-types/integer.mjs
24344 var format2 = {
24345 separatorThousand: ","
24346 };
24347 function getValueFormatted2({
24348 item,
24349 field
24350 }) {
24351 let value = field.getValue({ item });
24352 if (value === null || value === void 0) {
24353 return "";
24354 }
24355 value = Number(value);
24356 if (!Number.isFinite(value)) {
24357 return String(value);
24358 }
24359 let formatInteger;
24360 if (field.type !== "integer") {
24361 formatInteger = format2;
24362 } else {
24363 formatInteger = field.format;
24364 }
24365 const { separatorThousand } = formatInteger;
24366 const integerValue = Math.trunc(value);
24367 if (!separatorThousand) {
24368 return String(integerValue);
24369 }
24370 return String(integerValue).replace(
24371 /\B(?=(\d{3})+(?!\d))/g,
24372 separatorThousand
24373 );
24374 }
24375 function isValidCustom2(item, field) {
24376 const value = field.getValue({ item });
24377 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
24378 return (0, import_i18n38.__)("Value must be an integer.");
24379 }
24380 return null;
24381 }
24382 var integer_default = {
24383 type: "integer",
24384 render,
24385 Edit: "integer",
24386 sort: sort_number_default,
24387 enableSorting: true,
24388 enableGlobalSearch: false,
24389 defaultOperators: [
24390 OPERATOR_IS,
24391 OPERATOR_IS_NOT,
24392 OPERATOR_LESS_THAN,
24393 OPERATOR_GREATER_THAN,
24394 OPERATOR_LESS_THAN_OR_EQUAL,
24395 OPERATOR_GREATER_THAN_OR_EQUAL,
24396 OPERATOR_BETWEEN
24397 ],
24398 validOperators: [
24399 // Single-selection
24400 OPERATOR_IS,
24401 OPERATOR_IS_NOT,
24402 OPERATOR_LESS_THAN,
24403 OPERATOR_GREATER_THAN,
24404 OPERATOR_LESS_THAN_OR_EQUAL,
24405 OPERATOR_GREATER_THAN_OR_EQUAL,
24406 OPERATOR_BETWEEN,
24407 // Multiple-selection
24408 OPERATOR_IS_ANY,
24409 OPERATOR_IS_NONE,
24410 OPERATOR_IS_ALL,
24411 OPERATOR_IS_NOT_ALL
24412 ],
24413 format: format2,
24414 getValueFormatted: getValueFormatted2,
24415 validate: {
24416 required: isValidRequired,
24417 min: isValidMin,
24418 max: isValidMax,
24419 elements: isValidElements,
24420 custom: isValidCustom2
24421 }
24422 };
24423
24424 // packages/dataviews/build-module/field-types/number.mjs
24425 var import_i18n39 = __toESM(require_i18n(), 1);
24426 var format3 = {
24427 separatorThousand: ",",
24428 separatorDecimal: ".",
24429 decimals: 2
24430 };
24431 function getValueFormatted3({
24432 item,
24433 field
24434 }) {
24435 let value = field.getValue({ item });
24436 if (value === null || value === void 0) {
24437 return "";
24438 }
24439 value = Number(value);
24440 if (!Number.isFinite(value)) {
24441 return String(value);
24442 }
24443 let formatNumber;
24444 if (field.type !== "number") {
24445 formatNumber = format3;
24446 } else {
24447 formatNumber = field.format;
24448 }
24449 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
24450 const fixedValue = value.toFixed(decimals);
24451 const [integerPart, decimalPart] = fixedValue.split(".");
24452 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
24453 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
24454 }
24455 function isEmpty2(value) {
24456 return value === "" || value === void 0 || value === null;
24457 }
24458 function isValidCustom3(item, field) {
24459 const value = field.getValue({ item });
24460 if (!isEmpty2(value) && !Number.isFinite(value)) {
24461 return (0, import_i18n39.__)("Value must be a number.");
24462 }
24463 return null;
24464 }
24465 var number_default = {
24466 type: "number",
24467 render,
24468 Edit: "number",
24469 sort: sort_number_default,
24470 enableSorting: true,
24471 enableGlobalSearch: false,
24472 defaultOperators: [
24473 OPERATOR_IS,
24474 OPERATOR_IS_NOT,
24475 OPERATOR_LESS_THAN,
24476 OPERATOR_GREATER_THAN,
24477 OPERATOR_LESS_THAN_OR_EQUAL,
24478 OPERATOR_GREATER_THAN_OR_EQUAL,
24479 OPERATOR_BETWEEN
24480 ],
24481 validOperators: [
24482 // Single-selection
24483 OPERATOR_IS,
24484 OPERATOR_IS_NOT,
24485 OPERATOR_LESS_THAN,
24486 OPERATOR_GREATER_THAN,
24487 OPERATOR_LESS_THAN_OR_EQUAL,
24488 OPERATOR_GREATER_THAN_OR_EQUAL,
24489 OPERATOR_BETWEEN,
24490 // Multiple-selection
24491 OPERATOR_IS_ANY,
24492 OPERATOR_IS_NONE,
24493 OPERATOR_IS_ALL,
24494 OPERATOR_IS_NOT_ALL
24495 ],
24496 format: format3,
24497 getValueFormatted: getValueFormatted3,
24498 validate: {
24499 required: isValidRequired,
24500 min: isValidMin,
24501 max: isValidMax,
24502 elements: isValidElements,
24503 custom: isValidCustom3
24504 }
24505 };
24506
24507 // packages/dataviews/build-module/field-types/text.mjs
24508 var text_default = {
24509 type: "text",
24510 render,
24511 Edit: "text",
24512 sort: sort_text_default,
24513 enableSorting: true,
24514 enableGlobalSearch: false,
24515 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24516 validOperators: [
24517 // Single selection
24518 OPERATOR_IS,
24519 OPERATOR_IS_NOT,
24520 OPERATOR_CONTAINS,
24521 OPERATOR_NOT_CONTAINS,
24522 OPERATOR_STARTS_WITH,
24523 // Multiple selection
24524 OPERATOR_IS_ANY,
24525 OPERATOR_IS_NONE,
24526 OPERATOR_IS_ALL,
24527 OPERATOR_IS_NOT_ALL
24528 ],
24529 format: {},
24530 getValueFormatted: get_value_formatted_default_default,
24531 validate: {
24532 required: isValidRequired,
24533 pattern: isValidPattern,
24534 minLength: isValidMinLength,
24535 maxLength: isValidMaxLength,
24536 elements: isValidElements
24537 }
24538 };
24539
24540 // packages/dataviews/build-module/field-types/datetime.mjs
24541 var import_date7 = __toESM(require_date(), 1);
24542
24543 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
24544 var import_date6 = __toESM(require_date(), 1);
24545 function parseDateLike(value) {
24546 if (!value) {
24547 return null;
24548 }
24549 if (!isValid(new Date(value))) {
24550 return null;
24551 }
24552 const parsed = (0, import_date6.getDate)(value);
24553 return parsed && isValid(parsed) ? parsed : null;
24554 }
24555 function validateDateLikeBoundary(item, field, boundary) {
24556 const constraint = field.isValid[boundary]?.constraint;
24557 if (typeof constraint !== "string") {
24558 return false;
24559 }
24560 const value = field.getValue({ item });
24561 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
24562 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
24563 return true;
24564 }
24565 const parsedConstraint = parseDateLike(constraint);
24566 const parsedValue = parseDateLike(String(boundaryValue));
24567 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
24568 }
24569 function isValidMinDate(item, field) {
24570 return validateDateLikeBoundary(item, field, "min");
24571 }
24572 function isValidMaxDate(item, field) {
24573 return validateDateLikeBoundary(item, field, "max");
24574 }
24575
24576 // packages/dataviews/build-module/field-types/datetime.mjs
24577 var format4 = {
24578 datetime: (0, import_date7.getSettings)().formats.datetime,
24579 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
24580 };
24581 function getValueFormatted4({
24582 item,
24583 field
24584 }) {
24585 const value = field.getValue({ item });
24586 if (["", void 0, null].includes(value)) {
24587 return "";
24588 }
24589 let formatDatetime;
24590 if (field.type !== "datetime") {
24591 formatDatetime = format4;
24592 } else {
24593 formatDatetime = field.format;
24594 }
24595 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
24596 }
24597 var sort = (a2, b2, direction) => {
24598 const timeA = new Date(a2).getTime();
24599 const timeB = new Date(b2).getTime();
24600 return direction === "asc" ? timeA - timeB : timeB - timeA;
24601 };
24602 var datetime_default = {
24603 type: "datetime",
24604 render,
24605 Edit: "datetime",
24606 sort,
24607 enableSorting: true,
24608 enableGlobalSearch: false,
24609 defaultOperators: [
24610 OPERATOR_ON,
24611 OPERATOR_NOT_ON,
24612 OPERATOR_BEFORE,
24613 OPERATOR_AFTER,
24614 OPERATOR_BEFORE_INC,
24615 OPERATOR_AFTER_INC,
24616 OPERATOR_IN_THE_PAST,
24617 OPERATOR_OVER
24618 ],
24619 validOperators: [
24620 OPERATOR_ON,
24621 OPERATOR_NOT_ON,
24622 OPERATOR_BEFORE,
24623 OPERATOR_AFTER,
24624 OPERATOR_BEFORE_INC,
24625 OPERATOR_AFTER_INC,
24626 OPERATOR_IN_THE_PAST,
24627 OPERATOR_OVER
24628 ],
24629 format: format4,
24630 getValueFormatted: getValueFormatted4,
24631 validate: {
24632 required: isValidRequired,
24633 elements: isValidElements,
24634 min: isValidMinDate,
24635 max: isValidMaxDate
24636 }
24637 };
24638
24639 // packages/dataviews/build-module/field-types/date.mjs
24640 var import_date8 = __toESM(require_date(), 1);
24641 var format5 = {
24642 date: (0, import_date8.getSettings)().formats.date,
24643 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
24644 };
24645 function getValueFormatted5({
24646 item,
24647 field
24648 }) {
24649 const value = field.getValue({ item });
24650 if (["", void 0, null].includes(value)) {
24651 return "";
24652 }
24653 let formatDate2;
24654 if (field.type !== "date") {
24655 formatDate2 = format5;
24656 } else {
24657 formatDate2 = field.format;
24658 }
24659 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
24660 }
24661 var sort2 = (a2, b2, direction) => {
24662 const timeA = new Date(a2).getTime();
24663 const timeB = new Date(b2).getTime();
24664 return direction === "asc" ? timeA - timeB : timeB - timeA;
24665 };
24666 var date_default = {
24667 type: "date",
24668 render,
24669 Edit: "date",
24670 sort: sort2,
24671 enableSorting: true,
24672 enableGlobalSearch: false,
24673 defaultOperators: [
24674 OPERATOR_ON,
24675 OPERATOR_NOT_ON,
24676 OPERATOR_BEFORE,
24677 OPERATOR_AFTER,
24678 OPERATOR_BEFORE_INC,
24679 OPERATOR_AFTER_INC,
24680 OPERATOR_IN_THE_PAST,
24681 OPERATOR_OVER,
24682 OPERATOR_BETWEEN
24683 ],
24684 validOperators: [
24685 OPERATOR_ON,
24686 OPERATOR_NOT_ON,
24687 OPERATOR_BEFORE,
24688 OPERATOR_AFTER,
24689 OPERATOR_BEFORE_INC,
24690 OPERATOR_AFTER_INC,
24691 OPERATOR_IN_THE_PAST,
24692 OPERATOR_OVER,
24693 OPERATOR_BETWEEN
24694 ],
24695 format: format5,
24696 getValueFormatted: getValueFormatted5,
24697 validate: {
24698 required: isValidRequired,
24699 elements: isValidElements,
24700 min: isValidMinDate,
24701 max: isValidMaxDate
24702 }
24703 };
24704
24705 // packages/dataviews/build-module/field-types/boolean.mjs
24706 var import_i18n40 = __toESM(require_i18n(), 1);
24707
24708 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
24709 function isValidRequiredForBool(item, field) {
24710 const value = field.getValue({ item });
24711 return value === true;
24712 }
24713
24714 // packages/dataviews/build-module/field-types/boolean.mjs
24715 function getValueFormatted6({
24716 item,
24717 field
24718 }) {
24719 const value = field.getValue({ item });
24720 if (value === true) {
24721 return (0, import_i18n40.__)("True");
24722 }
24723 if (value === false) {
24724 return (0, import_i18n40.__)("False");
24725 }
24726 return "";
24727 }
24728 function isValidCustom4(item, field) {
24729 const value = field.getValue({ item });
24730 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
24731 return (0, import_i18n40.__)("Value must be true, false, or undefined");
24732 }
24733 return null;
24734 }
24735 var sort3 = (a2, b2, direction) => {
24736 const boolA = Boolean(a2);
24737 const boolB = Boolean(b2);
24738 if (boolA === boolB) {
24739 return 0;
24740 }
24741 if (direction === "asc") {
24742 return boolA ? 1 : -1;
24743 }
24744 return boolA ? -1 : 1;
24745 };
24746 var boolean_default = {
24747 type: "boolean",
24748 render,
24749 Edit: "checkbox",
24750 sort: sort3,
24751 validate: {
24752 required: isValidRequiredForBool,
24753 elements: isValidElements,
24754 custom: isValidCustom4
24755 },
24756 enableSorting: true,
24757 enableGlobalSearch: false,
24758 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24759 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
24760 format: {},
24761 getValueFormatted: getValueFormatted6
24762 };
24763
24764 // packages/dataviews/build-module/field-types/media.mjs
24765 var media_default = {
24766 type: "media",
24767 render: () => null,
24768 Edit: null,
24769 sort: () => 0,
24770 enableSorting: false,
24771 enableGlobalSearch: false,
24772 defaultOperators: [],
24773 validOperators: [],
24774 format: {},
24775 getValueFormatted: get_value_formatted_default_default,
24776 // cannot validate any constraint, so
24777 // the only available validation for the field author
24778 // would be providing a custom validator.
24779 validate: {}
24780 };
24781
24782 // packages/dataviews/build-module/field-types/array.mjs
24783 var import_i18n41 = __toESM(require_i18n(), 1);
24784
24785 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
24786 function isValidRequiredForArray(item, field) {
24787 const value = field.getValue({ item });
24788 return Array.isArray(value) && value.length > 0 && value.every(
24789 (element) => ![void 0, "", null].includes(element)
24790 );
24791 }
24792
24793 // packages/dataviews/build-module/field-types/array.mjs
24794 function getValueFormatted7({
24795 item,
24796 field
24797 }) {
24798 const value = field.getValue({ item });
24799 const arr = Array.isArray(value) ? value : [];
24800 return arr.join(", ");
24801 }
24802 function render2({ item, field }) {
24803 return getValueFormatted7({ item, field });
24804 }
24805 function isValidCustom5(item, field) {
24806 const value = field.getValue({ item });
24807 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
24808 return (0, import_i18n41.__)("Value must be an array.");
24809 }
24810 if (!value.every((v2) => typeof v2 === "string")) {
24811 return (0, import_i18n41.__)("Every value must be a string.");
24812 }
24813 return null;
24814 }
24815 var sort4 = (a2, b2, direction) => {
24816 const arrA = Array.isArray(a2) ? a2 : [];
24817 const arrB = Array.isArray(b2) ? b2 : [];
24818 if (arrA.length !== arrB.length) {
24819 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
24820 }
24821 const joinedA = arrA.join(",");
24822 const joinedB = arrB.join(",");
24823 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
24824 };
24825 var array_default = {
24826 type: "array",
24827 render: render2,
24828 Edit: "array",
24829 sort: sort4,
24830 enableSorting: true,
24831 enableGlobalSearch: false,
24832 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24833 validOperators: [
24834 OPERATOR_IS_ANY,
24835 OPERATOR_IS_NONE,
24836 OPERATOR_IS_ALL,
24837 OPERATOR_IS_NOT_ALL
24838 ],
24839 format: {},
24840 getValueFormatted: getValueFormatted7,
24841 validate: {
24842 required: isValidRequiredForArray,
24843 elements: isValidElements,
24844 custom: isValidCustom5
24845 }
24846 };
24847
24848 // packages/dataviews/build-module/field-types/password.mjs
24849 function getValueFormatted8({
24850 item,
24851 field
24852 }) {
24853 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
24854 }
24855 var password_default = {
24856 type: "password",
24857 render,
24858 Edit: "password",
24859 sort: () => 0,
24860 // Passwords should not be sortable for security reasons
24861 enableSorting: false,
24862 enableGlobalSearch: false,
24863 defaultOperators: [],
24864 validOperators: [],
24865 format: {},
24866 getValueFormatted: getValueFormatted8,
24867 validate: {
24868 required: isValidRequired,
24869 pattern: isValidPattern,
24870 minLength: isValidMinLength,
24871 maxLength: isValidMaxLength,
24872 elements: isValidElements
24873 }
24874 };
24875
24876 // packages/dataviews/build-module/field-types/telephone.mjs
24877 var telephone_default = {
24878 type: "telephone",
24879 render,
24880 Edit: "telephone",
24881 sort: sort_text_default,
24882 enableSorting: true,
24883 enableGlobalSearch: false,
24884 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24885 validOperators: [
24886 OPERATOR_IS,
24887 OPERATOR_IS_NOT,
24888 OPERATOR_CONTAINS,
24889 OPERATOR_NOT_CONTAINS,
24890 OPERATOR_STARTS_WITH,
24891 // Multiple selection
24892 OPERATOR_IS_ANY,
24893 OPERATOR_IS_NONE,
24894 OPERATOR_IS_ALL,
24895 OPERATOR_IS_NOT_ALL
24896 ],
24897 format: {},
24898 getValueFormatted: get_value_formatted_default_default,
24899 validate: {
24900 required: isValidRequired,
24901 pattern: isValidPattern,
24902 minLength: isValidMinLength,
24903 maxLength: isValidMaxLength,
24904 elements: isValidElements
24905 }
24906 };
24907
24908 // packages/dataviews/build-module/field-types/color.mjs
24909 var import_i18n42 = __toESM(require_i18n(), 1);
24910 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
24911 function render3({ item, field }) {
24912 if (field.hasElements) {
24913 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(RenderFromElements, { item, field });
24914 }
24915 const value = get_value_formatted_default_default({ item, field });
24916 if (!value || !w(value).isValid()) {
24917 return value;
24918 }
24919 return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
24920 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
24921 "div",
24922 {
24923 style: {
24924 width: "16px",
24925 height: "16px",
24926 borderRadius: "50%",
24927 backgroundColor: value,
24928 border: "1px solid #ddd",
24929 flexShrink: 0
24930 }
24931 }
24932 ),
24933 /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { children: value })
24934 ] });
24935 }
24936 function isValidCustom6(item, field) {
24937 const value = field.getValue({ item });
24938 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
24939 return (0, import_i18n42.__)("Value must be a valid color.");
24940 }
24941 return null;
24942 }
24943 var sort5 = (a2, b2, direction) => {
24944 const colorA = w(a2);
24945 const colorB = w(b2);
24946 if (!colorA.isValid() && !colorB.isValid()) {
24947 return 0;
24948 }
24949 if (!colorA.isValid()) {
24950 return direction === "asc" ? 1 : -1;
24951 }
24952 if (!colorB.isValid()) {
24953 return direction === "asc" ? -1 : 1;
24954 }
24955 const hslA = colorA.toHsl();
24956 const hslB = colorB.toHsl();
24957 if (hslA.h !== hslB.h) {
24958 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
24959 }
24960 if (hslA.s !== hslB.s) {
24961 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
24962 }
24963 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
24964 };
24965 var color_default = {
24966 type: "color",
24967 render: render3,
24968 Edit: "color",
24969 sort: sort5,
24970 enableSorting: true,
24971 enableGlobalSearch: false,
24972 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24973 validOperators: [
24974 OPERATOR_IS,
24975 OPERATOR_IS_NOT,
24976 OPERATOR_IS_ANY,
24977 OPERATOR_IS_NONE
24978 ],
24979 format: {},
24980 getValueFormatted: get_value_formatted_default_default,
24981 validate: {
24982 required: isValidRequired,
24983 elements: isValidElements,
24984 custom: isValidCustom6
24985 }
24986 };
24987
24988 // packages/dataviews/build-module/field-types/url.mjs
24989 var url_default = {
24990 type: "url",
24991 render,
24992 Edit: "url",
24993 sort: sort_text_default,
24994 enableSorting: true,
24995 enableGlobalSearch: false,
24996 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
24997 validOperators: [
24998 OPERATOR_IS,
24999 OPERATOR_IS_NOT,
25000 OPERATOR_CONTAINS,
25001 OPERATOR_NOT_CONTAINS,
25002 OPERATOR_STARTS_WITH,
25003 // Multiple selection
25004 OPERATOR_IS_ANY,
25005 OPERATOR_IS_NONE,
25006 OPERATOR_IS_ALL,
25007 OPERATOR_IS_NOT_ALL
25008 ],
25009 format: {},
25010 getValueFormatted: get_value_formatted_default_default,
25011 validate: {
25012 required: isValidRequired,
25013 pattern: isValidPattern,
25014 minLength: isValidMinLength,
25015 maxLength: isValidMaxLength,
25016 elements: isValidElements
25017 }
25018 };
25019
25020 // packages/dataviews/build-module/field-types/no-type.mjs
25021 var sort6 = (a2, b2, direction) => {
25022 if (typeof a2 === "number" && typeof b2 === "number") {
25023 return sort_number_default(a2, b2, direction);
25024 }
25025 return sort_text_default(a2, b2, direction);
25026 };
25027 var no_type_default = {
25028 // type: no type for this one
25029 render,
25030 Edit: null,
25031 sort: sort6,
25032 enableSorting: true,
25033 enableGlobalSearch: false,
25034 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
25035 validOperators: getAllOperatorNames(),
25036 format: {},
25037 getValueFormatted: get_value_formatted_default_default,
25038 validate: {
25039 required: isValidRequired,
25040 elements: isValidElements
25041 }
25042 };
25043
25044 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
25045 function supportsNumericRangeConstraint(type) {
25046 return type === "integer" || type === "number";
25047 }
25048 function supportsDateRangeConstraint(type) {
25049 return type === "date" || type === "datetime";
25050 }
25051 function normalizeRangeRule(value, fieldType, key) {
25052 const validator = fieldType.validate[key];
25053 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
25054 return { constraint: value, validate: validator };
25055 }
25056 return void 0;
25057 }
25058 function getIsValid(field, fieldType) {
25059 const rules = field.isValid;
25060 let required;
25061 if (rules?.required === true && fieldType.validate.required !== void 0) {
25062 required = {
25063 constraint: true,
25064 validate: fieldType.validate.required
25065 };
25066 }
25067 let elements;
25068 if ((rules?.elements === true || // elements is enabled unless the field opts-out
25069 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
25070 elements = {
25071 constraint: true,
25072 validate: fieldType.validate.elements
25073 };
25074 }
25075 const min2 = normalizeRangeRule(rules?.min, fieldType, "min");
25076 const max2 = normalizeRangeRule(rules?.max, fieldType, "max");
25077 const minLengthValue = rules?.minLength;
25078 let minLength;
25079 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
25080 minLength = {
25081 constraint: minLengthValue,
25082 validate: fieldType.validate.minLength
25083 };
25084 }
25085 const maxLengthValue = rules?.maxLength;
25086 let maxLength;
25087 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
25088 maxLength = {
25089 constraint: maxLengthValue,
25090 validate: fieldType.validate.maxLength
25091 };
25092 }
25093 const patternValue = rules?.pattern;
25094 let pattern;
25095 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
25096 pattern = {
25097 constraint: patternValue,
25098 validate: fieldType.validate.pattern
25099 };
25100 }
25101 const custom = rules?.custom ?? fieldType.validate.custom;
25102 return {
25103 required,
25104 elements,
25105 min: min2,
25106 max: max2,
25107 minLength,
25108 maxLength,
25109 pattern,
25110 custom
25111 };
25112 }
25113
25114 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
25115 function getFilter(fieldType) {
25116 return fieldType.validOperators.reduce((accumulator, operator) => {
25117 const operatorObj = getOperatorByName(operator);
25118 if (operatorObj?.filter) {
25119 accumulator[operator] = operatorObj.filter;
25120 }
25121 return accumulator;
25122 }, {});
25123 }
25124
25125 // packages/dataviews/build-module/field-types/utils/get-format.mjs
25126 function getFormat(field, fieldType) {
25127 return {
25128 ...fieldType.format,
25129 ...field.format
25130 };
25131 }
25132 var get_format_default = getFormat;
25133
25134 // packages/dataviews/build-module/field-types/index.mjs
25135 function getFieldTypeByName(type) {
25136 const found = [
25137 email_default,
25138 integer_default,
25139 number_default,
25140 text_default,
25141 datetime_default,
25142 date_default,
25143 boolean_default,
25144 media_default,
25145 array_default,
25146 password_default,
25147 telephone_default,
25148 color_default,
25149 url_default
25150 ].find((fieldType) => fieldType?.type === type);
25151 if (!!found) {
25152 return found;
25153 }
25154 return no_type_default;
25155 }
25156 function normalizeFields(fields) {
25157 return fields.map((field) => {
25158 const fieldType = getFieldTypeByName(field.type);
25159 const getValue = field.getValue || get_value_from_id_default(field.id);
25160 const sort7 = function(a2, b2, direction) {
25161 const aValue = getValue({ item: a2 });
25162 const bValue = getValue({ item: b2 });
25163 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
25164 };
25165 return {
25166 id: field.id,
25167 label: field.label || field.id,
25168 header: field.header || field.label || field.id,
25169 description: field.description,
25170 placeholder: field.placeholder,
25171 getValue,
25172 setValue: field.setValue || set_value_from_id_default(field.id),
25173 elements: field.elements,
25174 getElements: field.getElements,
25175 hasElements: hasElements(field),
25176 isVisible: field.isVisible,
25177 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
25178 enableHiding: field.enableHiding ?? true,
25179 readOnly: field.readOnly ?? false,
25180 // The type provides defaults for the following props
25181 type: fieldType.type,
25182 render: field.render ?? fieldType.render,
25183 Edit: getControl(field, fieldType.Edit),
25184 sort: sort7,
25185 enableSorting: field.enableSorting ?? fieldType.enableSorting,
25186 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
25187 isValid: getIsValid(field, fieldType),
25188 filterBy: get_filter_by_default(
25189 field,
25190 fieldType.defaultOperators,
25191 fieldType.validOperators
25192 ),
25193 filter: getFilter(fieldType),
25194 format: get_format_default(field, fieldType),
25195 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
25196 };
25197 });
25198 }
25199
25200 // packages/dataviews/build-module/hooks/use-data.mjs
25201 var import_element70 = __toESM(require_element(), 1);
25202 function useData({
25203 view,
25204 data: shownData,
25205 getItemId,
25206 isLoading,
25207 paginationInfo,
25208 selection
25209 }) {
25210 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
25211 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element70.useState)(
25212 !isLoading
25213 );
25214 (0, import_element70.useEffect)(() => {
25215 if (!isLoading) {
25216 setHasInitiallyLoaded(true);
25217 }
25218 }, [isLoading]);
25219 const previousDataRef = (0, import_element70.useRef)(shownData);
25220 const previousPaginationInfoRef = (0, import_element70.useRef)(paginationInfo);
25221 (0, import_element70.useEffect)(() => {
25222 if (!isLoading) {
25223 previousDataRef.current = shownData;
25224 previousPaginationInfoRef.current = paginationInfo;
25225 }
25226 }, [shownData, isLoading, paginationInfo]);
25227 const [visibleEntries, setVisibleEntries] = (0, import_element70.useState)([]);
25228 const positionMapRef = (0, import_element70.useRef)(/* @__PURE__ */ new Map());
25229 const allLoadedRecordsRef = (0, import_element70.useRef)([]);
25230 const prevViewParamsRef = (0, import_element70.useRef)({
25231 search: void 0,
25232 filters: void 0,
25233 perPage: void 0
25234 });
25235 const scrollDirectionRef = (0, import_element70.useRef)(void 0);
25236 const prevStartPositionRef = (0, import_element70.useRef)(void 0);
25237 const hasInitializedRef = (0, import_element70.useRef)(false);
25238 const allLoadedRecords = (0, import_element70.useMemo)(() => {
25239 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
25240 if (view.startPosition < prevStartPositionRef.current) {
25241 scrollDirectionRef.current = "up";
25242 } else if (view.startPosition > prevStartPositionRef.current) {
25243 scrollDirectionRef.current = "down";
25244 }
25245 }
25246 prevStartPositionRef.current = view.startPosition;
25247 const currentFiltersKey = JSON.stringify(view.filters ?? []);
25248 const prevFiltersKey = prevViewParamsRef.current.filters;
25249 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
25250 hasInitializedRef.current = true;
25251 prevViewParamsRef.current = {
25252 search: view.search,
25253 filters: currentFiltersKey,
25254 perPage: view.perPage
25255 };
25256 if (shouldReset) {
25257 positionMapRef.current.clear();
25258 scrollDirectionRef.current = void 0;
25259 const startPosition = view.search ? 1 : view.startPosition ?? 1;
25260 const records = shownData.map((record, index2) => {
25261 const position = startPosition + index2;
25262 positionMapRef.current.set(getItemId(record), position);
25263 return {
25264 ...record,
25265 position
25266 };
25267 });
25268 allLoadedRecordsRef.current = records;
25269 return records;
25270 }
25271 const prev = allLoadedRecordsRef.current;
25272 const shownDataIds = new Set(shownData.map(getItemId));
25273 const scrollDirection = scrollDirectionRef.current;
25274 const basePosition = view.search ? 1 : view.startPosition ?? 1;
25275 const newRecords = shownData.map((record, index2) => {
25276 const itemId = getItemId(record);
25277 const position = view.infiniteScrollEnabled ? basePosition + index2 : void 0;
25278 if (position !== void 0) {
25279 positionMapRef.current.set(itemId, position);
25280 }
25281 return {
25282 ...record,
25283 position
25284 };
25285 });
25286 if (newRecords.length === 0) {
25287 return prev;
25288 }
25289 const prevWithoutDuplicates = prev.filter(
25290 (record) => !shownDataIds.has(getItemId(record))
25291 );
25292 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
25293 allRecords.sort((a2, b2) => {
25294 const posA = a2.position;
25295 const posB = b2.position;
25296 return posA - posB;
25297 });
25298 let result = allRecords;
25299 if (visibleEntries.length > 0) {
25300 const visibleMin = Math.min(...visibleEntries);
25301 const visibleMax = Math.max(...visibleEntries);
25302 const buffer = 20;
25303 const recordPositions = allRecords.map(
25304 (r3) => r3.position
25305 );
25306 const minRecordPos = Math.min(...recordPositions);
25307 const maxRecordPos = Math.max(...recordPositions);
25308 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
25309 if (hasOverlap) {
25310 result = allRecords.filter((record) => {
25311 const itemId = getItemId(record);
25312 const isSelected2 = selection?.includes(itemId);
25313 if (isSelected2) {
25314 return true;
25315 }
25316 const itemPosition = record.position;
25317 if (scrollDirection === "up") {
25318 return itemPosition <= visibleMax + buffer;
25319 } else if (scrollDirection === "down") {
25320 return itemPosition >= visibleMin - buffer;
25321 }
25322 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
25323 });
25324 }
25325 }
25326 allLoadedRecordsRef.current = result;
25327 return result;
25328 }, [
25329 shownData,
25330 view.search,
25331 view.filters,
25332 view.perPage,
25333 view.startPosition,
25334 view.infiniteScrollEnabled,
25335 visibleEntries,
25336 selection,
25337 getItemId
25338 ]);
25339 if (!isInfiniteScrollEnabled) {
25340 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
25341 return {
25342 data: dataToReturn.map((item) => ({
25343 ...item,
25344 position: void 0
25345 })),
25346 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
25347 hasInitiallyLoaded,
25348 setVisibleEntries: void 0
25349 };
25350 }
25351 return {
25352 data: allLoadedRecords,
25353 paginationInfo,
25354 hasInitiallyLoaded,
25355 setVisibleEntries
25356 };
25357 }
25358
25359 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
25360 var import_element71 = __toESM(require_element(), 1);
25361 var import_compose11 = __toESM(require_compose(), 1);
25362 function captureAnchorElement(container, anchorElementRef, direction) {
25363 const containerRect = container.getBoundingClientRect();
25364 const centerY = containerRect.top + containerRect.height / 2;
25365 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
25366 if (items.length === 0) {
25367 return false;
25368 }
25369 const bestAnchor = items.reduce((best, item) => {
25370 const itemRect = item.getBoundingClientRect();
25371 const itemCenterY = itemRect.top + itemRect.height / 2;
25372 const distance = Math.abs(itemCenterY - centerY);
25373 const bestRect = best.getBoundingClientRect();
25374 const bestCenterY = bestRect.top + bestRect.height / 2;
25375 const bestDistance = Math.abs(bestCenterY - centerY);
25376 return distance < bestDistance ? item : best;
25377 });
25378 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
25379 const anchorRect = bestAnchor.getBoundingClientRect();
25380 anchorElementRef.current = {
25381 posinset,
25382 viewportOffset: anchorRect.top - containerRect.top,
25383 direction
25384 };
25385 return true;
25386 }
25387 function useInfiniteScroll({
25388 view,
25389 onChangeView,
25390 isLoading,
25391 paginationInfo,
25392 containerRef,
25393 setVisibleEntries
25394 }) {
25395 const anchorElementRef = (0, import_element71.useRef)(null);
25396 const viewRef = (0, import_element71.useRef)(view);
25397 const isLoadingRef = (0, import_element71.useRef)(isLoading);
25398 const onChangeViewRef = (0, import_element71.useRef)(onChangeView);
25399 const totalItemsRef = (0, import_element71.useRef)(paginationInfo.totalItems);
25400 (0, import_element71.useLayoutEffect)(() => {
25401 viewRef.current = view;
25402 isLoadingRef.current = isLoading;
25403 onChangeViewRef.current = onChangeView;
25404 totalItemsRef.current = paginationInfo.totalItems;
25405 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
25406 const intersectionObserverCallback = (0, import_element71.useCallback)(
25407 (entries) => {
25408 if (!setVisibleEntries) {
25409 return;
25410 }
25411 setVisibleEntries((prev) => {
25412 const newVisibleEntries = new Set(prev);
25413 let hasChanged = false;
25414 entries.forEach((entry) => {
25415 const posInSet = Number(
25416 entry.target?.attributes?.getNamedItem(
25417 "aria-posinset"
25418 )?.value
25419 );
25420 if (isNaN(posInSet)) {
25421 return;
25422 }
25423 if (entry.isIntersecting) {
25424 if (!newVisibleEntries.has(posInSet)) {
25425 newVisibleEntries.add(posInSet);
25426 hasChanged = true;
25427 }
25428 } else if (newVisibleEntries.has(posInSet)) {
25429 newVisibleEntries.delete(posInSet);
25430 hasChanged = true;
25431 }
25432 });
25433 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
25434 });
25435 },
25436 [setVisibleEntries]
25437 );
25438 (0, import_element71.useLayoutEffect)(() => {
25439 const container = containerRef.current;
25440 const anchor = anchorElementRef.current;
25441 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
25442 return;
25443 }
25444 const anchorElement = container.querySelector(
25445 `[aria-posinset="${anchor.posinset}"]`
25446 );
25447 if (anchorElement) {
25448 const containerRect = container.getBoundingClientRect();
25449 const anchorRect = anchorElement.getBoundingClientRect();
25450 const currentOffset = anchorRect.top - containerRect.top;
25451 const scrollAdjustment = currentOffset - anchor.viewportOffset;
25452 if (Math.abs(scrollAdjustment) > 1) {
25453 container.scrollTop += scrollAdjustment;
25454 }
25455 }
25456 anchorElementRef.current = null;
25457 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
25458 const intersectionObserverRef = (0, import_element71.useRef)(
25459 null
25460 );
25461 (0, import_element71.useEffect)(() => {
25462 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
25463 if (intersectionObserverRef.current) {
25464 intersectionObserverRef.current.disconnect();
25465 intersectionObserverRef.current = null;
25466 }
25467 return;
25468 }
25469 intersectionObserverRef.current = new IntersectionObserver(
25470 intersectionObserverCallback,
25471 { root: null, rootMargin: "0px", threshold: 0.1 }
25472 );
25473 return () => {
25474 if (intersectionObserverRef.current) {
25475 intersectionObserverRef.current.disconnect();
25476 intersectionObserverRef.current = null;
25477 }
25478 };
25479 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
25480 (0, import_element71.useEffect)(() => {
25481 if (!view.infiniteScrollEnabled || !containerRef.current) {
25482 return;
25483 }
25484 let lastScrollTop = 0;
25485 const BOTTOM_THRESHOLD = 600;
25486 const TOP_THRESHOLD = 800;
25487 const handleScroll = (0, import_compose11.throttle)((event) => {
25488 const currentView = viewRef.current;
25489 const totalItems = totalItemsRef.current;
25490 const target = event.target;
25491 const scrollTop = target.scrollTop;
25492 const scrollHeight = target.scrollHeight;
25493 const clientHeight = target.clientHeight;
25494 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
25495 lastScrollTop = scrollTop;
25496 if (isLoadingRef.current) {
25497 return;
25498 }
25499 const currentStartPosition = currentView.startPosition || 1;
25500 const batchSize = currentView.perPage || 10;
25501 const currentEndPosition = Math.min(
25502 currentStartPosition + batchSize,
25503 totalItems
25504 );
25505 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
25506 if (currentEndPosition < totalItems) {
25507 const newStartPosition = currentEndPosition;
25508 captureAnchorElement(target, anchorElementRef, "down");
25509 onChangeViewRef.current({
25510 ...currentView,
25511 startPosition: newStartPosition
25512 });
25513 }
25514 }
25515 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
25516 if (currentStartPosition > 1) {
25517 const calculatedStartPosition = currentStartPosition - batchSize;
25518 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
25519 captureAnchorElement(target, anchorElementRef, "up");
25520 onChangeViewRef.current({
25521 ...currentView,
25522 startPosition: newStartPosition
25523 });
25524 }
25525 }
25526 }, 50);
25527 const container = containerRef.current;
25528 container.addEventListener("scroll", handleScroll);
25529 return () => {
25530 container.removeEventListener("scroll", handleScroll);
25531 handleScroll.cancel();
25532 };
25533 }, [containerRef, view.infiniteScrollEnabled]);
25534 return {
25535 intersectionObserver: intersectionObserverRef.current
25536 };
25537 }
25538
25539 // packages/dataviews/build-module/dataviews/index.mjs
25540 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
25541 var defaultGetItemId = (item) => item.id;
25542 var defaultIsItemClickable = () => true;
25543 var EMPTY_ARRAY6 = [];
25544 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
25545 var dataViewsLayouts = VIEW_LAYOUTS.filter(
25546 (viewLayout) => !viewLayout.isPicker
25547 );
25548 function DefaultUI({
25549 header,
25550 search = true,
25551 searchLabel = void 0
25552 }) {
25553 const { view } = (0, import_element72.useContext)(dataviews_context_default);
25554 const isInfiniteScroll = view.infiniteScrollEnabled;
25555 return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(import_jsx_runtime109.Fragment, { children: [
25556 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25557 Stack,
25558 {
25559 direction: "row",
25560 align: "top",
25561 justify: "space-between",
25562 className: clsx_default("dataviews__view-actions", {
25563 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
25564 }),
25565 gap: "xs",
25566 children: [
25567 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
25568 Stack,
25569 {
25570 direction: "row",
25571 justify: "start",
25572 gap: "sm",
25573 className: "dataviews__search",
25574 children: [
25575 search && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(dataviews_search_default, { label: searchLabel }),
25576 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(toggle_default, {})
25577 ]
25578 }
25579 ),
25580 /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
25581 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(dataviews_view_config_default, {}),
25582 header
25583 ] })
25584 ]
25585 }
25586 ),
25587 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
25588 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DataViewsLayout, {}),
25589 /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(DataViewsFooter, {})
25590 ] });
25591 }
25592 function DataViews({
25593 view,
25594 onChangeView,
25595 fields,
25596 search = true,
25597 searchLabel = void 0,
25598 actions = EMPTY_ARRAY6,
25599 data,
25600 getItemId = defaultGetItemId,
25601 getItemLevel,
25602 isLoading = false,
25603 paginationInfo,
25604 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
25605 selection: selectionProperty,
25606 onChangeSelection,
25607 onClickItem,
25608 renderItemLink,
25609 isItemClickable = defaultIsItemClickable,
25610 header,
25611 children,
25612 config = { perPageSizes: [10, 20, 50, 100] },
25613 empty,
25614 onReset
25615 }) {
25616 const [selectionState, setSelectionState] = (0, import_element72.useState)([]);
25617 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
25618 const selection = isUncontrolled ? selectionState : selectionProperty;
25619 const {
25620 data: displayData,
25621 paginationInfo: displayPaginationInfo,
25622 hasInitiallyLoaded,
25623 setVisibleEntries
25624 } = useData({
25625 view,
25626 data,
25627 getItemId,
25628 isLoading,
25629 selection,
25630 paginationInfo
25631 });
25632 const containerRef = (0, import_element72.useRef)(null);
25633 const [containerWidth, setContainerWidth] = (0, import_element72.useState)(0);
25634 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
25635 (resizeObserverEntries) => {
25636 setContainerWidth(
25637 resizeObserverEntries[0].borderBoxSize[0].inlineSize
25638 );
25639 },
25640 { box: "border-box" }
25641 );
25642 const [openedFilter, setOpenedFilter] = (0, import_element72.useState)(null);
25643 function setSelectionWithChange(value) {
25644 const newValue = typeof value === "function" ? value(selection) : value;
25645 if (isUncontrolled) {
25646 setSelectionState(newValue);
25647 }
25648 if (onChangeSelection) {
25649 onChangeSelection(newValue);
25650 }
25651 }
25652 const _fields = (0, import_element72.useMemo)(() => normalizeFields(fields), [fields]);
25653 const _selection = (0, import_element72.useMemo)(() => {
25654 if (view.infiniteScrollEnabled) {
25655 return selection;
25656 }
25657 return selection.filter(
25658 (id) => data.some((item) => getItemId(item) === id)
25659 );
25660 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
25661 const filters = use_filters_default(_fields, view);
25662 const hasPrimaryOrLockedFilters = (0, import_element72.useMemo)(
25663 () => (filters || []).some(
25664 (filter) => filter.isPrimary || filter.isLocked
25665 ),
25666 [filters]
25667 );
25668 const [isShowingFilter, setIsShowingFilter] = (0, import_element72.useState)(
25669 hasPrimaryOrLockedFilters
25670 );
25671 const { intersectionObserver } = useInfiniteScroll({
25672 view,
25673 onChangeView,
25674 isLoading,
25675 paginationInfo,
25676 containerRef,
25677 setVisibleEntries
25678 });
25679 (0, import_element72.useEffect)(() => {
25680 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
25681 setIsShowingFilter(true);
25682 }
25683 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
25684 const defaultLayouts = (0, import_element72.useMemo)(
25685 () => Object.fromEntries(
25686 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
25687 return dataViewsLayouts.some(
25688 (viewLayout) => viewLayout.type === layoutType
25689 );
25690 }).map(([key, value]) => [
25691 key,
25692 value === true ? {} : value
25693 ])
25694 ),
25695 [defaultLayoutsProperty]
25696 );
25697 if (!defaultLayouts[view.type]) {
25698 return null;
25699 }
25700 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25701 dataviews_context_default.Provider,
25702 {
25703 value: {
25704 view,
25705 onChangeView,
25706 fields: _fields,
25707 actions,
25708 data: displayData,
25709 isLoading,
25710 paginationInfo: displayPaginationInfo,
25711 selection: _selection,
25712 onChangeSelection: setSelectionWithChange,
25713 openedFilter,
25714 setOpenedFilter,
25715 getItemId,
25716 getItemLevel,
25717 isItemClickable,
25718 onClickItem,
25719 renderItemLink,
25720 containerWidth,
25721 containerRef,
25722 resizeObserverRef,
25723 defaultLayouts,
25724 filters,
25725 isShowingFilter,
25726 setIsShowingFilter,
25727 config,
25728 empty,
25729 hasInitiallyLoaded,
25730 onReset,
25731 intersectionObserver
25732 },
25733 children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
25734 DefaultUI,
25735 {
25736 header,
25737 search,
25738 searchLabel
25739 }
25740 ) })
25741 }
25742 );
25743 }
25744 var DataViewsSubComponents = DataViews;
25745 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
25746 DataViewsSubComponents.Filters = filters_default;
25747 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
25748 DataViewsSubComponents.FiltersToggle = toggle_default;
25749 DataViewsSubComponents.Layout = DataViewsLayout;
25750 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
25751 DataViewsSubComponents.Pagination = DataViewsPagination;
25752 DataViewsSubComponents.Search = dataviews_search_default;
25753 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
25754 DataViewsSubComponents.Footer = DataViewsFooter;
25755 var dataviews_default = DataViewsSubComponents;
25756
25757 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
25758 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
25759 var import_deprecated = __toESM(require_deprecated(), 1);
25760 function normalizeSearchInput2(input = "") {
25761 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
25762 }
25763 var EMPTY_ARRAY7 = [];
25764 function filterSortAndPaginate(data, view, fields) {
25765 if (!data) {
25766 return {
25767 data: EMPTY_ARRAY7,
25768 paginationInfo: { totalItems: 0, totalPages: 0 }
25769 };
25770 }
25771 const _fields = normalizeFields(fields);
25772 let filteredData = [...data];
25773 if (view.search) {
25774 const normalizedSearch = normalizeSearchInput2(view.search);
25775 filteredData = filteredData.filter((item) => {
25776 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
25777 const fieldValue = field.getValue({ item });
25778 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
25779 return values.some(
25780 (value) => normalizeSearchInput2(String(value)).includes(
25781 normalizedSearch
25782 )
25783 );
25784 });
25785 });
25786 }
25787 if (view.filters && view.filters?.length > 0) {
25788 view.filters.forEach((filter) => {
25789 const field = _fields.find(
25790 (_field) => _field.id === filter.field
25791 );
25792 if (field) {
25793 if (filter.operator === OPERATOR_IS_NOT_ALL) {
25794 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
25795 since: "7.0",
25796 alternative: "'isNone'"
25797 });
25798 }
25799 const handler = field.filter[filter.operator];
25800 if (handler) {
25801 filteredData = filteredData.filter(
25802 (item) => handler(item, field, filter.value)
25803 );
25804 }
25805 }
25806 });
25807 }
25808 const sortByField = view.sort?.field ? _fields.find((field) => {
25809 return field.enableSorting !== false && field.id === view.sort?.field;
25810 }) : null;
25811 const groupByField = view.groupBy?.field ? _fields.find((field) => {
25812 return field.enableSorting !== false && field.id === view.groupBy?.field;
25813 }) : null;
25814 if (sortByField || groupByField) {
25815 filteredData.sort((a2, b2) => {
25816 if (groupByField) {
25817 const groupCompare = groupByField.sort(
25818 a2,
25819 b2,
25820 view.groupBy?.direction ?? "asc"
25821 );
25822 if (groupCompare !== 0) {
25823 return groupCompare;
25824 }
25825 }
25826 if (sortByField) {
25827 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
25828 }
25829 return 0;
25830 });
25831 }
25832 let totalItems = filteredData.length;
25833 let totalPages = 1;
25834 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
25835 const start = view.startPosition - 1;
25836 const end = Math.min(start + view.perPage, totalItems);
25837 filteredData = filteredData?.slice(start, end);
25838 } else if (view.page !== void 0 && view.perPage !== void 0) {
25839 const start = (view.page - 1) * view.perPage;
25840 totalItems = filteredData?.length || 0;
25841 totalPages = Math.ceil(totalItems / view.perPage);
25842 filteredData = filteredData?.slice(start, start + view.perPage);
25843 }
25844 return {
25845 data: filteredData,
25846 paginationInfo: {
25847 totalItems,
25848 totalPages
25849 }
25850 };
25851 }
25852
25853 // packages/admin-ui/build-module/navigable-region/index.mjs
25854 var import_element73 = __toESM(require_element(), 1);
25855 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
25856 var NavigableRegion = (0, import_element73.forwardRef)(
25857 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
25858 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
25859 Tag,
25860 {
25861 ref,
25862 className: clsx_default("admin-ui-navigable-region", className),
25863 "aria-label": ariaLabel,
25864 role: "region",
25865 tabIndex: "-1",
25866 ...props,
25867 children
25868 }
25869 );
25870 }
25871 );
25872 NavigableRegion.displayName = "NavigableRegion";
25873 var navigable_region_default = NavigableRegion;
25874
25875 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
25876 var import_components45 = __toESM(require_components(), 1);
25877 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components45.createSlotFill)("SidebarToggle");
25878
25879 // packages/admin-ui/build-module/page/header.mjs
25880 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
25881 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
25882 function getRuntime7() {
25883 const globalScope = globalThis;
25884 if (globalScope.__wpStyleRuntime) {
25885 return globalScope.__wpStyleRuntime;
25886 }
25887 globalScope.__wpStyleRuntime = {
25888 documents: /* @__PURE__ */ new Map(),
25889 styles: /* @__PURE__ */ new Map(),
25890 injectedStyles: /* @__PURE__ */ new WeakMap()
25891 };
25892 if (typeof document !== "undefined") {
25893 registerDocument7(document);
25894 }
25895 return globalScope.__wpStyleRuntime;
25896 }
25897 function documentContainsStyleHash7(targetDocument, hash) {
25898 if (!targetDocument.head) {
25899 return false;
25900 }
25901 for (const style of targetDocument.head.querySelectorAll(
25902 `style[${STYLE_HASH_ATTRIBUTE7}]`
25903 )) {
25904 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
25905 return true;
25906 }
25907 }
25908 return false;
25909 }
25910 function injectStyle7(targetDocument, hash, css) {
25911 if (!targetDocument.head) {
25912 return;
25913 }
25914 const runtime = getRuntime7();
25915 let injectedStyles = runtime.injectedStyles.get(targetDocument);
25916 if (!injectedStyles) {
25917 injectedStyles = /* @__PURE__ */ new Set();
25918 runtime.injectedStyles.set(targetDocument, injectedStyles);
25919 }
25920 if (injectedStyles.has(hash)) {
25921 return;
25922 }
25923 if (documentContainsStyleHash7(targetDocument, hash)) {
25924 injectedStyles.add(hash);
25925 return;
25926 }
25927 const style = targetDocument.createElement("style");
25928 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
25929 style.appendChild(targetDocument.createTextNode(css));
25930 targetDocument.head.appendChild(style);
25931 injectedStyles.add(hash);
25932 }
25933 function registerDocument7(targetDocument) {
25934 const runtime = getRuntime7();
25935 runtime.documents.set(
25936 targetDocument,
25937 (runtime.documents.get(targetDocument) ?? 0) + 1
25938 );
25939 for (const [hash, css] of runtime.styles) {
25940 injectStyle7(targetDocument, hash, css);
25941 }
25942 return () => {
25943 const count = runtime.documents.get(targetDocument);
25944 if (count === void 0) {
25945 return;
25946 }
25947 if (count <= 1) {
25948 runtime.documents.delete(targetDocument);
25949 return;
25950 }
25951 runtime.documents.set(targetDocument, count - 1);
25952 };
25953 }
25954 function registerStyle7(hash, css) {
25955 const runtime = getRuntime7();
25956 runtime.styles.set(hash, css);
25957 for (const targetDocument of runtime.documents.keys()) {
25958 injectStyle7(targetDocument, hash, css);
25959 }
25960 }
25961 if (typeof process === "undefined" || true) {
25962 registerStyle7("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
25963 }
25964 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" };
25965 function Header({
25966 headingLevel = 1,
25967 breadcrumbs,
25968 badges,
25969 visual,
25970 title,
25971 subTitle,
25972 actions,
25973 showSidebarToggle = true
25974 }) {
25975 const HeadingTag = `h${headingLevel}`;
25976 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(Stack, { direction: "column", className: style_default6.header, children: [
25977 /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
25978 Stack,
25979 {
25980 className: style_default6["header-content"],
25981 direction: "row",
25982 gap: "sm",
25983 justify: "space-between",
25984 children: [
25985 /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
25986 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25987 SidebarToggleSlot,
25988 {
25989 bubblesVirtually: true,
25990 className: style_default6["sidebar-toggle-slot"]
25991 }
25992 ),
25993 visual && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
25994 "div",
25995 {
25996 className: style_default6["header-visual"],
25997 "aria-hidden": "true",
25998 children: visual
25999 }
26000 ),
26001 title && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26002 Text,
26003 {
26004 className: style_default6["header-title"],
26005 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(HeadingTag, {}),
26006 variant: "heading-lg",
26007 children: title
26008 }
26009 ),
26010 breadcrumbs,
26011 badges
26012 ] }),
26013 actions && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26014 Stack,
26015 {
26016 align: "center",
26017 className: style_default6["header-actions"],
26018 direction: "row",
26019 gap: "sm",
26020 children: actions
26021 }
26022 )
26023 ]
26024 }
26025 ),
26026 subTitle && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
26027 Text,
26028 {
26029 render: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("p", {}),
26030 variant: "body-md",
26031 className: style_default6["header-subtitle"],
26032 children: subTitle
26033 }
26034 )
26035 ] });
26036 }
26037
26038 // packages/admin-ui/build-module/page/index.mjs
26039 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
26040 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
26041 function getRuntime8() {
26042 const globalScope = globalThis;
26043 if (globalScope.__wpStyleRuntime) {
26044 return globalScope.__wpStyleRuntime;
26045 }
26046 globalScope.__wpStyleRuntime = {
26047 documents: /* @__PURE__ */ new Map(),
26048 styles: /* @__PURE__ */ new Map(),
26049 injectedStyles: /* @__PURE__ */ new WeakMap()
26050 };
26051 if (typeof document !== "undefined") {
26052 registerDocument8(document);
26053 }
26054 return globalScope.__wpStyleRuntime;
26055 }
26056 function documentContainsStyleHash8(targetDocument, hash) {
26057 if (!targetDocument.head) {
26058 return false;
26059 }
26060 for (const style of targetDocument.head.querySelectorAll(
26061 `style[${STYLE_HASH_ATTRIBUTE8}]`
26062 )) {
26063 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
26064 return true;
26065 }
26066 }
26067 return false;
26068 }
26069 function injectStyle8(targetDocument, hash, css) {
26070 if (!targetDocument.head) {
26071 return;
26072 }
26073 const runtime = getRuntime8();
26074 let injectedStyles = runtime.injectedStyles.get(targetDocument);
26075 if (!injectedStyles) {
26076 injectedStyles = /* @__PURE__ */ new Set();
26077 runtime.injectedStyles.set(targetDocument, injectedStyles);
26078 }
26079 if (injectedStyles.has(hash)) {
26080 return;
26081 }
26082 if (documentContainsStyleHash8(targetDocument, hash)) {
26083 injectedStyles.add(hash);
26084 return;
26085 }
26086 const style = targetDocument.createElement("style");
26087 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
26088 style.appendChild(targetDocument.createTextNode(css));
26089 targetDocument.head.appendChild(style);
26090 injectedStyles.add(hash);
26091 }
26092 function registerDocument8(targetDocument) {
26093 const runtime = getRuntime8();
26094 runtime.documents.set(
26095 targetDocument,
26096 (runtime.documents.get(targetDocument) ?? 0) + 1
26097 );
26098 for (const [hash, css] of runtime.styles) {
26099 injectStyle8(targetDocument, hash, css);
26100 }
26101 return () => {
26102 const count = runtime.documents.get(targetDocument);
26103 if (count === void 0) {
26104 return;
26105 }
26106 if (count <= 1) {
26107 runtime.documents.delete(targetDocument);
26108 return;
26109 }
26110 runtime.documents.set(targetDocument, count - 1);
26111 };
26112 }
26113 function registerStyle8(hash, css) {
26114 const runtime = getRuntime8();
26115 runtime.styles.set(hash, css);
26116 for (const targetDocument of runtime.documents.keys()) {
26117 injectStyle8(targetDocument, hash, css);
26118 }
26119 }
26120 if (typeof process === "undefined" || true) {
26121 registerStyle8("aa9c241ccc", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
26122 }
26123 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" };
26124 function Page({
26125 headingLevel,
26126 breadcrumbs,
26127 badges,
26128 visual,
26129 title,
26130 subTitle,
26131 children,
26132 className,
26133 actions,
26134 ariaLabel,
26135 hasPadding = false,
26136 showSidebarToggle = true
26137 }) {
26138 const classes = clsx_default(style_default7.page, className);
26139 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
26140 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
26141 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26142 Header,
26143 {
26144 headingLevel,
26145 breadcrumbs,
26146 badges,
26147 visual,
26148 title,
26149 subTitle,
26150 actions,
26151 showSidebarToggle
26152 }
26153 ),
26154 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
26155 "div",
26156 {
26157 className: clsx_default(
26158 style_default7.content,
26159 style_default7["has-padding"]
26160 ),
26161 children
26162 }
26163 ) : children
26164 ] });
26165 }
26166 Page.SidebarToggleFill = SidebarToggleFill;
26167 var page_default = Page;
26168
26169 // routes/pattern-list/stage.tsx
26170 var import_core_data4 = __toESM(require_core_data());
26171 var import_components46 = __toESM(require_components());
26172 var import_data11 = __toESM(require_data());
26173 var import_element76 = __toESM(require_element());
26174 var import_editor = __toESM(require_editor());
26175 var import_patterns3 = __toESM(require_patterns());
26176 var import_i18n47 = __toESM(require_i18n());
26177
26178 // routes/lock-unlock.ts
26179 var import_private_apis4 = __toESM(require_private_apis());
26180 var { lock: lock4, unlock: unlock4 } = (0, import_private_apis4.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
26181 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
26182 "@wordpress/routes"
26183 );
26184
26185 // routes/pattern-list/view-utils.ts
26186 var import_i18n43 = __toESM(require_i18n());
26187 var LAYOUT_GRID2 = "grid";
26188 var LAYOUT_TABLE2 = "table";
26189 var DEFAULT_VIEW = {
26190 type: LAYOUT_GRID2,
26191 perPage: 20,
26192 sort: {
26193 field: "title",
26194 direction: "asc"
26195 },
26196 filters: [],
26197 fields: ["sync-status"],
26198 layout: {
26199 badgeFields: ["sync-status"]
26200 },
26201 titleField: "title",
26202 mediaField: "preview"
26203 };
26204 var DEFAULT_VIEWS = [
26205 {
26206 slug: "all",
26207 label: (0, import_i18n43.__)("All patterns")
26208 },
26209 {
26210 slug: "my-patterns",
26211 label: (0, import_i18n43.__)("My patterns")
26212 },
26213 {
26214 slug: "registered",
26215 label: (0, import_i18n43.__)("Registered")
26216 }
26217 ];
26218 var DEFAULT_LAYOUTS2 = {
26219 [LAYOUT_TABLE2]: true,
26220 [LAYOUT_GRID2]: {
26221 layout: {
26222 badgeFields: ["sync-status"]
26223 }
26224 }
26225 };
26226
26227 // routes/pattern-list/fields/preview.tsx
26228 var import_i18n44 = __toESM(require_i18n());
26229 import { Preview } from "@wordpress/lazy-editor";
26230 function PreviewField({ item }) {
26231 return /* @__PURE__ */ React.createElement(
26232 Preview,
26233 {
26234 blocks: item.blocks,
26235 content: item.content,
26236 description: item.description
26237 }
26238 );
26239 }
26240 var previewField = {
26241 label: (0, import_i18n44.__)("Preview"),
26242 id: "preview",
26243 render: PreviewField,
26244 enableSorting: false
26245 };
26246
26247 // routes/pattern-list/fields/sync-status.tsx
26248 var import_i18n45 = __toESM(require_i18n());
26249 var import_patterns = __toESM(require_patterns());
26250 var { PATTERN_SYNC_TYPES } = unlock4(import_patterns.privateApis);
26251 var OPERATOR_IS2 = "is";
26252 var SYNC_FILTERS = [
26253 {
26254 value: PATTERN_SYNC_TYPES.full,
26255 label: (0, import_i18n45._x)("Synced", "pattern (singular)"),
26256 description: (0, import_i18n45.__)("Patterns that are kept in sync across the site.")
26257 },
26258 {
26259 value: PATTERN_SYNC_TYPES.unsynced,
26260 label: (0, import_i18n45._x)("Not synced", "pattern (singular)"),
26261 description: (0, import_i18n45.__)(
26262 "Patterns that can be changed freely without affecting the site."
26263 )
26264 }
26265 ];
26266 var patternStatusField = {
26267 label: (0, import_i18n45.__)("Sync status"),
26268 id: "sync-status",
26269 render: ({ item }) => {
26270 const syncStatus = item.syncStatus;
26271 return /* @__PURE__ */ React.createElement(
26272 "span",
26273 {
26274 className: `routes-pattern-list__field-sync-status-${syncStatus}`
26275 },
26276 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
26277 );
26278 },
26279 elements: SYNC_FILTERS,
26280 filterBy: {
26281 operators: [OPERATOR_IS2],
26282 isPrimary: true
26283 },
26284 enableSorting: false
26285 };
26286
26287 // routes/pattern-list/fields/category.tsx
26288 var import_i18n46 = __toESM(require_i18n());
26289 var import_data9 = __toESM(require_data());
26290 var import_core_data2 = __toESM(require_core_data());
26291 var import_element74 = __toESM(require_element());
26292 var OPERATOR_IS3 = "is";
26293 function CategoryField({ item }) {
26294 const blockPatternCategories = (0, import_data9.useSelect)(
26295 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26296 []
26297 );
26298 const categoryLabels = (0, import_element74.useMemo)(() => {
26299 if (!item.categories || !Array.isArray(item.categories)) {
26300 return [];
26301 }
26302 return item.categories.map((catSlug) => {
26303 const category = blockPatternCategories?.find(
26304 (cat) => cat.name === catSlug
26305 );
26306 return category ? category.label || category.name : null;
26307 }).filter(Boolean);
26308 }, [item.categories, blockPatternCategories]);
26309 if (categoryLabels.length === 0) {
26310 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
26311 }
26312 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
26313 }
26314 function usePatternCategories() {
26315 const userPatternCategories = (0, import_data9.useSelect)(
26316 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
26317 []
26318 );
26319 const blockPatternCategories = (0, import_data9.useSelect)(
26320 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
26321 []
26322 );
26323 return (0, import_element74.useMemo)(() => {
26324 const categoryMap = /* @__PURE__ */ new Map();
26325 userPatternCategories?.forEach((cat) => {
26326 if (!categoryMap.has(cat.name)) {
26327 categoryMap.set(cat.name, {
26328 value: cat.name,
26329 label: cat.label || cat.name
26330 });
26331 }
26332 });
26333 blockPatternCategories?.forEach((cat) => {
26334 if (!categoryMap.has(cat.name)) {
26335 categoryMap.set(cat.name, {
26336 value: cat.name,
26337 label: cat.label || cat.name
26338 });
26339 }
26340 });
26341 return Array.from(categoryMap.values()).sort(
26342 (a2, b2) => a2.label.localeCompare(b2.label)
26343 );
26344 }, [userPatternCategories, blockPatternCategories]);
26345 }
26346 function usePatternCategoryField() {
26347 const categories = usePatternCategories();
26348 return {
26349 label: (0, import_i18n46.__)("Category"),
26350 id: "category",
26351 render: CategoryField,
26352 elements: categories,
26353 getValue: ({ item }) => {
26354 return item.categories;
26355 },
26356 filterBy: {
26357 operators: [OPERATOR_IS3],
26358 isPrimary: true
26359 },
26360 enableSorting: false
26361 };
26362 }
26363
26364 // routes/pattern-list/use-patterns.ts
26365 var import_data10 = __toESM(require_data());
26366 var import_core_data3 = __toESM(require_core_data());
26367 var import_element75 = __toESM(require_element());
26368 var import_patterns2 = __toESM(require_patterns());
26369 var import_block_editor = __toESM(require_block_editor());
26370
26371 // routes/pattern-list/utils.ts
26372 var filterOutDuplicatesByName = (currentItem, index2, items) => index2 === items.findIndex((item) => currentItem.name === item.name);
26373
26374 // routes/pattern-list/use-patterns.ts
26375 var {
26376 PATTERN_TYPES,
26377 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
26378 EXCLUDED_PATTERN_SOURCES,
26379 PATTERN_DEFAULT_CATEGORY
26380 } = unlock4(import_patterns2.privateApis);
26381 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock4(
26382 import_block_editor.privateApis
26383 );
26384 function normalizeThemePattern(pattern) {
26385 return {
26386 id: pattern.name,
26387 title: pattern.title,
26388 content: pattern.content,
26389 keywords: pattern.keywords || [],
26390 type: PATTERN_TYPES.theme,
26391 // Normalize categories to always be an array of slugs
26392 categories: pattern.categories || [],
26393 // Theme patterns are always unsynced
26394 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
26395 description: pattern.description || ""
26396 };
26397 }
26398 function normalizeUserPattern(pattern, userPatternCategories) {
26399 const categories = [];
26400 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
26401 pattern.wp_pattern_category.forEach((catId) => {
26402 const category = userPatternCategories?.find(
26403 (cat) => cat.id === catId
26404 );
26405 if (category) {
26406 categories.push(category.name);
26407 }
26408 });
26409 }
26410 const numericId = pattern.id;
26411 return {
26412 id: pattern.name || pattern.id.toString(),
26413 _recordId: numericId,
26414 // Keep numeric ID for permissions lookup
26415 keywords: [],
26416 type: PATTERN_TYPES.user,
26417 // Normalize categories to always be an array of slugs
26418 categories,
26419 // Normalize sync status
26420 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
26421 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
26422 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
26423 description: pattern.excerpt?.raw || "",
26424 blocks: pattern.blocks
26425 };
26426 }
26427 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
26428 return unmatchedTerms.filter(
26429 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
26430 (unprocessedTerm) => unprocessedTerm.includes(term)
26431 )
26432 );
26433 };
26434 function getItemSearchRank(item, searchTerm, config) {
26435 const { categoryId, hasCategory, onlyFilterByCategory } = config;
26436 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
26437 if (!rank || onlyFilterByCategory) {
26438 return rank;
26439 }
26440 const normalizedSearchInput = normalizeString2(searchTerm);
26441 const normalizedTitle = normalizeString2(item.title);
26442 if (normalizedSearchInput === normalizedTitle) {
26443 rank += 30;
26444 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
26445 rank += 20;
26446 } else {
26447 const terms = [
26448 item.id,
26449 item.title,
26450 item.description,
26451 ...item.keywords
26452 ].join(" ");
26453 const normalizedSearchTerms = extractWords(normalizedSearchInput);
26454 const unmatchedTerms = removeMatchingTerms(
26455 normalizedSearchTerms,
26456 terms
26457 );
26458 if (unmatchedTerms.length === 0) {
26459 rank += 10;
26460 }
26461 }
26462 return rank;
26463 }
26464 function searchItems(items = [], searchInput = "", config = {}) {
26465 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
26466 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
26467 const searchRankConfig = { ...config, onlyFilterByCategory };
26468 const threshold = onlyFilterByCategory ? 0 : 1;
26469 const rankedItems = items.map((item) => {
26470 return [
26471 item,
26472 getItemSearchRank(item, searchInput, searchRankConfig)
26473 ];
26474 }).filter(([, rank]) => rank > threshold);
26475 if (normalizedSearchTerms.length === 0) {
26476 return rankedItems.map(([item]) => item);
26477 }
26478 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
26479 return rankedItems.map(([item]) => item);
26480 }
26481 var selectThemePatterns = (0, import_data10.createSelector)(
26482 (select2) => {
26483 const { getBlockPatterns } = select2(import_core_data3.store);
26484 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
26485 const restBlockPatterns = getBlockPatterns();
26486 const patterns = (restBlockPatterns || []).filter(
26487 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
26488 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
26489 return {
26490 patterns,
26491 isResolving: isResolvingSelector("getBlockPatterns")
26492 };
26493 },
26494 (select2) => [
26495 select2(import_core_data3.store).getBlockPatterns(),
26496 select2(import_core_data3.store).isResolving("getBlockPatterns")
26497 ]
26498 );
26499 var selectUserPatterns = (0, import_data10.createSelector)(
26500 (select2, syncStatus = void 0, search = "") => {
26501 const {
26502 getEntityRecords,
26503 isResolving: isResolvingSelector,
26504 getUserPatternCategories
26505 } = select2(import_core_data3.store);
26506 const query = { per_page: -1 };
26507 const patternPosts = getEntityRecords(
26508 "postType",
26509 PATTERN_TYPES.user,
26510 query
26511 );
26512 const userPatternCategories = getUserPatternCategories();
26513 let patterns = (patternPosts ?? []).map(
26514 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
26515 );
26516 const isResolving = isResolvingSelector("getEntityRecords", [
26517 "postType",
26518 PATTERN_TYPES.user,
26519 query
26520 ]);
26521 if (syncStatus) {
26522 patterns = patterns.filter(
26523 (pattern) => pattern.syncStatus === syncStatus
26524 );
26525 }
26526 patterns = searchItems(patterns, search, {
26527 // We exit user pattern retrieval early if we aren't in the
26528 // catch-all category for user created patterns, so it has
26529 // to be in the category.
26530 categoryId: PATTERN_DEFAULT_CATEGORY,
26531 hasCategory: () => true
26532 });
26533 return {
26534 patterns,
26535 isResolving,
26536 categories: userPatternCategories
26537 };
26538 },
26539 (select2) => [
26540 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
26541 per_page: -1
26542 }),
26543 select2(import_core_data3.store).isResolving("getEntityRecords", [
26544 "postType",
26545 PATTERN_TYPES.user,
26546 { per_page: -1 }
26547 ]),
26548 select2(import_core_data3.store).getUserPatternCategories()
26549 ]
26550 );
26551 var selectPatterns = (0, import_data10.createSelector)(
26552 (select2, categoryId, syncStatus, search = "") => {
26553 const {
26554 patterns: themePatterns,
26555 isResolving: isResolvingThemePatterns
26556 } = selectThemePatterns(select2);
26557 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
26558 let patterns = [
26559 ...themePatterns || [],
26560 ...userPatterns || []
26561 ];
26562 if (syncStatus) {
26563 patterns = patterns.filter(
26564 (pattern) => pattern.syncStatus === syncStatus
26565 );
26566 }
26567 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26568 patterns = searchItems(patterns, search, {
26569 categoryId,
26570 hasCategory: (item, currentCategory) => {
26571 return item.categories?.includes(currentCategory);
26572 }
26573 });
26574 } else {
26575 patterns = searchItems(patterns, search, {
26576 categoryId: PATTERN_DEFAULT_CATEGORY,
26577 hasCategory: () => true
26578 });
26579 }
26580 return {
26581 patterns,
26582 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
26583 };
26584 },
26585 (select2) => [
26586 selectThemePatterns(select2),
26587 selectUserPatterns(select2)
26588 ]
26589 );
26590 function useAugmentPatternsWithPermissions(patterns) {
26591 const idsAndTypes = (0, import_element75.useMemo)(
26592 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
26593 record.type,
26594 record._recordId,
26595 record.id
26596 ]) ?? [],
26597 [patterns]
26598 );
26599 const permissions = (0, import_data10.useSelect)(
26600 (select2) => {
26601 const { getEntityRecordPermissions } = unlock4(
26602 select2(import_core_data3.store)
26603 );
26604 return idsAndTypes.reduce(
26605 (acc, [type, numericId, stringId]) => {
26606 acc[stringId] = getEntityRecordPermissions(
26607 "postType",
26608 type,
26609 numericId
26610 );
26611 return acc;
26612 },
26613 {}
26614 );
26615 },
26616 [idsAndTypes]
26617 );
26618 return (0, import_element75.useMemo)(
26619 () => patterns?.map((record) => ({
26620 ...record,
26621 permissions: permissions?.[record.id] ?? {}
26622 })) ?? [],
26623 [patterns, permissions]
26624 );
26625 }
26626 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
26627 return (0, import_data10.useSelect)(
26628 (select2) => {
26629 if (postType === PATTERN_TYPES.user) {
26630 const result = selectUserPatterns(select2, syncStatus, search);
26631 let { patterns } = result;
26632 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26633 patterns = patterns.filter(
26634 (pattern) => pattern.categories.includes(categoryId)
26635 );
26636 }
26637 return {
26638 patterns,
26639 isResolving: result.isResolving
26640 };
26641 } else if (postType === PATTERN_TYPES.theme) {
26642 const result = selectThemePatterns(select2);
26643 let { patterns } = result;
26644 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
26645 patterns = patterns.filter(
26646 (pattern) => pattern.categories.includes(categoryId)
26647 );
26648 }
26649 patterns = searchItems(patterns, search, {
26650 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
26651 hasCategory: () => true
26652 });
26653 return {
26654 patterns,
26655 isResolving: result.isResolving
26656 };
26657 }
26658 return selectPatterns(select2, categoryId, syncStatus, search);
26659 },
26660 [categoryId, postType, search, syncStatus]
26661 );
26662 };
26663 var use_patterns_default = usePatterns;
26664
26665 // routes/pattern-list/style.scss
26666 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c329396b1f']")) {
26667 const style = document.createElement("style");
26668 style.setAttribute("data-wp-hash", "c329396b1f");
26669 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)}"));
26670 document.head.appendChild(style);
26671 }
26672
26673 // routes/pattern-list/stage.tsx
26674 var { usePostActions, patternTitleField } = unlock4(import_editor.privateApis);
26675 var { Tabs } = unlock4(import_components46.privateApis);
26676 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock4(import_patterns3.privateApis);
26677 function PatternList() {
26678 const invalidate = useInvalidate();
26679 const { type = "all" } = useParams({
26680 from: "/patterns/list/$type"
26681 });
26682 const navigate = useNavigate();
26683 const searchParams = useSearch({ from: "/patterns/list/$type" });
26684 const postTypeObject = (0, import_data11.useSelect)(
26685 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
26686 []
26687 );
26688 const labels = postTypeObject?.labels;
26689 const canCreateRecord = (0, import_data11.useSelect)(
26690 (select2) => select2(import_core_data4.store).canUser("create", {
26691 kind: "postType",
26692 name: "wp_block"
26693 }),
26694 []
26695 );
26696 const [showPatternModal, setShowPatternModal] = (0, import_element76.useState)(false);
26697 const handleQueryParamsChange = (0, import_element76.useCallback)(
26698 (params) => {
26699 navigate({
26700 search: {
26701 ...searchParams,
26702 ...params
26703 }
26704 });
26705 },
26706 [searchParams, navigate]
26707 );
26708 const { view, isModified, updateView, resetToDefault } = useView({
26709 kind: "postType",
26710 name: "wp_block",
26711 slug: "default-new",
26712 defaultView: DEFAULT_VIEW,
26713 queryParams: searchParams,
26714 onChangeQueryParams: handleQueryParamsChange
26715 });
26716 const onReset = () => {
26717 resetToDefault();
26718 invalidate();
26719 };
26720 const onChangeView = (newView) => {
26721 updateView(newView);
26722 if (newView.type !== view.type) {
26723 invalidate();
26724 }
26725 };
26726 const categoryFilter = (0, import_element76.useMemo)(() => {
26727 const filter = view.filters?.find((f2) => f2.field === "category");
26728 return filter?.value || "all-patterns";
26729 }, [view.filters]);
26730 const syncStatusFilter = (0, import_element76.useMemo)(() => {
26731 const filter = view.filters?.find((f2) => f2.field === "sync-status");
26732 return filter?.value;
26733 }, [view.filters]);
26734 const patternType = (0, import_element76.useMemo)(() => {
26735 if (type === "my-patterns") {
26736 return PATTERN_TYPES2.user;
26737 } else if (type === "registered") {
26738 return PATTERN_TYPES2.theme;
26739 }
26740 return null;
26741 }, [type]);
26742 const { patterns, isResolving } = use_patterns_default(
26743 patternType,
26744 categoryFilter,
26745 {
26746 search: view.search,
26747 syncStatus: syncStatusFilter
26748 }
26749 );
26750 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
26751 const patternCategoryField = usePatternCategoryField();
26752 const fields = (0, import_element76.useMemo)(() => {
26753 const patternFields = [
26754 previewField,
26755 patternTitleField,
26756 patternCategoryField
26757 ];
26758 if (type === "my-patterns" || type === "all") {
26759 patternFields.push(patternStatusField);
26760 }
26761 return patternFields;
26762 }, [type, patternCategoryField]);
26763 const { data: posts, paginationInfo } = (0, import_element76.useMemo)(() => {
26764 const viewWithoutFilters = { ...view };
26765 delete viewWithoutFilters.search;
26766 viewWithoutFilters.filters = [];
26767 return filterSortAndPaginate(
26768 patternsWithPermissions,
26769 viewWithoutFilters,
26770 fields
26771 );
26772 }, [patternsWithPermissions, view, fields]);
26773 const { totalItems, totalPages } = paginationInfo;
26774 const cleanupDeletedPostIdsFromUrl = (0, import_element76.useCallback)(
26775 (deletedItems) => {
26776 const deletedIds = deletedItems.map((item) => item.id);
26777 const currentPostIds = searchParams.postIds || [];
26778 const remainingPostIds = currentPostIds.filter(
26779 (id) => !deletedIds.includes(id)
26780 );
26781 if (remainingPostIds.length !== currentPostIds.length) {
26782 navigate({
26783 search: {
26784 ...searchParams,
26785 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
26786 }
26787 });
26788 } else {
26789 invalidate();
26790 }
26791 },
26792 [invalidate, searchParams, navigate]
26793 );
26794 const postTypeActions = usePostActions({
26795 postType: "wp_block",
26796 context: "list",
26797 onActionPerformed: (actionId, items) => {
26798 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
26799 cleanupDeletedPostIdsFromUrl(items);
26800 }
26801 }
26802 });
26803 const actions = (0, import_element76.useMemo)(() => {
26804 return [
26805 ...postTypeActions?.flatMap((action) => {
26806 if (action.id === "view-post-revisions") {
26807 return [];
26808 }
26809 return [action];
26810 })
26811 ];
26812 }, [postTypeActions]);
26813 const handleTabChange = (0, import_element76.useCallback)(
26814 (typeSlug) => {
26815 navigate({
26816 to: `/patterns/list/${typeSlug}`
26817 });
26818 },
26819 [navigate]
26820 );
26821 if (!postTypeObject) {
26822 return null;
26823 }
26824 const selection = searchParams.postIds ?? [];
26825 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
26826 selection.push(posts[0].id);
26827 }
26828 if (view.type === "list") {
26829 selection.splice(1);
26830 }
26831 return /* @__PURE__ */ React.createElement(
26832 page_default,
26833 {
26834 title: (0, import_i18n47.__)("Patterns"),
26835 headingLevel: 2,
26836 subTitle: (0, import_i18n47.__)(
26837 "Reusable design elements for your site. Create once, use everywhere."
26838 ),
26839 className: "pattern-page",
26840 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
26841 import_components46.Button,
26842 {
26843 variant: "primary",
26844 onClick: () => setShowPatternModal(true),
26845 size: "compact"
26846 },
26847 labels.add_new_item
26848 ),
26849 hasPadding: false
26850 },
26851 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
26852 Tabs,
26853 {
26854 onSelect: handleTabChange,
26855 selectedTabId: type ?? "all"
26856 },
26857 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
26858 (filter) => /* @__PURE__ */ React.createElement(
26859 Tabs.Tab,
26860 {
26861 tabId: filter.slug,
26862 key: filter.slug
26863 },
26864 filter.label
26865 )
26866 ))
26867 )),
26868 /* @__PURE__ */ React.createElement(
26869 dataviews_default,
26870 {
26871 data: posts,
26872 fields,
26873 view,
26874 onChangeView,
26875 actions,
26876 isLoading: isResolving,
26877 paginationInfo: {
26878 totalItems,
26879 totalPages
26880 },
26881 defaultLayouts: DEFAULT_LAYOUTS2,
26882 selection,
26883 onReset: isModified ? onReset : false,
26884 onChangeSelection: (items) => {
26885 navigate({
26886 search: {
26887 ...searchParams,
26888 postIds: items.length > 0 ? items : void 0,
26889 edit: items.length === 0 ? void 0 : searchParams.edit
26890 }
26891 });
26892 },
26893 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
26894 renderItemLink: ({
26895 item,
26896 ...props
26897 }) => /* @__PURE__ */ React.createElement(
26898 Link,
26899 {
26900 to: `/types/wp_block/edit/${encodeURIComponent(
26901 item.id
26902 )}`,
26903 ...props,
26904 onClick: (event) => {
26905 event.stopPropagation();
26906 }
26907 }
26908 )
26909 }
26910 ),
26911 showPatternModal && /* @__PURE__ */ React.createElement(
26912 CreatePatternModal,
26913 {
26914 onClose: () => setShowPatternModal(false),
26915 onSuccess: ({
26916 pattern
26917 }) => {
26918 setShowPatternModal(false);
26919 navigate({
26920 to: `/types/wp_block/edit/${encodeURIComponent(
26921 pattern.id
26922 )}`
26923 });
26924 },
26925 content: []
26926 }
26927 )
26928 );
26929 }
26930 var stage = PatternList;
26931 export {
26932 stage
26933 };
26934 /*! Bundled license information:
26935
26936 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
26937 (**
26938 * @license React
26939 * use-sync-external-store-shim.development.js
26940 *
26941 * Copyright (c) Meta Platforms, Inc. and affiliates.
26942 *
26943 * This source code is licensed under the MIT license found in the
26944 * LICENSE file in the root directory of this source tree.
26945 *)
26946
26947 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
26948 (**
26949 * @license React
26950 * use-sync-external-store-shim/with-selector.development.js
26951 *
26952 * Copyright (c) Meta Platforms, Inc. and affiliates.
26953 *
26954 * This source code is licensed under the MIT license found in the
26955 * LICENSE file in the root directory of this source tree.
26956 *)
26957 */
26958